Closed rafaqz closed 2 years ago
I don't really understand. LINEARRING is a non-standard extension of WKT that several projects support. It basically is a closed LINESTRING. The OGRwkbGeometryType
has both wkbLineString
and wkbLinearRing
. GDAL seems to support it with a createlinearring
function that creates a LINEARRING on toWKT
. But why not use wkbLinearRing
as a geometry type? Perhaps because LINESTRING
is the more general type, which you can also close by having the first and last coordinate equal?
Yeah seems like something like that. So the question is really in what cases does GDAL actually return wkbLinearRing
form ogr_g_getgeometrytype
, if ever?
Hard to make things type stable without knowing that. This is a pretty commmon path too - getting rings from a polygon - so it would be good to make it faster.
It seems never, based on this comment:
wkbLinearRing = 101, /**< non-standard, just for createGeometry() */
From https://github.com/OSGeo/gdal/blob/v3.5.1/ogr/ogr_core.h#L401
Ok great. We can lock in wkbLineString
as the type parameter.
Edit: but I guess we still need to handle passing wkbLinearRing
but getting back a wkbLineString
. So a line or two of special casing for createlinearring
.
See: https://github.com/yeesian/ArchGDAL.jl/blob/master/test/test_geometry.jl#L292
I'm trying to fix type stability of geometry creation for performance (some large gains from small changes) but
createlinearring
is a strange wart to special-case.Why does it return a
wkbLineString
? as the comment says, it seems very odd.