DMSLatLonPoint Precision Issue

From: Karl Stuempfle <KStuempfle@optimetrics.org>
Date: Thu May 23 2002 - 11:01:19 EDT

I have noticed something with the DMSLatLonPoint class in OpenMap 4.4.2

Due to the fact that it uses the integer data type for "seconds" when
storing internally, there is a loss of precision when switching between
LatLonPoint and DMSLatLonPoint.

For instance, here is a very quick sample (code, followed by results):

import com.bbn.openmap.*;

public class Test {

 public static void main(String[] args) {
  LatLonPoint llp = new LatLonPoint(37.12345, 127.98762);
  System.out.println(llp);
  DMSLatLonPoint dms = new DMSLatLonPoint(llp);
  System.out.println(dms.getDecimalLatitude() + " " +
dms.getDecimalLongitude());
 }
}

LatLonPoint[lat=37.12345,lon=127.98762]
37.123333 127.987495

I modified the DMSLatLonPoint class to use floats for lon_seconds and
lat_seconds and also added a normalize_value() method that used those floats
and that seems to fix the problem (though I did not bother making the
hashCode() method work). I suppose for even greater precision, you could use
doubles, but floats did what I needed.

Karl...

--
[To unsubscribe to this list send an email to "majdart@bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Thu May 23 11:04:41 2002

This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:33 EDT