mftest.py
Click here to get the file
Size
1.1 kB
-
File type
text/python-source
File contents
from mapfiler import MapElementTree
import ElementBuilder as EB
m = EB.Element('MAP',
DEBUG="ON",
NAME="sl",
UNITS="dd",
EXTENT="%d %d %d %d" % (-180.0, -90.0, 180.0, 90.0)
)
m.append(EB.Element('PROJECTION', '\t"init=epsg:4326"'))
w = EB.Element('WEB')
w.append(EB.Element('METADATA',
'\t"wms_title" "My WMS"\n\t"wms_srs" "EPSG:4326"'))
m.append(w)
l1 = EB.Element('LAYER',
NAME='"my layer one"',
TYPE="POLYGON",
STATUS="default",
CONNECTIONTYPE="OGR",
CONNECTION="data.shp")
m.append(l1)
c = EB.Element('CLASS',
COLOR="255 255 204",
OUTLINECOLOR="0 0 0")
l1.append(c)
l1.append(EB.Element('METADATA',
'\t"wms_title" "My WMS"\n'
+ '\t"wms_abstract" "Cool Layers"\n'
+ '\t"wms_service" "GetMap"\n'
+ '\tWMS_SRS "init=epsg:4326"\n'))
l2 = EB.Element('LAYER')
l2.set("NAME", '"my layer two"')
m.append(l2)
MapElementTree(m).write("test.map")