/[thuban]/trunk/thuban/Thuban/Model/layer.py
ViewVC logotype

Diff of /trunk/thuban/Thuban/Model/layer.py

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

revision 1535 by bh, Fri Aug 1 14:27:13 2003 UTC revision 1978 by bh, Tue Nov 25 14:30:34 2003 UTC
# Line 8  Line 8 
8    
9  __version__ = "$Revision$"  __version__ = "$Revision$"
10    
11    import os
12  import warnings  import warnings
13    
14  from Thuban import _  from Thuban import _
# Line 19  import classification Line 20  import classification
20    
21  from color import Transparent, Black  from color import Transparent, Black
22  from base import TitledObject, Modifiable  from base import TitledObject, Modifiable
23  from data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT, Shape  from data import SHAPETYPE_POLYGON, SHAPETYPE_ARC, SHAPETYPE_POINT
24    
25  import resource  import resource
26    
# Line 124  class Layer(BaseLayer): Line 125  class Layer(BaseLayer):
125    
126          self.UnsetModified()          self.UnsetModified()
127    
     def __getattr__(self, attr):  
         """Access to some attributes for backwards compatibility  
   
         The attributes implemented here are now held by the shapestore  
         if at all. For backwards compatibility pretend that they are  
         still there but issue a DeprecationWarning when they are  
         accessed.  
         """  
         if attr in ("table", "shapetable"):  
             value = self.store.Table()  
         elif attr == "shapefile":  
             value = self.store.Shapefile()  
         elif attr == "filename":  
             value = self.store.FileName()  
         else:  
             raise AttributeError, attr  
         warnings.warn("The Layer attribute %r is deprecated."  
                       " It's value can be accessed through the shapestore"  
                       % attr, DeprecationWarning, stacklevel = 2)  
         return value  
   
128      def SetShapeStore(self, store):      def SetShapeStore(self, store):
129          # Set the classification to None if there is a classification          # Set the classification to None if there is a classification
130          # and the new shapestore doesn't have a table with a suitable          # and the new shapestore doesn't have a table with a suitable
# Line 253  class Layer(BaseLayer): Line 233  class Layer(BaseLayer):
233          """Return the shape with index index"""          """Return the shape with index index"""
234          return self.store.Shape(index)          return self.store.Shape(index)
235    
236      def ShapesInRegion(self, box):      def ShapesInRegion(self, bbox):
237          """Return the ids of the shapes that overlap the box.          """Return an iterable over the shapes that overlap the bounding box.
238    
239          Box is a tuple (left, bottom, right, top) in unprojected coordinates.          The bbox parameter should be the bounding box as a tuple in the
240            form (minx, miny, maxx, maxy) in unprojected coordinates.
241          """          """
         left, bottom, right, top = box  
   
242          if self.projection is not None:          if self.projection is not None:
243              left,  bottom = self.projection.Forward(left, bottom)              left, bottom, right, top = bbox
244              right, top    = self.projection.Forward(right, top)              xs = []; ys = []
245                for x, y in [(left, bottom), (left, top), (right, top),
246                             (right, bottom)]:
247                    x, y = self.projection.Forward(x, y)
248                    xs.append(x)
249                    ys.append(y)
250                bbox = (min(xs), min(ys), max(xs), max(ys))
251    
252          return self.store.ShapesInRegion((left, bottom, right, top))          return self.store.ShapesInRegion(bbox)
253    
254      def GetClassificationColumn(self):      def GetClassificationColumn(self):
255          return self.classification_column          return self.classification_column
# Line 365  class RasterLayer(BaseLayer): Line 350  class RasterLayer(BaseLayer):
350          BaseLayer.__init__(self, title, visible = visible)          BaseLayer.__init__(self, title, visible = visible)
351    
352          self.projection = projection          self.projection = projection
353          self.filename = filename          self.filename = os.path.abspath(filename)
354    
355          self.bbox = -1          self.bbox = -1
356    

Legend:
Removed from v.1535  
changed lines
  Added in v.1978

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26