[Thuban-commits] r2864 - trunk/thuban/Extensions/umn_mapserver

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Sat Aug 9 01:39:12 CEST 2008


Author: elachuni
Date: 2008-08-09 01:39:11 +0200 (Sat, 09 Aug 2008)
New Revision: 2864

Modified:
   trunk/thuban/Extensions/umn_mapserver/mapfile.py
   trunk/thuban/Extensions/umn_mapserver/mf_export.py
Log:
Making linecolor and background color work for polygons and points.



Modified: trunk/thuban/Extensions/umn_mapserver/mapfile.py
===================================================================
--- trunk/thuban/Extensions/umn_mapserver/mapfile.py	2008-08-08 23:38:24 UTC (rev 2863)
+++ trunk/thuban/Extensions/umn_mapserver/mapfile.py	2008-08-08 23:39:11 UTC (rev 2864)
@@ -320,10 +320,10 @@
     defines a single symbol which is used in the Symbolset
     
     the following settings are used:
-    name, type,
+    name, type, filled,
     
     the following settings are not used:
-    sizex, sizey, points, numpoints, filled, stylelength,
+    sizex, sizey, points, numpoints, stylelength,
     style, imagepath, transparent, transparentcolor, character, antialias,
     font, gap, position, linecap, linejoin, linejoinmaxsize, setPoints(),
     getPoints(), setStyle()
@@ -424,7 +424,7 @@
     createLegendIcon(), insertStyle(), removeStyle(), moveStyleUp(),
     moveStyleDown()
     """
-    def __init__(self, mf_class):
+    def __init__(self, mf_class, map):
         """
         Initialized a class from them given mapscript Class Object
 	with a list of the included styles.
@@ -432,10 +432,11 @@
 	wich are holt as a List i think.
         """
         self._clazz = mf_class
+        self.map = map
         self._styles = []
         self._numstyles = mf_class.numstyles
         for i in range(0,self._numstyles,1):
-            self._styles.append(MF_Style(mf_class.getStyle(i)))
+            self._styles.append(MF_Style(mf_class.getStyle(i)), self.map)
         
         if self._clazz.getExpressionString() == '"(null)"':
             self._expression = None
@@ -479,8 +480,8 @@
         """
         added a thuban style object to the mapobject
         """
-        new_styleobj = MF_Style(styleObj(self._clazz))
         if type == "line":
+            new_styleobj = MF_Style(styleObj(self._clazz), self.map)
             new_styleobj.set_color(tb_style.GetLineColor())
             new_styleobj.set_width(tb_style.GetLineWidth())
         elif type == "point":
@@ -488,22 +489,30 @@
             # symbol "circle" must create before
             # TODO: create a Symbol (more see MF_SymbolSet)
             # first the default symbol circle will be created and the size 8
-            new_styleobj.set_symbolname('circle')
-            new_styleobj.set_size(8)
-            if tb_style.GetLineColor() != Transparent:
-                new_styleobj.set_linecolor(tb_style.GetLineColor())
-            new_styleobj.set_color(tb_style.GetFill())
+            new_styleobj = MF_Style(styleObj(self._clazz), self.map)
+            if tb_style.GetFill() == Transparent:
+                new_styleobj.set_symbolname('circle')
+                if tb_style.GetLineColor() != Transparent:
+                    new_styleobj.set_color(tb_style.GetLineColor())
+            else:
+                new_styleobj.set_symbolname('circle_filled')
+                new_styleobj.set_color(tb_style.GetFill())
+                if tb_style.GetLineColor() != Transparent:
+                    new_styleobj.set_linecolor(tb_style.GetLineColor())
+            new_styleobj.set_size(9)
         else:
     # Suppose this is a polygon.  We'll need two styles for applying
     # the background color and outline width, as explained in
     # http://mapserver.gis.umn.edu/docs/faq/faqsection_view?section=Map%20Output
-            new_styleobj.set_color(tb_style.GetFill())
+            if tb_style.GetFill() != Transparent:
+                new_styleobj = MF_Style(styleObj(self._clazz), self.map)
+                new_styleobj.set_color(tb_style.GetFill())
     # And a second style.
     # The order here matters (first the background, then the
-            new_styleobj = MF_Style(styleObj(self._clazz))
-            new_styleobj.set_width(tb_style.GetLineWidth())
             if tb_style.GetLineColor() != Transparent:
+                new_styleobj = MF_Style(styleObj(self._clazz), self.map)
                 new_styleobj.set_linecolor(tb_style.GetLineColor())
+                new_styleobj.set_width(tb_style.GetLineWidth())
 
 
 
@@ -535,19 +544,19 @@
     getProcessing(), clearProcessing()   
     """
 
-    def __init__(self, mf_layer):
+    def __init__(self, mf_layer, map):
         """
 	Creates the Layer Object from the mapscript Layer Object.
 	the class objects in the layer object will be stored in
 	an array. The metadata are created as a new object.
         """
         self._mf_layer = mf_layer
-
+        self.map = map
         # Create Classes 
         # there could be more then 1 
         self._classes = []
         for i in range (self._mf_layer.numclasses):
-            self._classes.append(MF_Class(self._mf_layer.getClass(i)))
+            self._classes.append(MF_Class(self._mf_layer.getClass(i), self.map))
             
         self._projection = MF_Projection(self._mf_layer.getProjection())
         
@@ -654,7 +663,7 @@
         """
         Add a thuban class object
         """ 
-        new_class = MF_Class(classObj(self._mf_layer))
+        new_class = MF_Class(classObj(self._mf_layer), self.map)
         self._classes.append(new_class)
         # set the class name to the Label form thuban if given,
         # else set it to the value
@@ -901,7 +910,7 @@
         self._layers = []
         self._i = 0
         while self._i < self._mf_map.numlayers:
-            self._layers.append(MF_Layer(self._mf_map.getLayer(self._i)))
+            self._layers.append(MF_Layer(self._mf_map.getLayer(self._i)), self)
             self._i += 1
 
         # Shapepath if not set, shapepath will be empty
@@ -918,7 +927,7 @@
         the new layer must create inside the mapobj, because mapscript
         need the mapscript object as parameter for layerObj
         """
-        new_layer = MF_Layer(layerObj(self._mf_map))
+        new_layer = MF_Layer(layerObj(self._mf_map), self)
         self._layers.append(new_layer)
         # the new created layer must remove from the mapobject
         # because all layer will create new in export.
@@ -1068,10 +1077,10 @@
         from Thuban.Model.postgisdb import PostGISShapeStore
         if hasattr(tb_layer,"extension_umn_layerobj"):
             #print tb_layer.extension_umn_layerobj
-            #new_layer = MF_Layer(layerObj(self._mf_map))
+            #new_layer = MF_Layer(layerObj(self._mf_map), self)
             new_layer = tb_layer.extension_umn_layerobj
         else:
-            new_layer = MF_Layer(layerObj(self._mf_map))
+            new_layer = MF_Layer(layerObj(self._mf_map), self)
             self._layers.append(new_layer)
             tb_layer.extension_umn_layerobj = new_layer
         new_layer.remove_allclasses()
@@ -1454,7 +1463,7 @@
     antialias
     """
  
-    def __init__(self, mf_style):
+    def __init__(self, mf_style, map):
         """
 	Create a style object from the given mapscript style object.
 	The color Object from the color and the outlinecolor parameter
@@ -1463,6 +1472,7 @@
 	it will set to 'None'.
         """
         self._style = mf_style
+        self.map = map
         if self._style.color.red == -1:
             self._color = None
         else:
@@ -1506,5 +1516,5 @@
     
     def set_symbolname(self, newsymbol):
         # its possible to use stringnames instead of numbers
-        self._style.symbolname = newsymbol
+        self._style.setSymbolByName (self.map._mf_map, newsymbol)
 

Modified: trunk/thuban/Extensions/umn_mapserver/mf_export.py
===================================================================
--- trunk/thuban/Extensions/umn_mapserver/mf_export.py	2008-08-08 23:38:24 UTC (rev 2863)
+++ trunk/thuban/Extensions/umn_mapserver/mf_export.py	2008-08-08 23:39:11 UTC (rev 2864)
@@ -109,7 +109,7 @@
     """
     Added a circle object like the one shown in thuban
     """
-    if map.get_symbolset().get_symbol(1):
+    if map.get_symbolset().get_symbol(2):
         return
     else:
         new_symbol = MF_Symbol()
@@ -117,6 +117,11 @@
         new_symbol.set_type(mapscript.MS_SYMBOL_ELLIPSE)
         new_symbol.set_filled(False)
         map.get_symbolset().add_symbol(new_symbol)
+        new_symbol = MF_Symbol()
+        new_symbol.set_name("circle_filled")
+        new_symbol.set_type(mapscript.MS_SYMBOL_ELLIPSE)
+        new_symbol.set_filled(True)
+        map.get_symbolset().add_symbol(new_symbol)
 
 def write_creatorcomment(path,file):
     """
@@ -160,12 +165,12 @@
     else:
         return
 
+    #add symbol
+    add_circle_symbol(theMap)
+    
     # set all thuban context to the mapobj
     thuban_to_map(context, theMap)
 
-    #add symbol
-    add_circle_symbol(theMap)
-    
     # shapepath vom mapfile
     theMap.set_shapepath("")
 



More information about the Thuban-commits mailing list