New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@turf/point-on-line

Package Overview
Dependencies
Maintainers
4
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 4.7.3 to 5.0.0

main.js

23

index.d.ts
/// <reference types="geojson" />
import {Units} from '@turf/helpers'
import { Point, Feature, Units, Position, LineString, MultiLineString } from '@turf/helpers'
type Point = GeoJSON.Feature<GeoJSON.Point> | GeoJSON.Point | number[];
type LineString = GeoJSON.LineString;
type MultiLineString = GeoJSON.MultiLineString;
type Line = GeoJSON.Feature<LineString | MultiLineString> | LineString | MultiLineString;
interface PointOnLine extends GeoJSON.Feature<GeoJSON.Point> {
export interface PointOnLine extends Feature<Point> {
properties: {

@@ -22,8 +17,8 @@ index?: number

*/
declare function pointOnLine(
line: Line,
point: Point,
units?: Units): PointOnLine;
declare namespace pointOnLine { }
export = pointOnLine;
export default function pointOnLine<T extends MultiLineString | LineString>(
line: Feature<T> | T,
point: Feature<Point> | Point | Position,
options?: {
units?: Units
}
): PointOnLine;

@@ -1,12 +0,8 @@

var meta = require('@turf/meta');
var helpers = require('@turf/helpers');
var bearing = require('@turf/bearing');
var distance = require('@turf/distance');
var invariant = require('@turf/invariant');
var destination = require('@turf/destination');
var lineIntersects = require('@turf/line-intersect');
var point = helpers.point;
var getCoords = invariant.getCoords;
var lineString = helpers.lineString;
var flattenEach = meta.flattenEach;
import bearing from '@turf/bearing';
import distance from '@turf/distance';
import destination from '@turf/destination';
import lineIntersects from '@turf/line-intersect';
import { flattenEach } from '@turf/meta';
import { point, lineString } from '@turf/helpers';
import { getCoords } from '@turf/invariant';

@@ -19,3 +15,4 @@ /**

* @param {Geometry|Feature<Point>|number[]} pt point to snap from
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {Feature<Point>} closest point on the `line` to `point`. The properties object will contain three values: `index`: closest point was found on nth line part, `dist`: distance between pt and the closest point, `location`: distance along the line between start and the closest point.

@@ -39,3 +36,6 @@ * @example

*/
module.exports = function (lines, pt, units) {
function pointOnLine(lines, pt, options) {
// Backwards compatible with v4.0
var units = (typeof options === 'object') ? options.units : options;
// validation

@@ -98,2 +98,4 @@ var type = (lines.geometry) ? lines.geometry.type : lines.type;

return closestPt;
};
}
export default pointOnLine;
{
"name": "@turf/point-on-line",
"version": "4.7.3",
"version": "5.0.0",
"description": "turf point-on-line module",
"main": "index.js",
"main": "main",
"module": "index",
"jsnext:main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"main.js"
],
"scripts": {
"test": "node test.js",
"bench": "node bench.js"
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "uglifyjs main.js -o main.min.js",
"bench": "node -r @std/esm bench.js"
},

@@ -26,19 +31,26 @@ "repository": {

"devDependencies": {
"@turf/along": "^4.7.3",
"@turf/line-distance": "^4.7.3",
"@turf/truncate": "^4.7.3",
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
"@turf/along": "*",
"@turf/line-distance": "*",
"@turf/truncate": "*",
"benchmark": "*",
"load-json-file": "*",
"tape": "*",
"write-json-file": "*",
"rollup": "*",
"@std/esm": "*",
"uglify-js": "*"
},
"dependencies": {
"@turf/bearing": "^4.7.3",
"@turf/destination": "^4.7.3",
"@turf/distance": "^4.7.3",
"@turf/helpers": "^4.7.3",
"@turf/invariant": "^4.7.3",
"@turf/line-intersect": "^4.7.3",
"@turf/meta": "^4.7.3"
"@turf/bearing": "5.0.0",
"@turf/destination": "5.0.0",
"@turf/distance": "5.0.0",
"@turf/helpers": "5.0.0",
"@turf/invariant": "5.0.0",
"@turf/line-intersect": "5.0.0",
"@turf/meta": "5.0.0"
},
"@std/esm": {
"esm": "js",
"cjs": true
}
}
# @turf/point-on-line
# pointOnLine
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## pointOnLine
Takes a [Point](http://geojson.org/geojson-spec.html#point) and a [LineString](http://geojson.org/geojson-spec.html#linestring) and calculates the closest Point on the (Multi)LineString.

@@ -11,3 +13,3 @@

- `pt` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** point to snap from
- `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`)
- `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`)

@@ -14,0 +16,0 @@ **Examples**

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