del.icio.us stuff
 
Document Actions

mftest.py.html

by Allan Doyle last modified 2006-08-07 15:15

Click here to get the file

Size 3.9 kB - File type text/html

File contents

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
 <head>
  <title>mftest.py</title>
 <meta name="generator" content="emacs 22.0.50.1; htmlfontify 0.20">
<style type="text/css"><!-- 
body { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default   { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.default a { background: rgb(255, 255, 255);  color: rgb(0, 0, 0);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.string   { color: rgb(0, 100, 0);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.string a { color: rgb(0, 100, 0);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
span.keyword   { color: rgb(160, 32, 240);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: none; }
span.keyword a { color: rgb(160, 32, 240);  background: rgb(255, 255, 255);  font-style: normal;  font-weight: 500;  font-stretch: normal;  font-family: adobe-courier;  font-size: 11pt;  text-decoration: underline; }
 --></style>

 </head>
  <body>

<pre>
<span class="keyword">from</span> mapfiler <span class="keyword">import</span> MapElementTree

<span class="keyword">import</span> ElementBuilder <span class="keyword">as</span> EB

m = EB.Element(<span class="string">'MAP'</span>,
               DEBUG=<span class="string">&quot;ON&quot;</span>,
               NAME=<span class="string">&quot;sl&quot;</span>,
               UNITS=<span class="string">&quot;dd&quot;</span>,
               EXTENT=<span class="string">&quot;%d %d %d %d&quot;</span> % (-180.0, -90.0, 180.0, 90.0)
              )

m.append(EB.Element(<span class="string">'PROJECTION'</span>, <span class="string">'\t&quot;init=epsg:4326&quot;'</span>))

w = EB.Element(<span class="string">'WEB'</span>)
w.append(EB.Element(<span class="string">'METADATA'</span>,
                    <span class="string">'\t&quot;wms_title&quot; &quot;My WMS&quot;\n\t&quot;wms_srs&quot; &quot;EPSG:4326&quot;'</span>))
m.append(w)

l1 = EB.Element(<span class="string">'LAYER'</span>,
                NAME=<span class="string">'&quot;my layer one&quot;'</span>,
                TYPE=<span class="string">&quot;POLYGON&quot;</span>,
                STATUS=<span class="string">&quot;default&quot;</span>,
                CONNECTIONTYPE=<span class="string">&quot;OGR&quot;</span>,
                CONNECTION=<span class="string">&quot;data.shp&quot;</span>)
m.append(l1)

c = EB.Element(<span class="string">'CLASS'</span>,
               COLOR=<span class="string">&quot;255 255 204&quot;</span>,
               OUTLINECOLOR=<span class="string">&quot;0 0 0&quot;</span>)
l1.append(c)

l1.append(EB.Element(<span class="string">'METADATA'</span>,
                    <span class="string">'\t&quot;wms_title&quot; &quot;My WMS&quot;\n'</span>
                     + <span class="string">'\t&quot;wms_abstract&quot; &quot;Cool Layers&quot;\n'</span>
                     + <span class="string">'\t&quot;wms_service&quot; &quot;GetMap&quot;\n'</span>
                     + <span class="string">'\tWMS_SRS &quot;init=epsg:4326&quot;\n'</span>))


l2 = EB.Element(<span class="string">'LAYER'</span>)
l2.set(<span class="string">&quot;NAME&quot;</span>, <span class="string">'&quot;my layer two&quot;'</span>)
m.append(l2)

MapElementTree(m).write(<span class="string">&quot;test.map&quot;</span>)


</pre>

 </body>
</html>