This same problem or a similar one is encountered and solved in r.tileset
(This is actually almost all the work that r.tileset does since it doesn't
make optimal tilings). In r.tileset the problem might be the reverse of the
one encountered here. It is trying to find a resolution in the source
projection which will cover a specified resolution in the destination.
r.tilesets resolution calculation:
Projects destination bounding box (nsew) into the source (this makes 4 corners)
Find the bounding box (nsew) in the source of the above
Project the source bounding box back (nsew) into the destination (this makes 4
corners).
Now we have the four points of the corners in the destination of the bounding
box in the source of the bounding box in the destination.
We use this to calculate the lengths of the sides of the source bounding box
of the destination bounding box.
In each edge in the source we calculate it's length in the destination by the
metric of x scaled to 1/xres and y scaled to 1/yres. We take the maximum of
these in each direction. This is how many cells wide and tall the source
should be.
Note: The projection might do things like bulge in the middle. The bounding
box of bounding box doesn't really guarantee that we get the maximum lengths
through things. These transformations are very difficult to imagine.
-------------------------------------------- Managed by Request Tracker