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 |
151 |
layer.UnsetModified() |
layer.UnsetModified() |
152 |
self.label_layer.UnsetModified() |
self.label_layer.UnsetModified() |
153 |
|
|
154 |
|
def TreeInfo(self): |
155 |
|
items = [] |
156 |
|
if self.BoundingBox() != None: |
157 |
|
items.append("Extent (lat-lon): (%g, %g, %g, %g)" |
158 |
|
% self.BoundingBox()) |
159 |
|
if self.projection and len(self.projection.params) > 0: |
160 |
|
items.append("Extent (projected): (%g, %g, %g, %g)" |
161 |
|
% self.ProjectedBoundingBox()) |
162 |
|
items.append(("Projection", |
163 |
|
[str(param) |
164 |
|
for param in self.projection.params])) |
165 |
|
|
166 |
|
layers = self.layers[:] |
167 |
|
layers.reverse() |
168 |
|
items.extend(layers) |
169 |
|
|
170 |
|
return ("Map: %s" % self.title, items) |
171 |
|
|