/[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 143 by bh, Tue May 7 14:17:20 2002 UTC revision 171 by bh, Tue May 14 14:16:24 2002 UTC
# Line 7  Line 7 
7    
8  __version__ = "$Revision$"  __version__ = "$Revision$"
9    
10    from math import log, ceil
11    
12  import shapelib, shptree  import shapelib, shptree
13    
14  from messages import LAYER_PROJECTION_CHANGED, LAYER_LEGEND_CHANGED, \  from messages import LAYER_PROJECTION_CHANGED, LAYER_LEGEND_CHANGED, \
# Line 138  class Layer(BaseLayer): Line 140  class Layer(BaseLayer):
140              self.numshapes = numshapes              self.numshapes = numshapes
141              self.shapetype = shapelib_shapetypes[shapetype]              self.shapetype = shapelib_shapetypes[shapetype]
142              self.bbox = mins[:2] + maxs[:2]              self.bbox = mins[:2] + maxs[:2]
143              #print "building tree for", self.filename, "..."  
144              self.shapetree = shptree.SHPTree(self.shapefile.cobject(), 2, 0)              # estimate a good depth for the quad tree. Each depth
145              #print "done"              # multiplies the number of nodes by four, therefore we
146                # basically take the base 4 logarithm of the number of
147                # shapes.
148                if self.numshapes < 4:
149                    maxdepth = 1
150                else:
151                    maxdepth = int(ceil(log(self.numshapes / 4.0) / log(4)))
152    
153                self.shapetree = shptree.SHPTree(self.shapefile.cobject(), 2,
154                                                 maxdepth)
155    
156      def BoundingBox(self):      def BoundingBox(self):
157          """Return the bounding box of the layer's shapes in their default          """Return the bounding box of the layer's shapes in their default
# Line 189  class Layer(BaseLayer): Line 200  class Layer(BaseLayer):
200          system used by the layer's shapefile.          system used by the layer's shapefile.
201          """          """
202          left, bottom, right, top = box          left, bottom, right, top = box
203          import time          return self.shapetree.find_shapes((left, bottom), (right, top))
         start = time.time()  
         ids = self.shapetree.find_shapes((left, bottom), (right, top))  
         print "ShapesInRegion", time.time() - start  
         return ids  
204    
205      def SetProjection(self, projection):      def SetProjection(self, projection):
206          """Set the layer's projection"""          """Set the layer's projection"""

Legend:
Removed from v.143  
changed lines
  Added in v.171

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26