/[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 2338 by bh, Thu Jun 3 15:17:54 2004 UTC revision 2339 by silke, Fri Aug 20 16:59:21 2004 UTC
# Line 2  Line 2 
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  # Jonathan Coles <[email protected]>  # Jonathan Coles <[email protected]>
5    # Silke Reimer <[email protected]>
6  #  #
7  # This program is free software under the GPL (>=v2)  # This program is free software under the GPL (>=v2)
8  # Read the file COPYING coming with Thuban for details.  # Read the file COPYING coming with Thuban for details.
# Line 226  class Layer(BaseLayer): Line 227  class Layer(BaseLayer):
227          form (minx, miny, maxx, maxy) in unprojected coordinates.          form (minx, miny, maxx, maxy) in unprojected coordinates.
228          """          """
229          if self.projection is not None:          if self.projection is not None:
230              bbox = self.projection.ForwardBBox(bbox)              # Ensure that region lies within the layer's bounding box
231                # Otherwise projection of the region would lead to incorrect
232                # values.
233                clipbbox = self.ClipBoundingBox(bbox)
234                bbox = self.projection.ForwardBBox(clipbbox)
235          return self.store.ShapesInRegion(bbox)          return self.store.ShapesInRegion(bbox)
236    
237      def GetClassificationColumn(self):      def GetClassificationColumn(self):
# Line 302  class Layer(BaseLayer): Line 307  class Layer(BaseLayer):
307    
308          return (_("Layer '%s'") % self.Title(), items)          return (_("Layer '%s'") % self.Title(), items)
309    
310        def ClipBoundingBox(self, bbox):
311            """ Clip bbox to layer's bounding box.
312    
313            Returns that part of bbox that lies within the layers bounding box.
314            If bbox is completely outside of the layers bounding box, bbox is
315            returned.  It is assumed that bbox has sensible values, i.e. bminx
316            < bmaxx and bminy < bmaxy.
317            """
318            bminx, bminy, bmaxx, bmaxy = bbox
319            lminx, lminy, lmaxx, lmaxy = self.LatLongBoundingBox()
320            if bminx > lmaxx or bmaxx < lminx:
321                left, right = bminx, bmaxx
322            else:
323                left = max(lminx, bminx)
324                right = min(lmaxx, bmaxx)
325            if bminy > lmaxy or bmaxy < lminy:
326                bottom, top = bminy, bmaxy
327            else:
328                bottom = max(lminy, bminy)
329                top = min(lmaxy, bmaxy)
330            
331            return (left, bottom, right, top)
332    
333    
334  if resource.has_gdal_support():  if resource.has_gdal_support():
335      import gdal      import gdal

Legend:
Removed from v.2338  
changed lines
  Added in v.2339

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26