8 |
|
|
9 |
__version__ = "$Revision$" |
__version__ = "$Revision$" |
10 |
|
|
11 |
|
import os |
12 |
import warnings |
import warnings |
13 |
|
|
14 |
from Thuban import _ |
from Thuban import _ |
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 |
|
|
254 |
"""Return the shape with index index""" |
"""Return the shape with index index""" |
255 |
return self.store.Shape(index) |
return self.store.Shape(index) |
256 |
|
|
257 |
def ShapesInRegion(self, box): |
def ShapesInRegion(self, bbox): |
258 |
"""Return the ids of the shapes that overlap the box. |
"""Return an iterable over the shapes that overlap the bounding box. |
259 |
|
|
260 |
Box is a tuple (left, bottom, right, top) in unprojected coordinates. |
The bbox parameter should be the bounding box as a tuple in the |
261 |
|
form (minx, miny, maxx, maxy) in unprojected coordinates. |
262 |
""" |
""" |
|
left, bottom, right, top = box |
|
|
|
|
263 |
if self.projection is not None: |
if self.projection is not None: |
264 |
left, bottom = self.projection.Forward(left, bottom) |
left, bottom, right, top = bbox |
265 |
right, top = self.projection.Forward(right, top) |
xs = []; ys = [] |
266 |
|
for x, y in [(left, bottom), (left, top), (right, top), |
267 |
|
(right, bottom)]: |
268 |
|
x, y = self.projection.Forward(x, y) |
269 |
|
xs.append(x) |
270 |
|
ys.append(y) |
271 |
|
bbox = (min(xs), min(ys), max(xs), max(ys)) |
272 |
|
|
273 |
return self.store.ShapesInRegion((left, bottom, right, top)) |
return self.store.ShapesInRegion(bbox) |
274 |
|
|
275 |
def GetClassificationColumn(self): |
def GetClassificationColumn(self): |
276 |
return self.classification_column |
return self.classification_column |
371 |
BaseLayer.__init__(self, title, visible = visible) |
BaseLayer.__init__(self, title, visible = visible) |
372 |
|
|
373 |
self.projection = projection |
self.projection = projection |
374 |
self.filename = filename |
self.filename = os.path.abspath(filename) |
375 |
|
|
376 |
self.bbox = -1 |
self.bbox = -1 |
377 |
|
|