Aquire x/y coordinates from rectangle object

Lowell Filak lfilak at MEDINACO.ORG
Tue Sep 7 09:04:05 PDT 2004


The following message was sent by Lowell Filak <lfilak at MEDINACO.ORG> on
Tue, 7 Sep 2004 10:37:36 -0400.

> The following message was sent by G-Net Consulting
> <joelf at GNETCONSULTING.COM> on Sat, 4 Sep 2004 01:14:23 -0400.
>
> > Hello List:
> >
> > I'm looking for a snippet of code to grab the X/Y coordinates
> > from a point in a shape file.  I've pulled the shape data in
> > from the DBF (thanks to Lowell for that).  Now I would like
> > to display the data in overLib with a mouseover.
> >
> > So what is the best way to get the X/Y for each shape
> > in the chosen extent?
> >
> > Thanks.
> >
> > Joel
>
> Joel;
>
> You can:
>
> shapeObj = new shapeObj(type_point)
>
> use the shapeindex from resultCacheMemberObj with
> layer->getShape(shapeObj, 0, shapeindex)
>
> pointObj=shapeObj->get(0)
>
> pointObj->{x} & pointObj->{y}
>
> The doc (at least swigmapscript) needs to be clearer on this.
>
> Lowell

Joel;

Here's a correct example.

$data = $layer->{data};
$shapefile = new mapscript::shapefileObj($data,-1);
$point = new mapscript::pointObj();
$shapefile->getPoint(shapeindex,$point);
$x = $point->{x};
$y = $point->{y};

Lowell



More information about the MapServer-users mailing list