1 |
# Copyright (c) 2001 by Intevation GmbH |
# Copyright (c) 2001, 2002 by Intevation GmbH |
2 |
# Authors: |
# Authors: |
3 |
# Bernhard Herzog <[email protected]> |
# Bernhard Herzog <[email protected]> |
4 |
# |
# |
47 |
def Destroy(self): |
def Destroy(self): |
48 |
for layer in self.layers: |
for layer in self.layers: |
49 |
layer.Destroy() |
layer.Destroy() |
50 |
|
self.label_layer.Unsubscribe(CHANGED, self.forward, LAYERS_CHANGED) |
51 |
Modifiable.Destroy(self) |
Modifiable.Destroy(self) |
52 |
|
|
53 |
def AddLayer(self, layer): |
def AddLayer(self, layer): |
88 |
self.changed(LAYERS_CHANGED, self) |
self.changed(LAYERS_CHANGED, self) |
89 |
|
|
90 |
def BoundingBox(self): |
def BoundingBox(self): |
91 |
|
"""Return the bounding box of the map in projected coordinates. |
92 |
|
|
93 |
|
Return None if there are no layers or no layer contains any shapes. |
94 |
|
""" |
95 |
if not self.layers: |
if not self.layers: |
96 |
return None |
return None |
97 |
llx = [] |
llx = [] |
101 |
for layer in self.layers: |
for layer in self.layers: |
102 |
if layer is self.label_layer: |
if layer is self.label_layer: |
103 |
continue |
continue |
104 |
left, bottom, right, top = layer.LatLongBoundingBox() |
# the layer's bbox may be None if it doesn't have any layers |
105 |
llx.append(left) |
bbox = layer.LatLongBoundingBox() |
106 |
lly.append(bottom) |
if bbox is not None: |
107 |
urx.append(right) |
left, bottom, right, top = bbox |
108 |
ury.append(top) |
llx.append(left) |
109 |
return (min(llx), min(lly), max(urx), max(ury)) |
lly.append(bottom) |
110 |
|
urx.append(right) |
111 |
|
ury.append(top) |
112 |
|
|
113 |
|
# check whether there were any empty layers. |
114 |
|
if llx: |
115 |
|
return (min(llx), min(lly), max(urx), max(ury)) |
116 |
|
else: |
117 |
|
return None |
118 |
|
|
119 |
def ProjectedBoundingBox(self): |
def ProjectedBoundingBox(self): |
120 |
# This simply returns the rectangle given by the projected |
# This simply returns the rectangle given by the projected |