dartclub / turf_dart

A turf.js-like geospatial analysis library working with GeoJSON, written in pure Dart.
https://pub.dev/packages/turf
MIT License
62 stars 28 forks source link

truncate throws RangeError (index) with MultiPolygon #146

Closed ggastv closed 1 year ago

ggastv commented 1 year ago

Hi. During the implementation process of transformRotate, I noticed an error on some test cases. When I launch test of truncate function with Feature<MultiPoint> it return falsy result, and with Feature<MultiLineString> or Feature<MultiPolygon> it throws RangeError. Other tests are succeed. I use test fixtures from turf-js repo.

RangeError (index): Invalid value: Not in inclusive range 0..2: 3

dart:core List.[]= package:turf/src/truncate.dart 65:60 _replaceCoords.. package:turf/src/meta/coord.dart 113:19 _forEachCoordInNestedCollection package:turf/src/meta/coord.dart 76:5 _forEachCoordInGeometryObject package:turf/src/meta/coord.dart 46:9 coordEach. package:turf/src/meta/geom.dart 68:17 _forEachGeomInGeometryObject package:turf/src/meta/geom.dart 36:7 geomEach package:turf/src/meta/coord.dart 33:5 coordEach package:turf/src/truncate.dart 46:7 _replaceCoords. package:turf/src/meta/geom.dart 68:17 _forEachGeomInGeometryObject package:turf/src/meta/geom.dart 56:3 _forEachGeomInFeature package:turf/src/meta/geom.dart 34:7 geomEach package:turf/src/truncate.dart 37:3 _replaceCoords package:turf/src/truncate.dart 29:5 truncate test\components\truncate_test.dart 35:27 main..

You can watch last commits in my fork. Or get test data files from zip, put it in test/examples/truncate folder and run test for _test/components/truncatetest.dart. truncate_test.zip

lukas-h commented 1 year ago

Hey, would you like to create a PR for your changes?

Thanks for contributing

lukas-h commented 1 year ago

@armantorkzaban can you have a look at what's going on here? At what causes the range error?

lukas-h commented 1 year ago

I handled most issues. MultiPolygon seems to have just a few remaining issues

lukas-h commented 1 year ago

@ggastv Didi you make any progress on this issue? I'm preparing a new release of turf to pub.dev where I have to deal with this problem

ggastv commented 1 year ago

@lukas-h Hi. Sorry for long wait. See PR #148.

lukas-h commented 1 year ago

@ggastv no worries. Big thanks for your contributions!