Opened 14 months ago

Closed 13 months ago

Last modified 13 months ago

#6659 closed defect (fixed)

OGR_FD_GetGeomFieldDefn with SpatialViews, returns more than one Geometry

Reported by: mj10777 Owned by: warmerdam
Priority: high Milestone:
Component: OGR_SF Version: 2.0.0
Severity: major Keywords: Sqlite, Spatialite, SpatialView
Cc:

Description

I am attempting to adapt the QgsOgrProvider? to retrieve Geometry Layers correctly when using gdal 2.*.

Based on the idea that for each Layer, one must loop through the Feature count.

This works correctly for both gdal 1.* and 2.* SpatialTables? with multiple Geometries.

It also works correctly when a SpatialView? has been properly defined

  • 1 geometry properly declared
    • only this geometry is contained in the view

However, should the view also contain other geometries

  • the geometries up to the declared geometry are also listed in the result
    • OGR_FD_GetGeomFieldCount(fdef) (both gdal 1.* and 2.*)

Sample: view contains 4 geometries, the second is declared

  • 1) a MULTIPOLYGON
  • 2) a MULTILINESTRING <-- registered as view-geometry
  • 3) a MULTIPOLYGON
  • 4) a POINT
field_count=OGR_FD_GetGeomFieldCount(fdef)
// returns 2
// loop i_field 
OGRGeomFieldDefnH fdef_geom=OGR_FD_GetGeomFieldDefn(fdef,i_field);
QString theLayerFieldName = FROM8(OGR_GFld_GetNameRef(fdef_geom));
OGRwkbGeometryType layerGeomType=OGR_GFld_GetType(fdef_geom);

i_field=0:

  • OGR_GFld_GetNameRef
    • will return the name of the first MULTIPOLYGON
  • OGR_GFld_GetType
    • will return the type MULTILINESTRING (not MULTIPOLYGON)

i_field=1:

  • OGR_GFld_GetNameRef
    • will return the name of the MULTILINESTRING
  • OGR_GFld_GetType
    • will return the type MULTILINESTRING

GDALDatasetGetLayerByName

  • does not return a usable result for both

For a SpatialView?

  • only 1 geometry should be returned
    • being the one found during OGRSQLiteDataSource::Open
  • the others should be ignored

Change History (8)

comment:1 Changed 14 months ago by mj10777

After correcting the 'sloppy' views

  • placing the registered geometry as the first listed in the view
    • everything works correctly (gdal 1.11.2 and 2.2.0dev)

OGR_FD_GetGeomFieldCount(fdef) returns 1

  • thus ignoring the others, which is the expected behavior

So the problem is only when the registered geometry in not the first listed

  • those before that geometry are counted and the names returned
    • but not the geometry type
  • none of which can be properly retrieved

comment:2 Changed 13 months ago by Even Rouault

Resolution: fixed
Status: newclosed

In 35898:

Spatialite: do not report some BLOB columns as geometry columns of tables/views (when found before the geometry column(s)) (fixes #6695, fixes #6659)

comment:3 Changed 13 months ago by Even Rouault

In 35899:

Spatialite: do not report some BLOB columns as geometry columns of tables/views (when found before the geometry column(s)) (fixes #6695, fixes #6659)

comment:4 Changed 13 months ago by Even Rouault

In 35900:

Spatialite: do not report some BLOB columns as geometry columns of tables/views (when found before the geometry column(s)) (fixes #6695, fixes #6659)

comment:5 Changed 13 months ago by Even Rouault

In 35901:

Spatialite: do not report some BLOB columns as geometry columns of tables/views (when found before the geometry column(s)) (fixes #6695, fixes #6659)

comment:6 Changed 13 months ago by Even Rouault

In 35904:

Spatialite: fix previous commit that broke VirtualShape? (refs #6695, refs #6659)

comment:7 Changed 13 months ago by Even Rouault

In 35905:

Spatialite: fix previous commit that broke VirtualShape? (refs #6695, refs #6659)

comment:8 Changed 13 months ago by Even Rouault

In 35906:

Spatialite: fix previous commit that broke VirtualShape? (refs #6695, refs #6659)

Note: See TracTickets for help on using tickets.