@turf/nearest-point 7.0.0 → 7.1.0-alpha.7

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.
@@ -17,7 +17,6 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
21
20
 
22
21
  // index.ts
23
22
  var _clone = require('@turf/clone');
@@ -45,7 +44,6 @@ function nearestPoint(targetPoint, points, options = {}) {
45
44
  })
46
45
  });
47
46
  }
48
- __name(nearestPoint, "nearestPoint");
49
47
  var turf_nearest_point_default = nearestPoint;
50
48
 
51
49
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"names":["nearestPoint"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAoC5B,SAAS,aACP,aACA,QACA,UAEI,CAAC,GACS;AAEd,MAAI,CAAC;AAAa,UAAM,IAAI,MAAM,yBAAyB;AAC3D,MAAI,CAAC;AAAQ,UAAM,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;AA9BS;AAiCT,IAAO,6BAAQ","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 * @name nearestPoint\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"]}
1
+ {"version":3,"sources":["../../index.ts"],"names":["nearestPoint"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAoC5B,SAAS,aACP,aACA,QACA,UAEI,CAAC,GACS;AAEd,MAAI,CAAC;AAAa,UAAM,IAAI,MAAM,yBAAyB;AAC3D,MAAI,CAAC;AAAQ,UAAM,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","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 * @name nearestPoint\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/esm/index.js CHANGED
@@ -17,7 +17,6 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
21
20
 
22
21
  // index.ts
23
22
  import { clone } from "@turf/clone";
@@ -45,7 +44,6 @@ function nearestPoint(targetPoint, points, options = {}) {
45
44
  })
46
45
  });
47
46
  }
48
- __name(nearestPoint, "nearestPoint");
49
47
  var turf_nearest_point_default = nearestPoint;
50
48
  export {
51
49
  turf_nearest_point_default as default,
@@ -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 * @name nearestPoint\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;AAAa,UAAM,IAAI,MAAM,yBAAyB;AAC3D,MAAI,CAAC;AAAQ,UAAM,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;AA9BS;AAiCT,IAAO,6BAAQ;","names":["nearestPoint"]}
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 * @name nearestPoint\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;AAAa,UAAM,IAAI,MAAM,yBAAyB;AAC3D,MAAI,CAAC;AAAQ,UAAM,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.0.0",
3
+ "version": "7.1.0-alpha.7+0ce6ecca0",
4
4
  "description": "turf nearest-point module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -66,11 +66,11 @@
66
66
  "write-json-file": "^5.0.0"
67
67
  },
68
68
  "dependencies": {
69
- "@turf/clone": "^7.0.0",
70
- "@turf/distance": "^7.0.0",
71
- "@turf/helpers": "^7.0.0",
72
- "@turf/meta": "^7.0.0",
69
+ "@turf/clone": "^7.1.0-alpha.7+0ce6ecca0",
70
+ "@turf/distance": "^7.1.0-alpha.7+0ce6ecca0",
71
+ "@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
72
+ "@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
73
73
  "tslib": "^2.6.2"
74
74
  },
75
- "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
75
+ "gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
76
76
  }