[geotk] Re: Mapping coordinate system axis order to i,j indices
on a map images
Martin Desruisseaux
martin.desruisseaux at geomatys.fr
Mon Apr 19 13:38:58 EDT 2010
Le 19/04/10 18:43, Jonathan Blower a écrit :
> Yes, I can see how this works - and clearly a replacement for GridGeometry is needed in the Coverage world. My main question is - what happens if the transformation from real-world to grid coordinates is not affine? We have quite a few situations like this, and they are becoming more and more common in global and coastal oceanography. In these cases the grid is complex and distorted, perhaps to avoid the polar singularity and/or to distort around the coasts.
Yes, this is a hard question. I see two possible approachs:
1) Declare that 'gridToCRS' shall always be affine
--------------------------------------------------
We can do that by declaring that the coverage CRS is not a ProjectedCRS or
GeographicCRS, but rather an DerivedCRS. So we have two transforms:
* 'gridToCRS' (which must be affine) from the grid to the DerivedCRS.
* The transform from DerivedCRS to GeographicCRS/ProjectedCRS, which
can be any.
However I admit it just push the problem forward.
2) Use MathTransform.derivative(DirectPosition)
-----------------------------------------------
One possible approach is that once we get the MathTransform (which may or may
not be affine), invoke:
Matrix m = gridToCRS.derivative(centralPoint);
where 'centralPoint' is any DirectPosition close to the center of your coverage.
Then you can inspect the axis order and direction. However this approach assume
that the axis order and direction stay consistent over the full coverage extent.
If the axis order/directory is position-dependent, then we need to invoke the
above 'derivative' method in many different places.
Note that MathTransform.derivative(DirectPosition) is only partially implemented
in Geotk, but one of our guys is in the process of implementing them for map
projections right now.
> My second question: in the method
>
>> wmsImage.drawRenderedImage(coverageImage, gridToCRS);
>
> what kind of interpolation is used from coverageImage to the wmsImage? Is it nearest-neighbour?
It can be nearest neighboard, bilinear or bicubic at your choice. We can control
that with java.awt.RenderingHints, for example:
Graphics2D graphics = ...;
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_BILINEAR);
> or does it extract the whole of coverageImage in one operation and then do the subsetting in memory?
I don't know; I think this is highly implementation dependent, deep in the
Java2D rendering chain. I think that they delegate a lot of work to the video
card. For example BufferedImage tries to use the video card memory when possible.
Regards,
Martin
More information about the Geotoolkit
mailing list