17. NS BASIC Tech Note

NS BASIC Tech Note: How to find your longitude and latitude    8 Dec 1995
-------------------------------------------------------------------------
[Contributed by Jonathan Kipling Knight (KKnight-COS3© Kaman.com) of 
Colorado
Springs, CO]

I've been writing astronomy programs in NS BASIC but one of the fundamental
things was to know your longitude and latitude.  If you look at the frame
GetGlobals().userConfiguration.location you'll notice very odd looking 
numbers
for the longitude and latitude.  I proceeded to do some number analysis on
various locations and came up with formulae to convert to the numbers that
you'd get off of a map.  The following is a listing of a program that will
display the degrees longitude and latitude of your current location.

0010 LET maxInt=pow(2,29)-1
0020 LET here=GetGlobals().userConfiguration.location
0030 IF here.longitude>(maxInt/2) THEN west=1 ELSE west=0
0040 IF here.latitude>(maxInt/4) THEN south=1 ELSE south=0
0050 LET longit=360*(here.longitude/maxInt-west)
0060 LET latit=360*(here.latitude/maxInt-south)
0070 PRINT "You're in ";here.name;" at"
0080 PRINT "Longitude (W<0) ";longit;chr(176)
0090 PRINT "Latitude (S<0) ";latit;chr(176)

I found that the internal representation can pinpoint an object on Earth 
to an
accuracy of about 7.5 cm. If you'd like a complete list of available 
locations 
on your newton look at the elements in GetRoot().|worldclock|.cards.