[Mapserver-users] Help: Using two or more symbols based on attributes within a Query
P Wilkerson
1wilkerson at charter.net
Tue Jun 15 20:05:06 PDT 2004
I would like to use PHP/Mapscript to query one layer that contains two
classes.
My goal is to have the following result of a query:
All points where FULL_NAME="JOSIAH SMITH"
Display those points as a circle where DATA_CODE = "RES"
Display those points as a triangle where DATA_CODE = "COM"
Note about data: In the SHP file there are two entries for JOSIAH SMITH, one
for his residence address; another for his business address. Ideally, the
residence would plot as a circle and the business address would plot as a
triangle.
My problem is that the code below returns the contents of the whole SHP
file. Obviously I am missing something important and need help.
I would very much appreciate any suggestions you might offer!
Peter Wilkerson
--------------------------
CURRENT SCRIPT
$poLayer = $gpoMap->getlayerbyname(Layer01Q);
$poLayer->setMetaData("RESULT_FIELDS", "DATA_CODE
FULL_NAME OCCUPATION COMM_ADDR
RES_ADDR");
$poClass1 = $poLayer->getClass(0);
$poStyle1 = $poClass1->getStyle(0);
$poStyle1->set("symbolname", "circle");
$poClass2 = $poLayer->getClass(1);
$poStyle2 = $poClass2->getStyle(0);
$poStyle2->set("symbolname", "triangle");
$poLayer->set(classitem,$L1elements[4]);
$poClass1->setexpression("('[DATA_CODE]' = \"RES\") and ('[$L1elements[4]]'
=
$L1elements[5])");
$poClass2->setexpression("('[DATA_CODE]' = \"COM\") and ('[$L1elements[4]]'
=
$L1elements[5])");
// WHERE $L1elements[4] is a variable containing a valid field name, say
"FULL_NAME"
// WHERE $L1elements[5] is a variable that contains a string value supplied
by the end user.
--------------------------------
MAP FILE FOR LAYER (Layer01Q)
LAYER #Query
NAME Layer01Q
METADATA
"DESCRIPTION" "1855 Residential Directory"
"RESULT_FIELDS" "DATA_CODE NAME OCCUPATION RESADDR"
"DISPLAY_FIELDS" "Code Name Occupation Address"
END
TYPE POINT
STATUS OFF
DATA "/usr/local/www/htdocs/pwilkerson.decimaldegrees.com/data/d1855/1855_
residential"
TOLERANCE 20
# Defines the field to be searched
CLASS
NAME "RES"
COLOR 153 204 255
OUTLINECOLOR 51 51 51
TEMPLATE "ttt_query.html"
SYMBOL "circle"
SIZE 10
END # class
CLASS
NAME "COM"
COLOR 0 204 255
OUTLINECOLOR 51 51 51
TEMPLATE "ttt_query.html"
SYMBOL "triangle"
SIZE 10
END # class
END # layer
More information about the MapServer-users
mailing list