[Mapserver-users] getShape() with SDE and PostGIS
Daniel Morissette
dmorissette at dmsolutions.ca
Wed Feb 4 10:57:44 PST 2004
Ellis Robin (Bundaberg) wrote:
> I'm using PHP mapscript with version 3.6.3 of Mapserver. Using the following mapscript I can successfully return the extent of a polygon from a PostGIS layer, however I can't repeat the success with a similar SDE layer.
>
> $zoomdcdblayer->queryByAttributes(MS_MULTIPLE);
> $thenum_results = $zoomdcdblayer->getNumResults();
>
> for ($i=0;$i < $thenum_results; $i++) {
> $result = $zoomdcdblayer->getResult($i);
> $zoomdcdblayer->open("test");
> $rvshape = $zoomdcdblayer->getShape($result->{tileindex}, $result->{shapeindex});
> $shpbnd = $rvshape->bounds;
> print_r($shpbnd);
> $zoomdcdblayer->close();
> }
>
>>From my PostGIS layer I get this 'shpbnd' output:
> rect Object ( [_handle_] => Resource id #23 [minx] => 152.226563 [miny] => -25.004187 [maxx] => 152.234491 [maxy] => -24.997927 )
>
> But from my SDE layer I get this:
> rect Object ( [_handle_] => Resource id #18 [minx] => -1 [miny] => -1 [maxx] => -1 [maxy] => -1 )
>
It seems that the bound of the shapeObj were not set by the SDE driver,
and according to CVS logs this would have been fixed in V 4.0:
-----------
revision 1.59
date: 2003/01/22 18:20:09; author: sdlime; state: Exp; lines: +8 -0
Fixed SDE code to properly set the bounds of a shape.
-----------
So you will have to upgrade to get that fix, unless you want to patch
your local copy of the source (see the diff output below).
Daniel
------------------------------------------------------------
Daniel Morissette dmorissette at dmsolutions.ca
DM Solutions Group http://www.dmsolutions.ca/
------------------------------------------------------------
$ cvs diff -u -r 1.58 -r 1.59 mapsde.c
Index: mapsde.c
===================================================================
RCS file: /data2/cvsroot/mapserver/mapsde.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- mapsde.c 21 Jan 2003 23:41:21 -0000 1.58
+++ mapsde.c 22 Jan 2003 18:20:09 -0000 1.59
@@ -42,6 +42,7 @@
long numparts, numsubparts, numpoints;
long *subparts=NULL;
SE_POINT *points=NULL;
+ SE_ENVELOPE envelope;
long type, status;
lineObj line={0,NULL};
@@ -121,6 +122,13 @@
free(subparts);
free(points);
+
+ // finally copy the bounding box for the entire shape
+ SE_shape_get_extent(inshp, 0, &envelope);
+ outshp->bounds.minx = envelope.minx;
+ outshp->bounds.miny = envelope.miny;
+ outshp->bounds.maxx = envelope.maxx;
+ outshp->bounds.maxy = envelope.maxy;
return(MS_SUCCESS);
}
More information about the MapServer-users
mailing list