<div dir="ltr"><div><div><div>Hi Cullen,<br><br></div>I think the problem comes from the usage of EPSG:4326. In Geotoolkit, we strictly follow EPSG database definition, which states EPSG:4326 is a latitude first coordinate system. So, when drawing an image with this CRS, the horizontal axis of the image will be the latitude.<br><br></div>To overcome this problem, you should rather use "CRS:84" coordinate system, which is the equivalent of EPSG:4326, but with longitude as x-axis. You can acquire it by using one of these two methods : <br> - <a href="http://sis.apache.org/apidocs/org/apache/sis/referencing/CRS.html#forCode-java.lang.String-">CRS.forCode("CRS:84"),</a><br> - <a href="http://sis.apache.org/apidocs/org/apache/sis/referencing/CommonCRS.html#defaultGeographic--">CommonCRS.defaultGeographic().</a><br><br></div>Regards,<br></div><div class="gmail_extra"><br><div class="gmail_quote">2017-07-12 17:56 GMT+02:00 Cullen Rombach <span dir="ltr"><<a href="mailto:cullenr@imagemattersllc.com" target="_blank">cullenr@imagemattersllc.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hello all,<div><br></div><div>I am using DefaultPortrayalService to render a MapContext to a BufferedImage. My (heavily simplified) code looks something like this:</div><div><br></div><div><font face="monospace, monospace">MapContext context = ... (created earlier)</font></div><div><font face="monospace, monospace">Envelope envelope = ... (created earlier)</font></div><div><font face="monospace, monospace">OutputStream outputStream = ... (created earlier)</font></div><div><font face="monospace, monospace">Dimension dimension = ... (created earlier)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">BufferedImage img = DefaultPortrayalService.<wbr>portray(context, envelope, dimension, false);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">ImageIO.write(img, "PNG", outputStream);</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">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.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">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?</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">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).</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Regards</font></div><span class="HOEnZb"><font color="#888888"><div><font face="arial, helvetica, sans-serif">Cullen Rombach</font></div><div><div><br></div>-- <br><div class="m_-5595665342706755865gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Cullen Rombach<div>Image Matters LLC</div><div><a href="http://www.imagemattersllc.com" target="_blank">www.imagemattersllc.com</a></div></div></div>
</div></font></span></div>
<br>______________________________<wbr>_________________<br>
Geotoolkit mailing list<br>
<a href="mailto:Geotoolkit@lists.osgeo.org">Geotoolkit@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/geotoolkit" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/geotoolkit</a><br></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Alexis Manin,<br>Développeur JAVA/JEE.<br>Geomatys.<br><br><img src="https://drive.google.com/a/geomatys.com/uc?id=0BzSiAcVRHmQcdXhxZjgwQlM4ODJIUXRrRk5Fa1ZQT3prTm5Z&export=download"><br><img alt=""></div></div></div></div></div></div></div></div></div></div></div></div></div>
</div>