-
Notifications
You must be signed in to change notification settings - Fork 952
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1117 from Turfjs/add-geometry-support
Add extra geometry support to @turf/points-within-polygon
- Loading branch information
Showing
8 changed files
with
122 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { FeatureCollection, Polygon, MultiPolygon, Point } from '@turf/helpers' | ||
import { Feature, FeatureCollection, Polygon, MultiPolygon, Point } from '@turf/helpers' | ||
|
||
/** | ||
* http://turfjs.org/docs/#pointswithinpolygon | ||
*/ | ||
export default function pointsWithinPolygon( | ||
points: FeatureCollection<Point>, | ||
polygons: FeatureCollection<Polygon | MultiPolygon> | ||
export default function pointsWithinPolygon<G extends Polygon | MultiPolygon>( | ||
points: Feature<Point> | FeatureCollection<Point>, | ||
polygons: Feature<G> | FeatureCollection<G> | G | ||
): FeatureCollection<Point>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pointsWithinPolygon from './' | ||
import { points, polygon } from '@turf/helpers' | ||
|
||
const pts = points([ | ||
[-46.6318, -23.5523], | ||
[-46.6246, -23.5325], | ||
[-46.6062, -23.5513], | ||
[-46.663, -23.554], | ||
[-46.643, -23.557] | ||
]); | ||
const searchWithin = polygon([[ | ||
[-46.653,-23.543], | ||
[-46.634,-23.5346], | ||
[-46.613,-23.543], | ||
[-46.614,-23.559], | ||
[-46.631,-23.567], | ||
[-46.653,-23.560], | ||
[-46.653,-23.543] | ||
]]); | ||
const ptsWithin = pointsWithinPolygon(pts, searchWithin); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters