mapscript: $result->shapeindex returns 0 and querying failed
Lin Huang
linh200210 at YAHOO.COM
Thu Oct 6 07:59:57 PDT 2005
Hi all,
My mapserver application using PHP/mapscripts works
great. But I got errors when doing a query and hope
someone could point out where did I do wrong.
The query part in my php code:
------------
$layer = $mMap->getLayerByName(sites);
$layer->open();
//Querying one layer
$res = $layer->getResult(0);
//print shapeindex
echo "shpaindex: {$oRes->shapeindex}";
$shape =
$layer->getShape($res->tileindex,$res->shapeindex);
$i=0;
while (list($key,$val) = each($shape->values) )
{
$fields[$i++] = $key;
echo "Result: $key, $val";
if ($i>=4) break;
}
-------------
The output:
---------------
shpaindex: 0
Warning: Variable passed to each() is not an array or
object
in /usr/local/ms/htdocs/net.inc.php on line 294
-------------
The querying layer in my map file
-------------
LAYER
CONNECTIONTYPE postgis
NAME "sites"
DEBUG on
# Connect to a remote spatial database
CONNECTION "user=net100 dbname=netbase
host=localhost"
DATA "location from (select cust_id,
site_id,location, product_id,
site_name from customer_obs) as new_table using unique
site_id using
srid=4326"
STATUS ON
TYPE POINT
TOLERANCE 5
CLASSITEM "product_id"
LABELITEM "site_name"
CLASS
NAME 'wxm'
EXPRESSION /5/
STYLE
COLOR 255 000 255
SYMBOL 'star'
SIZE 9
END
LABEL
COLOR 255 000 255
SIZE small
POSITION CL
MINDISTANCE 100
END # end of label
TEMPLATE 'templates/icao_query.html'
END
HEADER "templates/icao_header.html"
FOOTER "templates/footer.html"
END
--------------------
Looks to me like the problem is in the shapeindex. Why
it always returns
0?
Thanks very much for any help!
Lin
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
More information about the MapServer-users
mailing list