-
Notifications
You must be signed in to change notification settings - Fork 26
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
Can't create valid linearring #325
Comments
Interesting. Using LibGEOS.jl this works as expected: julia> using LibGEOS
julia> ring1 = readgeom("LINEARRING (0 0,0 1,1 1)")
ERROR: GEOSError
IllegalArgumentException: Points of LinearRing do not form a closed linestring
julia> ring2 = readgeom("LINEARRING (0 0,0 1,1 1,0 0)")
LinearRing(Ptr{Nothing} @0x0000000075ee4360)
julia> isValid(ring2)
true In GDAL.jl I guess this would reproduce it, but it gives an error code back for unsupported geometry. using GDAL
ring2 = Ref(C_NULL)
wkt = "LINEARRING (0 0,0 1,1 1,0 0)"
GDAL.ogr_g_createfromwkt([wkt], C_NULL, ring2)
# returns OGRERR_UNSUPPORTED_GEOMETRY_TYPE = 3
# GDAL.ogr_g_isvalid(ring2[]) # doesn't work since ring2 is still C_NULL This is probably related to GDAL itself and how it handles this geometry type, see also #314. I added JuliaGeo/GDAL.jl#141 to double check that we build GDAL with GEOS support. |
Hmm yeah I checked the implementation in https://github.com/OSGeo/gdal/blob/82401cb09515840dfde480ac4aa10cac7286983a/ogr/ogrgeometry.cpp#L2191-L2213 and don't know what else to try here. If we might be able to translate it into the corresponding GDAL function calls, we can file an issue with https://github.com/OSGeo/gdal/issues |
It seems it might have been reported in the past but never addressed: https://trac.osgeo.org/gdal/ticket/5006. To fix it, GDAL should support bidirectional translation to/from WKB for LinearRings. However, I don't think LibGEOS properly supports WKB for LinearRings. To verify this, running the following code will return a linestring: using LibGEOS
wkbwriter = LibGEOS.WKBWriter(LibGEOS._context)
ring = LibGEOS.readgeom("LINEARRING (0 0,0 1,1 1,0 0)")
wkb = LibGEOS.writegeom(ring, wkbwriter)
LibGEOS.readgeom(wkb) On the other hand, running the following code will return a linearring: using LibGEOS
wktwriter = LibGEOS.WKTWriter(LibGEOS._context)
ring = LibGEOS.readgeom("LINEARRING (0 0,0 1,1 1,0 0)")
wkt = LibGEOS.writegeom(ring, wktwriter)
LibGEOS.readgeom(wkt) I suspect this is due to WKBs not having first-class support as one of the original 7 simple features defined in https://libgeos.org/specifications/wkb/#geometry-types. |
While working through the Documentation I was not able to create a linearring which would pass the validity test.
MWE:
Interestingly, Polygons can be valid, if the contained linearrings have the same first and last point, even if the rings themselves are not valid. (and if the other conditions for polygons are met)
The text was updated successfully, but these errors were encountered: