/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Model/map.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Model/map.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 707 by jonathan, Wed Apr 23 08:44:34 2003 UTC revision 991 by frank, Thu May 22 16:51:44 2003 UTC
# Line 7  Line 7 
7    
8  __version__ = "$Revision$"  __version__ = "$Revision$"
9    
10  #from messages import MAP_LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \  from messages import MAP_LAYERS_CHANGED, MAP_PROJECTION_CHANGED, \
11       #CHANGED, LAYER_PROJECTION_CHANGED, LAYER_LEGEND_CHANGED, \       CHANGED, LAYER_PROJECTION_CHANGED, LAYER_LEGEND_CHANGED, \
12       #LAYER_VISIBILITY_CHANGED       LAYER_VISIBILITY_CHANGED, LAYER_CHANGED, MAP_STACKING_CHANGED, \
13         MAP_LAYERS_ADDED, MAP_LAYERS_REMOVED
 from messages import *  
14    
15  from Thuban import _  from Thuban import _
16    
# Line 20  from base import TitledObject, Modifiabl Line 19  from base import TitledObject, Modifiabl
19  from label import LabelLayer  from label import LabelLayer
20    
21    
   
22  class Map(TitledObject, Modifiable):  class Map(TitledObject, Modifiable):
23    
24      """Represent a map. A map is simply a list of layers.      """Represent a map. A map is simply a list of layers.
# Line 119  class Map(TitledObject, Modifiable): Line 117  class Map(TitledObject, Modifiable):
117          """Return true if the map has at least one shape layer"""          """Return true if the map has at least one shape layer"""
118          return len(self.layers) > 0          return len(self.layers) > 0
119    
120        def TopLayer(self, layer):
121            """Put the layer on top of the layer stack.
122    
123            If the layer is already at the top do nothing. If the stacking
124            order has been changed, issue a MAP_LAYERS_CHANGED message.
125            """
126            index = self.layers.index(layer)
127            if index < len(self.layers) - 1:
128                del self.layers[index]
129                self.layers.append(layer)
130                self.changed(MAP_LAYERS_CHANGED, self)
131                self.changed(MAP_STACKING_CHANGED, self)
132    
133            
134      def RaiseLayer(self, layer):      def RaiseLayer(self, layer):
135          """Swap the layer with the one above it.          """Swap the layer with the one above it.
136    
# Line 145  class Map(TitledObject, Modifiable): Line 157  class Map(TitledObject, Modifiable):
157              self.changed(MAP_LAYERS_CHANGED, self)              self.changed(MAP_LAYERS_CHANGED, self)
158              self.changed(MAP_STACKING_CHANGED, self)              self.changed(MAP_STACKING_CHANGED, self)
159    
160        def BottomLayer(self, layer):
161            """Put the layer at the bottom of the stack.
162    
163            If the layer is already at the bottom do nothing. If the
164            stacking order has been changed, issue a MAP_LAYERS_CHANGED message.
165            """
166            index = self.layers.index(layer)
167            if index > 0:
168                del self.layers[index]
169                self.layers.insert(0, layer)
170                self.changed(MAP_LAYERS_CHANGED, self)
171                self.changed(MAP_STACKING_CHANGED, self)
172    
173      def BoundingBox(self):      def BoundingBox(self):
174          """Return the bounding box of the map in Lat/Lon coordinates.          """Return the bounding box of the map in Lat/Lon coordinates.
175    
# Line 159  class Map(TitledObject, Modifiable): Line 184  class Map(TitledObject, Modifiable):
184          for layer in self.layers:          for layer in self.layers:
185              if layer is self.label_layer:              if layer is self.label_layer:
186                  continue                  continue
187              # the layer's bbox may be None if it doesn't have any layers              # the layer's bbox may be None if it doesn't have any shapes
188              bbox = layer.LatLongBoundingBox()              bbox = layer.LatLongBoundingBox()
189              if bbox is not None:              if bbox is not None:
190                  left, bottom, right, top = bbox                  left, bottom, right, top = bbox

Legend:
Removed from v.707  
changed lines
  Added in v.991

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26