@turf/point-to-line-distance
Advanced tools
Comparing version 5.0.4 to 5.1.0
@@ -26,4 +26,4 @@ // (logic of computation inspired by: | ||
* @name pointToLineDistance | ||
* @param {Geometry|Feature<Point>|Array<number>} pt Feature or Geometry | ||
* @param {Geometry|Feature<LineString>|Array<Array<number>>} line GeoJSON Feature or Geometry | ||
* @param {Coord} pt Feature or Geometry | ||
* @param {Feature<LineString>} line GeoJSON Feature or Geometry | ||
* @param {Object} [options={}] Optional parameters | ||
@@ -30,0 +30,0 @@ * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers |
34
main.js
@@ -22,4 +22,4 @@ 'use strict'; | ||
* @name pointToLineDistance | ||
* @param {Geometry|Feature<Point>|Array<number>} pt Feature or Geometry | ||
* @param {Geometry|Feature<LineString>|Array<Array<number>>} line GeoJSON Feature or Geometry | ||
* @param {Coord} pt Feature or Geometry | ||
* @param {Feature<LineString>} line GeoJSON Feature or Geometry | ||
* @param {Object} [options={}] Optional parameters | ||
@@ -39,14 +39,14 @@ * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error('options is invalid'); | ||
if (!helpers.isObject(options)) { throw new Error('options is invalid'); } | ||
// validation | ||
if (!pt) throw new Error('pt is required'); | ||
if (Array.isArray(pt)) pt = helpers.point(pt); | ||
else if (pt.type === 'Point') pt = helpers.feature(pt); | ||
else invariant.featureOf(pt, 'Point', 'point'); | ||
if (!pt) { throw new Error('pt is required'); } | ||
if (Array.isArray(pt)) { pt = helpers.point(pt); } | ||
else if (pt.type === 'Point') { pt = helpers.feature(pt); } | ||
else { invariant.featureOf(pt, 'Point', 'point'); } | ||
if (!line) throw new Error('line is required'); | ||
if (Array.isArray(line)) line = helpers.lineString(line); | ||
else if (line.type === 'LineString') line = helpers.feature(line); | ||
else invariant.featureOf(line, 'LineString', 'line'); | ||
if (!line) { throw new Error('line is required'); } | ||
if (Array.isArray(line)) { line = helpers.lineString(line); } | ||
else if (line.type === 'LineString') { line = helpers.feature(line); } | ||
else { invariant.featureOf(line, 'LineString', 'line'); } | ||
@@ -59,3 +59,3 @@ var distance$$1 = Infinity; | ||
var d = distanceToSegment(p, a, b, options); | ||
if (distance$$1 > d) distance$$1 = d; | ||
if (distance$$1 > d) { distance$$1 = d; } | ||
}); | ||
@@ -95,3 +95,3 @@ return distance$$1; | ||
*/ | ||
if (angleA > 90) return distanceAP; | ||
if (angleA > 90) { return distanceAP; } | ||
@@ -101,3 +101,3 @@ var azimuthBA = (azimuthAB + 180) % 360; | ||
var angleB = Math.abs(azimuthBP - azimuthBA); | ||
if (angleB > 180) angleB = Math.abs(angleB - 360); | ||
if (angleB > 180) { angleB = Math.abs(angleB - 360); } | ||
// also if the angle ABP is acute the projection of P falls outside the segment, on the other side | ||
@@ -113,3 +113,3 @@ // so return the distance between P and the end point B | ||
*/ | ||
if (angleB > 90) return (mercator !== true) ? distance(p, b, options) : euclideanDistance(p, b, options); | ||
if (angleB > 90) { return (mercator !== true) ? distance(p, b, options) : euclideanDistance(p, b, options); } | ||
// finally if the projection falls inside the segment | ||
@@ -126,3 +126,3 @@ // return the distance between P and the segment | ||
*/ | ||
if (mercator !== true) return distanceAP * Math.sin(helpers.degreesToRadians(angleA)); | ||
if (mercator !== true) { return distanceAP * Math.sin(helpers.degreesToRadians(angleA)); } | ||
return mercatorPH(a, b, p, options); | ||
@@ -155,3 +155,3 @@ } | ||
if (delta !== 0) h[0] -= delta; // translate back to original position | ||
if (delta !== 0) { h[0] -= delta; } // translate back to original position | ||
var distancePH = rhumbDistance(origin, h, options); | ||
@@ -158,0 +158,0 @@ return distancePH; |
{ | ||
"name": "@turf/point-to-line-distance", | ||
"version": "5.0.4", | ||
"version": "5.1.0", | ||
"description": "turf point-to-line-distance module", | ||
"main": "main", | ||
"module": "index", | ||
"jsnext:main": "index", | ||
"main": "main.js", | ||
"module": "main.mjs", | ||
"types": "index.d.ts", | ||
@@ -12,3 +11,4 @@ "files": [ | ||
"index.d.ts", | ||
"main.js" | ||
"main.js", | ||
"main.mjs" | ||
], | ||
@@ -18,3 +18,4 @@ "scripts": { | ||
"test": "node -r @std/esm test.js", | ||
"bench": "node -r @std/esm bench.js" | ||
"bench": "node -r @std/esm bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
}, | ||
@@ -41,6 +42,7 @@ "repository": { | ||
"@std/esm": "*", | ||
"@turf/circle": "^5.0.4", | ||
"@turf/circle": "^5.1.0", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"rollup-plugin-buble": "*", | ||
"tape": "*", | ||
@@ -50,10 +52,10 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/bearing": "^5.0.4", | ||
"@turf/distance": "^5.0.4", | ||
"@turf/helpers": "^5.0.4", | ||
"@turf/invariant": "^5.0.4", | ||
"@turf/meta": "^5.0.4", | ||
"@turf/projection": "^5.0.4", | ||
"@turf/rhumb-bearing": "^5.0.4", | ||
"@turf/rhumb-distance": "^5.0.4" | ||
"@turf/bearing": "^5.1.0", | ||
"@turf/distance": "^5.1.0", | ||
"@turf/helpers": "^5.1.0", | ||
"@turf/invariant": "^5.1.0", | ||
"@turf/meta": "^5.1.0", | ||
"@turf/projection": "^5.1.0", | ||
"@turf/rhumb-bearing": "^5.1.0", | ||
"@turf/rhumb-distance": "^5.1.0" | ||
}, | ||
@@ -60,0 +62,0 @@ "@std/esm": { |
@@ -7,3 +7,3 @@ # @turf/point-to-line-distance | ||
Returns the minimum distance between a [Point](http://geojson.org/geojson-spec.html#point) and a [LineString](http://geojson.org/geojson-spec.html#linestring), being the distance from a line the | ||
Returns the minimum distance between a [Point](https://tools.ietf.org/html/rfc7946#section-3.1.2) and a [LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4), being the distance from a line the | ||
minimum distance between the point and any segment of the `LineString`. | ||
@@ -13,4 +13,4 @@ | ||
- `pt` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** Feature or Geometry | ||
- `line` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<[LineString](http://geojson.org/geojson-spec.html#linestring)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>>)** GeoJSON Feature or Geometry | ||
- `pt` **[Coord](https://tools.ietf.org/html/rfc7946#section-3.1.1)** Feature or Geometry | ||
- `line` **[Feature](https://tools.ietf.org/html/rfc7946#section-3.2)<[LineString](https://tools.ietf.org/html/rfc7946#section-3.1.4)>** GeoJSON Feature or Geometry | ||
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`) | ||
@@ -17,0 +17,0 @@ - `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28651
7
590
8
Updated@turf/bearing@^5.1.0
Updated@turf/distance@^5.1.0
Updated@turf/helpers@^5.1.0
Updated@turf/invariant@^5.1.0
Updated@turf/meta@^5.1.0
Updated@turf/projection@^5.1.0
Updated@turf/rhumb-bearing@^5.1.0
Updated@turf/rhumb-distance@^5.1.0