all these changes

This commit is contained in:
Jake Kasper
2026-04-09 13:19:47 -05:00
parent e83a51a051
commit 65315f36d1
39102 changed files with 7932979 additions and 567 deletions

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2017 TurfJS
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,86 @@
# @turf/points-within-polygon
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## pointsWithinPolygon
Finds [Points][1] that fall within [(Multi)Polygon(s)][2].
**Parameters**
- `points` **([Feature][3] \| [FeatureCollection][4]&lt;[Point][5]>)** Points as input search
- `polygons` **([FeatureCollection][4] \| [Geometry][6] \| [Feature][3]&lt;([Polygon][7] \| [MultiPolygon][8])>)** Points must be within these (Multi)Polygon(s)
**Examples**
```javascript
var points = turf.points([
[-46.6318, -23.5523],
[-46.6246, -23.5325],
[-46.6062, -23.5513],
[-46.663, -23.554],
[-46.643, -23.557]
]);
var searchWithin = turf.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]
]]);
var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);
//addToMap
var addToMap = [points, searchWithin, ptsWithin]
turf.featureEach(ptsWithin, function (currentFeature) {
currentFeature.properties['marker-size'] = 'large';
currentFeature.properties['marker-color'] = '#000';
});
```
Returns **[FeatureCollection][4]&lt;[Point][5]>** points that land within at least one polygon
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.6
[3]: https://tools.ietf.org/html/rfc7946#section-3.2
[4]: https://tools.ietf.org/html/rfc7946#section-3.3
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.2
[6]: https://tools.ietf.org/html/rfc7946#section-3.1
[7]: https://tools.ietf.org/html/rfc7946#section-3.1.6
[8]: https://tools.ietf.org/html/rfc7946#section-3.1.7
<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
./scripts/generate-readmes in the turf project. -->
---
This module is part of the [Turfjs project](http://turfjs.org/), an open source
module collection dedicated to geographic algorithms. It is maintained in the
[Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
PRs and issues.
### Installation
Install this module individually:
```sh
$ npm install @turf/points-within-polygon
```
Or install the Turf module that includes it as a function:
```sh
$ npm install @turf/turf
```

View File

@@ -0,0 +1,71 @@
import pointInPolygon from '@turf/boolean-point-in-polygon';
import { multiPoint, featureCollection } from '@turf/helpers';
import { featureEach, geomEach, coordEach } from '@turf/meta';
/**
* Finds {@link Points} or {@link MultiPoint} coordinate positions that fall within {@link (Multi)Polygon(s)}.
*
* @name pointsWithinPolygon
* @param {Feature|FeatureCollection<Point|MultiPoint>} points Point(s) or MultiPoint(s) as input search
* @param {FeatureCollection|Geometry|Feature<Polygon|MultiPolygon>} polygons (Multi)Polygon(s) to check if points are within
* @returns {FeatureCollection<Point|MultiPoint>} Point(s) or MultiPoint(s) with positions that land within at least one polygon. The geometry type will match what was passsed in
* @example
* var points = turf.points([
* [-46.6318, -23.5523],
* [-46.6246, -23.5325],
* [-46.6062, -23.5513],
* [-46.663, -23.554],
* [-46.643, -23.557]
* ]);
*
* var searchWithin = turf.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]
* ]]);
*
* var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);
*
* //addToMap
* var addToMap = [points, searchWithin, ptsWithin]
* turf.featureEach(ptsWithin, function (currentFeature) {
* currentFeature.properties['marker-size'] = 'large';
* currentFeature.properties['marker-color'] = '#000';
* });
*/
function pointsWithinPolygon(points, polygons) {
var results = [];
featureEach(points, function (point) {
var contained = false;
if (point.geometry.type === "Point") {
geomEach(polygons, function (polygon) {
if (pointInPolygon(point, polygon)) contained = true;
});
if (contained) {
results.push(point);
}
} else if (point.geometry.type === "MultiPoint") {
var pointsWithin = [];
geomEach(polygons, function (polygon) {
coordEach(point, function (pointCoord) {
if (pointInPolygon(pointCoord, polygon)) {
contained = true;
pointsWithin.push(pointCoord);
}
});
});
if (contained) {
results.push(multiPoint(pointsWithin));
}
} else {
throw new Error("Input geometry must be a Point or MultiPoint");
}
});
return featureCollection(results);
}
export default pointsWithinPolygon;

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,78 @@
'use strict';
var pointInPolygon = require('@turf/boolean-point-in-polygon');
var helpers = require('@turf/helpers');
var meta = require('@turf/meta');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var pointInPolygon__default = /*#__PURE__*/_interopDefaultLegacy(pointInPolygon);
/**
* Finds {@link Points} or {@link MultiPoint} coordinate positions that fall within {@link (Multi)Polygon(s)}.
*
* @name pointsWithinPolygon
* @param {Feature|FeatureCollection<Point|MultiPoint>} points Point(s) or MultiPoint(s) as input search
* @param {FeatureCollection|Geometry|Feature<Polygon|MultiPolygon>} polygons (Multi)Polygon(s) to check if points are within
* @returns {FeatureCollection<Point|MultiPoint>} Point(s) or MultiPoint(s) with positions that land within at least one polygon. The geometry type will match what was passsed in
* @example
* var points = turf.points([
* [-46.6318, -23.5523],
* [-46.6246, -23.5325],
* [-46.6062, -23.5513],
* [-46.663, -23.554],
* [-46.643, -23.557]
* ]);
*
* var searchWithin = turf.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]
* ]]);
*
* var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);
*
* //addToMap
* var addToMap = [points, searchWithin, ptsWithin]
* turf.featureEach(ptsWithin, function (currentFeature) {
* currentFeature.properties['marker-size'] = 'large';
* currentFeature.properties['marker-color'] = '#000';
* });
*/
function pointsWithinPolygon(points, polygons) {
var results = [];
meta.featureEach(points, function (point) {
var contained = false;
if (point.geometry.type === "Point") {
meta.geomEach(polygons, function (polygon) {
if (pointInPolygon__default['default'](point, polygon)) contained = true;
});
if (contained) {
results.push(point);
}
} else if (point.geometry.type === "MultiPoint") {
var pointsWithin = [];
meta.geomEach(polygons, function (polygon) {
meta.coordEach(point, function (pointCoord) {
if (pointInPolygon__default['default'](pointCoord, polygon)) {
contained = true;
pointsWithin.push(pointCoord);
}
});
});
if (contained) {
results.push(helpers.multiPoint(pointsWithin));
}
} else {
throw new Error("Input geometry must be a Point or MultiPoint");
}
});
return helpers.featureCollection(results);
}
module.exports = pointsWithinPolygon;
module.exports.default = pointsWithinPolygon;

View File

@@ -0,0 +1,21 @@
import {
Feature,
FeatureCollection,
Polygon,
MultiPolygon,
MultiPoint,
Point,
Properties,
} from "@turf/helpers";
/**
* http://turfjs.org/docs/#pointswithinpolygon
*/
export default function pointsWithinPolygon<
F extends Point | MultiPoint,
G extends Polygon | MultiPolygon,
P = Properties
>(
points: Feature<F, P> | FeatureCollection<F, P>,
polygons: Feature<G> | FeatureCollection<G> | G
): FeatureCollection<F, P>;

View File

@@ -0,0 +1,61 @@
{
"name": "@turf/points-within-polygon",
"version": "6.5.0",
"description": "turf points-within-polygon module",
"author": "Turf Authors",
"license": "MIT",
"bugs": {
"url": "https://github.com/Turfjs/turf/issues"
},
"homepage": "https://github.com/Turfjs/turf",
"repository": {
"type": "git",
"url": "git://github.com/Turfjs/turf.git"
},
"funding": "https://opencollective.com/turf",
"publishConfig": {
"access": "public"
},
"keywords": [
"geojson",
"within",
"point",
"polygon",
"featurecollection"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
}
},
"types": "index.d.ts",
"sideEffects": false,
"files": [
"dist",
"index.d.ts"
],
"scripts": {
"bench": "node -r esm bench.js",
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "node -r esm test.js",
"test:types": "tsc --esModuleInterop --noEmit types.ts"
},
"devDependencies": {
"benchmark": "*",
"npm-run-all": "*",
"rollup": "*",
"tape": "*"
},
"dependencies": {
"@turf/boolean-point-in-polygon": "^6.5.0",
"@turf/helpers": "^6.5.0",
"@turf/meta": "^6.5.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
}