mirror of
https://github.com/Turfjs/turf.git
synced 2025-12-08 20:26:16 +00:00
Added new point-to-polygon-distance package (#2735)
Added turf-point-to-polygon-distance package to complement point-to-line functionality. Resolves #1743 --------- Co-authored-by: James Beard <james@smallsaucepan.com>
This commit is contained in:
parent
1dec2f2474
commit
5d1e0ec2f5
@ -16,6 +16,7 @@ toc:
|
||||
- pointOnFeature
|
||||
- polygonTangents
|
||||
- pointToLineDistance
|
||||
- pointToPolygonDistance
|
||||
- rhumbBearing
|
||||
- rhumbDestination
|
||||
- rhumbDistance
|
||||
|
||||
20
packages/turf-point-to-polygon-distance/LICENSE
Normal file
20
packages/turf-point-to-polygon-distance/LICENSE
Normal 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.
|
||||
61
packages/turf-point-to-polygon-distance/README.md
Normal file
61
packages/turf-point-to-polygon-distance/README.md
Normal file
@ -0,0 +1,61 @@
|
||||
# @turf/point-to-polygon-distance
|
||||
|
||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
||||
|
||||
## pointToPolygonDistance
|
||||
|
||||
Calculates the distance from a point to the edges of a polygon or multi-polygon.
|
||||
Returns negative values for points inside the polygon.
|
||||
Handles polygons with holes and multi-polygons.
|
||||
A hole is treated as the exterior of the polygon.
|
||||
|
||||
### Parameters
|
||||
|
||||
* `point` **([Feature][1]<[Point][2]> | [Point][2] | [Position][3])** Input point
|
||||
* `polygonOrMultiPolygon` **([Feature][1]<([Polygon][4] | [MultiPolygon][5])> | [Polygon][4] | [MultiPolygon][5])** Input polygon or multipolygon
|
||||
* `options` **[Object][6]** Optional parameters (optional, default `{}`)
|
||||
|
||||
* `options.units` **Units** Units of the result e.g. "kilometers", "miles", "meters"
|
||||
* `options.method` **(`"geodesic"` | `"planar"`)** Method of the result
|
||||
|
||||
<!---->
|
||||
|
||||
* Throws **[Error][7]** If input geometries are invalid
|
||||
|
||||
Returns **[number][8]** Distance in meters (negative values for points inside the polygon)
|
||||
|
||||
[1]: https://tools.ietf.org/html/rfc7946#section-3.2
|
||||
|
||||
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
||||
|
||||
[3]: https://developer.mozilla.org/docs/Web/API/Position
|
||||
|
||||
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
||||
|
||||
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.7
|
||||
|
||||
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
||||
|
||||
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error
|
||||
|
||||
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
||||
|
||||
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
||||
|
||||
---
|
||||
|
||||
This module is part of the [Turfjs project](https://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 single module individually:
|
||||
|
||||
```sh
|
||||
$ npm install @turf/point-to-polygon-distance
|
||||
```
|
||||
|
||||
Or install the all-encompassing @turf/turf module that includes all modules as functions:
|
||||
|
||||
```sh
|
||||
$ npm install @turf/turf
|
||||
```
|
||||
65
packages/turf-point-to-polygon-distance/bench.ts
Normal file
65
packages/turf-point-to-polygon-distance/bench.ts
Normal file
@ -0,0 +1,65 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { loadJsonFileSync } from "load-json-file";
|
||||
import Benchmark from "benchmark";
|
||||
import { pointToPolygonDistance } from "./index.js";
|
||||
import { featureCollection } from "@turf/helpers";
|
||||
import {
|
||||
Feature,
|
||||
GeoJsonProperties,
|
||||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const fixturesPath = path.join(__dirname, "test_fixtures") + path.sep;
|
||||
|
||||
const fixtures = fs.readdirSync(fixturesPath).map((filename) => {
|
||||
return {
|
||||
filename,
|
||||
name: path.parse(filename).name,
|
||||
geojson: loadJsonFileSync(fixturesPath + filename),
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Benchmark Results
|
||||
*
|
||||
* long-lines-poly - pointA x 154,135 ops/sec ±0.36% (96 runs sampled)
|
||||
* long-lines-poly - pointB x 167,645 ops/sec ±0.30% (98 runs sampled)
|
||||
* long-lines-poly - pointC x 164,454 ops/sec ±0.25% (100 runs sampled)
|
||||
* multi-polygon - outer x 16,604 ops/sec ±0.22% (97 runs sampled)
|
||||
* multi-polygon - inner1 x 16,428 ops/sec ±0.20% (99 runs sampled)
|
||||
* multi-polygon - inner2 x 16,329 ops/sec ±0.19% (100 runs sampled)
|
||||
* multi-polygon - inner3-close-to-hole x 16,409 ops/sec ±0.26% (99 runs sampled)
|
||||
* multi-polygon - in-hole-close-to-poly-in-hole x 16,589 ops/sec ±0.27% (101 runs sampled)
|
||||
* multi-polygon - in-hole-close-to-hole-border x 16,251 ops/sec ±0.26% (98 runs sampled)
|
||||
* multi-polygon - in-poly-in-hole x 16,763 ops/sec ±0.50% (98 runs sampled)
|
||||
* simple-polygon - outer x 118,008 ops/sec ±0.17% (101 runs sampled)
|
||||
* simple-polygon - inner x 121,173 ops/sec ±0.17% (99 runs sampled)
|
||||
**/
|
||||
const suite = new Benchmark.Suite("turf-point-to-polygon-distance");
|
||||
|
||||
for (const { name, geojson } of fixtures) {
|
||||
// @ts-expect-error geojson
|
||||
const fc = featureCollection(geojson?.features || []);
|
||||
const points = fc.features.filter(
|
||||
(f): f is Feature<Point, GeoJsonProperties> => f.geometry.type === "Point"
|
||||
);
|
||||
const polygon = fc.features.find((f) =>
|
||||
["Polygon", "MultiPolygon"].includes(f.geometry.type)
|
||||
) as Feature<Polygon | MultiPolygon, GeoJsonProperties>;
|
||||
if (!polygon) {
|
||||
throw new Error(`No polygon found in the feature collection in ${name}`);
|
||||
}
|
||||
for (const point of points) {
|
||||
const caseName = `${name} - ${point.properties?.name || "unnamed point"}`;
|
||||
suite.add(caseName, () => {
|
||||
pointToPolygonDistance(point, polygon);
|
||||
});
|
||||
}
|
||||
}
|
||||
// @ts-expect-error benchmark
|
||||
suite.on("cycle", (e) => console.log(String(e.target))).run();
|
||||
90
packages/turf-point-to-polygon-distance/index.ts
Normal file
90
packages/turf-point-to-polygon-distance/index.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon";
|
||||
import {
|
||||
Feature,
|
||||
Point,
|
||||
Polygon,
|
||||
MultiPolygon,
|
||||
LineString,
|
||||
Position,
|
||||
} from "geojson";
|
||||
import { pointToLineDistance } from "@turf/point-to-line-distance";
|
||||
import { polygonToLine } from "@turf/polygon-to-line";
|
||||
import { getGeom } from "@turf/invariant";
|
||||
import { flattenEach } from "@turf/meta";
|
||||
import { polygon, Units } from "@turf/helpers";
|
||||
|
||||
/**
|
||||
* Calculates the distance from a point to the edges of a polygon or multi-polygon.
|
||||
* Returns negative values for points inside the polygon.
|
||||
* Handles polygons with holes and multi-polygons.
|
||||
* A hole is treated as the exterior of the polygon.
|
||||
*
|
||||
* @param {Feature<Point> | Point | Position} point Input point
|
||||
* @param {Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon} polygonOrMultiPolygon Input polygon or multipolygon
|
||||
* @param {Object} options Optional parameters
|
||||
* @param {Units} options.units Units of the result e.g. "kilometers", "miles", "meters"
|
||||
* @param {"geodesic" | "planar"} options.method Method of the result
|
||||
* @returns {number} Distance in meters (negative values for points inside the polygon)
|
||||
* @throws {Error} If input geometries are invalid
|
||||
*/
|
||||
export function pointToPolygonDistance(
|
||||
point: Feature<Point> | Point | Position,
|
||||
polygonOrMultiPolygon:
|
||||
| Feature<Polygon | MultiPolygon>
|
||||
| Polygon
|
||||
| MultiPolygon,
|
||||
options: {
|
||||
units?: Units;
|
||||
method?: "geodesic" | "planar";
|
||||
} = {}
|
||||
): number {
|
||||
const method = options.method ?? "geodesic";
|
||||
const units = options.units ?? "kilometers";
|
||||
// Input validation
|
||||
if (!point) throw new Error("point is required");
|
||||
if (!polygonOrMultiPolygon)
|
||||
throw new Error("polygon or multi-polygon is required");
|
||||
|
||||
const geom = getGeom(polygonOrMultiPolygon);
|
||||
|
||||
if (geom.type === "MultiPolygon") {
|
||||
const distances = geom.coordinates.map((coords) =>
|
||||
pointToPolygonDistance(point, polygon(coords), { method, units })
|
||||
);
|
||||
return (
|
||||
Math.min(...distances.map(Math.abs)) *
|
||||
(booleanPointInPolygon(point, polygonOrMultiPolygon) ? -1 : 1)
|
||||
);
|
||||
}
|
||||
|
||||
if (geom.coordinates.length > 1) {
|
||||
// Has holes
|
||||
const [exteriorDistance, ...interiorDistances] = geom.coordinates.map(
|
||||
(coords) =>
|
||||
pointToPolygonDistance(point, polygon([coords]), { method, units })
|
||||
);
|
||||
if (exteriorDistance >= 0) return exteriorDistance;
|
||||
// point is inside the exterior polygon shape
|
||||
const smallestInteriorDistance = Math.min(...interiorDistances);
|
||||
// point is inside one of the holes?
|
||||
if (smallestInteriorDistance < 0) return Math.abs(smallestInteriorDistance);
|
||||
// find which is closer, the distance to the hole or the distance to the edge of the exterior
|
||||
return Math.min(smallestInteriorDistance, Math.abs(exteriorDistance));
|
||||
}
|
||||
// The actual distance operation - on a normal, hole-less polygon in meters
|
||||
const lines = polygonToLine(geom);
|
||||
let minDistance = Infinity;
|
||||
flattenEach(lines, (feature) => {
|
||||
minDistance = Math.min(
|
||||
minDistance,
|
||||
pointToLineDistance(point, feature as Feature<LineString>, {
|
||||
method,
|
||||
units,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return booleanPointInPolygon(point, geom) ? -minDistance : minDistance;
|
||||
}
|
||||
|
||||
export default pointToPolygonDistance;
|
||||
79
packages/turf-point-to-polygon-distance/package.json
Normal file
79
packages/turf-point-to-polygon-distance/package.json
Normal file
@ -0,0 +1,79 @@
|
||||
{
|
||||
"name": "@turf/point-to-polygon-distance",
|
||||
"version": "7.1.0",
|
||||
"description": "turf point-to-polygon-distance module",
|
||||
"author": "Turf Authors",
|
||||
"contributors": [
|
||||
"Marc <@pachacamac>"
|
||||
],
|
||||
"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": [
|
||||
"turf",
|
||||
"gis",
|
||||
"point",
|
||||
"polygon",
|
||||
"distance"
|
||||
],
|
||||
"type": "module",
|
||||
"main": "dist/cjs/index.cjs",
|
||||
"module": "dist/esm/index.js",
|
||||
"types": "dist/esm/index.d.ts",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/cjs/index.d.cts",
|
||||
"default": "./dist/cjs/index.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"bench": "tsx bench.ts",
|
||||
"build": "tsup --config ../../tsup.config.ts",
|
||||
"docs": "tsx ../../scripts/generate-readmes.ts",
|
||||
"test": "npm-run-all --npm-path npm test:*",
|
||||
"test:tape": "tsx test.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/benchmark": "^2.1.5",
|
||||
"@types/tape": "^4.2.32",
|
||||
"benchmark": "^2.1.4",
|
||||
"load-json-file": "^7.0.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"tape": "^5.7.2",
|
||||
"tsup": "^8.0.1",
|
||||
"tsx": "^4.6.2",
|
||||
"typescript": "^5.5.4",
|
||||
"write-json-file": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@turf/boolean-point-in-polygon": "workspace:^",
|
||||
"@turf/helpers": "workspace:^",
|
||||
"@turf/invariant": "workspace:^",
|
||||
"@turf/meta": "workspace:^",
|
||||
"@turf/point-to-line-distance": "workspace:^",
|
||||
"@turf/polygon-to-line": "workspace:^",
|
||||
"@types/geojson": "^7946.0.10",
|
||||
"tslib": "^2.6.2"
|
||||
}
|
||||
}
|
||||
62
packages/turf-point-to-polygon-distance/test.ts
Normal file
62
packages/turf-point-to-polygon-distance/test.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import fs from "fs";
|
||||
import test from "tape";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { loadJsonFileSync } from "load-json-file";
|
||||
import { point } from "@turf/helpers";
|
||||
import { polygon } from "@turf/helpers";
|
||||
import { pointToPolygonDistance } from "./index.js";
|
||||
import { featureCollection } from "@turf/helpers";
|
||||
import {
|
||||
Feature,
|
||||
GeoJsonProperties,
|
||||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
} from "geojson";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
const fixturesPath = path.join(__dirname, "test_fixtures") + path.sep;
|
||||
|
||||
const fixtures = fs.readdirSync(fixturesPath).map((filename) => {
|
||||
return {
|
||||
filename,
|
||||
name: path.parse(filename).name,
|
||||
geojson: loadJsonFileSync(fixturesPath + filename),
|
||||
};
|
||||
});
|
||||
|
||||
test("turf-point-to-polygon-distance", (t) => {
|
||||
for (const { name, geojson } of fixtures) {
|
||||
// @ts-expect-error geojson
|
||||
const fc = featureCollection(geojson?.features || []);
|
||||
const points: Feature<Point, GeoJsonProperties>[] = fc.features.filter(
|
||||
(f): f is Feature<Point, GeoJsonProperties> => f.geometry.type === "Point"
|
||||
);
|
||||
const polygon = fc.features.find((f) =>
|
||||
["Polygon", "MultiPolygon"].includes(f.geometry.type)
|
||||
) as Feature<Polygon | MultiPolygon, GeoJsonProperties>;
|
||||
if (!polygon)
|
||||
throw new Error(`No polygon found in the feature collection in ${name}`);
|
||||
for (const point of points) {
|
||||
const expectedDistance = point.properties?.expected_distance;
|
||||
const units = point.properties?.units;
|
||||
const distance = pointToPolygonDistance(point, polygon, { units });
|
||||
t.equal(distance, expectedDistance, name, {
|
||||
message: `${name} - ${point.properties?.name}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
// Handle Errors
|
||||
t.throws(
|
||||
// @ts-expect-error invalid geometry
|
||||
() => pointToPolygonDistance(polygon([]), polygon([])),
|
||||
"throws - invalid geometry"
|
||||
);
|
||||
t.throws(
|
||||
() => pointToPolygonDistance(point([0, 0]), polygon([])),
|
||||
"throws - empty coordinates"
|
||||
);
|
||||
t.end();
|
||||
});
|
||||
@ -0,0 +1,56 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[3.3657268318160334, 25.76155695292222],
|
||||
[46.65471569612228, -18.814141655384176],
|
||||
[28.889827996699864, 25.16583746201097],
|
||||
[3.3657268318160334, 25.76155695292222]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "pointA",
|
||||
"expected_distance": 720.8195022016121,
|
||||
"units": "miles"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [-3.848091969075085, 17.75559032718766],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "pointB",
|
||||
"expected_distance": 174.26575299684424,
|
||||
"units": "miles"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [20.161990331199632, 5.93692849667535],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "pointC",
|
||||
"expected_distance": 1422.4933025064167,
|
||||
"units": "miles"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [15.761757321831652, -16.46137822158427],
|
||||
"type": "Point"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,143 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "outer",
|
||||
"expected_distance": 22.10311139107688,
|
||||
"units": "meters"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.403019116525968, 52.4749917692433],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "inner1",
|
||||
"expected_distance": -0.18712846397492156,
|
||||
"units": "kilometers"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.399915241855979, 52.472957280225245],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "inner2",
|
||||
"expected_distance": -0.2539006541753242,
|
||||
"units": "kilometers"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.396946319940724, 52.47723165382479],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "inner3-close-to-hole",
|
||||
"expected_distance": -16.135385380792886,
|
||||
"units": "meters"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.403283336358811, 52.47790995176382],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "in-hole-close-to-poly-in-hole",
|
||||
"expected_distance": 16.36078019912375,
|
||||
"units": "meters"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.403043879952975, 52.47832947539942],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "in-hole-close-to-hole-border",
|
||||
"expected_distance": 6.627508849855802,
|
||||
"units": "meters"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.40253783003243, 52.47852394247576],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "in-poly-in-hole",
|
||||
"expected_distance": -5.519191580154778,
|
||||
"units": "meters"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.403378284487616, 52.47824096630322],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
[13.391148572399459, 52.47422924057807],
|
||||
[13.39059601479363, 52.473247558678],
|
||||
[13.392253687611202, 52.47097558229518],
|
||||
[13.416658315199754, 52.47162072331574],
|
||||
[13.415415060587122, 52.475379182951684],
|
||||
[13.391148572399459, 52.47422924057807]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[13.391747176472563, 52.47470604959969],
|
||||
[13.415276921185495, 52.475771839318895],
|
||||
[13.415230874718247, 52.476444956368084],
|
||||
[13.410948553273812, 52.477258292397494],
|
||||
[13.406574138894086, 52.479333633450835],
|
||||
[13.3941415927641, 52.47961407743651],
|
||||
[13.392161594676793, 52.47734242974954],
|
||||
[13.392576012880966, 52.475743792551725],
|
||||
[13.391747176472563, 52.47470604959969]
|
||||
],
|
||||
[
|
||||
[13.402432150152691, 52.478581408896446],
|
||||
[13.402365252169176, 52.4782640275981],
|
||||
[13.402520173815134, 52.47815680366921],
|
||||
[13.402967334020701, 52.478034568071365],
|
||||
[13.403537727352841, 52.47807316882296],
|
||||
[13.403643355748358, 52.47818468191565],
|
||||
[13.403882780109853, 52.47820827118747],
|
||||
[13.403777151715332, 52.478392695967955],
|
||||
[13.403474350316174, 52.47848061913734],
|
||||
[13.403372242867533, 52.478600709036584],
|
||||
[13.402432150152691, 52.478581408896446]
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
[13.403245369174186, 52.478248303401074],
|
||||
[13.403353680211723, 52.478162544659085],
|
||||
[13.403550445261601, 52.47824170658075],
|
||||
[13.40335909576305, 52.47830327686577],
|
||||
[13.403245369174186, 52.478248303401074]
|
||||
]
|
||||
]
|
||||
],
|
||||
"type": "MultiPolygon"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
{
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "outer",
|
||||
"expected_distance": 0.0020673867731590976,
|
||||
"units": "kilometers"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.40811681056141, 52.52027359015821],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"name": "inner",
|
||||
"expected_distance": -7.980019325365333,
|
||||
"units": "meters"
|
||||
},
|
||||
"geometry": {
|
||||
"coordinates": [13.408017009112001, 52.52035996357455],
|
||||
"type": "Point"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[13.407833971095158, 52.52015934998451],
|
||||
[13.40823074294758, 52.52035304587994],
|
||||
[13.40819208895536, 52.52053359735595],
|
||||
[13.407789632692584, 52.520343361105404],
|
||||
[13.407833971095158, 52.52015934998451]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
3
packages/turf-point-to-polygon-distance/tsconfig.json
Normal file
3
packages/turf-point-to-polygon-distance/tsconfig.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../../tsconfig.shared.json"
|
||||
}
|
||||
@ -91,6 +91,7 @@ export { pointGrid } from "@turf/point-grid";
|
||||
export { pointOnFeature } from "@turf/point-on-feature";
|
||||
export { pointsWithinPolygon } from "@turf/points-within-polygon";
|
||||
export { pointToLineDistance } from "@turf/point-to-line-distance";
|
||||
export { pointToPolygonDistance } from "@turf/point-to-polygon-distance";
|
||||
export { polygonize } from "@turf/polygonize";
|
||||
export { polygonSmooth } from "@turf/polygon-smooth";
|
||||
export { polygonTangents } from "@turf/polygon-tangents";
|
||||
|
||||
@ -173,6 +173,7 @@
|
||||
"@turf/point-grid": "workspace:^",
|
||||
"@turf/point-on-feature": "workspace:^",
|
||||
"@turf/point-to-line-distance": "workspace:^",
|
||||
"@turf/point-to-polygon-distance": "workspace:^",
|
||||
"@turf/points-within-polygon": "workspace:^",
|
||||
"@turf/polygon-smooth": "workspace:^",
|
||||
"@turf/polygon-tangents": "workspace:^",
|
||||
|
||||
65
pnpm-lock.yaml
generated
65
pnpm-lock.yaml
generated
@ -353,6 +353,9 @@ importers:
|
||||
'@turf/point-to-line-distance':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-point-to-line-distance
|
||||
'@turf/point-to-polygon-distance':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-point-to-polygon-distance
|
||||
'@turf/points-within-polygon':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-points-within-polygon
|
||||
@ -4871,6 +4874,64 @@ importers:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.0
|
||||
|
||||
packages/turf-point-to-polygon-distance:
|
||||
dependencies:
|
||||
'@turf/boolean-point-in-polygon':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-boolean-point-in-polygon
|
||||
'@turf/helpers':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-helpers
|
||||
'@turf/invariant':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-invariant
|
||||
'@turf/meta':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-meta
|
||||
'@turf/point-to-line-distance':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-point-to-line-distance
|
||||
'@turf/polygon-to-line':
|
||||
specifier: workspace:^
|
||||
version: link:../turf-polygon-to-line
|
||||
'@types/geojson':
|
||||
specifier: ^7946.0.10
|
||||
version: 7946.0.14
|
||||
tslib:
|
||||
specifier: ^2.6.2
|
||||
version: 2.6.2
|
||||
devDependencies:
|
||||
'@types/benchmark':
|
||||
specifier: ^2.1.5
|
||||
version: 2.1.5
|
||||
'@types/tape':
|
||||
specifier: ^4.2.32
|
||||
version: 4.13.4
|
||||
benchmark:
|
||||
specifier: ^2.1.4
|
||||
version: 2.1.4
|
||||
load-json-file:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1
|
||||
npm-run-all:
|
||||
specifier: ^4.1.5
|
||||
version: 4.1.5
|
||||
tape:
|
||||
specifier: ^5.7.2
|
||||
version: 5.7.2
|
||||
tsup:
|
||||
specifier: ^8.0.1
|
||||
version: 8.0.1(postcss@8.4.40)(ts-node@9.1.1)(typescript@5.5.4)
|
||||
tsx:
|
||||
specifier: ^4.6.2
|
||||
version: 4.6.2
|
||||
typescript:
|
||||
specifier: ^5.5.4
|
||||
version: 5.5.4
|
||||
write-json-file:
|
||||
specifier: ^5.0.0
|
||||
version: 5.0.0
|
||||
|
||||
packages/turf-points-within-polygon:
|
||||
dependencies:
|
||||
'@turf/boolean-point-in-polygon':
|
||||
@ -9530,7 +9591,7 @@ packages:
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 7.18.0
|
||||
'@typescript-eslint/visitor-keys': 7.18.0
|
||||
debug: 4.3.4
|
||||
debug: 4.3.6
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
minimatch: 9.0.4
|
||||
@ -16262,7 +16323,7 @@ packages:
|
||||
bundle-require: 4.0.2(esbuild@0.19.11)
|
||||
cac: 6.7.14
|
||||
chokidar: 3.5.3
|
||||
debug: 4.3.4
|
||||
debug: 4.3.6
|
||||
esbuild: 0.19.11
|
||||
execa: 5.1.1
|
||||
globby: 11.1.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user