@turf/points-within-polygon 6.5.0 → 7.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -13
- package/dist/es/index.js +1 -1
- package/dist/js/index.js +1 -1
- package/index.d.ts +3 -3
- package/package.json +12 -10
package/README.md
CHANGED
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
## pointsWithinPolygon
|
|
6
6
|
|
|
7
|
-
Finds [Points][1] that fall within [(Multi)Polygon(s)][
|
|
7
|
+
Finds [Points][1] or [MultiPoint][2] coordinate positions that fall within [(Multi)Polygon(s)][3].
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* `points` **([Feature][4] | [FeatureCollection][5]<([Point][6] | [MultiPoint][7])>)** Point(s) or MultiPoint(s) as input search
|
|
12
|
+
* `polygons` **([FeatureCollection][5] | [Geometry][8] | [Feature][4]<([Polygon][9] | [MultiPolygon][10])>)** (Multi)Polygon(s) to check if points are within
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### Examples
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
17
|
var points = turf.points([
|
|
@@ -42,23 +42,27 @@ turf.featureEach(ptsWithin, function (currentFeature) {
|
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
Returns **[FeatureCollection][
|
|
45
|
+
Returns **[FeatureCollection][5]<([Point][6] | [MultiPoint][7])>** Point(s) or MultiPoint(s) with positions that land within at least one polygon. The geometry type will match what was passsed in
|
|
46
46
|
|
|
47
47
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
48
48
|
|
|
49
|
-
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.
|
|
49
|
+
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.3
|
|
50
50
|
|
|
51
|
-
[3]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
51
|
+
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
52
52
|
|
|
53
|
-
[4]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
53
|
+
[4]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
54
54
|
|
|
55
|
-
[5]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
55
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
56
56
|
|
|
57
|
-
[6]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
57
|
+
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
58
58
|
|
|
59
|
-
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.
|
|
59
|
+
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.3
|
|
60
60
|
|
|
61
|
-
[8]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
61
|
+
[8]: https://tools.ietf.org/html/rfc7946#section-3.1
|
|
62
|
+
|
|
63
|
+
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
64
|
+
|
|
65
|
+
[10]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
|
62
66
|
|
|
63
67
|
<!-- This file is automatically generated. Please don't edit it directly:
|
|
64
68
|
if you find an error, edit the source file (likely index.js), and re-run
|
package/dist/es/index.js
CHANGED
|
@@ -59,7 +59,7 @@ function pointsWithinPolygon(points, polygons) {
|
|
|
59
59
|
});
|
|
60
60
|
});
|
|
61
61
|
if (contained) {
|
|
62
|
-
results.push(multiPoint(pointsWithin));
|
|
62
|
+
results.push(multiPoint(pointsWithin, point.properties || {}));
|
|
63
63
|
}
|
|
64
64
|
} else {
|
|
65
65
|
throw new Error("Input geometry must be a Point or MultiPoint");
|
package/dist/js/index.js
CHANGED
|
@@ -65,7 +65,7 @@ function pointsWithinPolygon(points, polygons) {
|
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
if (contained) {
|
|
68
|
-
results.push(helpers.multiPoint(pointsWithin));
|
|
68
|
+
results.push(helpers.multiPoint(pointsWithin, point.properties || {}));
|
|
69
69
|
}
|
|
70
70
|
} else {
|
|
71
71
|
throw new Error("Input geometry must be a Point or MultiPoint");
|
package/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import {
|
|
|
5
5
|
MultiPolygon,
|
|
6
6
|
MultiPoint,
|
|
7
7
|
Point,
|
|
8
|
-
|
|
9
|
-
} from "
|
|
8
|
+
GeoJsonProperties,
|
|
9
|
+
} from "geojson";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* http://turfjs.org/docs/#pointswithinpolygon
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
export default function pointsWithinPolygon<
|
|
15
15
|
F extends Point | MultiPoint,
|
|
16
16
|
G extends Polygon | MultiPolygon,
|
|
17
|
-
P =
|
|
17
|
+
P = GeoJsonProperties
|
|
18
18
|
>(
|
|
19
19
|
points: Feature<F, P> | FeatureCollection<F, P>,
|
|
20
20
|
polygons: Feature<G> | FeatureCollection<G> | G
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/points-within-polygon",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.1",
|
|
4
4
|
"description": "turf points-within-polygon module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"exports": {
|
|
29
29
|
"./package.json": "./package.json",
|
|
30
30
|
".": {
|
|
31
|
+
"types": "./index.d.ts",
|
|
31
32
|
"import": "./dist/es/index.js",
|
|
32
33
|
"require": "./dist/js/index.js"
|
|
33
34
|
}
|
|
@@ -39,23 +40,24 @@
|
|
|
39
40
|
"index.d.ts"
|
|
40
41
|
],
|
|
41
42
|
"scripts": {
|
|
42
|
-
"bench": "
|
|
43
|
+
"bench": "tsx bench.js",
|
|
43
44
|
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
|
|
44
|
-
"docs": "
|
|
45
|
+
"docs": "tsx ../../scripts/generate-readmes",
|
|
45
46
|
"test": "npm-run-all test:*",
|
|
46
|
-
"test:tape": "
|
|
47
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
47
|
+
"test:tape": "tsx test.js",
|
|
48
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
51
|
"benchmark": "*",
|
|
51
52
|
"npm-run-all": "*",
|
|
52
53
|
"rollup": "*",
|
|
53
|
-
"tape": "*"
|
|
54
|
+
"tape": "*",
|
|
55
|
+
"tsx": "*"
|
|
54
56
|
},
|
|
55
57
|
"dependencies": {
|
|
56
|
-
"@turf/boolean-point-in-polygon": "^
|
|
57
|
-
"@turf/helpers": "^
|
|
58
|
-
"@turf/meta": "^
|
|
58
|
+
"@turf/boolean-point-in-polygon": "^7.0.0-alpha.1",
|
|
59
|
+
"@turf/helpers": "^7.0.0-alpha.1",
|
|
60
|
+
"@turf/meta": "^7.0.0-alpha.1"
|
|
59
61
|
},
|
|
60
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
|
|
61
63
|
}
|