35 |
|
|
36 |
from Thuban.Model.classification import Classification |
from Thuban.Model.classification import Classification |
37 |
from Thuban.Model.color import Color |
from Thuban.Model.color import Color |
38 |
|
import Thuban.Model.resource |
39 |
|
|
40 |
class MapRenderer: |
class MapRenderer: |
41 |
|
|
73 |
self.map = map |
self.map = map |
74 |
seenRaster = True |
seenRaster = True |
75 |
|
|
76 |
|
if self.scale == 0: |
77 |
|
return |
78 |
|
|
79 |
# |
# |
80 |
# This is only a good optimization if there is only one |
# This is only a good optimization if there is only one |
81 |
# raster layer and the image covers the entire window (as |
# raster layer and the image covers the entire window (as |
82 |
# it currently does). |
# it currently does). We note if there is a raster layer |
83 |
|
# and only begin drawing layers once we have drawn it. |
84 |
|
# That way we avoid drawing layers that won't be seen. |
85 |
# |
# |
86 |
for layer in map.Layers(): |
for layer in map.Layers(): |
87 |
if isinstance(layer, RasterLayer): |
if isinstance(layer, RasterLayer) and layer.Visible(): |
88 |
seenRaster = False |
seenRaster = False |
89 |
break |
break |
90 |
|
|
94 |
if not self.honor_visibility or layer.Visible(): |
if not self.honor_visibility or layer.Visible(): |
95 |
if isinstance(layer, Layer) and seenRaster: |
if isinstance(layer, Layer) and seenRaster: |
96 |
self.draw_shape_layer(layer) |
self.draw_shape_layer(layer) |
97 |
elif isinstance(layer, RasterLayer): |
elif isinstance(layer, RasterLayer) \ |
98 |
|
and Thuban.Model.resource.has_gdal_support(): |
99 |
self.draw_raster_layer(layer) |
self.draw_raster_layer(layer) |
100 |
seenRaster = True |
seenRaster = True |
101 |
|
|
196 |
for p in proj.GetAllParameters(): |
for p in proj.GetAllParameters(): |
197 |
outProj += "+" + p + " " |
outProj += "+" + p + " " |
198 |
|
|
|
print "self.scale: ", self.scale, offx, offy, width, height |
|
199 |
xmin = (0 - offx) / self.scale |
xmin = (0 - offx) / self.scale |
200 |
ymin = (offy - height) / self.scale |
ymin = (offy - height) / self.scale |
201 |
xmax = (width - offx) / self.scale |
xmax = (width - offx) / self.scale |
206 |
layer.GetImageFilename(), |
layer.GetImageFilename(), |
207 |
inProj, |
inProj, |
208 |
outProj, |
outProj, |
209 |
str(xmin), str(ymin), str(xmax), str(ymax), |
(xmin, ymin, xmax, ymax), |
210 |
"", str(width), str(height)); |
"", (width, height)) |
211 |
except (AttributeError, IOError, ValueError): |
except IOError, (strerr): |
212 |
|
print strerr |
213 |
|
except (AttributeError, ValueError): |
214 |
pass |
pass |
215 |
else: |
else: |
216 |
if data is not None: |
if data is not None: |