querying attributes in mapserver
Michael Kleih
michael.kleih at jrc.it
Thu Oct 5 01:34:23 PDT 2000
Hello,
I made a lot of attempts in querying the attributes of a shapefile
using mapscript, but always failed. For example in the
following example I tried to print out the number of results
I should get with my query. The mapfile 'countries_onec.map'
that I use has the following content:
NAME DEMO
STATUS ON
SIZE 600 600
EXTENT -5 34.66 20 60.83
UNITS DD
SHAPEPATH "data"
IMAGECOLOR 80 204 255
TRANSPARENT OFF
LAYER
NAME country
TYPE POLYGON
STATUS ON
DATA country
TOLERANCE 3
CLASSITEM Color_map
CLASS
EXPRESSION ([COLOR_MAP]<9)
COLOR 0 174 66
BACKGROUNDCOLOR 0 204 255
OUTLINECOLOR 0 0 0
END
END
END
The mapscript script in PERL has the following content:
#!/usr/bin/perl
use mapscript;
use GD;
$map = new mapObj('countries_onec.map') or die('Unable to open
mapfile.');
$img = $map->draw() or die('Unable to draw map');
mapscript::msSaveImage($img, "out.gif", false, false);
$lay = $map->getLayer(0);
$rect = new rectObj();
$rect ->{minx}=197;
$rect ->{miny}=297;
$rect ->{maxx}=203;
$rect ->{maxy}=303;
$qeur= $lay->queryUsingRect($map,$rect);
print $qeur->numresults;
This should print me the number of results of the query, but instead
I get the message:
Can't call method "numresults" on an undefined value at ./scripttst.pl
Can somebody help? It would really be nice!
Michael
--
__________________________________
Michael Kleih
Centro Comune di Ricerca-JRC
Commissione Europea
Via Fermi 1
TP 270
Tel. 0039/0332785039
__________________________________
More information about the MapServer-users
mailing list