Skip to content

Commit 9a3043e

Browse files
Mark old nearest-point-on-line properties as deprecated (#3005)
* Deprecate old properties in nearestPointOnLine Modify generate-readmes script to exclude deprecated tags * Use new nearestPointOnLine properties everywhere Affects lineOverlap, lineSlice, lineSplit and pointToLineDistance --------- Co-authored-by: mfedderly <24275386+mfedderly@users.noreply.github.com>
1 parent 1fed227 commit 9a3043e

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

packages/turf-line-overlap/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ function lineOverlap<
8888
tolerance === 0
8989
? booleanPointOnLine(coordsSegment[0], match) &&
9090
booleanPointOnLine(coordsSegment[1], match)
91-
: nearestPointOnLine(match, coordsSegment[0]).properties.dist! <=
92-
tolerance &&
93-
nearestPointOnLine(match, coordsSegment[1]).properties.dist! <=
94-
tolerance
91+
: nearestPointOnLine(match, coordsSegment[0]).properties
92+
.pointDistance! <= tolerance &&
93+
nearestPointOnLine(match, coordsSegment[1]).properties
94+
.pointDistance! <= tolerance
9595
) {
9696
doesOverlaps = true;
9797
if (overlapSegment) {
@@ -102,10 +102,10 @@ function lineOverlap<
102102
tolerance === 0
103103
? booleanPointOnLine(coordsMatch[0], segment) &&
104104
booleanPointOnLine(coordsMatch[1], segment)
105-
: nearestPointOnLine(segment, coordsMatch[0]).properties.dist! <=
106-
tolerance &&
107-
nearestPointOnLine(segment, coordsMatch[1]).properties.dist! <=
108-
tolerance
105+
: nearestPointOnLine(segment, coordsMatch[0]).properties
106+
.pointDistance! <= tolerance &&
107+
nearestPointOnLine(segment, coordsMatch[1]).properties
108+
.pointDistance! <= tolerance
109109
) {
110110
// Do not define (doesOverlap = true) since more matches can occur within the same segment
111111
// doesOverlaps = true;

packages/turf-line-split/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function findClosestFeature(
239239
var closestDistance = Infinity;
240240
featureEach(lines, function (segment) {
241241
var pt = nearestPointOnLine(segment, point);
242-
var dist = pt.properties.dist;
242+
var dist = pt.properties.pointDistance;
243243
if (dist < closestDistance) {
244244
closestFeature = segment;
245245
closestDistance = dist;

packages/turf-nearest-point-on-line/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,16 @@ function nearestPointOnLine<G extends LineString | MultiLineString>(
6565
lineDistance: number;
6666
segmentDistance: number;
6767
pointDistance: number;
68+
// deprecated properties START
69+
/** @deprecated use `lineStringIndex` instead */
6870
multiFeatureIndex: number;
71+
/** @deprecated use `segmentIndex` instead */
6972
index: number;
73+
/** @deprecated use `totalDistance` instead */
7074
location: number;
75+
/** @deprecated use `pointDistance` instead */
7176
dist: number;
77+
// deprecated properties END
7278
[key: string]: any;
7379
}
7480
> {

packages/turf-point-to-line-distance/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function distanceToSegment(
108108
const nearest = nearestPointOnLine(lineString([a, b]).geometry, p, {
109109
units: "degrees",
110110
});
111-
return nearest.properties.dist;
111+
return nearest.properties.pointDistance;
112112
}
113113

114114
// Perform scalar calculations instead using rhumb lines.

scripts/generate-readmes.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ const yaml = require("yamljs");
5151
if (res === undefined) return console.warn(packagePath);
5252
console.log("Building Docs: " + name);
5353

54+
// Workaround to exclude @deprecated tags from docs
55+
// See https://github.com/documentationjs/documentation/issues/1596
56+
res = res.filter((item) =>
57+
item.tags.every((tag) => tag.title !== "deprecated")
58+
);
59+
5460
// Format Markdown
5561
documentation.formats
5662
.md(res, { paths })

0 commit comments

Comments
 (0)