Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turf-points-within-polygon: Allow MultiPolygons in the types #1116

Merged
merged 3 commits into from
Nov 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/turf-points-within-polygon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

## pointsWithinPolygon

Takes a set of [points](http://geojson.org/geojson-spec.html#point) and a set of [polygons](http://geojson.org/geojson-spec.html#polygon) and returns the points that fall within the polygons.
Takes a set of [points](http://geojson.org/geojson-spec.html#point) and a set of [polygons](http://geojson.org/geojson-spec.html#polygon) or [multi polygons](http://geojson.org/geojson-spec.html#multipolygon) and returns the points that fall within the polygons.

**Parameters**

- `points` **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)<[Point](http://geojson.org/geojson-spec.html#point)>** input points
- `polygons` **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)<[Polygon](http://geojson.org/geojson-spec.html#polygon)>** input polygons
- `polygons` **[FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects)<([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>** input polygons

**Examples**

Expand Down
4 changes: 2 additions & 2 deletions packages/turf-points-within-polygon/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FeatureCollection, Polygon, Point } from '@turf/helpers'
import { FeatureCollection, Polygon, MultiPolygon, Point } from '@turf/helpers'

/**
* http://turfjs.org/docs/#pointswithinpolygon
*/
export default function pointsWithinPolygon(
points: FeatureCollection<Point>,
polygons: FeatureCollection<Polygon>
polygons: FeatureCollection<Polygon | MultiPolygon>
): FeatureCollection<Point>;
4 changes: 2 additions & 2 deletions packages/turf-points-within-polygon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import booleanPointInPolygon from '@turf/boolean-point-in-polygon';
import { featureCollection } from '@turf/helpers';

/**
* Takes a set of {@link Point|points} and a set of {@link Polygon|polygons} and returns the points that fall within the polygons.
* Takes a set of {@link Points} and a set of {@link (Multi)Polygons} and returns the points that fall within the polygons.
*
* @name pointsWithinPolygon
* @param {FeatureCollection<Point>} points input points
* @param {FeatureCollection<Polygon>} polygons input polygons
* @param {FeatureCollection<Polygon|MultiPolygon>} polygons input polygons
* @returns {FeatureCollection<Point>} points that land within at least one polygon
* @example
* var searchWithin = turf.featureCollection([
Expand Down
12 changes: 12 additions & 0 deletions scripts/generate-readmes
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,23 @@ const paths = {
GeoJSON: 'http://geojson.org/geojson-spec.html#geojson-objects',
GeometryCollection: 'http://geojson.org/geojson-spec.html#geometrycollection',
Point: 'http://geojson.org/geojson-spec.html#point',
Points: 'http://geojson.org/geojson-spec.html#point',
'(Multi)Point': 'http://geojson.org/geojson-spec.html#point',
'(Multi)Points': 'http://geojson.org/geojson-spec.html#point',
MultiPoint: 'http://geojson.org/geojson-spec.html#multipoint',
MultiPoints: 'http://geojson.org/geojson-spec.html#multipoint',
LineString: 'http://geojson.org/geojson-spec.html#linestring',
LineStrings: 'http://geojson.org/geojson-spec.html#linestring',
'(Multi)LineString': 'http://geojson.org/geojson-spec.html#linestring',
'(Multi)LineStrings': 'http://geojson.org/geojson-spec.html#linestring',
MultiLineString: 'http://geojson.org/geojson-spec.html#multilinestring',
MultiLineStrings: 'http://geojson.org/geojson-spec.html#multilinestring',
Polygon: 'http://geojson.org/geojson-spec.html#polygon',
Polygons: 'http://geojson.org/geojson-spec.html#polygon',
'(Multi)Polygon': 'http://geojson.org/geojson-spec.html#polygon',
'(Multi)Polygons': 'http://geojson.org/geojson-spec.html#polygon',
MultiPolygon: 'http://geojson.org/geojson-spec.html#multipolygon',
MultiPolygons: 'http://geojson.org/geojson-spec.html#multipolygon',
Geometry: 'http://geojson.org/geojson-spec.html#geometry',
Feature: 'http://geojson.org/geojson-spec.html#feature-objects',
FeatureCollection: 'http://geojson.org/geojson-spec.html#feature-collection-objects'
Expand Down