jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.3,1.4

cvs@intevation.de cvs at intevation.de
Tue Jul 6 16:28:54 CEST 2004


Author: jschuengel

Update of /thubanrepository/thuban/Extensions/umn_mapserver
In directory doto:/tmp/cvs-serv4485

Modified Files:
	mapfile.py 
Log Message:
Added the symbolObj, pointObj and line Obj and add the scalebar_status_type, scalebar_style_type and scalebar_position_type.
Added the symbol- and symbolsetObject (MF_Symbol,MF_Symbolset). The are only used to create a Symbol like the circle in Thuban.
Added the scalebarObject (MF_Scalebar)
(MF_Class): Added set_status and get_status.
(MF_Layer.add_thubanclass): Added code to set the class status
(MF_Map): Added code to handle the symbols and scalebar 
(MF_Label): Added the set_partials and get_partials functions


Index: mapfile.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mapfile.py	1 Jul 2004 14:39:00 -0000	1.3
+++ mapfile.py	6 Jul 2004 14:28:52 -0000	1.4
@@ -34,7 +34,8 @@
 
 from Thuban.Model.color import Color, Transparent 
 
-from mapscript import layerObj, classObj, colorObj, styleObj, rectObj
+from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \
+                      pointObj, lineObj
                       
 
 # ###################################
@@ -63,6 +64,21 @@
                         3:"embed" } 
                         # 2 = Default but will not be imported because 
                         # mapscript dont support it and its not allowed
+scalebar_status_type = { 0:"OFF",
+                        1:"ON",
+                        3:"embed" } 
+                        # 2 = Default but will not be imported because 
+                        # mapscript dont support it and its not allowed
+
+scalebar_style_type = { 0:"0",
+                        1:"1" }
+
+scalebar_position_type = { 0:"ul",
+                         1:"lr",
+                         2:"ur",
+                         3:"ll",
+                         6:"uc",
+                         7:"lc"}
 
 layer_status_type = { 0:"OFF",
                         1:"ON",
@@ -236,8 +252,40 @@
     getPoints(), setStyle()
     """
     
-    def __init__(self, mf_symbol):
-        print "nothing"
+    def __init__(self, mf_symbol = "newone"):
+        # create a circle Object like shown in Thuban
+        # because Thuban don't support other symbols
+        if mf_symbol == "newone":
+            mf_symbol = symbolObj("")            
+            newpoint = pointObj()
+            newpoint.x = 1
+            newpoint.y = 1
+            newline = lineObj()
+            newline.add(newpoint)
+            mf_symbol.setPoints(newline)
+        
+        self._symbol = mf_symbol
+    
+    def get_symbolObj(self):
+        return self._symbol
+    
+    def get_name(self):
+        return self._symbol.name
+    
+    def set_name(self, new_name):
+        self._symbol.name = new_name
+    
+    def set_type(self, new_type):
+        # TODO include a function to set the type by a string
+        self._symbol.type = new_type
+    
+    def set_filled(self, new_filled):
+        if new_filled:
+            self._symbol.filled = 1
+        else:
+            self._symbol.filled = 0
+    
+    
 
 class MF_SymbolSet:
     """
@@ -252,8 +300,33 @@
     # create an extra symbol file and not to include it direct to the 
     # mapfile itself
     def __init__(self, mf_symbolset):
-        print "nothing"
+        self._symbolset = mf_symbolset
+        
+        # Initial Symbol List
+        self._symbols = []
+        self._numsymbols = self._symbolset.numsymbols
+        self._i = 1
+        while self._i < self._numsymbols:
+            self._symbols.append(MF_Symbol(self._symbolset.getSymbol(self._i)))
+            self._i += 1
 
+#    POINT
+#   1 1
+#   END
+
+    def add_symbol(self, new_symbol):
+        self._symbolset.appendSymbol(new_symbol.get_symbolObj())
+        self._symbols.append(new_symbol)
+        # the save function must be run to set the symbols to the
+        # mapfile. I don't know why this ist so but it must be.
+        self._symbolset.save("tempsymbol")
+        os.remove("tempsymbol")
+
+    def get_symbol(self, symbolnr):
+        if symbolnr < self._numsymbols:
+            return self._symbols[symbolnr-1]
+        else:
+            return None
 
 class MF_Class:
     """
@@ -318,6 +391,18 @@
         self._clazz.setExpression(newstring)
         self._expression = self._clazz.getExpressionString()
     
+    def get_status(self):
+        if self._clazz.status == 1:
+            return True
+        else:
+            return False
+    
+    def set_status(self, new_status):
+        if new_status:
+            self._clazz.status = 1
+        else:
+            self._clazz.status = 0
+
     def add_thubanstyle(self, tb_style, type="default"):
         """
         added a thuban style object to the mapobject
@@ -341,6 +426,7 @@
             new_styleobj.set_color(tb_style.GetFill())
 
 
+
 class MF_Layer:
     """
     The following parameters and functions, which the mapscript style obj
@@ -495,8 +581,89 @@
             new_class.set_expressionstring('/./')
         else:
             new_class.set_expressionstring(str(tb_class.GetValue()))
+        new_class.set_status(tb_class.IsVisible())
         self._classes.append(new_class)
 
+class MF_Scalebar:
+    """
+    The following settings are (not) used:
+    imagecolor, height, width, style, intervals, label, color, backgroundcolor,
+    outlinecolor, units, status, position, postlabelcache
+    """
+    def __init__(self, mf_scalebar):
+        self._scalebar = mf_scalebar
+        self._color = MF_Color(self._scalebar.color)
+        self._imagecolor = MF_Color(self._scalebar.imagecolor)
+        self._label = MF_Label(self._scalebar.label)
+    
+    def get_label(self):
+        return self._label
+    
+    def get_color(self):
+        return self._color
+    
+    def get_imagecolor(self):
+        return self._imagecolor
+    
+    def get_style(self):
+        return self._scalebar.style
+    
+    def set_style(self, new_style):
+        self._scalebar.style = new_style
+    
+    def get_size(self):
+        #returns the size
+        return (self._scalebar.width, self._scalebar.height)
+
+    def set_size(self, new_width, new_height):
+        self._scalebar.width = new_width
+        self._scalebar.height = new_height
+    
+    def get_intervals(self):
+        return self._scalebar.intervals
+    
+    def set_intervals(self, new_intervals):
+        self._scalebar.intervals = new_intervals
+
+    def get_units(self):
+        #returns the unittype
+        return unit_type[self._scalebar.units]
+
+    def set_units(self, units):
+        if unit_type.has_key(units):
+            self._scalebar.units = units
+        else:
+            for unit_paar_nr in unit_type:
+               if unit_type[unit_paar_nr] == units:
+                   self._scalebar.units = unit_paar_nr
+        
+    def get_status(self, art="integer"):
+        if art == "string":
+            return scalebar_status_type[self._scalebar.status]
+        else:
+            return self._scalebar.status
+    
+    def set_status(self, new_status):
+        if scalebar_status_type.has_key(new_status):
+            self._scalebar.status = new_status
+        else:
+            for scalebar_status_type_nr in scalebar_status_type:
+                if scalebar_status_type[scalebar_status_type_nr] == new_status:
+                    self._scalebar.status = scalebar_status_type_nr
+    
+    def get_position(self, art="integer"):
+        if art == "string":
+            return scalebar_position_type[self._scalebar.position]
+        else:
+            return self._scalebar.position
+    
+    def set_position(self, new_position):
+        if scalebar_position_type.has_key(new_position):
+            self._scalebar.position = new_position
+        else:
+            for scalebar_position_type_nr in legend_position_type:
+                if scalebar_position_type[scalebar_position_type_nr] == new_position:
+                    self._scalebar.position = scalebar_position_type_nr
 
 class MF_Map:
     """
@@ -538,6 +705,10 @@
         self._imagecolor = MF_Color(self._mf_map.imagecolor)
         self._web = MF_Web(self._mf_map.web)
         self._legend = MF_Legend(self._mf_map.legend)
+        self._scalebar = MF_Scalebar(self._mf_map.scalebar)
+        
+        # symbols
+        self._symbolset = MF_SymbolSet(self._mf_map.symbolset)
 
         # if the map name is not set it will return a MS string.
         if self._mf_map.name != "MS":
@@ -573,12 +744,18 @@
                 self._metadata.add_metadata(self._metafkey,self._metakeydata)
                 self._metafkey = self._mf_map.getNextMetaDataKey(self._metafkey)
     
+    def get_symbolset(self):
+        return self._symbolset
+    
     def get_status(self):
         if layer_status_type[self._mf_map.status] == "OFF":
             return false
         else:
             return true
 
+    def get_scalebar(self):
+        return self._scalebar
+    
     def get_web(self):
         return self._web
     
@@ -659,7 +836,7 @@
         Add a thuban layer
         """
         new_layer = MF_Layer(layerObj(self._mf_map))
-        new_layer.set_name(tb_layer.Title())
+        new_layer.set_name(tb_layer.Title())        
         
         # TODO: implement relative pathnames
         # yet only absolute pathnames in the LayerObj are set
@@ -668,6 +845,7 @@
         except:
             new_layer.set_data(tb_layer.GetImageFilename(), type="raster")
             new_layer.set_type("raster")
+            new_layer.set_status(tb_layer.Visible())
         else:
             new_layer.set_status(tb_layer.Visible())
             new_layer.set_type(tb_layer.ShapeType())
@@ -769,6 +947,21 @@
     def get_color(self):
         return self._color
     
+    def get_partials(self):
+        if self._label.partials == 1:
+            return True
+        else:
+            return False
+    
+    def set_partials(self, new_partials):
+        # if partials = True
+        if new_partials:
+            self._label.partials = 1
+        elif new_partials == False:
+            self._label.partials = 0
+        else:
+            print "Boolean exspected"
+    
     def get_type(self):
         return label_font_type[self._label.type]
     
@@ -852,7 +1045,6 @@
             for legend_position_type_nr in legend_position_type:
                 if legend_position_type[legend_position_type_nr] == new_position:
                     self._mf_legend.position = legend_position_type_nr
-
 
 class MF_Projection:
     """





More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)