Skip to content

Commit

Permalink
Merge pull request #1116 from woutervh-/master
Browse files Browse the repository at this point in the history
turf-points-within-polygon: Allow MultiPolygons in the types
  • Loading branch information
DenisCarriere authored Nov 22, 2017
2 parents dd44d85 + cd3da1b commit dc27a2e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
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

0 comments on commit dc27a2e

Please sign in to comment.