diff --git a/packages/turf-boolean-equal/README.md b/packages/turf-boolean-equal/README.md index cc599dc9f6..63bfab9783 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 3565587ee2..e685e9fca1 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(); });