dartclub / turf_dart

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

booleanValid #129

Closed armantorkzaban closed 1 year ago

armantorkzaban commented 1 year ago

part of the validity of the data in the JSON is checked in the constructor of the different GeometryObjects. The problem is however that the assertion error trigger in debugging/development and not in production. However, during the dev/debug they trigger and mess with the tests. On the other hand some of the tests on the polygons are unknown to me and I will need to wrap my head around them. The mixture does not help. This issue is here for the conversation about the function. @lukas-h, you may join the rescue effort any time. :-)

armantorkzaban commented 1 year ago

While the issue above is now solved (geojson test was checking all the test examples and would trigger error!) there is one single test that fails: './test/examples/booleans/valid/true/MultiPolygon/multipolygon-touch.geojson ' Since the function is supposed to "... check if the geometry is a valid according to the OGC Simple Feature Specification." according to L10, turfJS/b-valid and the standard states "2. The Boundaries of any 2 Polygons that are elements of a MultiPolygon may not ‘cross’ and may touch at only a finite number of points. (Note that crossing is prevented by assertion 1 above). ∀ M ∈ MultiPolygon, ∀ Pi, Pj ∈ M.Geometries(), ∀ ci ∈ Pi.Boundaries(), cj ∈ Pj.Boundaries() ci ∩ cj = {p1, ….., pk | pi ∈ Point, 1 <= i <= k}" and multipolygon-touch.geojson touches apparently only in one point ('finite number of points), I conclude that we need to change the code to let this case pass. The issue is I do not know what 'finite' should mean. Can we call one point finite? @lukas-h

I will propose a change and mention the commit hash here.

armantorkzaban commented 1 year ago

@lukas-h - what do you think about this proposal: 775f0e

lukas-h commented 1 year ago

booleanValid should not have any assertions, and should be solely based on boolean conditions, and the function returning false/true

lukas-h commented 1 year ago

The issue is I do not know what 'finite' should mean. Can we call one point finite? @lukas-h

Yes, let's do that.

And let's merge the feature now, with the warning, that is it not properly tested yet (early testing phase)