[gdal-dev] Why MultiLinestring in GeometryCollection is unexpected for SQLite dialect?

Even Rouault even.rouault at spatialys.com
Wed Dec 11 10:06:59 PST 2019


Jukka,

> This command fails with SQLite dialect
>
>ogrinfo -dialect sqlite -sql "select geometry from jump_gc as geom" 
>jump_gc.jml
>Had to open data source read-only.
>INFO: Open of `jump_gc.jml'
>      using driver `JML' successful.
>ERROR 1: Unexpected geometry type MULTILINESTRING as part of 
>GEOMETRYCOLLECTION

Candidate fix in https://github.com/OSGeo/gdal/pull/2095

Basically, Spatialite geometries don't support arbitrary nesting of geometry 
collections (understood as the abstract type, that is GEOMETRYCOLLECTION, 
MULTIPOINT, MULTILINESTRING, MULTIPOLYGON) in a GEOMETRYCOLLECTION. I see that 
Spatiliate ST_GeomFromText() flattens the structure in such situation

$ ogrinfo -dialect sqlite -sql "select 
st_astext(st_geomfromtext('GEOMETRYCOLLECTION(MULTIPOINT(0 1,2 3))'))" 
:memory: -al -q

Layer name: SELECT
OGRFeature(SELECT):0
  [...] = GEOMETRYCOLLECTION(POINT(0 1), POINT(2 3))

This limitation can be infered from
https://www.gaia-gis.it/gaia-sins/BLOB-Geometry.html
looking at the table below
"The following is the format expected for each one collection entity: "
where one can see that only POINT, LINESTRING and POLYGON are valid items
inside a collection.

So I'm now doing the same on conversion of OGR geometries to Spatialite ones 
when using the SQLite dialect

$ ogrinfo -dialect sqlite -sql "select geometry from test" test.jml -al -q

Layer name: SELECT
OGRFeature(SELECT):0
  GEOMETRYCOLLECTION (LINESTRING (280 420,540 420,560 440,540 440),LINESTRING 
(300 460,480 460,520 500),POINT (1 3))

Even


-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list