Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/turf-line-overlap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ function lineOverlap<
tolerance === 0
? booleanPointOnLine(coordsSegment[0], match) &&
booleanPointOnLine(coordsSegment[1], match)
: nearestPointOnLine(match, coordsSegment[0]).properties.dist! <=
tolerance &&
nearestPointOnLine(match, coordsSegment[1]).properties.dist! <=
tolerance
: nearestPointOnLine(match, coordsSegment[0]).properties
.pointDistance! <= tolerance &&
nearestPointOnLine(match, coordsSegment[1]).properties
.pointDistance! <= tolerance
) {
doesOverlaps = true;
if (overlapSegment) {
Expand All @@ -102,10 +102,10 @@ function lineOverlap<
tolerance === 0
? booleanPointOnLine(coordsMatch[0], segment) &&
booleanPointOnLine(coordsMatch[1], segment)
: nearestPointOnLine(segment, coordsMatch[0]).properties.dist! <=
tolerance &&
nearestPointOnLine(segment, coordsMatch[1]).properties.dist! <=
tolerance
: nearestPointOnLine(segment, coordsMatch[0]).properties
.pointDistance! <= tolerance &&
nearestPointOnLine(segment, coordsMatch[1]).properties
.pointDistance! <= tolerance
) {
// Do not define (doesOverlap = true) since more matches can occur within the same segment
// doesOverlaps = true;
Expand Down
6 changes: 3 additions & 3 deletions packages/turf-line-slice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function lineSlice(
const startVertex = nearestPointOnLine(line, startPt);
const stopVertex = nearestPointOnLine(line, stopPt);
const ends =
startVertex.properties.index <= stopVertex.properties.index
startVertex.properties.segmentIndex <= stopVertex.properties.segmentIndex
? [startVertex, stopVertex]
: [stopVertex, startVertex];
const clipCoords = [ends[0].geometry.coordinates];
for (
let i = ends[0].properties.index + 1;
i < ends[1].properties.index + 1;
let i = ends[0].properties.segmentIndex + 1;
i < ends[1].properties.segmentIndex + 1;
i++
) {
clipCoords.push(coords[i]);
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-line-split/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function findClosestFeature(
var closestDistance = Infinity;
featureEach(lines, function (segment) {
var pt = nearestPointOnLine(segment, point);
var dist = pt.properties.dist;
var dist = pt.properties.pointDistance;
if (dist < closestDistance) {
closestFeature = segment;
closestDistance = dist;
Expand Down
13 changes: 0 additions & 13 deletions packages/turf-nearest-point-on-line/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,6 @@ If any of the segments in the input line string are antipodal and therefore
have an undefined arc, this function will instead return that the point lies
on the line.

⚠️ We have begun the process of migrating to different return properties for
this function. The new properties we recommend using as of v7.4 are:

* lineStringIndex - point was found on the nth LineString of an input MultiLineString. Previously `multiFeatureIndex`
* segmentIndex - point was found on the nth segment of the above LineString. Previously `index`
* totalDistance - distance from the start of the overall MultiLineString. Previously `location`
* lineDistance - distance from the start of the relevant LineString
* segmentDistance - distance from the start of the relevant segment
* pointDistance - distance between found point is from input reference point. Previously `dist`

multiFeatureIndex, index, location, and dist continue to work as previously
until at least the next major release.

### Parameters

* `lines` **([Geometry][1] | [Feature][2]<([LineString][3] | [MultiLineString][4])>)** Lines to snap to
Expand Down
36 changes: 0 additions & 36 deletions packages/turf-nearest-point-on-line/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,6 @@ import { getCoord, getCoords } from "@turf/invariant";
* have an undefined arc, this function will instead return that the point lies
* on the line.
*
* ⚠️ We have begun the process of migrating to different return properties for
* this function. The new properties we recommend using as of v7.4 are:
* - lineStringIndex - point was found on the nth LineString of an input MultiLineString. Previously `multiFeatureIndex`
* - segmentIndex - point was found on the nth segment of the above LineString. Previously `index`
* - totalDistance - distance from the start of the overall MultiLineString. Previously `location`
* - lineDistance - distance from the start of the relevant LineString
* - segmentDistance - distance from the start of the relevant segment
* - pointDistance - distance between found point is from input reference point. Previously `dist`
*
* multiFeatureIndex, index, location, and dist continue to work as previously
* until at least the next major release.
*
* @function
* @param {Geometry|Feature<LineString|MultiLineString>} lines Lines to snap to
* @param {Geometry|Feature<Point>|number[]} inputPoint Point to snap from
Expand Down Expand Up @@ -65,10 +53,6 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
lineDistance: number;
segmentDistance: number;
pointDistance: number;
multiFeatureIndex: number;
index: number;
location: number;
dist: number;
[key: string]: any;
}
> {
Expand All @@ -85,12 +69,6 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
lineDistance: -1,
segmentDistance: -1,
pointDistance: Infinity,
// deprecated properties START
multiFeatureIndex: -1,
index: -1,
location: -1,
dist: Infinity,
// deprecated properties END
});

let totalDistance = 0.0;
Expand Down Expand Up @@ -153,21 +131,7 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
lineDistance: lineDistance + segmentDistance,
segmentDistance: segmentDistance,
pointDistance: pointDistance,
// deprecated properties START
multiFeatureIndex: -1,
index: -1,
location: -1,
dist: Infinity,
// deprecated properties END
});
closestPt.properties = {
...closestPt.properties,
multiFeatureIndex: closestPt.properties.lineStringIndex,
index: closestPt.properties.segmentIndex,
location: closestPt.properties.totalDistance,
dist: closestPt.properties.pointDistance,
// deprecated properties END
};
}

// update totalDistance and lineDistance
Expand Down
4 changes: 0 additions & 4 deletions packages/turf-nearest-point-on-line/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ test("turf-nearest-point-on-line", (t) => {
6
);
onLine.properties.pointDistance = round(onLine.properties.pointDistance, 6);
// deprecated properties START
onLine.properties.dist = round(onLine.properties.dist, 6);
onLine.properties.location = round(onLine.properties.location, 6);
// deprecated properties END
onLine.properties["marker-color"] = "#F0F";
const between = lineString(
[onLine.geometry.coordinates, point.geometry.coordinates],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@
{
"type": "Feature",
"properties": {
"dist": 0.373652,
"location": 3.505821,
"index": 2,
"multiFeatureIndex": 0,
"lineStringIndex": 0,
"segmentIndex": 2,
"totalDistance": 3.505821,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
{
"type": "Feature",
"properties": {
"dist": 0.373652,
"location": 3.505821,
"index": 1,
"multiFeatureIndex": 0,
"lineStringIndex": 0,
"segmentIndex": 1,
"totalDistance": 3.505821,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
"lineDistance": 19.748879,
"segmentDistance": 1.771897,
"pointDistance": 5.959562,
"dist": 5.959562,
"multiFeatureIndex": 0,
"location": 19.748879,
"index": 1,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
4 changes: 0 additions & 4 deletions packages/turf-nearest-point-on-line/test/out/line1.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@
"lineDistance": 22.137494,
"segmentDistance": 3.445915,
"pointDistance": 2.556271,
"dist": 2.556271,
"multiFeatureIndex": 0,
"location": 22.137494,
"index": 1,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@
"lineDistance": 4800.716022,
"segmentDistance": 173.221741,
"pointDistance": 114.725451,
"dist": 114.725451,
"multiFeatureIndex": 1,
"location": 9479.011715,
"index": 20,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@
"lineDistance": 0,
"segmentDistance": 0,
"pointDistance": 390.942725,
"dist": 390.942725,
"multiFeatureIndex": 1,
"location": 1656.139708,
"index": 0,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@
"lineDistance": 214.735285,
"segmentDistance": 214.735285,
"pointDistance": 121.937841,
"dist": 121.937841,
"multiFeatureIndex": 0,
"location": 214.735285,
"index": 0,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
4 changes: 0 additions & 4 deletions packages/turf-nearest-point-on-line/test/out/route1.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -4798,10 +4798,6 @@
"lineDistance": 183.46844,
"segmentDistance": 0.044741,
"pointDistance": 7.876557,
"dist": 7.876557,
"multiFeatureIndex": 0,
"location": 183.46844,
"index": 3104,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
4 changes: 0 additions & 4 deletions packages/turf-nearest-point-on-line/test/out/route2.geojson
Original file line number Diff line number Diff line change
Expand Up @@ -3802,10 +3802,6 @@
"lineDistance": 303.639629,
"segmentDistance": 0.867249,
"pointDistance": 19.22738,
"dist": 19.22738,
"multiFeatureIndex": 0,
"location": 303.639629,
"index": 1185,
"marker-color": "#F0F"
},
"geometry": {
Expand Down
2 changes: 1 addition & 1 deletion packages/turf-point-to-line-distance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function distanceToSegment(
const nearest = nearestPointOnLine(lineString([a, b]).geometry, p, {
units: "degrees",
});
return nearest.properties.dist;
return nearest.properties.pointDistance;
}

// Perform scalar calculations instead using rhumb lines.
Expand Down