[Gdal-dev] Re: OGR PGResultLayer definition reading error?
Frank Warmerdam
warmerdam at pobox.com
Tue Nov 8 10:36:26 EST 2005
On 11/8/05, Oleg Semykin <oss-dev at rambler.ru> wrote:
> Hi, all!
>
> When I use executeSQL() for fetching features from PostgreSQL, result
> layer have wrong feature definition
> It can't determine a geometry column.
>
> For example:
> I am use:
> PostgreSQL 8.0
> POSTGIS="1.0.0" GEOS="2.1.1" PROJ="Rel. 4.4.9, 29 Oct 2004" USE_STATS
> DBPROC="0.3.0" RELPROC="0.3.0"
>
> ogrinfo 'PG:dbname=db host=dbhost user=postgres' t_table_22 -so
>
> returns:
>
> INFO: Open of `PG:dbname=db host=dbhost user=postgres'
> using driver `PostgreSQL' successful.
>
> Layer name: t_table_22
> Geometry: Multi Point
> Feature Count: 13
> Extent: (6421011.500000, 6621845.500000) - (6426622.000000, 6633781.000000)
> Layer SRS WKT:
> LOCAL_CS["Nonearth",
> UNIT["Meter",1.0]]
> IDOBJ: Real (0.0)
> order: Integer (0.0)
> gid: Integer (0.0)
> id_style: Integer (0.0)
> id_type_object: Integer (0.0)
>
> but:
>
> ogrinfo -sql "select * from t_table_22" 'PG:dbname=db host=dbhost
> user=postgres' -so
>
> returns:
>
> INFO: Open of `PG:dbname=db host=dbhost user=postgres'
> using driver `PostgreSQL' successful.
>
> Layer name: sql_statement
> Geometry: Unknown (any)
> Feature Count: 13
> Layer SRS WKT:
> (unknown)
> gid: Integer (0.0)
> id_style: Integer (0.0)
> id_type_object: Integer (0.0)
> order: Integer (0.0)
> IDOBJ: Real (0.0)
>
> Geometry and SRS - unknown
>
> Is it bug?
Oleg,
OGR does not parse the SELECT statement, it just inspects
the rows that come back. Based on that, there isn't enough
information to determine the SRS of the table or the geometry
type. So things are working normally.
Now we could likely work out the SRS by inspecting the SRS
of the geometry of the first record but reading ahead to the first
record at ExecuteSQL() time could result in a high performance
cost (to restart for real reading), or complexity of code to preserve
the pre-read row for the first call to GetNextFeature(). It would also
be possible that the first row would have NULL geometry.
Does that make sense?
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