@turf/boolean-point-on-line
Advanced tools
Comparing version 6.3.0 to 6.4.0
@@ -11,2 +11,3 @@ import { getCoord, getCoords } from "@turf/invariant"; | ||
* @param {boolean} [options.ignoreEndVertices=false] whether to ignore the start and end vertices. | ||
* @param {number} [options.epsilon] Fractional number to compare with the cross product result. Useful for dealing with floating points such as lng/lat points | ||
* @returns {boolean} true/false | ||
@@ -38,3 +39,3 @@ * @example | ||
} | ||
if (isPointOnLineSegment(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary)) { | ||
if (isPointOnLineSegment(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary, typeof options.epsilon === "undefined" ? null : options.epsilon)) { | ||
return true; | ||
@@ -46,2 +47,3 @@ } | ||
// See http://stackoverflow.com/a/4833823/1979085 | ||
// See https://stackoverflow.com/a/328122/1048847 | ||
/** | ||
@@ -53,6 +55,7 @@ * @private | ||
* @param {boolean|string} excludeBoundary whether the point is allowed to fall on the line ends. | ||
* @param {number} epsilon Fractional number to compare with the cross product result. Useful for dealing with floating points such as lng/lat points | ||
* If true which end to ignore. | ||
* @returns {boolean} true/false | ||
*/ | ||
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt, excludeBoundary) { | ||
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt, excludeBoundary, epsilon) { | ||
var x = pt[0]; | ||
@@ -69,3 +72,8 @@ var y = pt[1]; | ||
var cross = dxc * dyl - dyc * dxl; | ||
if (cross !== 0) { | ||
if (epsilon !== null) { | ||
if (Math.abs(cross) > epsilon) { | ||
return false; | ||
} | ||
} | ||
else if (cross !== 0) { | ||
return false; | ||
@@ -72,0 +80,0 @@ } |
@@ -11,2 +11,3 @@ import { Coord, Feature, LineString } from "@turf/helpers"; | ||
* @param {boolean} [options.ignoreEndVertices=false] whether to ignore the start and end vertices. | ||
* @param {number} [options.epsilon] Fractional number to compare with the cross product result. Useful for dealing with floating points such as lng/lat points | ||
* @returns {boolean} true/false | ||
@@ -21,3 +22,4 @@ * @example | ||
ignoreEndVertices?: boolean; | ||
epsilon?: number; | ||
}): boolean; | ||
export default booleanPointOnLine; |
@@ -13,2 +13,3 @@ "use strict"; | ||
* @param {boolean} [options.ignoreEndVertices=false] whether to ignore the start and end vertices. | ||
* @param {number} [options.epsilon] Fractional number to compare with the cross product result. Useful for dealing with floating points such as lng/lat points | ||
* @returns {boolean} true/false | ||
@@ -40,3 +41,3 @@ * @example | ||
} | ||
if (isPointOnLineSegment(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary)) { | ||
if (isPointOnLineSegment(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary, typeof options.epsilon === "undefined" ? null : options.epsilon)) { | ||
return true; | ||
@@ -48,2 +49,3 @@ } | ||
// See http://stackoverflow.com/a/4833823/1979085 | ||
// See https://stackoverflow.com/a/328122/1048847 | ||
/** | ||
@@ -55,6 +57,7 @@ * @private | ||
* @param {boolean|string} excludeBoundary whether the point is allowed to fall on the line ends. | ||
* @param {number} epsilon Fractional number to compare with the cross product result. Useful for dealing with floating points such as lng/lat points | ||
* If true which end to ignore. | ||
* @returns {boolean} true/false | ||
*/ | ||
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt, excludeBoundary) { | ||
function isPointOnLineSegment(lineSegmentStart, lineSegmentEnd, pt, excludeBoundary, epsilon) { | ||
var x = pt[0]; | ||
@@ -71,3 +74,8 @@ var y = pt[1]; | ||
var cross = dxc * dyl - dyc * dxl; | ||
if (cross !== 0) { | ||
if (epsilon !== null) { | ||
if (Math.abs(cross) > epsilon) { | ||
return false; | ||
} | ||
} | ||
else if (cross !== 0) { | ||
return false; | ||
@@ -74,0 +82,0 @@ } |
{ | ||
"name": "@turf/boolean-point-on-line", | ||
"version": "6.3.0", | ||
"version": "6.4.0", | ||
"description": "turf boolean-point-on-line module", | ||
@@ -61,6 +61,6 @@ "author": "Turf Authors", | ||
"dependencies": { | ||
"@turf/helpers": "^6.3.0", | ||
"@turf/invariant": "^6.3.0" | ||
"@turf/helpers": "^6.4.0", | ||
"@turf/invariant": "^6.4.0" | ||
}, | ||
"gitHead": "57c8877e1e2d67effc2cdd23385c02b2a6615a49" | ||
"gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
13392
229
1
Updated@turf/helpers@^6.4.0
Updated@turf/invariant@^6.4.0