[Mapserver-users] Polygon hilite
Mark Balman
Mark.Balman at birdlife.org.uk
Wed Feb 5 01:20:11 PST 2003
Hi list
Firstly I would like to say what a fantastic forum....and thanks Chip for
helping me (months ago!) with the mapscript HOWTO example, which resulted in
me being really stupid.. I initially called the file test.html which just
produced a dump of php... renaming the file to test.phtml produced the
desired result e.g. a simple map...
Recently I have finally managed to get my prototype application (built using
MapLab) to zoom to a polygon from a text input box using mail archive
suggestions from Paul Spencer and Andreas Berweger as follows :).
Unfortunately this is not "on-line" yet and is sitting on my laptop until I
can get the go ahead to put this on a server.. (could be weeks but more
likely months away : ( )
My problem:
In my test.php file in apache\htdocs\maplab\projects\gmf_apps\test I have
placed:
if ( $http_form_vars["SpeciesName"])
{
$szSpeciesName = $http_form_vars["SpeciesName"];
$oExtents = $oMapSession->oMap->extent;
$oldExtents=$oExtents;
$oSpeciesLayer = $oMapSession->oMap->getLayerByName( "range" );
$oSpeciesLayer->set( "filteritem", "SPCSPECIES" );
$oSpeciesLayer->setFilter("\"$szSpeciesName\"");
$oSpeciesLayer->queryByAttributes( MS_MULTIPLE );
if ($oSpeciesLayer->getNumResults() > 0 )
{
$oResult = $oSpeciesLayer->getResult( 0 );
$oSpeciesLayer->open($oMapSession->oMap->shapepath);
$oShape = $oSpeciesLayer->getShape($oResult->tileindex,$oResult->shapeindex
);
$oExtents = $oShape->bounds;
$oShape->free();
My mapfile contains:
MAP
EXTENT -180 -90 180 90
SHAPEPATH "./data"
SIZE 600 300
STATUS ON
TRANSPARENT FALSE
UNITS DD
NAME "world"
QUERYMAP
STATUS ON
COLOR 0 0 255
STYLE HILITE
END
WEB
IMAGEPATH "/tmp/ms_tmp/"
IMAGEURL "/ms_tmp/"
END
LAYER
DATA "country"
NAME "country"
SIZEUNITS PIXELS
STATUS DEFAULT
TOLERANCE 3
TOLERANCEUNITS PIXELS
TYPE POLYGON
UNITS METERS
CLASS
NAME "Cntry_name"
MAXSIZE 100
MINSIZE 1
OUTLINECOLOR 50 50 50
SIZE 1
SYMBOL 0
TEMPLATE "ttt_query.html"
END
END
LAYER
NAME range
DATA range
STATUS ON
TYPE POLYGON
CLASSITEM SPCSPECIES
CLASS
NAME "Selected"
TEMPLATE "ttt_query.html"
EXPRESSION ""
COLOR 150 0 0
OUTLINECOLOR 128 128 128
END
CLASS
NAME "Others"
TEMPLATE "ttt_query.html"
EXPRESSION /./
COLOR 180 180 180
OUTLINECOLOR 128 128 128
END
END
END
END
What I cannot understand is how to return the result hilighted :(
Although I could achieve this using mapserver CGI. In my init.html file I
have the following:
<form method=GET action='/cgi-bin/mapserv.exe'>
<input type="hidden" name="map"
value="c:\apache\apache\htdocs\world\world.map">
<input type="hidden" name="qlayer" value="ranges_region">
<input type="hidden" name="mode" value="itemnquery">
<input type="hidden" name="item" value="SCINAME">
<input type="hidden" name="program" value="/cgi-bin/mapserv.exe">
<input type="hidden" name="map_web_imagepath"
value="c:\apache\apache\htdocs\world\tmp\">
<input type="hidden" name="map_web_imageurl" value="/world/tmp/">
<input type="hidden" name="mapext" value="shapes">
<center><input type="submit" value="Initialize"></center>
Select a species distribution:
<select name="value" size="1">
<option>Accipiter brachyurus
<option>Accipiter butleri
<option>Accipiter gundlachi
<option>Accipiter imitator
<option>Accipiter luteoschistaceus
.
.
</select>
</form>
</body></html>
with my map file as follows:
#map
name world
status on
size 600 600
extent -180.0 -90.0 180.0 90.0
units dd
shapepath "data"
# symbolset "symbols/all.sym"
symbol
name 'circle'
type ellipse
points 1 1 end
filled true
end
# 4 web world.html
web
header world_header.html
footer world_footer.html
imagepath "/world/tmp/"
imageurl "/tmp/"
#template world.html
template case1_template.html
end
# 5 querymap hilite
QUERYMAP
SIZE600 400
STATUS on
STYLE selected
END
LAYER
NAME ranges_region
DATA ranges_region
STATUS OFF
TYPE POLYGON
FILTERITEM SCINAME
FILTER "%value%"
CLASSITEM SPCMAPDIST#
CLASS
EXPRESSION "K"#
COLOR 255 0 0
TEMPLATE case1_template.html#
END#
CLASS#
EXPRESSION "H"#
COLOR 0 255 0#
TEMPLATE case1_template.html#
END
CLASS
EXPRESSION "P"
COLOR 0 0 255
TEMPLATE case1_template.html
END
CLASS
EXPRESSION "R"
COLOR 128 128 255
TEMPLATE case1_template.html
END
END
LAYER
NAME World
TYPE Polygon
CONNECTIONTYPE OGR
CONNECTION "./Data/World.tab"
STATUS DEFAULT
CLASS
OUTLINECOLOR 128 128 128
END
END
Could anyone enlighten me as to what I am missing? Many thanks in advance
Mark
More information about the MapServer-users
mailing list