1 |
# Copyright (c) 2001, 2002, 2003 by Intevation GmbH |
# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH |
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. |
55 |
self.issue(LAYER_VISIBILITY_CHANGED, self) |
self.issue(LAYER_VISIBILITY_CHANGED, self) |
56 |
|
|
57 |
def HasClassification(self): |
def HasClassification(self): |
58 |
"""Determine if this layer support classifications.""" |
"""Determine if this layer supports classifications.""" |
59 |
return False |
return False |
60 |
|
|
61 |
def HasShapes(self): |
def HasShapes(self): |
67 |
return self.projection |
return self.projection |
68 |
|
|
69 |
def SetProjection(self, projection): |
def SetProjection(self, projection): |
70 |
"""Set the layer's projection""" |
"""Set the layer's projection.""" |
71 |
self.projection = projection |
self.projection = projection |
72 |
self.changed(LAYER_PROJECTION_CHANGED, self) |
self.changed(LAYER_PROJECTION_CHANGED, self) |
73 |
|
|
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): |
294 |
|
|
295 |
bbox = self.LatLongBoundingBox() |
bbox = self.LatLongBoundingBox() |
296 |
if bbox is not None: |
if bbox is not None: |
297 |
items.append(_("Extent (lat-lon): (%g, %g, %g, %g)") % bbox) |
items.append(_("Extent (lat-lon): (%g, %g, %g, %g)") % tuple(bbox)) |
298 |
else: |
else: |
299 |
items.append(_("Extent (lat-lon):")) |
items.append(_("Extent (lat-lon):")) |
300 |
items.append(_("Shapetype: %s") % shapetype_names[self.ShapeType()]) |
items.append(_("Shapetype: %s") % shapetype_names[self.ShapeType()]) |
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 |