/[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 63 by bh, Fri Sep 14 12:20:02 2001 UTC revision 217 by bh, Wed Jul 17 10:50:40 2002 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001 by Intevation GmbH  # Copyright (c) 2001, 2002 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 88  class Map(TitledObject, Modifiable): Line 88  class Map(TitledObject, Modifiable):
88          self.changed(LAYERS_CHANGED, self)          self.changed(LAYERS_CHANGED, self)
89    
90      def BoundingBox(self):      def BoundingBox(self):
91            """Return the bounding box of the map in projected coordinates.
92    
93            Return None if there are no layers or no layer contains any shapes.
94            """
95          if not self.layers:          if not self.layers:
96              return None              return None
97          llx = []          llx = []
# Line 97  class Map(TitledObject, Modifiable): Line 101  class Map(TitledObject, Modifiable):
101          for layer in self.layers:          for layer in self.layers:
102              if layer is self.label_layer:              if layer is self.label_layer:
103                  continue                  continue
104              left, bottom, right, top = layer.LatLongBoundingBox()              # the layer's bbox may be None if it doesn't have any layers
105              llx.append(left)              bbox = layer.LatLongBoundingBox()
106              lly.append(bottom)              if bbox is not None:
107              urx.append(right)                  left, bottom, right, top = bbox
108              ury.append(top)                  llx.append(left)
109          return (min(llx), min(lly), max(urx), max(ury))                  lly.append(bottom)
110                    urx.append(right)
111                    ury.append(top)
112    
113            # check whether there were any empty layers.
114            if llx:
115                return (min(llx), min(lly), max(urx), max(ury))
116            else:
117                return None
118    
119      def ProjectedBoundingBox(self):      def ProjectedBoundingBox(self):
120          # This simply returns the rectangle given by the projected          # This simply returns the rectangle given by the projected
# Line 139  class Map(TitledObject, Modifiable): Line 151  class Map(TitledObject, Modifiable):
151              layer.UnsetModified()              layer.UnsetModified()
152          self.label_layer.UnsetModified()          self.label_layer.UnsetModified()
153    
154        def TreeInfo(self):
155            items = []
156            if self.BoundingBox() != None:
157                items.append("Extent (lat-lon): (%g, %g, %g, %g)"
158                             % self.BoundingBox())
159            if self.projection and len(self.projection.params) > 0:
160                items.append("Extent (projected): (%g, %g, %g, %g)"
161                             % self.ProjectedBoundingBox())
162                items.append(("Projection",
163                              [str(param) for param in self.projection.params]))
164    
165            layers = self.layers[:]
166            layers.reverse()
167            items.extend(layers)
168    
169            return ("Map: %s" % self.title, items)
170    

Legend:
Removed from v.63  
changed lines
  Added in v.217

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26