[mapserver-users] mapscript queryUsing Point question

Manfred Meier m.meier at spiekermann.de
Tue Jan 22 08:20:43 EST 2002


Hello,

I'm referencing to this 'old' mail, because I now have the same problem.
Using mapserver 3.5 and mapscript and perl 5.6.1.
The creation of the .png file with msSaveImage is ok.
And queryByPoint and getResult is ok.

The creation of a new shape object with $s = new
shapeObj($mapscript::MS_SHAPE_POINT) returns a valid object. But then
executing $x = layerobj->getShape($s, -1, 67) (e.g.) gives a segmentation
fault.

Has this problem be solved? Can someone point me to an answer?

Thank you
Manfred Meier

Paul Ramsey schrieb:

> Robert,
> My perl code (3.5 cvs) seems to do a queryByPoint correctly. See the
> file below. I think the problem w/ your code might be that you are
> supplying a querypoint in image coordinates rather than geographic
> coordinates.
>
> My own problem is that when I call getShape() in the code below, perl
> cores out. Ouch.
>
> PS - As a perl fool, I would like to note that having MS_SUCCESS == 0 is
> highly counter-intuitive :)
>
> ------------
>
> use mapscript;
>
> my $map = new mapObj("/home/pramsey/arcims_proxy/imsbin/demo.map");
>
> my $pt = new pointObj();
> $pt->{x} = 900000;
> $pt->{y} = 900000;
>
> my $lyr = $map->getLayer(0);
>
> print $lyr,"\n";
>
> print $lyr->{metadata},"\n";
>
> my $rv = $lyr->queryByPoint($map,$pt,$mapscript::MS_SINGLE,10.0);
>
> die "Query failed" if $rv != $mapscript::MS_SUCCESS;
>
> print $rv,"\n";
>
> my $rsltcache = $lyr->{resultcache};
>
> my $bds = $rsltcache->{bounds};
>
> print "(" . $bds->{minx} . "," . $bds->{miny} . ") ";
> print "(" . $bds->{maxx} . "," . $bds->{maxy} . ")\n";
>
> my $numrslt = $rsltcache->{numresults};
>
> my $rslt = $lyr->getResult(0);
>
> print $rslt->{shapeindex},"\n";
> print $rslt->{tileindex},"\n";
>
> my $shp = new shapeObj($mapscript::MS_SHAPE_POLYGON);
> $rv = $lyr->getShape($shp,$rslt->{tileindex},$rslt->{shapeindex});
>
> ------------
>
> [pramsey at localhost imsbin]$ perl imsbin.pl
> layerObj=HASH(0x80d3e48)
> hashTableObjPtr=SCALAR(0x80aa194)
> 0
> (866069.209709852,888026.148641071) (1000000.03274901,1001458.47721688)
> 52
> -1
> Segmentation fault (core dumped)







More information about the mapserver-users mailing list