22 |
|
|
23 |
class Map(TitledObject, Modifiable): |
class Map(TitledObject, Modifiable): |
24 |
|
|
25 |
"""Represent a map. A map is a list of layers. Additionally |
"""Represent a map. |
26 |
|
|
27 |
|
A map is a list of layers. Additionally |
28 |
there is a special label layer containing all labels that |
there is a special label layer containing all labels that |
29 |
are defined for the map. |
are defined for the map. |
30 |
|
|
55 |
self.projection = projection |
self.projection = projection |
56 |
|
|
57 |
def Destroy(self): |
def Destroy(self): |
58 |
"""Destroys the map object with all layers including |
"""Destroys the map object with all layers including the label layer. |
|
the label layer. |
|
59 |
|
|
60 |
Calls Modifiable.Destroy first since it will call |
Calls Modifiable. Destroy first since it will call |
61 |
Publisher.Destroy which removes all subscriptions. Otherwise |
Publisher.Destroy which removes all subscriptions. Otherwise |
62 |
clearing the layers results in messages to be sent which can |
clearing the layers results in messages to be sent which can |
63 |
cause problems. |
cause problems. |
76 |
|
|
77 |
def RemoveLayer(self, layer): |
def RemoveLayer(self, layer): |
78 |
"""Remove layer from the map. |
"""Remove layer from the map. |
79 |
|
|
80 |
This can not be applied for the label layer of the map. |
This can not be applied for the label layer of the map. |
81 |
""" |
""" |
82 |
self.unsubscribe_layer_channels(layer) |
self.unsubscribe_layer_channels(layer) |
95 |
return 1 |
return 1 |
96 |
|
|
97 |
def ClearLayers(self): |
def ClearLayers(self): |
98 |
"""Delete all layers and also remove all labels from the |
"""Delete all layers and also remove all labels from the label layer. |
|
label layer. |
|
99 |
""" |
""" |
100 |
for layer in self.layers: |
for layer in self.layers: |
101 |
self.unsubscribe_layer_channels(layer) |
self.unsubscribe_layer_channels(layer) |
127 |
return self.layers |
return self.layers |
128 |
|
|
129 |
def HasLayers(self): |
def HasLayers(self): |
130 |
"""Return true if the map has at least one layer other |
"""Information whether this map has layers. |
131 |
|
|
132 |
|
Returns true if the map has at least one layer other |
133 |
than the label layer.""" |
than the label layer.""" |
134 |
return len(self.layers) > 0 |
return len(self.layers) > 0 |
135 |
|
|
136 |
def MoveLayerToTop(self, layer): |
def MoveLayerToTop(self, layer): |
137 |
"""Put the layer on top of the layer stack. This can not |
"""Put the layer on top of the layer stack. |
138 |
be applied to the label layer. |
|
139 |
|
This can not be applied to the label layer. |
140 |
|
|
141 |
If the layer is already at the top do nothing. If the stacking |
If the layer is already at the top do nothing. If the stacking |
142 |
order has been changed, issue a MAP_LAYERS_CHANGED message. |
order has been changed, issue a MAP_LAYERS_CHANGED message. |
149 |
self.changed(MAP_STACKING_CHANGED, self) |
self.changed(MAP_STACKING_CHANGED, self) |
150 |
|
|
151 |
def RaiseLayer(self, layer): |
def RaiseLayer(self, layer): |
152 |
"""Swap the layer with the one above it. This does |
"""Swap the layer with the one above it. |
153 |
not apply to the label layer. |
|
154 |
|
This does not apply to the label layer. |
155 |
|
|
156 |
If the layer is already at the top do nothing. If the stacking |
If the layer is already at the top do nothing. If the stacking |
157 |
order has been changed, issue a MAP_LAYERS_CHANGED message. |
order has been changed, issue a MAP_LAYERS_CHANGED message. |
164 |
self.changed(MAP_STACKING_CHANGED, self) |
self.changed(MAP_STACKING_CHANGED, self) |
165 |
|
|
166 |
def LowerLayer(self, layer): |
def LowerLayer(self, layer): |
167 |
"""Swap the layer with the one below it. This does |
"""Swap the layer with the one below it. |
168 |
not apply to the label layer. |
|
169 |
|
This does not apply to the label layer. |
170 |
|
|
171 |
If the layer is already at the bottom do nothing. If the |
If the layer is already at the bottom do nothing. If the |
172 |
stacking order has been changed, issue a MAP_LAYERS_CHANGED message. |
stacking order has been changed, issue a MAP_LAYERS_CHANGED message. |
179 |
self.changed(MAP_STACKING_CHANGED, self) |
self.changed(MAP_STACKING_CHANGED, self) |
180 |
|
|
181 |
def MoveLayerToBottom(self, layer): |
def MoveLayerToBottom(self, layer): |
182 |
"""Put the layer at the bottom of the stack. This does |
"""Put the layer at the bottom of the stack. |
183 |
not apply to the label layer. |
|
184 |
|
This does not apply to the label layer. |
185 |
|
|
186 |
If the layer is already at the bottom do nothing. If the |
If the layer is already at the bottom do nothing. If the |
187 |
stacking order has been changed, issue a MAP_LAYERS_CHANGED message. |
stacking order has been changed, issue a MAP_LAYERS_CHANGED message. |
195 |
|
|
196 |
def BoundingBox(self): |
def BoundingBox(self): |
197 |
"""Return the bounding box of the map in Lat/Lon coordinates. |
"""Return the bounding box of the map in Lat/Lon coordinates. |
198 |
|
|
199 |
The label layer is not considered for the computation of the |
The label layer is not considered for the computation of the |
200 |
bounding box. |
bounding box. |
201 |
|
|
226 |
|
|
227 |
def ProjectedBoundingBox(self): |
def ProjectedBoundingBox(self): |
228 |
"""Return the bounding box of the map in projected coordinates. |
"""Return the bounding box of the map in projected coordinates. |
229 |
|
|
230 |
The label layer is not considered for the computation of the |
The label layer is not considered for the computation of the |
231 |
bounding box. |
bounding box. |
232 |
|
|
247 |
def SetProjection(self, projection): |
def SetProjection(self, projection): |
248 |
"""Set the projection of the map. |
"""Set the projection of the map. |
249 |
|
|
250 |
Issue a MAP_PROJECTION_CHANGED message.""" |
Issue a MAP_PROJECTION_CHANGED message. |
251 |
|
""" |
252 |
old_proj = self.projection |
old_proj = self.projection |
253 |
self.projection = projection |
self.projection = projection |
254 |
self.changed(MAP_PROJECTION_CHANGED, self, old_proj) |
self.changed(MAP_PROJECTION_CHANGED, self, old_proj) |
277 |
self.label_layer.UnsetModified() |
self.label_layer.UnsetModified() |
278 |
|
|
279 |
def TreeInfo(self): |
def TreeInfo(self): |
280 |
"""Return a tuple of (title, tupel) describing the contents |
"""Return a description of the object. |
281 |
of the object in a tree-structure. |
|
282 |
|
A tuple of (title, tupel) describing the contents |
283 |
|
of the object in a tree-structure is returned. |
284 |
""" |
""" |
285 |
items = [] |
items = [] |
286 |
if self.BoundingBox() != None: |
if self.BoundingBox() != None: |