queryByAttributes and PHP
Matthew Roberson
adidassneakers at YAHOO.COM
Fri Jun 17 13:26:20 PDT 2005
Hello,
I am trying to using the queryByAttributes method of
the LayerObj class of PHP/Mapscript and I am doing
something wrong, because I get the following error:
Fatal error: Unsupported operand types in
C:\ms4w\apps\test\htdocs\LA.phtml on line 12
I am running in Windows XP professional with:
ms4w 1.1
I also get the same error in MacOS X with a custom
compiled version of MapSever.
The Map File is contains:
MAP
NAME LA
IMAGETYPE PNG
SIZE 600 600
IMAGECOLOR 240 240 240
SHAPEPATH "../data"
FONTSET ../etc/fonts.txt
EXTENT -94.043147 28.925011 -88.817017 33.019457
UNITS METERS
WEB
IMAGEPATH "/ms4w/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
END
LEGEND
STATUS EMBED
POSITION UR
END
SCALEBAR
TRANSPARENT ON
BACKGROUNDCOLOR 0 0 0
STATUS EMBED
POSITION LR
STYLE 1
END
LAYER
NAME "LA zip code boundaries"
TYPE POLYGON
STATUS DEFAULT
DATA "zt22_d00"
LABELITEM "ZCTA"
CLASS
COLOR 254 0 0
LABEL
COLOR 60 60 60
SHADOWCOLOR 218 218 218
SHADOWSIZE 1 1
TYPE TRUETYPE
FONT fritqat
SIZE 8
ANTIALIAS TRUE
POSITION CL
PARTIALS FALSE
MINDISTANCE 5
BUFFER 4
END
OUTLINECOLOR 60 60 60
SYMBOL 0
END
TEMPLATE "x"
END
LAYER
NAME "credits"
STATUS DEFAULT
TRANSFORM FALSE
TYPE ANNOTATION
FEATURE
POINTS
10 680
END
TEXT 'Made with Mapserver.'
END
CLASS
LABEL
TYPE BITMAP
POSITION CR
COLOR 0 0 0
END
END
END
END
and the .phtml file contains:
<?php
if (!extension_loaded("MapScript"))
{
dl("php_mapscript_44.dll");
}
if (!extension_loaded("dbase"))
{
dl("php_dbase.dll");
}
$map_file="./LA.map";
$map = ms_newMapObj($map_file);
//$image=$map->draw();
//$image_url=$image->saveWebImage();
$oZipLayer = $map->getLayerByName("LA zip code
boundaries");
//Do query
$sZip = '12603';
$sAttrName = 'ZCTA';
$qresult =
@$oZipLayer->queryByAttributes($sAttrName,$sZip,MS_MULTIPLE);
$image = $map->drawQuery();
$image_url = $image->saveWebImage();
$error = ms_GetErrorObj();
while($error && $error->code != MS_NOERR)
{
printf("Error in %s: %s \n", $error-routine,
$error->messaage);
$error = $error->next();
}
?>
<HTML>
<HEAD>
<TITLE>LA Zip Codes</TITLE>
</HEAD>
<BODY>
<img SRC="<?php echo $image_url?>">
<p>This is an unprojected map of the 5 digit zip code
boundries for the state of Louisianna,
from the <a
href="http://www.census.gov/geo/www/cob/z32000.html">
US Census Bureau</a>.</p>
<p>To find the categories for the legend, I used the
<code>ogrinfo</code> utility twice.
<code>ogrinfo -a -summary zt22_d00.shp</code> let me
see what fields were available, and
<code>ogrinfo -a zt22_d00.shp|grep SYMBOL|sort
-u</code> told me what all of the unique values were
so that
I could build my <code>CLASS</code> definitions in
<code>LA.map</code>.
</p>
</BODY>
</html>
<?php
print_r($oZipLayer);
print_r($qresult);
if ($oZipLayer->getNumResults() > 0)
echo $oZipLayer->getNumResults()." zips found.";
else
echo "No zips found."
?>
I would appreciate any help or suggestions anyone has
to offer.
__________________________________
Do you Yahoo!?
Yahoo! Mail - You care about security. So do we.
http://promotions.yahoo.com/new_mail
More information about the MapServer-users
mailing list