jschuengel: thuban/Extensions/umn_mapserver mf_import.py, 1.10, 1.11

cvs@intevation.de cvs at intevation.de
Mon Aug 9 13:41:37 CEST 2004


Author: jschuengel

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

Modified Files:
	mf_import.py 
Log Message:
Now all layers which are imported, will be linked with the associated MF_Layer.
(import_mapfile): All layers, which are not selected, will be removed.
Disable the "import layer from mapfile" menu option.


Index: mf_import.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/umn_mapserver/mf_import.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- mf_import.py	3 Aug 2004 11:58:05 -0000	1.10
+++ mf_import.py	9 Aug 2004 11:41:35 -0000	1.11
@@ -275,6 +275,8 @@
         # because thuban don't supports annotation.
         layertitle = maplayer.get_name()
         annotationlayer = AnnotationLayer(layertitle,store)
+        # associate a copy of the maplayer object to the layer in thuban.
+        annotationlayer.extension_umn_layerobj = maplayer
         tb_map.AddLayer(annotationlayer)
     
 
@@ -309,6 +311,9 @@
         rasterlayer.SetVisible(maplayer.get_status())
         #add the projection if exists
         set_projection_to_tb(rasterlayer, maplayer)
+        
+        # associate a copy of the maplayer object to the layer in thuban.
+        rasterlayer.extension_umn_layerobj = maplayer
         tb_map.AddLayer(rasterlayer)
 
 
@@ -365,7 +370,6 @@
             clazz_name = map_clazz.get_name()
             clazz = layer.GetClassification()
             prop = ClassGroupProperties()
-
             # set the layerprojection if given
             # TODO check this, becaus it is not working correctly
             # set_projection_to_tb(layer, maplayer)
@@ -479,7 +483,7 @@
         set_projection_to_tb(layer, maplayer)
         
         # associate a copy of the maplayer object to the layer in thuban.
-        # layer.extension_umn_layerobj =maplayer
+        layer.extension_umn_layerobj =maplayer
         #add the layer into thuban
         tb_map.AddLayer(layer)
 
@@ -536,7 +540,7 @@
 
     # Parse mapfile
     mapobj = parse_mapfile(filename)
-    
+       
     # Show number of Layer found in file
     numlayers = len(mapobj.get_layers())
     if numlayers == 0:
@@ -651,7 +655,19 @@
             set_projection_to_tb(tb_map,mapobj)
 
             selectedlayer = list(selectedlayer)
-
+            # remove not selected layer from the mapfile
+            incount = 0
+            delcount = 0
+            newselect = []
+            for iii in range(0, len(mapobj.get_layers()), 1):
+                if iii in selectedlayer:
+                    newselect.append(selectedlayer[incount]-delcount)
+                    incount += 1
+                else:
+                    mapobj.remove_layer(iii-delcount)
+                    delcount += 1
+            selectedlayer = newselect
+           
             # Check for each Layer if it is possible to show in Thuban
             for layernr in selectedlayer:
 
@@ -674,13 +690,6 @@
                     add_annotationlayer(context, tb_map, mapobj, maplayer)
                     layer_count += 1
     
-            # remove alle layer from the mapobj, because the layer will be
-            # created new in export, and the unused layers are not needed
-            # TODO: Save the layers which are not used somewhere, to edit
-            # them later and export it.
-    ##~         for nr in range(len(mapobj.get_layers())-1, -1, -1):
-    ##~             mapobj.remove_layer(nr)
-    
             # add the map object to thuban, to use it later
             tb_map.extension_umn_mapobj = mapobj
     
@@ -711,6 +720,7 @@
 
 # check if an mapobj exists, to control the menuitem is available or not
 def _has_umn_mapobj(context):
+    return False
     """Return true if a umn_mapobj exists"""
     return hasattr(context.mainwindow.canvas.Map(), "extension_umn_mapobj")
 





More information about the Thuban-devel mailing list

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