[Mapserver-users] A QUERY only mapfile, PHP/Mapscript, get not results
woodbri at swoodbridge.com
woodbri at swoodbridge.com
Sat Mar 8 11:46:02 PST 2003
Hi all,
My brain must have gone on vacation or something, because I have what
I thought should be a trivial example to put together and I can not
seem to get it to work!
Built a simple php script to do a query of a query only mapfile and
print the results. I have included below the results, query.map,
t2.php
So, does anyone have any ideas on what stupid thing I have
overlooked. Oh, the world_countries_shp file is good and in units DD.
I have tried this with 12 different layers all with the same results.
I just stripped that down to this simple example. And I have tried it
on php-4.3.1 and MS-3.7_dev with the same results.
-Steve W.
------------------------------ results
query point = (-71.3940, 42.6140)
LAYER country, 0
STATUS 1
TYPE 5
SHAPEPATH /data/mdata/
TILEINDEX
DATA world/world_countries_shp
TEMPLATE dummy
TOLERANCE 3.000 6
Warning: MapServer Error in msQueryByPoint(): No matching record(s)
found.
in /home/httpd/html/maptools/rgeo/t2.php on line 29
ret=1
---------------------------------- query.map
MAP
NAME "EXAMPLE"
STATUS ON
EXTENT -180.0 -14.8 -51.75 113.4
SHAPEPATH "/data/mdata/"
UNITS DD
LAYER # this is a polygon layer
NAME "country"
TYPE QUERY
STATUS ON
DATA "world/world_countries_shp"
TEMPLATE "dummy"
METADATA
"DESCRIPTION" "World Countries"
"RESULT_FIELDS" "NAME CAPITAL CONTINENT"
END
END
END
---------------------------------- t2.php
<?php
dl("php4.2.2_mapscript-20020904.so"); # mapserver 3.6.2
define(MAPFILE, '/data/mdata/query.map');
$point = ms_newPointObj();
$point->setXY(-71.394, 42.614);
print "<pre>\n";
printf("query point = (%.4f, %.4f)\n\n", $point->x, $point->y);
$map = ms_newMapObj(MAPFILE) or
die("Can't create mapObj using " . MAPFILE);
$map->preparequery();
$shapepath = $map->shapepath;
for ($i=0; $i<$map->numlayers; $i++) {
$layer = $map->getLayer($i);
$layer->set('status', MS_ON);
printf("LAYER %s, %d\n", $layer->name, $layer->index);
printf(" STATUS %d\n TYPE %d\n", $layer->status, $layer->type);
printf(" SHAPEPATH %s\n", $shapepath);
printf(" TILEINDEX %s\n", $layer->tileindex);
printf(" DATA %s\n", $layer->data);
printf(" TEMPLATE %s\n", $layer->template);
printf(" TOLERANCE %.3f %d\n", $layer->tolerance, $layer-
>toleranceunits);
$ret = $layer->queryByPoint($point, MS_MULTIPLE, 1.0);
print "ret=$ret\n";
if ($ret == MS_SUCCESS) {
for ($j=0; $j<$layer->getNumResults(); $j++) {
$result = $layer->getResult($j);
printf("lay=%d, res=%d, si=%d, ti=%d, ci=%d\n",
$i, $j, $result->shapeindex, $result->tileindex,
$result->classindex);
}
}
}
phpinfo();
?>
More information about the MapServer-users
mailing list