[mapserver-users] Templates & JOIN object (one to many)
Ted Spradley
tspradley at snoogems.com
Tue Jan 12 11:17:58 PST 2010
Hi guys,
I have a query layer that joins two PostGIS tables. Mapserver objects if a
TEMPLATE is not declared in the
JOIN object, but I couldn't find a reference to a template being needed in
the documentation other than in
the LAYER object. The GetFeatureInfo request for this layer returns an
empty page (browser).
I believe the primary problem is either in the template tags or the template
references in either the LAYER
or JOIN objects. Please note that the same template is specified for both
objects. I am not able to get a clear understanding from the docs regarding
the template tags or the placement of the TEMPLATE directive.
The code ....
/* GetFeatureInfo url */
http://url.com/cgi-bin/mapserv?
map=/path/to/cad.map
&SERVICE=WMS
&VERSION=1.1.1
&REQUEST=GetFeatureInfo
&SRS=EPSG%3A102740
&WIDTH=800
&HEIGHT=800
&BBOX=3102785.400463,13832395.006499,3104115.230452,13833724.836488
&LAYERS=building_comp_query
&STYLES=
&FORMAT=image%2Fpng
&QUERY_LAYERS=building_comp_query
&X=398&Y=390
&INFO_FORMAT=text/html
/* layer definition */
LAYER
NAME 'building_comp_query'
TYPE QUERY
STATUS ON
DEBUG 3
TEMPLATE bldgCompGetFeatureInfo.html
HEADER bldgCompGetFeatureInfo_header.html
FOOTER bldgCompGetFeatureInfo_footer.html
PROCESSING "CLOSE_CONNECTION=DEFER"
PROCESSING 'LABEL_NO_CLIP=1'
DUMP TRUE
MAXSCALEDENOM 10000
CONNECTIONTYPE POSTGIS
CONNECTION "dbname=cad1 user=user password=password host=localhost
port=5432"
DATA "the_geom from (select b.the_geom AS the_geom, b.gid AS gid,
b.hcad_num AS hcad_num FROM parcels b) as foo using unique gid using
srid=-1"
JOIN
NAME "building_components"
CONNECTION "dbname=cad1 user=user password=password host=localhost
port=5432"
CONNECTIONTYPE ogr
TABLE "building_component_areas"
FROM "hcad_num"
TO "hcad_acct"
TYPE ONE-TO-MANY
TEMPLATE bldgCompGetFeatureInfo.html
END
PROJECTION
"init=epsg:102740"
END
METADATA
"wms_title" "Building Component Areas Query Layer"
"wfs_title" "Building Component Areas Query Layer"
"wms_srs" "epsg:102740 epsg:4326"
"gml_include_items" "all"
"wms_include_items" "all"
"gml_featureid" "ogc_fid" ## REQUIRED
"qstring_validation_pattern" '.'
END
END # End layer 'building_component_areas_query'
/* template bldgCompGetFeatureInfo_header.html */
<!-- Mapserver Template -->
<br />
<!-- Build javascript to handle output -->
<script language="javascript">
/* We are retrieving three attributes: building_num, building_component,
and area. There will be one or more values for each attribute. Build
an array for attribute. Use the arrays in a for loop where MapServer
fills
in the array values. Then write out the array values in an html table
after MapServer finishes filling in the array values. */
/* The arrays */
var building_num = new Array();
var building_component = new Array();
var area = new Array();
/* template bldgCompGetFeatureInfo.html */
/* Mapserver Template */
building_num =
building_num.push('[building_components_building_num]');
building_component =
building_component.push('[building_components_building_component]');
area = area.push('[building_components_area]');
/* template bldgCompGetFeatureInfo_footer.html */
<!-- Mapserver Template -->
/* Write out the table by accessing the arrays */
document.write("
<table id=\"bldg_comp_areas\">
<tr>
<th colspan=\"2\">Building Details</th>
</tr>
<tr>
<td>Building Number</td>
<td>Building Component</td>
<td>Area</td>
<td>units</td>
</tr>"
);
for(key in building_num){
document.write("<tr><td>" + building_num[key] + "</td><td>" +
building_component[key] + "</td><td>" + area[key] + "</td><td>" +
"sq ft");
}
document.write("
</table>
<br />
");
Thanks for taking a look!
Ted S
--
View this message in context: http://n2.nabble.com/Templates-JOIN-object-one-to-many-tp4293738p4293738.html
Sent from the Mapserver - User mailing list archive at Nabble.com.
More information about the MapServer-users
mailing list