[mapserver-users] Simple ItemQuery with QueryMap & php MapScr ipt
Hankley, Chip
Chip.Hankley at GASAI.Com
Mon Aug 12 07:25:15 PDT 2002
Nicol...
I'm forwarding this to the MapServer list. On first glance, it looks OK to
me...
I don't generally create mapfiles on the fly, so, it's hard for me to de-bug
that part of your code... that could be where the problem is. For de-bugging
purposes, I'd first go back and try to do this against a static mapfile. See
if that works, then try to implement it with building the mapfile on-the-fly
like that.
Chip
-----Original Message-----
From: Nicol Hermann [mailto:mapserver at geochem.de]
Sent: Saturday, August 10, 2002 1:39 PM
To: Hankley, Chip
Subject: RE: [mapserver-users] Simple ItemQuery with QueryMap & php
MapScript
Hi Chip,
inspired by your posting in the Mapserver-Newsgroup i try to reproduce
the 'simple ItemQuery' with PHP-Mapscript.
This works fine till i tryed to get the values of the selected EXPRESSION.
I try the following at the position
// ===> <===
marked in the Script
$numResults = $Layer->getNumResults();
$Layer->open($map->shapepath);
$getDesc = $lyObj->getMetaData("DESCRIPTION");
$selFields = explode(" ", $Layer->getMetaData("RESULT_FIELDS"));
for($j = 0;$j < $numResults;$j++)
{
$oRes = $Layer->getResult($j);
$oShape = $Layer->getShape($oRes->tileindex,$oRes->shapeindex);
$res = $res.'|'.$oShape->values[$selFields[0]];
}
$numResults is 0
so i get nothing back.
Here is my Script so far. Could you please give me an hint or a short
code snippet what i have to do to get the values.
My setting is:
Mapserver 3.6.1
Debian 3.0
PHP (CGI) 4.2.2
Thank you very much
Nicol
P.S The Script is based on the Shapes from
http://maps.dnr.state.mn.us/mapserver_demos/tests3.5/itemquery/test.html
////////////////////////////
<?
dl("../php_mapscript.so");
$serverpfad = "/~nicol/mapserver/itemquery/";
$verzpfad = "/home/nicol/public_html/mapserver/itemquery/";
$datapath = "data";
$data = "county";
$some_co_value = "Anoka";
$descr = "Laenderuebersicht";
$map = ms_newMapObj('') or die('Unable to open mapfile.');
$nColorId = $map -> addColor(255, 0, 0);
$nOutLineColor = $map -> addColor(0, 0, 0);
$nOtherColorId = $map -> addColor(212, 212, 212);
$map -> web -> set ("imagepath","{$verzpfad}tmp/");
$map -> web -> set ("imageurl", "{$serverpfad}tmp/");
$map -> set ("width", 300);
$map -> set ("height", 300);
$map -> setExtent(74000,4775000,798000,5499000);
$Layer = ms_newLayerObj($map);
$Layer -> set("name","county");
$Layer -> set("status", 1);
$Layer -> set("data","{$verzpfad}{$datapath}/$data");
$Layer -> setMetaData("DESCRIPTION","$descr");
$Layer -> setMetaData("RESULT_FIELDS","CTY_NAME COUN");
$Layer -> set("classitem", "cty_name"); // entspr. FILTERITEM im map-File
$Layer -> set("type", MS_LAYER_POLYGON );
$poClass = ms_newClassObj($Layer);
$poClass -> set("color", $nColorId); // Farbe des gewaehlten Elements
$poClass -> set("outlinecolor", $nOutLineColor); // Umrissfarbe des
gewaehlten Elements
$poClass -> set("template", "php_selected.html");
$poClass -> set("name", "Selektiere Elemente");
$Object = $Layer->getClass(0);
$Object -> setexpression($some_co_value); // entspr. FILTER im map-File
// ===> <===
$otherClass = ms_newClassObj($Layer);
$otherClass -> set("color", $nOtherColorId);
$otherClass -> set("outlinecolor", $nOutLineColor); // Umrissfarbe der
nicht gewaehlten Elemente
$otherClass -> set("template", "php_selected.html");
$otherClass -> set("name", "Nicht selektiere Elemente");
$img = $map->draw();
$url = $img->saveWebImage(MS_PNG, $map->transparent, $map->interlace, 50);
$img->free();
printf("<p>Referenzkarte: <br> <IMG SRC=%s>\n", $url);
?>
More information about the MapServer-users
mailing list