jschuengel: thuban/Extensions/umn_mapserver mapfile.py,1.9,1.10

cvs@intevation.de cvs at intevation.de
Tue Aug 3 13:46:02 CEST 2004


Author: jschuengel

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

Modified Files:
	mapfile.py 
Log Message:
(MF_Metadata): Added a function to remove all metadata.
(MF_Layer): Added two functions to handle the group setting.
Removed the extra numlayers variable, used the mapscript parameter instead.
(MF_Map): Added a function to get the numlayers parameter.
Added a funtion to remove all layers.
(MF_Map.add_thubanlayer): Replaced the exception handling by a check if the object is an instance. Also added the annotation layer here to export, but only the layer is created in the mapfile.


Index: mapfile.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mapfile.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mapfile.py	28 Jul 2004 12:35:32 -0000	1.9
+++ mapfile.py	3 Aug 2004 11:46:00 -0000	1.10
@@ -42,6 +42,9 @@
 from Thuban.Model.classification import ClassGroupDefault, \
                                         ClassGroupSingleton, ClassGroupRange
 
+from Thuban.Model.layer import RasterLayer
+from Extensions.umn_mapserver.mf_import import AnnotationLayer
+
 from mapscript import layerObj, classObj, colorObj, styleObj, rectObj, symbolObj, \
                       pointObj, lineObj
 
@@ -235,6 +238,12 @@
     def __init__(self, mapobj):
         self.mapobj = mapobj
 
+    def remove_allmetadata(self):
+        keylist = self.get_metadatakeys()
+        if keylist:
+            for key in keylist:
+                self.mapobj.removeMetaData(key)
+
     def get_metadatakeys(self):
         keylist = []
         try:
@@ -557,6 +566,13 @@
             return True
         #return self._mf_layer.status
     
+    def get_group(self):
+        return self._mf_layer.group
+
+    def set_group(self, new_group):
+        self._mf_layer.group = new_group
+    
+    
     def set_name(self, newname):
         self._mf_layer.name = newname 
     
@@ -601,7 +617,7 @@
     def add_thubanclass(self, tb_class, type=""):
         """
         Add a thuban class object
-        """      
+        """     
         new_class = MF_Class(classObj(self._mf_layer))
         # set the class name to the Label form thuban if given,
         # else set it to the value
@@ -843,9 +859,8 @@
 
         # Initial Layer List
         self._layers = []
-        self._numlayers = self._mf_map.numlayers
         self._i = 0
-        while self._i < self._numlayers:
+        while self._i < self._mf_map.numlayers:
             self._layers.append(MF_Layer(self._mf_map.getLayer(self._i)))
             self._i += 1
 
@@ -857,7 +872,6 @@
 
         # Create Metadata
         self._metadata = MF_Metadata(self._mf_map)
-       
     
     def get_mappath(self):
         return self._mf_map.mappath
@@ -865,7 +879,6 @@
     def set_mappath(self, new_mappath):
         self._mf_map.mappath = new_mappath
     
-    
     def get_outputformat(self):
         return self._outputformat
     
@@ -908,6 +921,9 @@
     def get_layers(self):
         return self._layers
     
+    def get_numlayers(self):
+        return self._mf_map.numlayers
+    
     def get_projection(self):
         return self._projection
     
@@ -924,10 +940,10 @@
     
     def get_imagetype(self):
         return self._mf_map.imagetype
-    
+
     def get_layerorder(self):
         # shows the order of layer as list
-        return self._mf_map.getLayerOrder()   
+        return self._mf_map.getLayerOrder()
     
     def get_size(self):
         #returns the size
@@ -995,13 +1011,15 @@
 
         # TODO: implement relative pathnames
         # yet only absolute pathnames in the LayerObj are set 
-        try:
-            new_layer.set_data(tb_layer.ShapeStore().FileName())
-        except:
+        if isinstance(tb_layer, RasterLayer ):
             new_layer.set_data(tb_layer.GetImageFilename(), type="raster")
             new_layer.set_type("raster")
             new_layer.set_status(tb_layer.Visible())
+        elif isinstance(tb_layer, AnnotationLayer):
+            new_layer.set_type("annotation")
+            new_layer.set_status(tb_layer.Visible())
         else:
+            new_layer.set_data(tb_layer.ShapeStore().FileName())
             new_layer.set_status(tb_layer.Visible())
             new_layer.set_type(tb_layer.ShapeType())
         
@@ -1038,9 +1056,15 @@
         self._layers.append(new_layer)
     
     def remove_layer(self, nr):
+        #remove the last layer from the layer list and not the one which
+        # is removed in mapscript. This must be, becaus mapscript
+        # set the object links anew. Don't understand really :)
+        self._layers.pop()
         self._mf_map.removeLayer(nr)
-        self._numlayers -= 1
-        self._layers.remove(self._layers[nr])
+    
+    def remove_all_layers(self):
+        for i in range (self._mf_map.numlayers,0,-1):
+            self.remove_layer(i-1)
     
     def save_map(self, filepath):
         # save the Map





More information about the Thuban-devel mailing list

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