[geotk] DefaultPortrayalService BufferedImage Flipped/Rotated

Cullen Rombach cullenr at imagemattersllc.com
Wed Jul 12 08:56:16 PDT 2017


Hello all,

I am using DefaultPortrayalService to render a MapContext to a
BufferedImage. My (heavily simplified) code looks something like this:

MapContext context = ... (created earlier)
Envelope envelope = ... (created earlier)
OutputStream outputStream = ... (created earlier)
Dimension dimension = ... (created earlier)

BufferedImage img = DefaultPortrayalService.portray(context, envelope,
dimension, false);

ImageIO.write(img, "PNG", outputStream);

As far as I can tell, this is the proper way to render a MapContext.
However, the image I get back in the output stream is incorrect. In order
to get the image oriented properly, I need to flip it upside down and
rotate it -90 degrees. Additionally, if the supplied dimensions are not
square, the original image is missing content because it is drawn in the
wrong orientation (that is, it gets cropped). I've attached a few example
files.

I'm trying to work around the issue by performing AffineTransforms on the
rendered image to get it oriented properly, but I would obviously prefer if
the image were correct on the first try. Is this an issue with the way I am
using DefaultPortrayalService, or is it a bug?

In case it is relevant, I am getting the FeatureCollection in my MapContext
from WGS 1984 shape files. I have tried a few different shape files, so I
don't think it's an issue caused only by certain data sets. Also of note is
that my source CRS and target CRS are the same (EPSG:4326, AKA WGS 1984).

Regards
Cullen Rombach

-- 
Cullen Rombach
Image Matters LLC
www.imagemattersllc.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170712/20d7ef52/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: square_image.png
Type: image/png
Size: 10593 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170712/20d7ef52/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: square_image_fixed.png
Type: image/png
Size: 11789 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170712/20d7ef52/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1000x500_fixed.png
Type: image/png
Size: 20216 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170712/20d7ef52/attachment-0006.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1000x500.png
Type: image/png
Size: 17989 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170712/20d7ef52/attachment-0007.png>


More information about the Geotoolkit mailing list