@turf/nearest-point 7.1.0 → 7.2.0
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/dist/cjs/index.cjs +2 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js +2 -4
- package/dist/esm/index.js.map +1 -1
- package/package.json +12 -12
package/dist/cjs/index.cjs
CHANGED
|
@@ -23,10 +23,8 @@ var _clone = require('@turf/clone');
|
|
|
23
23
|
var _distance = require('@turf/distance');
|
|
24
24
|
var _meta = require('@turf/meta');
|
|
25
25
|
function nearestPoint(targetPoint, points, options = {}) {
|
|
26
|
-
if (!targetPoint)
|
|
27
|
-
|
|
28
|
-
if (!points)
|
|
29
|
-
throw new Error("points is required");
|
|
26
|
+
if (!targetPoint) throw new Error("targetPoint is required");
|
|
27
|
+
if (!points) throw new Error("points is required");
|
|
30
28
|
let minDist = Infinity;
|
|
31
29
|
let bestFeatureIndex = 0;
|
|
32
30
|
_meta.featureEach.call(void 0, points, (pt, featureIndex) => {
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"names":["nearestPoint"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-nearest-point/dist/cjs/index.cjs","../../index.ts"],"names":["nearestPoint"],"mappings":"AAAA,6EAAI,UAAU,EAAE,MAAM,CAAC,cAAc;AACrC,IAAI,WAAW,EAAE,MAAM,CAAC,gBAAgB;AACxC,IAAI,kBAAkB,EAAE,MAAM,CAAC,yBAAyB;AACxD,IAAI,oBAAoB,EAAE,MAAM,CAAC,qBAAqB;AACtD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,cAAc;AAClD,IAAI,aAAa,EAAE,MAAM,CAAC,SAAS,CAAC,oBAAoB;AACxD,IAAI,gBAAgB,EAAE,CA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IAAI,KAAA,CAAM,oBAAoB,CAAA;AAEjD,EAAA,IAAI,QAAA,EAAU,QAAA;AACd,EAAA,IAAI,iBAAA,EAAmB,CAAA;AACvB,EAAA,+BAAA,MAAY,EAAQ,CAAC,EAAA,EAAI,YAAA,EAAA,GAAiB;AACxC,IAAA,MAAM,gBAAA,EAAkB,gCAAA,WAAS,EAAa,EAAA,EAAI,OAAO,CAAA;AACzD,IAAA,GAAA,CAAI,gBAAA,EAAkB,OAAA,EAAS;AAC7B,MAAA,iBAAA,EAAmB,YAAA;AACnB,MAAA,QAAA,EAAU,eAAA;AAAA,IACZ;AAAA,EACF,CAAC,CAAA;AACD,EAAA,MAAMA,cAAAA,EAAe,0BAAA,MAAM,CAAO,QAAA,CAAS,gBAAgB,CAAC,CAAA;AAE5D,EAAA,OAAO,aAAA,CAAA,cAAA,CAAA,CAAA,CAAA,EACFA,aAAAA,CAAAA,EADE;AAAA,IAEL,UAAA,EAAY,aAAA,CAAA,cAAA,CAAA,CAAA,CAAA,EACPA,aAAAA,CAAa,UAAA,CAAA,EADN;AAAA,MAEV,YAAA,EAAc,gBAAA;AAAA,MACd,eAAA,EAAiB;AAAA,IACnB,CAAA;AAAA,EACF,CAAA,CAAA;AACF;AAGA,IAAO,2BAAA,EAAQ,YAAA;AD5Bf;AACE;AACA;AACF,kFAAC","file":"/home/runner/work/turf/turf/packages/turf-nearest-point/dist/cjs/index.cjs","sourcesContent":[null,"import { Feature, FeatureCollection, Point } from \"geojson\";\nimport { Coord, Units } from \"@turf/helpers\";\nimport { clone } from \"@turf/clone\";\nimport { distance } from \"@turf/distance\";\nimport { featureEach } from \"@turf/meta\";\n\ninterface NearestPoint extends Feature<Point> {\n properties: {\n featureIndex: number;\n distanceToPoint: number;\n [key: string]: any;\n };\n}\n\n/**\n * Takes a reference {@link Point|point} and a FeatureCollection of Features\n * with Point geometries and returns the\n * point from the FeatureCollection closest to the reference. This calculation\n * is geodesic.\n *\n * @function\n * @param {Coord} targetPoint the reference point\n * @param {FeatureCollection<Point>} points against input point set\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] the units of the numeric result\n * @returns {Feature<Point>} the closest point in the set to the reference point\n * @example\n * var targetPoint = turf.point([28.965797, 41.010086], {\"marker-color\": \"#0F0\"});\n * var points = turf.featureCollection([\n * turf.point([28.973865, 41.011122]),\n * turf.point([28.948459, 41.024204]),\n * turf.point([28.938674, 41.013324])\n * ]);\n *\n * var nearest = turf.nearestPoint(targetPoint, points);\n *\n * //addToMap\n * var addToMap = [targetPoint, points, nearest];\n * nearest.properties['marker-color'] = '#F00';\n */\nfunction nearestPoint(\n targetPoint: Coord,\n points: FeatureCollection<Point>,\n options: {\n units?: Units;\n } = {}\n): NearestPoint {\n // Input validation\n if (!targetPoint) throw new Error(\"targetPoint is required\");\n if (!points) throw new Error(\"points is required\");\n\n let minDist = Infinity;\n let bestFeatureIndex = 0;\n featureEach(points, (pt, featureIndex) => {\n const distanceToPoint = distance(targetPoint, pt, options);\n if (distanceToPoint < minDist) {\n bestFeatureIndex = featureIndex;\n minDist = distanceToPoint;\n }\n });\n const nearestPoint = clone(points.features[bestFeatureIndex]);\n\n return {\n ...nearestPoint,\n properties: {\n ...nearestPoint.properties,\n featureIndex: bestFeatureIndex,\n distanceToPoint: minDist,\n },\n };\n}\n\nexport { nearestPoint, NearestPoint };\nexport default nearestPoint;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -14,7 +14,7 @@ interface NearestPoint extends Feature<Point> {
|
|
|
14
14
|
* point from the FeatureCollection closest to the reference. This calculation
|
|
15
15
|
* is geodesic.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
17
|
+
* @function
|
|
18
18
|
* @param {Coord} targetPoint the reference point
|
|
19
19
|
* @param {FeatureCollection<Point>} points against input point set
|
|
20
20
|
* @param {Object} [options={}] Optional parameters
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ interface NearestPoint extends Feature<Point> {
|
|
|
14
14
|
* point from the FeatureCollection closest to the reference. This calculation
|
|
15
15
|
* is geodesic.
|
|
16
16
|
*
|
|
17
|
-
* @
|
|
17
|
+
* @function
|
|
18
18
|
* @param {Coord} targetPoint the reference point
|
|
19
19
|
* @param {FeatureCollection<Point>} points against input point set
|
|
20
20
|
* @param {Object} [options={}] Optional parameters
|
package/dist/esm/index.js
CHANGED
|
@@ -23,10 +23,8 @@ import { clone } from "@turf/clone";
|
|
|
23
23
|
import { distance } from "@turf/distance";
|
|
24
24
|
import { featureEach } from "@turf/meta";
|
|
25
25
|
function nearestPoint(targetPoint, points, options = {}) {
|
|
26
|
-
if (!targetPoint)
|
|
27
|
-
|
|
28
|
-
if (!points)
|
|
29
|
-
throw new Error("points is required");
|
|
26
|
+
if (!targetPoint) throw new Error("targetPoint is required");
|
|
27
|
+
if (!points) throw new Error("points is required");
|
|
30
28
|
let minDist = Infinity;
|
|
31
29
|
let bestFeatureIndex = 0;
|
|
32
30
|
featureEach(points, (pt, featureIndex) => {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, Point } from \"geojson\";\nimport { Coord, Units } from \"@turf/helpers\";\nimport { clone } from \"@turf/clone\";\nimport { distance } from \"@turf/distance\";\nimport { featureEach } from \"@turf/meta\";\n\ninterface NearestPoint extends Feature<Point> {\n properties: {\n featureIndex: number;\n distanceToPoint: number;\n [key: string]: any;\n };\n}\n\n/**\n * Takes a reference {@link Point|point} and a FeatureCollection of Features\n * with Point geometries and returns the\n * point from the FeatureCollection closest to the reference. This calculation\n * is geodesic.\n *\n * @
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, Point } from \"geojson\";\nimport { Coord, Units } from \"@turf/helpers\";\nimport { clone } from \"@turf/clone\";\nimport { distance } from \"@turf/distance\";\nimport { featureEach } from \"@turf/meta\";\n\ninterface NearestPoint extends Feature<Point> {\n properties: {\n featureIndex: number;\n distanceToPoint: number;\n [key: string]: any;\n };\n}\n\n/**\n * Takes a reference {@link Point|point} and a FeatureCollection of Features\n * with Point geometries and returns the\n * point from the FeatureCollection closest to the reference. This calculation\n * is geodesic.\n *\n * @function\n * @param {Coord} targetPoint the reference point\n * @param {FeatureCollection<Point>} points against input point set\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] the units of the numeric result\n * @returns {Feature<Point>} the closest point in the set to the reference point\n * @example\n * var targetPoint = turf.point([28.965797, 41.010086], {\"marker-color\": \"#0F0\"});\n * var points = turf.featureCollection([\n * turf.point([28.973865, 41.011122]),\n * turf.point([28.948459, 41.024204]),\n * turf.point([28.938674, 41.013324])\n * ]);\n *\n * var nearest = turf.nearestPoint(targetPoint, points);\n *\n * //addToMap\n * var addToMap = [targetPoint, points, nearest];\n * nearest.properties['marker-color'] = '#F00';\n */\nfunction nearestPoint(\n targetPoint: Coord,\n points: FeatureCollection<Point>,\n options: {\n units?: Units;\n } = {}\n): NearestPoint {\n // Input validation\n if (!targetPoint) throw new Error(\"targetPoint is required\");\n if (!points) throw new Error(\"points is required\");\n\n let minDist = Infinity;\n let bestFeatureIndex = 0;\n featureEach(points, (pt, featureIndex) => {\n const distanceToPoint = distance(targetPoint, pt, options);\n if (distanceToPoint < minDist) {\n bestFeatureIndex = featureIndex;\n minDist = distanceToPoint;\n }\n });\n const nearestPoint = clone(points.features[bestFeatureIndex]);\n\n return {\n ...nearestPoint,\n properties: {\n ...nearestPoint.properties,\n featureIndex: bestFeatureIndex,\n distanceToPoint: minDist,\n },\n };\n}\n\nexport { nearestPoint, NearestPoint };\nexport default nearestPoint;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAoC5B,SAAS,aACP,aACA,QACA,UAEI,CAAC,GACS;AAEd,MAAI,CAAC,YAAa,OAAM,IAAI,MAAM,yBAAyB;AAC3D,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,oBAAoB;AAEjD,MAAI,UAAU;AACd,MAAI,mBAAmB;AACvB,cAAY,QAAQ,CAAC,IAAI,iBAAiB;AACxC,UAAM,kBAAkB,SAAS,aAAa,IAAI,OAAO;AACzD,QAAI,kBAAkB,SAAS;AAC7B,yBAAmB;AACnB,gBAAU;AAAA,IACZ;AAAA,EACF,CAAC;AACD,QAAMA,gBAAe,MAAM,OAAO,SAAS,gBAAgB,CAAC;AAE5D,SAAO,iCACFA,gBADE;AAAA,IAEL,YAAY,iCACPA,cAAa,aADN;AAAA,MAEV,cAAc;AAAA,MACd,iBAAiB;AAAA,IACnB;AAAA,EACF;AACF;AAGA,IAAO,6BAAQ;","names":["nearestPoint"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/nearest-point",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "turf nearest-point module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,23 +55,23 @@
|
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/benchmark": "^2.1.5",
|
|
58
|
-
"@types/tape": "^4.
|
|
58
|
+
"@types/tape": "^4.13.4",
|
|
59
59
|
"benchmark": "^2.1.4",
|
|
60
60
|
"load-json-file": "^7.0.1",
|
|
61
61
|
"npm-run-all": "^4.1.5",
|
|
62
|
-
"tape": "^5.
|
|
63
|
-
"tsup": "^8.
|
|
64
|
-
"tsx": "^4.
|
|
65
|
-
"typescript": "^5.
|
|
62
|
+
"tape": "^5.9.0",
|
|
63
|
+
"tsup": "^8.3.5",
|
|
64
|
+
"tsx": "^4.19.2",
|
|
65
|
+
"typescript": "^5.5.4",
|
|
66
66
|
"write-json-file": "^5.0.0"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@turf/clone": "^7.
|
|
70
|
-
"@turf/distance": "^7.
|
|
71
|
-
"@turf/helpers": "^7.
|
|
72
|
-
"@turf/meta": "^7.
|
|
69
|
+
"@turf/clone": "^7.2.0",
|
|
70
|
+
"@turf/distance": "^7.2.0",
|
|
71
|
+
"@turf/helpers": "^7.2.0",
|
|
72
|
+
"@turf/meta": "^7.2.0",
|
|
73
73
|
"@types/geojson": "^7946.0.10",
|
|
74
|
-
"tslib": "^2.
|
|
74
|
+
"tslib": "^2.8.1"
|
|
75
75
|
},
|
|
76
|
-
"gitHead": "
|
|
76
|
+
"gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
|
|
77
77
|
}
|