NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdf-java] BUG: ucar.unidata.geoloc.LatLonPointImpl.betweenLon()

agreed, I have deprecated LatLonPointImpl.betweenLon(). we dont use it anywhere in our code. thanks

On 7/14/2010 8:02 AM, Christian D Ward-Garrison wrote:
So, I realized what the problem with LatLonPointImpl.betweenLon() (a problem that my proposed replacement shares): there's not enough information to determine which way (east or west) the longitude range extends. For example, how should

LatLonPointImpl.betweenLon(10, 20, 0);

be interpreted? Does that lon range extend from 20 west to 0 (20 degrees) or from 20 east to 0 (340 degrees)?

As a result, I've eschewed betweenLon altogether and started using LatLonRect instead:

new LatLonRect(new LatLonPointImpl(0, 20), 0, 340).contains(0, 10); // false new LatLonRect(new LatLonPointImpl(0, 20), 0, -20).contains(0, 10); // true

I think that betweenLon() should be made deprecated, since it'll give unexpected results for arguments such as:

LatLonPointImpl.betweenLon(45, 0, 360);

which is a Bad Thing, given how common [0, 360] is as a longitude range.

Regards,
Christian Ward-Garrison


-----netcdf-java-bounces@xxxxxxxxxxxxxxxx wrote: -----

    To: netcdf-java@xxxxxxxxxxxxxxxx
    From: Christian D Ward-Garrison <cwardgar@xxxxxxxx>
    Sent by: netcdf-java-bounces@xxxxxxxxxxxxxxxx
    Date: 07/13/2010 05:46AM
    Subject: [netcdf-java] BUG:
    ucar.unidata.geoloc.LatLonPointImpl.betweenLon()


      LatLonPointImpl.betweenLon(68, 52, 340)  // Returns false but
      should be true.


      The method fails because it normalizes lonEnd to -20, which is
      less than 68. I propose this fix:

      static public boolean betweenLon(double lon, double lonBeg,
      double lonEnd) {
          double lonNormal = lonNormal(lon, (lonBeg + lonEnd) / 2);

          // Don't assume that lonBeg <= lonEnd.
          return Math.min(lonBeg, lonEnd) <= lonNormal && lonNormal <=
      Math.max(lonBeg, lonEnd);
      }


      Regards,
      Christian Ward-Garrison

    _______________________________________________
    netcdf-java mailing list
    netcdf-java@xxxxxxxxxxxxxxxx
    For list information or to unsubscribe, visit:
http://www.unidata.ucar.edu/mailing_lists/


_______________________________________________
netcdf-java mailing list
netcdf-java@xxxxxxxxxxxxxxxx
For list information or to unsubscribe, visit: 
http://www.unidata.ucar.edu/mailing_lists/

  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: