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

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

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

revision 1559 by bh, Thu Aug 7 17:32:20 2003 UTC revision 1605 by bh, Tue Aug 19 11:00:40 2003 UTC
# Line 7  Line 7 
7    
8  """Data source abstractions"""  """Data source abstractions"""
9    
10    from __future__ import generators
11    
12  __version__ = "$Revision$"  __version__ = "$Revision$"
13  # $Source$  # $Source$
14  # $Id$  # $Id$
# Line 43  RAW_PYTHON = "RAW_PYTHON" Line 45  RAW_PYTHON = "RAW_PYTHON"
45  # raw data.  # raw data.
46  RAW_SHAPEFILE = "RAW_SHAPEFILE"  RAW_SHAPEFILE = "RAW_SHAPEFILE"
47    
48    # Raw data in well-known text format
49    RAW_WKT = "RAW_WKT"
50    
51    
52  class ShapefileShape:  class ShapefileShape:
53    
# Line 64  class ShapefileShape: Line 69  class ShapefileShape:
69                  ys.append(y)                  ys.append(y)
70          return (min(xs), min(ys), max(xs), max(ys))          return (min(xs), min(ys), max(xs), max(ys))
71    
72        def ShapeID(self):
73            return self.shapeid
74    
75      def Points(self):      def Points(self):
76          """Return the coordinates of the shape as a list of lists of pairs"""          """Return the coordinates of the shape as a list of lists of pairs"""
77          shape = self.shapefile.read_object(self.shapeid)          shape = self.shapefile.read_object(self.shapeid)
# Line 191  class ShapefileStore: Line 199  class ShapefileStore:
199          """          """
200          return self.bbox          return self.bbox
201    
202      def ShapesInRegion(self, box):      def ShapesInRegion(self, bbox):
203          """Return the ids of the shapes that overlap the box.          """Return an iterable over the shapes that overlap the bounding box.
204    
205          Box is a tuple (left, bottom, right, top) in the coordinate          The bbox parameter should be the bounding box as a tuple in the
206          system used used in the shapefile.          form (minx, miny, maxx, maxy) in the coordinate system of the
207          """          shape store.
208          left, bottom, right, top = box          """
209          return self.shapetree.find_shapes((left, bottom), (right, top))          left, bottom, right, top = bbox
210            for i in self.shapetree.find_shapes((left, bottom), (right, top)):
211                yield ShapefileShape(self.shapefile, i)
212    
213        def AllShapes(self):
214            """Return an iterable over the shapes in the shape store."""
215            for i in xrange(self.NumShapes()):
216                yield ShapefileShape(self.shapefile, i)
217    
218      def Shape(self, index):      def Shape(self, index):
219          """Return the shape with index index"""          """Return the shape with index index"""
# Line 257  class DerivedShapeStore: Line 272  class DerivedShapeStore:
272          """          """
273          return self.shapestore.ShapesInRegion(bbox)          return self.shapestore.ShapesInRegion(bbox)
274    
275        def AllShapes(self):
276            """Return an iterable over the shapes in the shape store.
277    
278            This method is simply delegated to the shapestore the
279            DerivedShapeStore was instantiated with.
280            """
281            return self.shapestore.AllShapes()
282    
283      def ShapeType(self):      def ShapeType(self):
284          """Return the type of the shapes in the layer.          """Return the type of the shapes in the layer.
285    
# Line 265  class DerivedShapeStore: Line 288  class DerivedShapeStore:
288          """          """
289          return self.shapestore.ShapeType()          return self.shapestore.ShapeType()
290    
291        def RawShapeFormat(self):
292            """Return the raw data format of the shapes.
293    
294            This method is simply delegated to the shapestore the
295            DerivedShapeStore was instantiated with.
296            """
297            return self.shapestore.RawShapeFormat()
298    
299      def NumShapes(self):      def NumShapes(self):
300          """Return the number of shapes in the shapestore."""          """Return the number of shapes in the shapestore."""
301          return self.shapestore.NumShapes()          return self.shapestore.NumShapes()

Legend:
Removed from v.1559  
changed lines
  Added in v.1605

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26