Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/boolean-point-on-line

Package Overview
Dependencies
Maintainers
7
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/boolean-point-on-line - npm Package Compare versions

Comparing version 6.5.0 to 7.0.0-alpha.0

33

dist/es/index.js

@@ -19,10 +19,9 @@ import { getCoord, getCoords } from "@turf/invariant";

*/
function booleanPointOnLine(pt, line, options) {
if (options === void 0) { options = {}; }
function booleanPointOnLine(pt, line, options = {}) {
// Normalize inputs
var ptCoords = getCoord(pt);
var lineCoords = getCoords(line);
const ptCoords = getCoord(pt);
const lineCoords = getCoords(line);
// Main
for (var i = 0; i < lineCoords.length - 1; i++) {
var ignoreBoundary = false;
for (let i = 0; i < lineCoords.length - 1; i++) {
let ignoreBoundary = false;
if (options.ignoreEndVertices) {

@@ -58,13 +57,13 @@ if (i === 0) {

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;
const x = pt[0];
const y = pt[1];
const x1 = lineSegmentStart[0];
const y1 = lineSegmentStart[1];
const x2 = lineSegmentEnd[0];
const y2 = lineSegmentEnd[1];
const dxc = pt[0] - x1;
const dyc = pt[1] - y1;
const dxl = x2 - x1;
const dyl = y2 - y1;
const cross = dxc * dyl - dyc * dxl;
if (epsilon !== null) {

@@ -71,0 +70,0 @@ if (Math.abs(cross) > epsilon) {

@@ -1,2 +0,3 @@

import { Coord, Feature, LineString } from "@turf/helpers";
import { Feature, LineString } from "geojson";
import { Coord } from "@turf/helpers";
/**

@@ -3,0 +4,0 @@ * Returns true if a point is on a line. Accepts a optional parameter to ignore the

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var invariant_1 = require("@turf/invariant");
const invariant_1 = require("@turf/invariant");
/**

@@ -21,10 +21,9 @@ * Returns true if a point is on a line. Accepts a optional parameter to ignore the

*/
function booleanPointOnLine(pt, line, options) {
if (options === void 0) { options = {}; }
function booleanPointOnLine(pt, line, options = {}) {
// Normalize inputs
var ptCoords = invariant_1.getCoord(pt);
var lineCoords = invariant_1.getCoords(line);
const ptCoords = invariant_1.getCoord(pt);
const lineCoords = invariant_1.getCoords(line);
// Main
for (var i = 0; i < lineCoords.length - 1; i++) {
var ignoreBoundary = false;
for (let i = 0; i < lineCoords.length - 1; i++) {
let ignoreBoundary = false;
if (options.ignoreEndVertices) {

@@ -60,13 +59,13 @@ if (i === 0) {

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;
const x = pt[0];
const y = pt[1];
const x1 = lineSegmentStart[0];
const y1 = lineSegmentStart[1];
const x2 = lineSegmentEnd[0];
const y2 = lineSegmentEnd[1];
const dxc = pt[0] - x1;
const dyc = pt[1] - y1;
const dxl = x2 - x1;
const dyl = y2 - y1;
const cross = dxc * dyl - dyc * dxl;
if (epsilon !== null) {

@@ -73,0 +72,0 @@ if (Math.abs(cross) > epsilon) {

{
"name": "@turf/boolean-point-on-line",
"version": "6.5.0",
"version": "7.0.0-alpha.0",
"description": "turf boolean-point-on-line module",

@@ -62,6 +62,7 @@ "author": "Turf Authors",

"dependencies": {
"@turf/helpers": "^6.5.0",
"@turf/invariant": "^6.5.0"
"@turf/helpers": "^7.0.0-alpha.0",
"@turf/invariant": "^7.0.0-alpha.0",
"tslib": "^2.3.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
}

@@ -7,13 +7,16 @@ # @turf/boolean-point-on-line

Returns true if a point is on a line. Accepts a optional parameter to ignore the start and end vertices of the linestring.
Returns true if a point is on a line. Accepts a optional parameter to ignore the
start and end vertices of the linestring.
**Parameters**
### 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`)
* `pt` **[Coord][1]** GeoJSON Point
* `line` **[Feature][2]<[LineString][3]>** GeoJSON LineString
* `options` **[Object][4]** Optional parameters (optional, default `{}`)
**Examples**
* `options.ignoreEndVertices` **[boolean][5]** whether to ignore the start and end vertices. (optional, default `false`)
* `options.epsilon` **[number][6]?** Fractional number to compare with the cross product result. Useful for dealing with floating points such as lng/lat points
### Examples
```javascript

@@ -38,2 +41,4 @@ var pt = turf.point([0, 0]);

[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
<!-- This file is automatically generated. Please don't edit it directly:

@@ -40,0 +45,0 @@ if you find an error, edit the source file (likely index.js), and re-run

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc