1 | <?xml version="1.0" encoding="ISO-8859-1"?> |
---|
2 | |
---|
3 | <xsl:stylesheet version="3.0" |
---|
4 | xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" |
---|
5 | xmlns:xs ="http://www.w3.org/2001/XMLSchema" |
---|
6 | xmlns:ibis="http://www.ibisph.org" |
---|
7 | |
---|
8 | exclude-result-prefixes="ibis xs xsl" |
---|
9 | > |
---|
10 | |
---|
11 | <ibis:doc> |
---|
12 | <name>json/LeafletMap</name> |
---|
13 | <summary>Templates that create the appropriate json code for Leaflet maps</summary> |
---|
14 | <description> |
---|
15 | Provides templates that creates the title, height, and chart URL then |
---|
16 | calls the graphic.chart template to generate the appropriate HTML |
---|
17 | code needed for a query result map/chart. |
---|
18 | </description> |
---|
19 | </ibis:doc> |
---|
20 | |
---|
21 | |
---|
22 | <xsl:param name="LeafletMap.jsonFilePath" select="ibis:getContentPath('json/leaflet/')"/> |
---|
23 | <xsl:param name="LeafletMap.baseJSONFilename" select="'_Base.json'"/> |
---|
24 | |
---|
25 | <xsl:param name="LeafletMap.ajaxGeoJSONMapLayersFilePath" select="'view/json/geo/'" |
---|
26 | ibis:doc="Path injected into the ajax call to get map layer geojson files." |
---|
27 | /> |
---|
28 | <xsl:param name="LeafletMap.geoJSONIDPropertyName" select="'GeoID'" |
---|
29 | ibis:doc="Geo ID field name (property name in geojson) for the Choro area |
---|
30 | that is associated/corresponds to the data's geo dimension value. |
---|
31 | " |
---|
32 | /> |
---|
33 | |
---|
34 | <xsl:param name="LeafletMap.emptyConfigurationName" select="'_empty'" ibis:doc="name to be used for JSON file when no config name"/> |
---|
35 | |
---|
36 | <xsl:param name="LeafletMap.lowerConfidenceLimitFieldName" select="'LowerConfidenceLimit'"/> |
---|
37 | <xsl:param name="LeafletMap.upperConfidenceLimitFieldName" select="'UpperConfidenceLimit'"/> |
---|
38 | <xsl:param name="LeafletMap.lowerConfidenceLimitTitleFieldName" select="'LowerConfidenceLimitTitle'"/> |
---|
39 | <xsl:param name="LeafletMap.upperConfidenceLimitTitleFieldName" select="'UpperConfidenceLimitTitle'"/> |
---|
40 | <xsl:param name="LeafletMap.numeratorTitleFieldName" select="'NumeratorTitle'"/> |
---|
41 | <xsl:param name="LeafletMap.denominatorTitleFieldName" select="'DenominatorTitle'"/> |
---|
42 | |
---|
43 | <xsl:template name="LeafletMap.namedConfigurationJSON" ibis:doc="Gets the named specific JSON options from the file."> |
---|
44 | <xsl:param name="configurationName"/> |
---|
45 | <xsl:variable name="configurationName" select="if(0 = string-length($configurationName)) then $LeafletMap.emptyConfigurationName else $configurationName"/> |
---|
46 | <!-- xsl:message select="'$$$$$$$$$$$$$$$$$$$$$$$$$$$$'"/> |
---|
47 | <xsl:message select="$configurationName"/ --> |
---|
48 | <xsl:copy-of select="unparsed-text(concat($LeafletMap.jsonFilePath, $configurationName, '.json'))"/> |
---|
49 | </xsl:template> |
---|
50 | <xsl:template name="LeafletMap.baseJSON" ibis:doc="Returns the base/core JSON."> |
---|
51 | <xsl:copy-of select="unparsed-text(concat($LeafletMap.jsonFilePath, $LeafletMap.baseJSONFilename))"/> |
---|
52 | </xsl:template> |
---|
53 | |
---|
54 | |
---|
55 | <xsl:template name="LeafletMap.requestJSON"> |
---|
56 | <xsl:param name="mapTitle" select="'Request JSON'"/> |
---|
57 | <xsl:param name="mapType" select="'selection'"/> |
---|
58 | <xsl:param name="webappContextPath" select="$ibis.contextPath"/> |
---|
59 | <xsl:param name="selectionLayerSetLayerKeys"/> |
---|
60 | <xsl:param name="selectionLayerSetSelectionType"/> |
---|
61 | |
---|
62 | { // Start of Request Specific JSON |
---|
63 | "title": "<xsl:value-of select="$mapTitle"/>" |
---|
64 | ,"webappContextPath": "<xsl:value-of select="$webappContextPath"/>" |
---|
65 | ,"type": "<xsl:value-of select="$mapType"/>" |
---|
66 | <xsl:if test="$selectionLayerSetLayerKeys"> |
---|
67 | ,"selectionLayerSetLayerKeys": <xsl:value-of select="ibis:textNodesToJSONArray($selectionLayerSetLayerKeys)"/> |
---|
68 | </xsl:if> |
---|
69 | <xsl:if test="0 != string-length($selectionLayerSetSelectionType)"> |
---|
70 | ,"selectionLayerSetSelectionType": "<xsl:value-of select="$selectionLayerSetSelectionType"/>" |
---|
71 | </xsl:if> |
---|
72 | } // End of Request Specific JSON |
---|
73 | </xsl:template> |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | <xsl:template name="LeafletMap.choroplethJSON"> |
---|
78 | <xsl:param name="javascriptRecordArrayVariableName" select="'records'"/> |
---|
79 | <xsl:param name="geoIDFieldName" select="'Category'" ibis:doc="data record's field that contains the geo ID to match against the GeoJSON ID field (typically 'Category' or 'Series')."/> |
---|
80 | <xsl:param name="geoIDFieldValuePrefixToRemove"/> |
---|
81 | |
---|
82 | <xsl:param name="geoJSONName" select="'GeoCnty'" ibis:doc="choro json layer filename - sans path and .json extension."/> |
---|
83 | <xsl:param name="geoTypeTitle" select="'County'" ibis:doc="Choro layer title - County, Region"/> |
---|
84 | <xsl:param name="legendTitle" select="'Count'" ibis:doc="Legend's value title - typically the measure title"/> |
---|
85 | |
---|
86 | <xsl:param name="dimensionFieldInclusionCriteria" select="NULL" |
---|
87 | ibis:doc="List of field name/field values to filter out/refine the |
---|
88 | approp data value record to use for the choro. These are typically |
---|
89 | the CONSTANT and SERIES dim values to hold constant. |
---|
90 | Example - when doing a map that has 3 total group by dimensions: |
---|
91 | GeoXXX, Year, and MotherAgeGrp. In this example we want the 2011 |
---|
92 | year and the 20-29 mothers age group for the county. If hooked |
---|
93 | up to a UI control then code will need to be added that sets the |
---|
94 | inclusion criteria, calls set the data properties, and notifies |
---|
95 | the choro to recalc. |
---|
96 | " |
---|
97 | /> |
---|
98 | |
---|
99 | <xsl:param name="reverseColors" select="false()"/> |
---|
100 | <xsl:param name="comparisonValue" select="0"/> |
---|
101 | <xsl:param name="desirableValue" select="'LOW'"/> |
---|
102 | |
---|
103 | <xsl:param name="geoTitleFieldName" select="concat($geoIDFieldName, 'Title')"/> |
---|
104 | <xsl:variable name="dimensionFieldInclusionCriteria" select="NULL"/> |
---|
105 | |
---|
106 | <xsl:message select="'========================= comp value in lm.cjson - GARTH TODO:'"/> |
---|
107 | <xsl:message select="$comparisonValue[1]"/> |
---|
108 | |
---|
109 | { // Start of Choropleth JSON |
---|
110 | "choroplethControl": |
---|
111 | { |
---|
112 | "legend": |
---|
113 | { |
---|
114 | "title": "<xsl:value-of select="$legendTitle"/>" |
---|
115 | } |
---|
116 | ,"reverseColors": <xsl:value-of select="$reverseColors"/> |
---|
117 | ,"layerSetsKey": "<xsl:value-of select="$geoJSONName"/>" |
---|
118 | ,"dataClasses": |
---|
119 | { |
---|
120 | "betterWorse": |
---|
121 | { |
---|
122 | "comparisonValue": "<xsl:value-of select="$comparisonValue[1]"/>" |
---|
123 | ,"desirableValue": "<xsl:value-of select="$desirableValue"/>" |
---|
124 | } |
---|
125 | } |
---|
126 | } |
---|
127 | ,"layerSets": |
---|
128 | { |
---|
129 | "sets": |
---|
130 | { |
---|
131 | "choropleth": |
---|
132 | { |
---|
133 | "title": "Choropleth" <!-- grouping title --> |
---|
134 | ,"type": "choropleth" |
---|
135 | ,"layers": |
---|
136 | { |
---|
137 | "<xsl:value-of select="$geoJSONName"/>": |
---|
138 | { |
---|
139 | "title": "<xsl:value-of select="$geoTypeTitle"/>" <!-- layer title --> |
---|
140 | ,"url": "<xsl:value-of select="concat($LeafletMap.ajaxGeoJSONMapLayersFilePath, $geoJSONName, '.json')"/>" |
---|
141 | ,"show": true |
---|
142 | ,"options": |
---|
143 | { |
---|
144 | "geoIDPropertyName": "<xsl:value-of select="$LeafletMap.geoJSONIDPropertyName"/>" |
---|
145 | ,"dataObject": |
---|
146 | { |
---|
147 | "data": <xsl:value-of select="$javascriptRecordArrayVariableName"/> |
---|
148 | ,"comparisonValue": "<xsl:value-of select="$comparisonValue[1]"/>" |
---|
149 | <xsl:if test="0 != string-length($geoIDFieldValuePrefixToRemove)"> |
---|
150 | ,"geoIDFieldValuePrefixToRemove": "<xsl:value-of select="$geoIDFieldValuePrefixToRemove"/>" |
---|
151 | </xsl:if> |
---|
152 | ,"fieldName": |
---|
153 | { |
---|
154 | <!-- GARTH TODO: |
---|
155 | maybe have a constant field name and value - these ARE dynamic and script set |
---|
156 | although the script could set these values and call the map refresh!!!!!!!!!! |
---|
157 | in the l.geojson.int.js the this.options.dataObject.dimensionFieldInclusionCriteria |
---|
158 | handles this... |
---|
159 | maybe have a series field name and value |
---|
160 | what about the new ancillary values and value attribute stuff????? |
---|
161 | |
---|
162 | <xsl:message select="'*************LeafletMapGraphic.requestOptionsJSON - dimensionFieldInclusionCriteria: '"/> |
---|
163 | <xsl:message select="$dimensionFieldInclusionCriteria"/> |
---|
164 | --> |
---|
165 | "geoID": "<xsl:value-of select="$geoIDFieldName"/>" |
---|
166 | ,"geoTitle": "<xsl:value-of select="$geoTitleFieldName"/>" |
---|
167 | ,"measureValue": "MeasureValue" |
---|
168 | ,"measureValueTitle": "MeasureValueTitle" |
---|
169 | ,"lowerLimit": "<xsl:value-of select="$LeafletMap.lowerConfidenceLimitFieldName"/>" |
---|
170 | ,"upperLimit": "<xsl:value-of select="$LeafletMap.upperConfidenceLimitFieldName"/>" |
---|
171 | ,"lowerLimitTitle": "<xsl:value-of select="$LeafletMap.lowerConfidenceLimitTitleFieldName"/>" |
---|
172 | ,"upperLimitTitle": "<xsl:value-of select="$LeafletMap.upperConfidenceLimitTitleFieldName"/>" |
---|
173 | ,"numeratorTitle": "<xsl:value-of select="$LeafletMap.numeratorTitleFieldName"/>" |
---|
174 | ,"denominatorTitle": "<xsl:value-of select="$LeafletMap.denominatorTitleFieldName"/>" |
---|
175 | ,"note": "Note" |
---|
176 | ,"label": "Label" |
---|
177 | ,"valueAttributeName": "ValueAttributeName" |
---|
178 | } |
---|
179 | <xsl:if test="count($dimensionFieldInclusionCriteria/*) != 0"> |
---|
180 | ,"dimensionFieldInclusionCriteria": |
---|
181 | [ |
---|
182 | <xsl:for-each select="$dimensionFieldInclusionCriteria/DIMENSION"> |
---|
183 | <xsl:if test="position() != 1">,</xsl:if> |
---|
184 | { |
---|
185 | "fieldName": "<xsl:value-of select="NAME"/>" |
---|
186 | ,"fieldTitle": "<xsl:value-of select="TITLE"/>" |
---|
187 | ,"value": "<xsl:value-of select="VALUE"/>" |
---|
188 | ,"valueTitle": "<xsl:value-of select="VALUE"/>" |
---|
189 | } |
---|
190 | </xsl:for-each> |
---|
191 | ] |
---|
192 | </xsl:if> |
---|
193 | } |
---|
194 | } |
---|
195 | } |
---|
196 | } |
---|
197 | } |
---|
198 | } |
---|
199 | } |
---|
200 | } // End of Choropleth JSON |
---|
201 | </xsl:template> |
---|
202 | |
---|
203 | </xsl:stylesheet> |
---|
204 | <!-- ============================= End of File ============================= --> |
---|
205 | |
---|