diff --git a/packages/turf-difference/index.mjs b/packages/turf-difference/index.mjs index 512b648931..0e07f12770 100644 --- a/packages/turf-difference/index.mjs +++ b/packages/turf-difference/index.mjs @@ -1,4 +1,4 @@ -import martinez from 'martinez-polygon-clipping'; +import * as martinez from 'martinez-polygon-clipping'; import area from '@turf/area'; import { feature, multiPolygon, polygon } from '@turf/helpers'; import { getGeom } from '@turf/invariant'; diff --git a/packages/turf-difference/package.json b/packages/turf-difference/package.json index c2b5440720..a3408e0fdb 100644 --- a/packages/turf-difference/package.json +++ b/packages/turf-difference/package.json @@ -43,6 +43,6 @@ "@turf/helpers": "6.x", "@turf/invariant": "6.x", "@turf/meta": "6.x", - "martinez-polygon-clipping": "*" + "martinez-polygon-clipping": "^0.4.3" } } diff --git a/packages/turf-intersect/package.json b/packages/turf-intersect/package.json index e8887734f0..383d9aaf2c 100644 --- a/packages/turf-intersect/package.json +++ b/packages/turf-intersect/package.json @@ -43,6 +43,6 @@ "dependencies": { "@turf/helpers": "6.x", "@turf/invariant": "6.x", - "martinez-polygon-clipping": "*" + "martinez-polygon-clipping": "^0.4.3" } } diff --git a/packages/turf-intersect/test/in/issue-1394.geojson b/packages/turf-intersect/test/in/issue-1394.geojson new file mode 100644 index 0000000000..6ec9a448fb --- /dev/null +++ b/packages/turf-intersect/test/in/issue-1394.geojson @@ -0,0 +1,82 @@ +{ + "type": "FeatureCollection", + "features": [{ + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-85.42358091, 41.76872876], + [-85.42358054, 41.76871738], + [-85.42343269, 41.76871941], + [-85.42342892, 41.7687873], + [-85.42343247, 41.76882923], + [-85.42343403, 41.76885906], + [-85.42343247, 41.76893021], + [-85.4234327, 41.76893113], + [-85.42343245, 41.768932], + [-85.42343245, 41.76896821], + [-85.42357911, 41.76896572], + [-85.42357911, 41.76895253], + [-85.42357911, 41.768932], + [-85.42358073, 41.76885781], + [-85.42357713, 41.76878899], + [-85.42358091, 41.76872876] + ] + ] + } + }, { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [-85.42775567, 41.76834521], + [-85.42261052, 41.76843269], + [-85.42260803, 41.76844995], + [-85.4226073, 41.76845496], + [-85.42260484, 41.76848048], + [-85.42260083, 41.76852204], + [-85.42260191, 41.76856362], + [-85.42260586, 41.7685989], + [-85.42263068, 41.76862319], + [-85.42334654, 41.76860736], + [-85.42335464, 41.76862399], + [-85.4233818, 41.76867993], + [-85.42338342, 41.76869724], + [-85.42338701, 41.76872004], + [-85.42339693, 41.76871991], + [-85.42343269, 41.76871941], + [-85.42358054, 41.76871738], + [-85.42358091, 41.76872876], + [-85.42357713, 41.768789], + [-85.42358073, 41.76885781], + [-85.42357911, 41.768932], + [-85.42357911, 41.76895253], + [-85.42357911, 41.76896572], + [-85.42595679, 41.76892533], + [-85.42595476, 41.76888531], + [-85.42599703, 41.7688939], + [-85.42599798, 41.76892451], + [-85.426518, 41.76891567], + [-85.42776659, 41.76889445], + [-85.42781994, 41.76889354], + [-85.42781971, 41.76888565], + [-85.42781923, 41.76886922], + [-85.42780934, 41.76879664], + [-85.42782049, 41.76870985], + [-85.42782211, 41.76864827], + [-85.42782265, 41.76858656], + [-85.42782337, 41.76852915], + [-85.42782301, 41.76847763], + [-85.42782337, 41.7684563], + [-85.42775364, 41.76845772], + [-85.42775456, 41.76840654], + [-85.42775499, 41.76838269], + [-85.42775536, 41.76836222], + [-85.42775567, 41.76834521] + ] + ] + } + }] +} diff --git a/packages/turf-intersect/test/out/issue-1394.geojson b/packages/turf-intersect/test/out/issue-1394.geojson new file mode 100644 index 0000000000..92c858fa29 --- /dev/null +++ b/packages/turf-intersect/test/out/issue-1394.geojson @@ -0,0 +1,303 @@ +{ + "type": "FeatureCollection", + "features": [ + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -85.42358091, + 41.76872876 + ], + [ + -85.42358054, + 41.76871738 + ], + [ + -85.42343269, + 41.76871941 + ], + [ + -85.42342892, + 41.7687873 + ], + [ + -85.42343247, + 41.76882923 + ], + [ + -85.42343403, + 41.76885906 + ], + [ + -85.42343247, + 41.76893021 + ], + [ + -85.4234327, + 41.76893113 + ], + [ + -85.42343245, + 41.768932 + ], + [ + -85.42343245, + 41.76896821 + ], + [ + -85.42357911, + 41.76896572 + ], + [ + -85.42357911, + 41.76895253 + ], + [ + -85.42357911, + 41.768932 + ], + [ + -85.42358073, + 41.76885781 + ], + [ + -85.42357713, + 41.76878899 + ], + [ + -85.42358091, + 41.76872876 + ] + ] + ] + }, + "properties": { + "fill-opacity": 0.5, + "fill": "#F00" + } + }, + { + "type": "Feature", + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -85.42775567, + 41.76834521 + ], + [ + -85.42261052, + 41.76843269 + ], + [ + -85.42260803, + 41.76844995 + ], + [ + -85.4226073, + 41.76845496 + ], + [ + -85.42260484, + 41.76848048 + ], + [ + -85.42260083, + 41.76852204 + ], + [ + -85.42260191, + 41.76856362 + ], + [ + -85.42260586, + 41.7685989 + ], + [ + -85.42263068, + 41.76862319 + ], + [ + -85.42334654, + 41.76860736 + ], + [ + -85.42335464, + 41.76862399 + ], + [ + -85.4233818, + 41.76867993 + ], + [ + -85.42338342, + 41.76869724 + ], + [ + -85.42338701, + 41.76872004 + ], + [ + -85.42339693, + 41.76871991 + ], + [ + -85.42343269, + 41.76871941 + ], + [ + -85.42358054, + 41.76871738 + ], + [ + -85.42358091, + 41.76872876 + ], + [ + -85.42357713, + 41.768789 + ], + [ + -85.42358073, + 41.76885781 + ], + [ + -85.42357911, + 41.768932 + ], + [ + -85.42357911, + 41.76895253 + ], + [ + -85.42357911, + 41.76896572 + ], + [ + -85.42595679, + 41.76892533 + ], + [ + -85.42595476, + 41.76888531 + ], + [ + -85.42599703, + 41.7688939 + ], + [ + -85.42599798, + 41.76892451 + ], + [ + -85.426518, + 41.76891567 + ], + [ + -85.42776659, + 41.76889445 + ], + [ + -85.42781994, + 41.76889354 + ], + [ + -85.42781971, + 41.76888565 + ], + [ + -85.42781923, + 41.76886922 + ], + [ + -85.42780934, + 41.76879664 + ], + [ + -85.42782049, + 41.76870985 + ], + [ + -85.42782211, + 41.76864827 + ], + [ + -85.42782265, + 41.76858656 + ], + [ + -85.42782337, + 41.76852915 + ], + [ + -85.42782301, + 41.76847763 + ], + [ + -85.42782337, + 41.7684563 + ], + [ + -85.42775364, + 41.76845772 + ], + [ + -85.42775456, + 41.76840654 + ], + [ + -85.42775499, + 41.76838269 + ], + [ + -85.42775536, + 41.76836222 + ], + [ + -85.42775567, + 41.76834521 + ] + ] + ] + }, + "properties": { + "fill-opacity": 0.5, + "fill": "#00F" + } + }, + { + "type": "Feature", + "properties": { + "fill-opacity": 1, + "fill": "#0F0" + }, + "geometry": { + "type": "Polygon", + "coordinates": [ + [ + [ + -85.42358073, + 41.76885781 + ], + [ + -85.42357713028528, + 41.76878899545362 + ], + [ + -85.42357713, + 41.768789 + ], + [ + -85.42358073, + 41.76885781 + ] + ] + ] + } + } + ] +} diff --git a/packages/turf-union/package.json b/packages/turf-union/package.json index e585a62c39..c1cf8cdd58 100644 --- a/packages/turf-union/package.json +++ b/packages/turf-union/package.json @@ -43,6 +43,6 @@ "dependencies": { "@turf/helpers": "6.x", "@turf/invariant": "6.x", - "martinez-polygon-clipping": "*" + "martinez-polygon-clipping": "^0.4.3" } } diff --git a/yarn.lock b/yarn.lock index bd9cd52e8a..3edf25b690 100644 --- a/yarn.lock +++ b/yarn.lock @@ -79,6 +79,13 @@ "@turf/helpers" "^5.1.5" "@turf/invariant" "^5.1.5" +"@turf/circle@^5.1.5": + version "5.1.5" + resolved "https://registry.yarnpkg.com/@turf/circle/-/circle-5.1.5.tgz#9b1577835508ab52fb1c10b2a5065cba2b87b6a5" + dependencies: + "@turf/destination" "^5.1.5" + "@turf/helpers" "^5.1.5" + "@turf/clean-coords@6.0.0": version "6.0.0" resolved "https://registry.yarnpkg.com/@turf/clean-coords/-/clean-coords-6.0.0.tgz#edac2b00dcbfd61c42dd035bfd5f21075c887565" @@ -152,6 +159,14 @@ dependencies: "@turf/helpers" "^5.1.5" +"@turf/line-arc@5.1.x", "@turf/line-arc@^5.1.5": + version "5.1.5" + resolved "https://registry.yarnpkg.com/@turf/line-arc/-/line-arc-5.1.5.tgz#0078a7447835a12ae414a211f9a64d1186150e15" + dependencies: + "@turf/circle" "^5.1.5" + "@turf/destination" "^5.1.5" + "@turf/helpers" "^5.1.5" + "@turf/line-intersect@^5.1.5": version "5.1.5" resolved "https://registry.yarnpkg.com/@turf/line-intersect/-/line-intersect-5.1.5.tgz#0e29071ae403295e491723bc49f5cfac8d11ddf3" @@ -509,10 +524,6 @@ atob@^2.0.0: version "2.0.3" resolved "https://registry.yarnpkg.com/atob/-/atob-2.0.3.tgz#19c7a760473774468f20b2d2d03372ad7d4cbf5d" -avl@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/avl/-/avl-1.4.1.tgz#c7ad7b26c7b81fb9919f4561c9601ff4c3e38ad7" - aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -3802,10 +3813,10 @@ markdown-table@^1.1.0: resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-1.1.1.tgz#4b3dd3a133d1518b8ef0dbc709bf2a1b4824bc8c" martinez-polygon-clipping@*: - version "0.3.3" - resolved "https://registry.yarnpkg.com/martinez-polygon-clipping/-/martinez-polygon-clipping-0.3.3.tgz#a7b9429c9d13cb118a86c97a5e1af5a62aedb6d9" + version "0.4.3" + resolved "https://registry.yarnpkg.com/martinez-polygon-clipping/-/martinez-polygon-clipping-0.4.3.tgz#a3971ddf1da147104b5d0fbbf68f728bb62885c1" dependencies: - avl "^1.4.1" + splaytree "^0.1.4" tinyqueue "^1.2.0" matrix-to-grid@*: @@ -5280,6 +5291,10 @@ spdx-license-ids@^1.0.2: version "1.2.2" resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" +splaytree@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/splaytree/-/splaytree-0.1.4.tgz#fc35475248edcc29d4938c9b67e43c6b7e55a659" + split-string@^3.0.1, split-string@^3.0.2: version "3.1.0" resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"