@@ -176,7 +176,13 @@ def writeWebSection(self):
176
176
self .outFile .write (" 'wms_title' '" + self .mapName + "'\n " )
177
177
self .outFile .write (" 'wms_onlineresource' 'http://my.host.com/cgi-bin/mapserv?map=wms.map&'\n " )
178
178
self .outFile .write (" 'wms_srs' 'EPSG:4326'\n " )
179
- self .outFile .write (" END\n " )
179
+ self .outFile .write (" END\n \n " )
180
+
181
+ self .outFile .write (" #Scale range at which web interface will operate\n " )
182
+ if self .minScale != "" :
183
+ self .outFile .write (" MINSCALE " + self .minScale + "\n " )
184
+ if self .maxScale != "" :
185
+ self .outFile .write (" MAXSCALE " + self .maxScale + "\n " )
180
186
181
187
self .outFile .write (" # Template and header/footer settings\n " )
182
188
self .outFile .write (" # Only the template parameter is required to display a map. See MapServer documentation\n " )
@@ -187,7 +193,7 @@ def writeWebSection(self):
187
193
self .outFile .write (" HEADER '" + self .header + "'\n " )
188
194
if self .footer != "" :
189
195
self .outFile .write (" FOOTER '" + self .footer + "'\n " )
190
- self .outFile .write (" END\n " )
196
+ self .outFile .write (" END\n \n " )
191
197
192
198
def parsePostgisConnection ( self , dataString ):
193
199
pg = {}
@@ -228,6 +234,11 @@ def writeMapLayers(self):
228
234
self .outFile .write (" TYPE " + lyr .getAttribute ("geometry" ).encode ().upper () + "\n " )
229
235
elif lyr .getAttribute ("type" ).encode () == 'raster' :
230
236
self .outFile .write (" TYPE " + lyr .getAttribute ("type" ).encode ().upper () + "\n " )
237
+
238
+ # Set min/max scales
239
+ if lyr .getAttribute ('scaleBasedVisibilityFlag' ).encode () == 1 :
240
+ self .outFile .write (" MINSCALE " + lyr .getAttribute ('minScale' ).encode () + "\n " )
241
+ self .outFile .write (" MAXSCALE " + lyr .getAttribute ('maxScale' ).encode () + "\n " )
231
242
232
243
# data
233
244
dataString = lyr .getElementsByTagName ("datasource" )[0 ].childNodes [0 ].nodeValue .encode ()
@@ -267,7 +278,7 @@ def writeMapLayers(self):
267
278
self .outFile .write (" METADATA\n " )
268
279
self .outFile .write (" 'wms_name' '" + layername + "'\n " )
269
280
self .outFile .write (" 'wms_server_version' '1.1.1'\n " )
270
- self .outFile .write (" 'wms_srs' 'EPSG:" + epsg + "'\n " )
281
+ self .outFile .write (" 'wms_srs' 'EPSG:4326 EPSG: " + epsg + "'\n " )
271
282
self .outFile .write (" 'wms_format' '" + format + "'\n " )
272
283
self .outFile .write (" 'wms_style' '" + style + "'\n " )
273
284
self .outFile .write (" END\n " )
@@ -341,11 +352,17 @@ def simpleRenderer(self, layerNode, symbolNode):
341
352
symbol = "'" + symbolName + "'"
342
353
343
354
self .outFile .write (" CLASS\n " )
355
+
356
+ self .outFile .write (" NAME "
357
+ + lyr .getElementsByTagName ("layername" )[0 ].childNodes [0 ].nodeValue .encode ()
358
+ + " \n " )
359
+
344
360
# use the point symbol map to lookup the mapserver symbol type
345
361
self .outFile .write (" SYMBOL " + symbol + " \n " )
346
362
self .outFile .write (" SIZE "
347
363
+ symbolNode .getElementsByTagName ('pointsize' )[0 ].childNodes [0 ].nodeValue .encode ()
348
- + " \n " )
364
+ + " \n " )
365
+
349
366
# outline color
350
367
outlineNode = symbolNode .getElementsByTagName ('outlinecolor' )[0 ]
351
368
self .outFile .write (" OUTLINECOLOR "
@@ -387,8 +404,17 @@ def graduatedRenderer(self, layerNode, symbolNode):
387
404
classes = layerNode .getElementsByTagName ('symbol' )
388
405
for cls in classes :
389
406
self .outFile .write (" CLASS\n " )
407
+
390
408
lower = cls .getElementsByTagName ('lowervalue' )[0 ].childNodes [0 ].nodeValue .encode ()
391
409
upper = cls .getElementsByTagName ('uppervalue' )[0 ].childNodes [0 ].nodeValue .encode ()
410
+
411
+ # If there's a label use it, otherwise autogenerate one
412
+ try :
413
+ label = cls .getElementsByTagName ('label' )[0 ].childNodes [0 ].nodeValue .encode ()
414
+ self .outFile .write (" NAME '" + label + "'\n " )
415
+ except :
416
+ self .outFile .write (" NAME '" + lower + " < " + classField + " < " + upper + "'\n " )
417
+
392
418
self .outFile .write (" EXPRESSION ( ([" + classField + "] >= " + lower + ") AND ([" + classField + "] <= " + upper + ") )\n " )
393
419
394
420
# contains the same markup for a layer regardless of type
@@ -450,6 +476,9 @@ def continuousRenderer(self, layerNode, symbolNode):
450
476
lower = symbolNode .getElementsByTagName ('lowestsymbol' )[0 ].getElementsByTagName ('symbol' )[0 ]
451
477
upper = symbolNode .getElementsByTagName ('highestsymbol' )[0 ].getElementsByTagName ('symbol' )[0 ]
452
478
479
+ # Class name irrelevant for color ramps since mapserver can't render their legend
480
+ #self.outFile.write(" NAME '" + classField + "'\n")
481
+
453
482
# color
454
483
lowerColor = lower .getElementsByTagName ('fillcolor' )[0 ]
455
484
upperColor = upper .getElementsByTagName ('fillcolor' )[0 ]
@@ -509,6 +538,14 @@ def uniqueRenderer(self, layerNode, symbolNode):
509
538
self .outFile .write (" CLASS\n " )
510
539
511
540
lower = cls .getElementsByTagName ('lowervalue' )[0 ].childNodes [0 ].nodeValue .encode ()
541
+
542
+ # If there's a label use it, otherwise autogenerate one
543
+ try :
544
+ label = cls .getElementsByTagName ('label' )[0 ].childNodes [0 ].nodeValue .encode ()
545
+ self .outFile .write (" NAME '" + label + "'\n " )
546
+ except :
547
+ self .outFile .write (" NAME '" + classField + " = " + lower + "' \n " )
548
+
512
549
self .outFile .write (" EXPRESSION '" + lower + "' \n " )
513
550
514
551
# contains the same markup for a layer regardless of type
@@ -532,14 +569,14 @@ def uniqueRenderer(self, layerNode, symbolNode):
532
569
533
570
# outline color
534
571
outlineNode = cls .getElementsByTagName ('outlinecolor' )[0 ]
535
- self .outFile .write (" OUTLINECOLOR "
572
+ self .outFile .write (" OUTLINECOLOR "
536
573
+ outlineNode .getAttribute ('red' ) + ' '
537
574
+ outlineNode .getAttribute ('green' ) + ' '
538
575
+ outlineNode .getAttribute ('blue' )
539
576
+ "\n " )
540
577
# color
541
578
colorNode = cls .getElementsByTagName ('fillcolor' )[0 ]
542
- self .outFile .write (" COLOR "
579
+ self .outFile .write (" COLOR "
543
580
+ colorNode .getAttribute ('red' ) + ' '
544
581
+ colorNode .getAttribute ('green' ) + ' '
545
582
+ colorNode .getAttribute ('blue' )
0 commit comments