[Gdal-dev] OGR and support for older PostGIS DBs?
Markus Neteler
neteler at itc.it
Wed Aug 3 13:06:35 EDT 2005
On Wed, Aug 03, 2005 at 09:22:26AM -0400, Frank Warmerdam wrote:
> On 8/1/05, Markus Neteler <neteler at itc.it> wrote:
> > Hi,
> >
> > I was trying the current OGR (today) against an older
> > PostGIS database (based on libpostgis.so.0.7 and PostgreSQL V7.3.3):
> ....
> > I am not sure what's wrong... AFAIK I didn't touch the PG DB for a long
> > while. Is backward compatibility supported? Otherwise I'll have to upgrade
> > my PG database.
> >
> > This patch cured at least the BOX3D problem:
> > --- ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp 20 Jul 2005 01:45:30 -0000 1.29
> > +++ ogr/ogrsf_frmts/pg/ogrpgtablelayer.cpp 1 Aug 2005 17:18:19 -0000
> > @@ -1282,7 +1282,7 @@
> > szVals[strstr(ptr,")") - ptr] = '\0';
> >
> > char ** papszTokens = CSLTokenizeString2(szVals," ,",CSLT_HONOURSTRINGS);
> > - if ( CSLCount(papszTokens) != 4 )
> > + if ( CSLCount(papszTokens) != 6 )
> > {
> > CPLError(CE_Failure, CPLE_IllegalArg, "Bad extent representation: '%s'", pszBox);
> > CSLDestroy(papszTokens);
> >
> >
> > Help is appreciated,
>
> Markus,
>
> Sorry about this. I asked Andrey and Oleg to look into this yesterday,
> but I believe Andrey is travelling today. I am commiting the following
> patch which I think should support the BOX3D if it is returned by
> the Extent() operator. I am not sure if this is a postgis version issue or
> not, but it is my intention to continue supporting earlier versions of
> PostGIS for a year or two at least.
>
> diff -u -b -r1.29 ogrpgtablelayer.cpp
[snip]
> Note my change differs from yours in that it correctly extract
> the extents in the case of a BOX3D and in that it continues
> to support the 2D version of the box.
>
> Andrey / Oleg, perhaps you guys could verify the changed
> code makes sense in all circumstances.
Thanks for the update! This solves the BOX problem. Unfortunately
I still cannot fetch from PostGIS:
ogrinfo PG:'host=myserver user=postgres dbname=spearfish' streams_pg
OGR_PG: DBName="spearfish"
OGR_PG: POSTGIS_VERSION=0.7
OGR_PG: Layer 'streams_geom' geometry type: GEOMETRY:Unknown (any), Dim=2
OGR_PG: Layer 'streams_length_geom' geometry type: GEOMETRY:Unknown (any), Dim=2
OGR_PG: Layer 'areecampione2' geometry type: POLYGON:Polygon, Dim=2
OGR_PG: Layer 'archistes' geometry type: POINT:Point, Dim=2
OGR_PG: Layer 'streams_pg' geometry type: LINESTRING:Line String, Dim=2
OGR_PG: Layer 'mystreams_pg' geometry type: LINESTRING:Line String, Dim=2
OGR: OGROpen(PG:host=myserver user=postgres dbname=spearfish) succeeded (0x97623f8).
INFO: Open of `PG:host=myserver user=postgres dbname=spearfish'
using driver `PostgreSQL' successful.
Layer name: streams_pg
Geometry: Line String
OGR_PG: PQexec(DECLARE countCursor CURSOR for SELECT count(*) FROM "streams_pg" )
Feature Count: 116
OGR_PG: PQexec(SELECT Extent("wkb_geometry") FROM "streams_pg")
Extent: (589443.060000, 4913935.460000) - (609526.750000, 4.000000)
Layer SRS WKT:
PROJCS["UTM Zone 13, Northern Hemisphere",
GEOGCS["clark66",
DATUM["North_American_Datum_1927",
SPHEROID["clark66",6378206.4,294.9786982]],
PRIMEM["Greenwich",0],
UNIT["degree",0.0174532925199433]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-105],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
UNIT["meter",1]]
cat: Integer (0.0)
label: String (0.0)
OGR_PG: PQexec(DECLARE OGRPGLayerReader CURSOR for SELECT "ogc_fid", AsEWKT("wkb_geometry"), "cat", "label" FROM "streams_pg" )
OGR_PG_NOTICE: WARNING: PerformPortalClose: portal "ogrpglayerreader" not found
Thanks
markus
More information about the Gdal-dev
mailing list