I fixed it. No bug in GT! Was a fault of myself!!

When I specify new colors for an existing GridCoverage, I create a new BufferedImage with a corresponding ColorModel and then a new GridCoverage of the BufferedImage.
And there was a (copy/paste-)bug in the creation of the BufferedImage:
I created it with
        BufferedImage bufIm  = new BufferedImage(
            raster.getHeight(),
            raster.getHeight(),
            ...
        )
instead of
        BufferedImage bufIm  = new BufferedImage(
            raster.getWidth(),
            raster.getHeight(),
            ...
        )

So my displayed raster was a little bit deformed compared to my original raster (from which I determined the raster value to the mouse position)!

Sorry for my unnecessary question...

Martin Schmitz


Martin Desruisseaux schrieb:
Martin Schmitz a écrit :

In the vertical direction everything is exactly correct. The problem is the horizontal.

As I found out just a minute ago, the reason seems not to be the method GeoMouseEvent.getMapCoordinate(.) because if I move the cursor in the lower left corner, it returns the correct lat/lon position of my raster! So the problem must be GridCoverage.evaluate(Point2D,.).

Is there a bug in the transformation from the lat/lon to raster coordinates? Rounding problems?


Not as far as I know. It seems to work correctly on my own software (but I may be wrong - more tests would be better). There is no separated processing for the horizontal and the vertical axis. Most transformations are handled by java.awt.geom.AffineTransform, which handle both axis simultaneously. An error may occurs while setting up the AffineTransform however. I suggest to try the following:

MathTransform tr = gridCoverage.getGridGeometry().getGridToCoordinateSystem();
 System.out.println(tr);

Make sure that the affine transform coefficients are the expected one.

The AffineTransform can be setup by GridCoverage2D at construction time from the image size and an user-supplied Envelope. Make sure that the envelope is correct. If the envelope is correct but GridCoverage2D setup an incorrect AffineTransform, please let me know.

    Martin.



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to