multiple rasters && mapview
Jonathan Coles
jonathan at jpcoles.com
Wed Jan 12 15:26:55 CET 2005
[i sent this once before but my current address wasn't on the mailing list so it was held. the
administrator can ignore that]
Am Samstag, den 08.01.2005, 02:10 -0500 schrieb Russell Nelson:
> I'm still tracking down the problem with multiple rasters. The
> intrinsic problem is that ProjectRasterFile (called from
> baserenderer.py and implemented in gdalwarp.cpp) always creates a
> bitmap that fills the viewport.
> The fix is going to have to be in the way ProjectRasterFile gets
> called. Instead of creating a BMP image, it needs to return a
> wxImage, clipping mask, and offset.
when i first implemented the raster code i discovered that the bounding
box of the projected image is different (usually larger) than the
bounding box returned from layer.LatLongBoundingBox(). this is because
the image may curve outward between the two extreme x points, but the
extreme of the outward curve is not recognized as the extend of the
bounding box. if you use those values to calculate the parameters to
ProjectRasterFile gdal generates an image which does not properly cover
the area you want. the quick fix was to have gdal generate an image that
covers the whole window. while obviously not ideal, this worked for a
first attempt.
i hacked up a quick solution (disclaimer: may not work in all instances)
that renders as little of the raster layer image as possible. however,
as i said before, since the projected bounding box information is
incorrect the image is not quite right.
if you can figure out how to correctly determine the projected bounding
box size, then i think you will be able to a) decrease the rendering
time since gdal isn't making an image for the whole window and b) easily
allow for multiple raster layers without using masks.
try the modifications to renderer.py and baserenderer.py i've listed
below and then load the iceland_sample_raster.thuban file to see what
i'm talking about. my code base is based on a cvs checkout from last
night.
good luck,
--jonathan
p.s. a big hello to everyone at intevation! hope you are all doing well.
RCS
file: /home/thuban/jail/thubanrepository/thuban/Thuban/UI/baserenderer.py,v
retrieving revision 1.13
diff -r1.13 baserenderer.py
372a373
>
481a483,499
> bb = layer.LatLongBoundingBox()
>
> bb = [[[bb[0], bb[1]], [bb[2], bb[3]],],]
>
> pmin, pmax = self.projected_points(layer, bb)[0]
>
> xmin = (pmin[0]-offx)/self.scale
> ymin = (offy - pmin[1])/self.scale
> xmax = (pmax[0]-offx)/self.scale
> ymax = (offy - pmax[1])/self.scale
>
> width = (xmax - xmin + 1) * self.scale
> height = (ymax - ymin + 1) * self.scale
>
> #print offx, offy, offx*self.scale, offy*self.scale
> #print xmin*self.scale, ymin*self.scale
>
493c511,512
< self.draw_raster_data(data, "BMP")
---
> self.draw_raster_data(pmin[0], pmin[1]-height, data,
"BMP")
> #self.draw_raster_data(offx*self.scale, offy*self.scale,
data, "BMP")
495c514
< def draw_raster_data(self, data, format="BMP"):
---
> def draw_raster_data(self, x, y, data, format="BMP"):
Index: Thuban/UI/renderer.py
===================================================================
RCS
file: /home/thuban/jail/thubanrepository/thuban/Thuban/UI/renderer.py,v
retrieving revision 1.53
diff -r1.53 renderer.py
40a41,42
> from math import floor
>
102c104
< def draw_raster_data(self, data, format = 'BMP'):
---
> def draw_raster_data(self, x,y, data, format = 'BMP'):
106c108
< self.dc.DrawBitmap(bitmap, 0, 0)
---
> self.dc.DrawBitmap(bitmap, int(floor(x)), int(floor(y)))
--
=====================================================================
Jonathan Coles http://www.jpcoles.com
jonathan at jpcoles.com GnuPG Key: /gpg_pub_key.asc
=====================================================================
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)