From fa673871a7985ab09e5d0e26491cb3996ebf6df6 Mon Sep 17 00:00:00 2001 From: Rowan Winsemius Date: Mon, 8 May 2023 21:36:22 +1000 Subject: [PATCH 01/19] Add booleanTouches to docs (#2431) --- documentation.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/documentation.yml b/documentation.yml index b5efb85ae..671d6b572 100644 --- a/documentation.yml +++ b/documentation.yml @@ -143,6 +143,7 @@ toc: - booleanParallel - booleanPointInPolygon - booleanPointOnLine + - booleanTouches - booleanWithin - name: Unit Conversion - bearingToAzimuth From ab2456fc661ef2437733fe4a152f001568955def Mon Sep 17 00:00:00 2001 From: J-Guenther <16701537+J-Guenther@users.noreply.github.com> Date: Mon, 8 May 2023 13:37:13 +0200 Subject: [PATCH 02/19] Fix boolean-equal docs and added new tests (#2401) (#2412) Co-authored-by: James Milner --- packages/turf-boolean-equal/README.md | 10 ++++-- packages/turf-boolean-equal/test.js | 48 +++++++++++++++++++-------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/packages/turf-boolean-equal/README.md b/packages/turf-boolean-equal/README.md index cc599dc9f..63bfab978 100644 --- a/packages/turf-boolean-equal/README.md +++ b/packages/turf-boolean-equal/README.md @@ -4,7 +4,7 @@ ## booleanEqual -Determine whether two geometries of the same type have identical X,Y coordinate values. +Determines whether two geometries or features of the same type have identical X,Y coordinate values and properties. See [http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm][1] ### Parameters @@ -21,11 +21,17 @@ See [http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relatio var pt1 = turf.point([0, 0]); var pt2 = turf.point([0, 0]); var pt3 = turf.point([1, 1]); +var pt4 = turf.point([0, 0], {prop: 'A'}); +var pt5 = turf.point([0, 0], {prop: 'B'}); turf.booleanEqual(pt1, pt2); //= true turf.booleanEqual(pt2, pt3); //= false +turf.booleanEqual(pt4, pt5); +//= false +turf.booleanEqual(pt4.geometry, pt5.geometry); +//= true ``` Returns **[boolean][6]** true if the objects are equal, false otherwise @@ -70,4 +76,4 @@ $ npm install @turf/turf ### Diagrams -![esri-equals](diagrams/esri-equals.gif) \ No newline at end of file +![esri-equals](diagrams/esri-equals.gif) diff --git a/packages/turf-boolean-equal/test.js b/packages/turf-boolean-equal/test.js index 3565587ee..e685e9fca 100644 --- a/packages/turf-boolean-equal/test.js +++ b/packages/turf-boolean-equal/test.js @@ -55,24 +55,30 @@ const line2 = lineString([ [8, 50], [9, 50], ]); -const poly1 = polygon([ +const poly1 = polygon( [ - [8.5, 50], - [9.5, 50], - [9.5, 49], - [8.5, 49], - [8.5, 50], + [ + [8.5, 50], + [9.5, 50], + [9.5, 49], + [8.5, 49], + [8.5, 50], + ], ], -]); -const poly2 = polygon([ + { prop: "A" } +); +const poly2 = polygon( [ - [8.5, 50], - [9.5, 50], - [9.5, 49], - [8.5, 49], - [8.5, 50], + [ + [8.5, 50], + [9.5, 50], + [9.5, 49], + [8.5, 49], + [8.5, 50], + ], ], -]); + { prop: "B" } +); const poly3 = polygon([ [ [10, 50], @@ -82,12 +88,26 @@ const poly3 = polygon([ [10, 50], ], ]); +const poly4 = polygon( + [ + [ + [8.5, 50], + [9.5, 50], + [9.5, 49], + [8.5, 49], + [8.5, 50], + ], + ], + { prop: "A" } +); test("turf-boolean-equal -- geometries", (t) => { t.true(equal(line1.geometry, line2.geometry), "[true] LineString geometry"); t.true(equal(poly1.geometry, poly2.geometry), "[true] Polygon geometry"); + t.true(equal(poly1, poly4), "[true] Polygon feature"); t.false(equal(poly1.geometry, poly3.geometry), "[false] Polygon geometry"); t.false(equal(pt, line1), "[false] different types"); + t.false(equal(poly1, poly2), "[false] different properties"); t.end(); }); From 88dfdbb2617b70c833e30923590400dc0189e601 Mon Sep 17 00:00:00 2001 From: Moritz Wenko Date: Mon, 8 May 2023 14:16:13 +0200 Subject: [PATCH 03/19] feature: add unit option to nearest-point (#2415) * feature: add unit option to nearest-point * chore: update types & docs * chore: add js-doc param * chore: update nearest-point readme --------- Co-authored-by: Rowan Winsemius --- packages/turf-nearest-point/README.md | 11 +++++++++-- packages/turf-nearest-point/index.ts | 11 ++++++++--- packages/turf-nearest-point/test.js | 16 ++++++++++++++++ packages/turf-nearest-point/types.ts | 2 +- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/turf-nearest-point/README.md b/packages/turf-nearest-point/README.md index 0e5e14c14..1d9002c0b 100644 --- a/packages/turf-nearest-point/README.md +++ b/packages/turf-nearest-point/README.md @@ -13,6 +13,9 @@ is geodesic. * `targetPoint` **[Coord][2]** the reference point * `points` **[FeatureCollection][3]<[Point][4]>** against input point set +* `options` **[Object][5]** Optional parameters (optional, default `{}`) + + * `options.units` **[string][6]** the units of the numeric result (optional, default `'kilometers'`) ### Examples @@ -31,7 +34,7 @@ var addToMap = [targetPoint, points, nearest]; nearest.properties['marker-color'] = '#F00'; ``` -Returns **[Feature][5]<[Point][4]>** the closest point in the set to the reference point +Returns **[Feature][7]<[Point][4]>** the closest point in the set to the reference point [1]: https://tools.ietf.org/html/rfc7946#section-3.1.2 @@ -41,7 +44,11 @@ Returns **[Feature][5]<[Point][4]>** the closest point in the set to the referen [4]: https://tools.ietf.org/html/rfc7946#section-3.1.2 -[5]: https://tools.ietf.org/html/rfc7946#section-3.2 +[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object + +[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String + +[7]: https://tools.ietf.org/html/rfc7946#section-3.2