[Gdal-dev] Determine table geometry type?

Frank Warmerdam fwarmerdam at gmail.com
Wed Jun 22 11:07:05 EDT 2005


On 6/21/05, Craig Miller <craig.miller at spatialminds.com> wrote:
> 
> I'm trying to determine the type of geometry stored in a PostGIS  table via
> OGR.  I am trying to do this by calling 
> 
> pogrLayer->GetLayerDefn()->GetGeomType(); 
> 
> In my code this always returns wkbUnknown for layers.  Is GeomType supported for layers? 

Craig,

I see that Andrey Kiselev has committed changes to pick up the
geometry type (where easy) from the geometry_columns tables 
on May 5th, 2005.  You might want to try upgrading to a more
recent GDAL from CVS or verify that your
gdal/ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp has  revision 1.27.

Note, this change came originally from Oleg Semykin. 

I would add that GetGeomType() is the right way to ask a 
layer for it's geometry type.  But some drivers don't set this,
either through omission as was the case with the PostGIS driver,
or because the underlying format does not restrict the layer to one
geometry type. 

> Another options is to query the OGIS extension tables directly and parse the
> results.  Is this the easiest/correct way of determining all spatial tables?
> 
>   
> 
> "SELECT f_table_catalog AS catalog, f_table_schema as schema, f_table_name
> AS tablename, f_geometry_column as dgname FROM Geometry_Columns"; 


Well, this still doesn't return the geometry type.  The patch fetches
the "type" field from the geometry_columns tables to get the type.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the Gdal-dev mailing list