Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does @turf/boolean-valid require MultiLineStrings to have at least two component LineStrings? #2837

Open
benjaminblack opened this issue Feb 10, 2025 · 1 comment

Comments

@benjaminblack
Copy link

benjaminblack commented Feb 10, 2025

I assume the OGC Simple Features spec mandates this but I am unable to find a source:

boolean-valid will reject a MultiLineString which has coordinates with only one LineString, e.g. "coordinates": [ [...] ]

The GeoJSON spec is frustratingly silent on whether or not MultiLineString coordinates can be empty; however, we frequently encounter GeoJSON MultiLineStrings composed of a single LineString, typically from GPS devices.

Curiously, for the other multipart geometries, boolean-valid does not enforce this. Why is that?

A GeometryCollection with an empty "geometries": [] is similarly rejected, though the GeoJSON spec explicitly allows this. Again, I assume the reason is the OGC spec, but I can't find a direct source.

As for MultiLineStrings, I observe that the case for MultiLineString is identical to the case for LineString, which would suggest this is a actually a bug; or at least that the MultiLineString case is missing an inner loop to validate that each coordinate has at least lng and lat, as is done with LineStrings.

@sharmaB01
Copy link

sharmaB01 commented Feb 24, 2025

@benjaminblack just do a change in code here

inlace of case "MultiLineString":
if (coords.length < 2) return false;
put :-
case "MultiLineString":
if (coords.length < 1) return false;

in their file. (https://github.com/Turfjs/turf/blob/master/packages/turf-boolean-valid/index.ts)

sharmaB01 added a commit to sharmaB01/turf that referenced this issue Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants