[Gdal-dev] Determine table geometry type?

Craig Miller craig.miller at spatialminds.com
Wed Jun 29 18:14:18 EDT 2005


Frank,

I downloaded today's daily-cvs(June 29th) and the type of geometry stored in
a PostGIS table appears to still always be returned as wkbUnknown.  Is
anyone else seeing the same thing?

The June 27th daily-cvs failed under windows when I was building the pg
driver.  I didn't look to see what, if any, changes have been made since
then.

I am a busy for the next two weeks, and then on vacation for a week after
that.  When I get back, I'll take a look at the code and see if I can
determine what is going on.  In the meantime, I just wanted to communicate
what I'm observing.

Thanks,
--Craig
 

-----Original Message-----
From: Frank Warmerdam [mailto:fwarmerdam at gmail.com] 
Sent: Wednesday, June 22, 2005 8:07 AM
To: Craig Miller
Cc: gdal-dev at xserve.flids.com
Subject: Re: [Gdal-dev] Determine table geometry type?

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