<div dir="ltr">Warning... I did a cleanup pass and split out the class definitions into a header to allow direct C++ testing. <div><br></div><div><a href="https://trac.osgeo.org/gdal/changeset/37530">https://trac.osgeo.org/gdal/changeset/37530</a><br></div><div><a href="https://trac.osgeo.org/gdal/changeset/37514">https://trac.osgeo.org/gdal/changeset/37514</a><br></div><div><a href="https://trac.osgeo.org/gdal/changeset/37510">https://trac.osgeo.org/gdal/changeset/37510</a><br></div><div><br></div><div>I haven't written that testing yet, but it will be similar to this:<div><br></div><div><a href="https://github.com/schwehr/gdal-autotest2/blob/master/cpp/frmts/jp2kak/jp2kakdataset_test.cc">https://github.com/schwehr/gdal-autotest2/blob/master/cpp/frmts/jp2kak/jp2kakdataset_test.cc</a><br></div><div><br></div><div>-kurt</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 1, 2017 at 2:56 AM, Damian Dixon <span dir="ltr"><<a href="mailto:damian.dixon@gmail.com" target="_blank">damian.dixon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Hi Taylor,</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">M_PI is defined pretty much everywhere. The only compiler that you have to jump through hoops to get it is Visual Studio where you have to define '<span style="color:rgb(80,0,112);font-size:12px;font-family:arial,sans-serif">#define _USE_MATH_DEFINES'.</span></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">As Even has mentioned it's also defined in the GDAL portability header. </div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">The main reason the use of atan jumped out is that I've run into problems with atan on Intel CPUs and GPUs in the past. Also the use of trig' of any sort is expensive so I tend to take a look to see if it can be removed or moved.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">I spotted that this is a very old bug so I'm pleased that you've taken the time to fix it.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Regards</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Damian</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 27 February 2017 at 22:12, Brown, Taylor Alexander <span dir="ltr"><<a href="mailto:browtayl@oregonstate.edu" target="_blank">browtayl@oregonstate.edu</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div><div>Damian,<br><br></div>I agree that it would be preferable to use a predefined constant. However, I was under the impression that M_PI is a compiler extension and not part of standard C++, so I wanted to make sure it was compatible. If using M_PI is acceptable, I would be happy to change it. I will be submitting my pull request shortly.<span class="m_2253791182412564635HOEnZb"><font color="#888888"><br><br><br></font></span></div></span><span class="m_2253791182412564635HOEnZb"><font color="#888888">Taylor<br></font></span></div><div><div class="h5"><div class="m_2253791182412564635HOEnZb"><div class="m_2253791182412564635h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 27, 2017 at 5:01 AM, Damian Dixon <span dir="ltr"><<a href="mailto:damian.dixon@gmail.com" target="_blank">damian.dixon@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Hi Taylor,</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">I'm just lurking on the mailing list myself.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">I had a look at the code changes, as this is one of the formats I'm interested in, and one point springs out at me:</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><span class="m_2253791182412564635m_3470040181306976656m_-9048352380260265557gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">const</span><span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)"> </span><span class="m_2253791182412564635m_3470040181306976656m_-9048352380260265557gmail-pl-k" style="box-sizing:border-box;color:rgb(167,29,93);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">double</span><span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)"> PI = </span><span class="m_2253791182412564635m_3470040181306976656m_-9048352380260265557gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">atan</span><span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">(</span><span class="m_2253791182412564635m_3470040181306976656m_-9048352380260265557gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">1.0</span><span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">) * </span><span class="m_2253791182412564635m_3470040181306976656m_-9048352380260265557gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,134,179);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">4</span><span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)">;</span><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><span style="color:rgb(51,51,51);font-family:sfmono-regular,consolas,"liberation mono",menlo,courier,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(234,255,234)"><br></span></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">I find this line potentially a confusing way to define PI, particularly when you combine it with (PI/180) later.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Personally I would use M_PI.</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Regards</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif">Damian</div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"><br></div><div class="gmail_default" style="font-family:"trebuchet ms",sans-serif"> <br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 February 2017 at 11:55, Taylor Alexander Brown <span dir="ltr"><<a href="mailto:browtayl@oregonstate.edu" target="_blank">browtayl@oregonstate.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Greetings GDAL Community,<br>
<br>
I am developing an application [0] to process georeferenced raster<br>
hyperspectral imagery in ENVI format from NASA's Airborne<br>
Visual/Infrared Imaging Spectrometer (AVIRIS) [1].<br>
<br>
The `map info` section of the header files contain an undocumented [2]<br>
rotation field which is currently ignored by GDAL. As a result, the<br>
image is rotated incorrectly when I process it with `gdalwarp` or the<br>
GDAL Python API. Furthermore, the image is scaled incorrectly when I try<br>
to override the geotransform.<br>
<br>
I documented my experiences on the GIS Stack Exchange [3]. It has<br>
previously been described on the GDAL mailing list [4] and bug tracker<br>
[5]. I believe this issue also affects ASTER imagery [6][7].<br>
<br>
I have implemented a fix based off of branch `tags/2.1.3` and shared my<br>
code on GitHub [8]. It reads the `units` and `rotation` parameter from<br>
the `map info` section and uses these to calculate the geotransform. The<br>
scaling was off because the code expected the `units` parameter to be<br>
the last element in the list, when in my case it was the second to last.<br>
You can verify this behavior with the single-band image I have been<br>
using for testing [9].<br>
<br>
You are welcome to evaluate my code and contribute it back to the<br>
library. I am a novice at both GDAL and GIS, so there may well be<br>
problems. I would be willing to submit a pull request against your<br>
GitHub mirror if desired.<br>
<br>
<br>
Peace,<br>
<br>
Taylor Alexander Brown<br>
<br>
<br>
[0] <a href="https://github.com/capstone-coal/pycoal" rel="noreferrer" target="_blank">https://github.com/capstone-co<wbr>al/pycoal</a><br>
[1] <a href="https://aviris.jpl.nasa.gov/" rel="noreferrer" target="_blank">https://aviris.jpl.nasa.gov/</a><br>
[2] <a href="http://www.harrisgeospatial.com/docs/enviheaderfiles.html" rel="noreferrer" target="_blank">http://www.harrisgeospatial.co<wbr>m/docs/enviheaderfiles.html</a><br>
[3]<br>
<a href="http://gis.stackexchange.com/questions/229952/rotate-envi-hyperspectral-imagery-with-gdal" rel="noreferrer" target="_blank">http://gis.stackexchange.com/q<wbr>uestions/229952/rotate-envi-hy<wbr>perspectral-imagery-with-gdal</a><br>
[4] <a href="https://lists.osgeo.org/pipermail/gdal-dev/2013-January/035146.html" rel="noreferrer" target="_blank">https://lists.osgeo.org/piperm<wbr>ail/gdal-dev/2013-January/0351<wbr>46.html</a><br>
[5] <a href="https://trac.osgeo.org/gdal/ticket/1778" rel="noreferrer" target="_blank">https://trac.osgeo.org/gdal/ti<wbr>cket/1778</a><br>
[6] <a href="http://yceo.yale.edu/opening-aster-files-envi" rel="noreferrer" target="_blank">http://yceo.yale.edu/opening-a<wbr>ster-files-envi</a><br>
[7] <a href="http://yceo.yale.edu/faq-page#t2n504" rel="noreferrer" target="_blank">http://yceo.yale.edu/faq-page#<wbr>t2n504</a><br>
[8]<br>
<a href="https://github.com/OSGeo/gdal/compare/tags/2.1.3...browtayl:fix-envi-rotation?expand=1" rel="noreferrer" target="_blank">https://github.com/OSGeo/gdal/<wbr>compare/tags/2.1.3...browtayl:<wbr>fix-envi-rotation?expand=1</a><br>
[9] <a href="https://drive.google.com/open?id=0BxysdOuBmaIGalY5dVhCa1Y5M0k" rel="noreferrer" target="_blank">https://drive.google.com/open?<wbr>id=0BxysdOuBmaIGalY5dVhCa1Y5M0<wbr>k</a><br>
______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailma<wbr>n/listinfo/gdal-dev</a></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></div></div></blockquote></div><br></div>
<br>______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">--<div><a href="http://schwehr.org" target="_blank">http://schwehr.org</a></div></div>
</div>