jan: thuban/Thuban/Model map.py,1.18,1.18.2.1

cvs@intevation.de cvs at intevation.de
Thu Feb 17 00:21:49 CET 2005


Author: jan

Update of /thubanrepository/thuban/Thuban/Model
In directory doto:/tmp/cvs-serv9070

Modified Files:
      Tag: thuban-1-0-branch
	map.py 
Log Message:
(Map, Map.Destroy, Map.RemoveLayer, Map.ClearLayers,
Map.Layers, Map.HasLayers, Map.MoveLayerToTop,
Map.RaiseLayer, Map.LowerLayer, Map.MoveLayerToBottom,
Map.ProjectedBoundingBox, Map.GetProjection): Improved/added
doc string.
(Map.BoundingBox): Removed superfluous test for label_layer
and improved doc string.
(Map.TreeInfo): Added label_layer and improved sdo string.


Index: map.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/Model/map.py,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- map.py	10 Jul 2003 14:53:15 -0000	1.18
+++ map.py	16 Feb 2005 23:21:47 -0000	1.18.2.1
@@ -21,7 +21,9 @@
 
 class Map(TitledObject, Modifiable):
 
-    """Represent a map. A map is simply a list of layers.
+    """Represent a map. A map is a list of layers. Additionally
+    there is a special label layer containing all labels that
+    are defined for the map.
 
     Map objects send the following message types:
 
@@ -50,10 +52,14 @@
         self.projection = projection
 
     def Destroy(self):
-        # call Modifiable.Destroy first since it will call
-        # Publisher.Destroy which removes all subscriptions. Otherwise
-        # clearing the layers results in messages to be sent which can
-        # cause problems.
+        """Destroys the map object with all layers including
+        the label layer.
+
+        Calls Modifiable.Destroy first since it will call
+        Publisher.Destroy which removes all subscriptions. Otherwise
+        clearing the layers results in messages to be sent which can
+        cause problems.
+        """
         Modifiable.Destroy(self)
         self.ClearLayers()
         self.label_layer.Unsubscribe(CHANGED, self.forward, MAP_LAYERS_CHANGED)
@@ -67,7 +73,9 @@
         self.changed(MAP_LAYERS_ADDED, self)
 
     def RemoveLayer(self, layer):
-        """Remove layer from the map."""
+        """Remove layer from the map.
+        This can not be applied for the label layer of the map.
+        """
         self.unsubscribe_layer_channels(layer)
         self.layers.remove(layer)
         self.changed(MAP_LAYERS_CHANGED, self)
@@ -84,7 +92,9 @@
         return 1
 
     def ClearLayers(self):
-        """Delete all layers."""
+        """Delete all layers and also remove all labels from the
+        label layer.
+        """
         for layer in self.layers:
             self.unsubscribe_layer_channels(layer)
             layer.Destroy()
@@ -110,15 +120,18 @@
     def Layers(self):
         """Return the list of layers contained in the map.
 
-        The list does not include the label layer"""
+        The list does not include the label layer which
+        can be retrieved by a separate method."""
         return self.layers
 
     def HasLayers(self):
-        """Return true if the map has at least one shape layer"""
+        """Return true if the map has at least one layer other
+        than the label layer."""
         return len(self.layers) > 0
 
     def MoveLayerToTop(self, layer):
-        """Put the layer on top of the layer stack.
+        """Put the layer on top of the layer stack. This can not
+        be applied to the label layer.
 
         If the layer is already at the top do nothing. If the stacking
         order has been changed, issue a MAP_LAYERS_CHANGED message.
@@ -130,9 +143,9 @@
             self.changed(MAP_LAYERS_CHANGED, self)
             self.changed(MAP_STACKING_CHANGED, self)
 
-        
     def RaiseLayer(self, layer):
-        """Swap the layer with the one above it.
+        """Swap the layer with the one above it. This does
+        not apply to the label layer.
 
         If the layer is already at the top do nothing. If the stacking
         order has been changed, issue a MAP_LAYERS_CHANGED message.
@@ -145,7 +158,8 @@
             self.changed(MAP_STACKING_CHANGED, self)
 
     def LowerLayer(self, layer):
-        """Swap the layer with the one below it.
+        """Swap the layer with the one below it. This does
+        not apply to the label layer.
 
         If the layer is already at the bottom do nothing. If the
         stacking order has been changed, issue a MAP_LAYERS_CHANGED message.
@@ -158,7 +172,8 @@
             self.changed(MAP_STACKING_CHANGED, self)
 
     def MoveLayerToBottom(self, layer):
-        """Put the layer at the bottom of the stack.
+        """Put the layer at the bottom of the stack. This does
+        not apply to the label layer.
 
         If the layer is already at the bottom do nothing. If the
         stacking order has been changed, issue a MAP_LAYERS_CHANGED message.
@@ -172,8 +187,11 @@
 
     def BoundingBox(self):
         """Return the bounding box of the map in Lat/Lon coordinates.
+        The label layer is not considered for the computation of the
+        bounding box.
 
-        Return None if there are no layers or no layer contains any shapes.
+        Return None if there are no layers (except the label layer) or
+        no layer contains any shapes.
         """
         if not self.layers:
             return None
@@ -182,8 +200,6 @@
         urx = []
         ury = []
         for layer in self.layers:
-            if layer is self.label_layer:
-                continue
             # the layer's bbox may be None if it doesn't have any shapes
             bbox = layer.LatLongBoundingBox()
             if bbox is not None:
@@ -201,8 +217,11 @@
 
     def ProjectedBoundingBox(self):
         """Return the bounding box of the map in projected coordinates.
+        The label layer is not considered for the computation of the
+        bounding box.
 
-        Return None if there are no layers or no layer contains any shapes.
+        Return None if there are no layers (except the label layer) or
+        no layer contains any shapes.
         """
         # This simply returns the rectangle given by the projected
         # corners of the non-projected bbox.
@@ -212,6 +231,7 @@
         return bbox
 
     def GetProjection(self):
+        """Return the projection of the map."""
         return self.projection
 
     def SetProjection(self, projection):
@@ -246,6 +266,9 @@
         self.label_layer.UnsetModified()
 
     def TreeInfo(self):
+        """Return a tuple of (title, tupel) describing the contents
+        of the object in a tree-structure.
+        """
         items = []
         if self.BoundingBox() != None:
             items.append(_("Extent (lat-lon): (%g, %g, %g, %g)")
@@ -260,6 +283,6 @@
         layers = self.layers[:]
         layers.reverse()
         items.extend(layers)
+        items.append(self.label_layer)
 
         return (_("Map: %s") % self.title, items)
-





More information about the Thuban-devel mailing list

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