all these changes

This commit is contained in:
Jake Kasper
2026-04-09 13:19:47 -05:00
parent e83a51a051
commit 65315f36d1
39102 changed files with 7932979 additions and 567 deletions

View 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.

View File

@@ -0,0 +1,60 @@
# @turf/boolean-point-on-line
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## booleanPointOnLine
Returns true if a point is on a line. Accepts a optional parameter to ignore the start and end vertices of the linestring.
**Parameters**
- `pt` **[Coord][1]** GeoJSON Point
- `line` **[Feature][2]&lt;[LineString][3]>** GeoJSON LineString
- `options` **[Object][4]** Optional parameters (optional, default `{}`)
- `options.ignoreEndVertices` **[boolean][5]** whether to ignore the start and end vertices. (optional, default `false`)
**Examples**
```javascript
var pt = turf.point([0, 0]);
var line = turf.lineString([[-1, -1],[1, 1],[1.5, 2.2]]);
var isPointOnLine = turf.booleanPointOnLine(pt, line);
//=true
```
Returns **[boolean][5]** true/false
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.1
[2]: https://tools.ietf.org/html/rfc7946#section-3.2
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.4
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
<!-- This file is automatically generated. Please don't edit it directly:
if you find an error, edit the source file (likely index.js), and re-run
./scripts/generate-readmes in the turf project. -->
---
This module is part of the [Turfjs project](http://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 module individually:
```sh
$ npm install @turf/boolean-point-on-line
```
Or install the Turf module that includes it as a function:
```sh
$ npm install @turf/turf
```

View File

@@ -0,0 +1,102 @@
import { getCoord, getCoords } from "@turf/invariant";
/**
* Returns true if a point is on a line. Accepts a optional parameter to ignore the
* start and end vertices of the linestring.
*
* @name booleanPointOnLine
* @param {Coord} pt GeoJSON Point
* @param {Feature<LineString>} line GeoJSON LineString
* @param {Object} [options={}] Optional parameters
* @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
* @example
* var pt = turf.point([0, 0]);
* var line = turf.lineString([[-1, -1],[1, 1],[1.5, 2.2]]);
* var isPointOnLine = turf.booleanPointOnLine(pt, line);
* //=true
*/
function booleanPointOnLine(pt, line, options) {
if (options === void 0) { options = {}; }
// Normalize inputs
var ptCoords = getCoord(pt);
var lineCoords = getCoords(line);
// Main
for (var i = 0; i < lineCoords.length - 1; i++) {
var ignoreBoundary = false;
if (options.ignoreEndVertices) {
if (i === 0) {
ignoreBoundary = "start";
}
if (i === lineCoords.length - 2) {
ignoreBoundary = "end";
}
if (i === 0 && i + 1 === lineCoords.length - 1) {
ignoreBoundary = "both";
}
}
if (isPointOnLineSegment(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary, typeof options.epsilon === "undefined" ? null : options.epsilon)) {
return true;
}
}
return false;
}
// See http://stackoverflow.com/a/4833823/1979085
// See https://stackoverflow.com/a/328122/1048847
/**
* @private
* @param {Position} lineSegmentStart coord pair of start of line
* @param {Position} lineSegmentEnd coord pair of end of line
* @param {Position} pt coord pair of point to check
* @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, epsilon) {
var x = pt[0];
var y = pt[1];
var x1 = lineSegmentStart[0];
var y1 = lineSegmentStart[1];
var x2 = lineSegmentEnd[0];
var y2 = lineSegmentEnd[1];
var dxc = pt[0] - x1;
var dyc = pt[1] - y1;
var dxl = x2 - x1;
var dyl = y2 - y1;
var cross = dxc * dyl - dyc * dxl;
if (epsilon !== null) {
if (Math.abs(cross) > epsilon) {
return false;
}
}
else if (cross !== 0) {
return false;
}
if (!excludeBoundary) {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 <= x && x <= x2 : x2 <= x && x <= x1;
}
return dyl > 0 ? y1 <= y && y <= y2 : y2 <= y && y <= y1;
}
else if (excludeBoundary === "start") {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 < x && x <= x2 : x2 <= x && x < x1;
}
return dyl > 0 ? y1 < y && y <= y2 : y2 <= y && y < y1;
}
else if (excludeBoundary === "end") {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 <= x && x < x2 : x2 < x && x <= x1;
}
return dyl > 0 ? y1 <= y && y < y2 : y2 < y && y <= y1;
}
else if (excludeBoundary === "both") {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 < x && x < x2 : x2 < x && x < x1;
}
return dyl > 0 ? y1 < y && y < y2 : y2 < y && y < y1;
}
return false;
}
export default booleanPointOnLine;

View File

@@ -0,0 +1 @@
{"type":"module"}

View File

@@ -0,0 +1,23 @@
import { Coord, Feature, LineString } from "@turf/helpers";
/**
* Returns true if a point is on a line. Accepts a optional parameter to ignore the
* start and end vertices of the linestring.
*
* @name booleanPointOnLine
* @param {Coord} pt GeoJSON Point
* @param {Feature<LineString>} line GeoJSON LineString
* @param {Object} [options={}] Optional parameters
* @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
* @example
* var pt = turf.point([0, 0]);
* var line = turf.lineString([[-1, -1],[1, 1],[1.5, 2.2]]);
* var isPointOnLine = turf.booleanPointOnLine(pt, line);
* //=true
*/
declare function booleanPointOnLine(pt: Coord, line: Feature<LineString> | LineString, options?: {
ignoreEndVertices?: boolean;
epsilon?: number;
}): boolean;
export default booleanPointOnLine;

View File

@@ -0,0 +1,104 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var invariant_1 = require("@turf/invariant");
/**
* Returns true if a point is on a line. Accepts a optional parameter to ignore the
* start and end vertices of the linestring.
*
* @name booleanPointOnLine
* @param {Coord} pt GeoJSON Point
* @param {Feature<LineString>} line GeoJSON LineString
* @param {Object} [options={}] Optional parameters
* @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
* @example
* var pt = turf.point([0, 0]);
* var line = turf.lineString([[-1, -1],[1, 1],[1.5, 2.2]]);
* var isPointOnLine = turf.booleanPointOnLine(pt, line);
* //=true
*/
function booleanPointOnLine(pt, line, options) {
if (options === void 0) { options = {}; }
// Normalize inputs
var ptCoords = invariant_1.getCoord(pt);
var lineCoords = invariant_1.getCoords(line);
// Main
for (var i = 0; i < lineCoords.length - 1; i++) {
var ignoreBoundary = false;
if (options.ignoreEndVertices) {
if (i === 0) {
ignoreBoundary = "start";
}
if (i === lineCoords.length - 2) {
ignoreBoundary = "end";
}
if (i === 0 && i + 1 === lineCoords.length - 1) {
ignoreBoundary = "both";
}
}
if (isPointOnLineSegment(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary, typeof options.epsilon === "undefined" ? null : options.epsilon)) {
return true;
}
}
return false;
}
// See http://stackoverflow.com/a/4833823/1979085
// See https://stackoverflow.com/a/328122/1048847
/**
* @private
* @param {Position} lineSegmentStart coord pair of start of line
* @param {Position} lineSegmentEnd coord pair of end of line
* @param {Position} pt coord pair of point to check
* @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, epsilon) {
var x = pt[0];
var y = pt[1];
var x1 = lineSegmentStart[0];
var y1 = lineSegmentStart[1];
var x2 = lineSegmentEnd[0];
var y2 = lineSegmentEnd[1];
var dxc = pt[0] - x1;
var dyc = pt[1] - y1;
var dxl = x2 - x1;
var dyl = y2 - y1;
var cross = dxc * dyl - dyc * dxl;
if (epsilon !== null) {
if (Math.abs(cross) > epsilon) {
return false;
}
}
else if (cross !== 0) {
return false;
}
if (!excludeBoundary) {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 <= x && x <= x2 : x2 <= x && x <= x1;
}
return dyl > 0 ? y1 <= y && y <= y2 : y2 <= y && y <= y1;
}
else if (excludeBoundary === "start") {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 < x && x <= x2 : x2 <= x && x < x1;
}
return dyl > 0 ? y1 < y && y <= y2 : y2 <= y && y < y1;
}
else if (excludeBoundary === "end") {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 <= x && x < x2 : x2 < x && x <= x1;
}
return dyl > 0 ? y1 <= y && y < y2 : y2 < y && y <= y1;
}
else if (excludeBoundary === "both") {
if (Math.abs(dxl) >= Math.abs(dyl)) {
return dxl > 0 ? x1 < x && x < x2 : x2 < x && x < x1;
}
return dyl > 0 ? y1 < y && y < y2 : y2 < y && y < y1;
}
return false;
}
exports.default = booleanPointOnLine;

View File

@@ -0,0 +1,66 @@
{
"name": "@turf/boolean-point-on-line",
"version": "6.5.0",
"description": "turf boolean-point-on-line module",
"author": "Turf Authors",
"contributors": [
"Rowan Winsemius <@rowanwins>"
],
"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",
"booleanPointOnLine"
],
"main": "dist/js/index.js",
"module": "dist/es/index.js",
"exports": {
"./package.json": "./package.json",
".": {
"import": "./dist/es/index.js",
"require": "./dist/js/index.js"
}
},
"types": "dist/js/index.d.ts",
"sideEffects": false,
"files": [
"dist"
],
"scripts": {
"bench": "ts-node bench.js",
"build": "npm-run-all build:*",
"build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
"build:js": "tsc",
"docs": "node ../../scripts/generate-readmes",
"test": "npm-run-all test:*",
"test:tape": "ts-node -r esm test.js"
},
"devDependencies": {
"@types/tape": "*",
"benchmark": "*",
"glob": "*",
"load-json-file": "*",
"npm-run-all": "*",
"tape": "*",
"ts-node": "*",
"tslint": "*",
"typescript": "*",
"write-json-file": "*"
},
"dependencies": {
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
}