142 |
# all dispatchers should be used for the 0.8 and 0.9 namespaces too |
# all dispatchers should be used for the 0.8 and 0.9 namespaces too |
143 |
for xmlns in ("http://thuban.intevation.org/dtds/thuban-0.8.dtd", |
for xmlns in ("http://thuban.intevation.org/dtds/thuban-0.8.dtd", |
144 |
"http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd", |
"http://thuban.intevation.org/dtds/thuban-0.9-dev.dtd", |
145 |
"http://thuban.intevation.org/dtds/thuban-0.9.dtd"): |
"http://thuban.intevation.org/dtds/thuban-0.9.dtd", |
146 |
|
"http://thuban.intevation.org/dtds/thuban-1.0-dev.dtd"): |
147 |
for key, value in dispatchers.items(): |
for key, value in dispatchers.items(): |
148 |
dispatchers[(xmlns, key)] = value |
dispatchers[(xmlns, key)] = value |
149 |
|
|
200 |
|
|
201 |
'ascii' -- The attribute is converted to a bytestring with |
'ascii' -- The attribute is converted to a bytestring with |
202 |
ascii encoding. |
ascii encoding. |
203 |
|
|
204 |
|
a callable -- The attribute value is passed to the callable |
205 |
|
and the return value is used a as the converted |
206 |
|
value |
207 |
""" |
""" |
208 |
normalized = {} |
normalized = {} |
209 |
|
|
234 |
value)) |
value)) |
235 |
elif d.conversion == "ascii": |
elif d.conversion == "ascii": |
236 |
value = value.encode("ascii") |
value = value.encode("ascii") |
237 |
else: |
elif d.conversion: |
238 |
if d.conversion: |
# Assume it's a callable |
239 |
raise ValueError("Unknown attribute conversion %r" |
value = d.conversion(value) |
|
% d.conversion) |
|
240 |
|
|
241 |
normalized[d.name] = value |
normalized[d.name] = value |
242 |
return normalized |
return normalized |
368 |
self.aMap = None |
self.aMap = None |
369 |
|
|
370 |
def start_projection(self, name, qname, attrs): |
def start_projection(self, name, qname, attrs): |
371 |
self.ProjectionName = self.encode(attrs.get((None, 'name'), None)) |
attrs = self.check_attrs(name, attrs, |
372 |
self.ProjectionParams = [ ] |
[AttrDesc("name", conversion=self.encode), |
373 |
|
AttrDesc("epsg", default=None, |
374 |
|
conversion=self.encode)]) |
375 |
|
self.projection_name = attrs["name"] |
376 |
|
self.projection_epsg = attrs["epsg"] |
377 |
|
self.projection_params = [ ] |
378 |
|
|
379 |
def end_projection(self, name, qname): |
def end_projection(self, name, qname): |
380 |
if self.aLayer is not None: |
if self.aLayer is not None: |
385 |
assert False, "projection tag out of context" |
assert False, "projection tag out of context" |
386 |
pass |
pass |
387 |
|
|
388 |
obj.SetProjection( |
obj.SetProjection(Projection(self.projection_params, |
389 |
Projection(self.ProjectionParams, self.ProjectionName)) |
self.projection_name, |
390 |
|
epsg = self.projection_epsg)) |
391 |
|
|
392 |
def start_parameter(self, name, qname, attrs): |
def start_parameter(self, name, qname, attrs): |
393 |
s = attrs.get((None, 'value')) |
s = attrs.get((None, 'value')) |
394 |
s = str(s) # we can't handle unicode in proj |
s = str(s) # we can't handle unicode in proj |
395 |
self.ProjectionParams.append(s) |
self.projection_params.append(s) |
396 |
|
|
397 |
def start_layer(self, name, qname, attrs, layer_class = Layer): |
def start_layer(self, name, qname, attrs, layer_class = Layer): |
398 |
"""Start a layer |
"""Start a layer |