GPS coordinates to metres

2006-03-07 Thread Francis Nugent Dixon

Hi Monte,

in your mail you don't show the complete Lat/Long information
(you need N/S for Lat, and E/W for Long).  I suppose that you
didn't include them, but you need them for what follows.

Try the Haversine formula I use to get distances between 2
points. You first have to convert your Lat/Long into Radians.

I got my co-ordinates (corresponding to a city) from a data
base, and converted them to radians first.

Let's assume you have your Lat and Long co-ordinates in
fields MyLatitude and MyLongitude, and the direction in fields
MyNS and MyEW, and you want the radian answer in fields
MyRadLatitude and MyRadLongitude, you convert to radians
by :

  set numberFormat to 0.  -- We need precision here !
  --
  -- Convert Latitude and Logitude from degrees to Radians
  -- (Latitude and Longitude must be valid co-ordinates).
  --
  -- This is in preparation for the calculation of distances between
  -- two point on the earths surface.
  --
  -- These co-ordinates must be converted into Radians to use them  
in

  -- my Haversine formula.
  --
  put field MyLatitude into LVWork1
  put LVWork1 * 0.017453293 into LVIntermed1
  put LVIntermed1 into field MyRadLatitude
  put field MyLongitude into LVWork2
  put LVWork2 * 0.017453293 into LVIntermed2
  put LVIntermed2 into field MyRadLongitude
  if field MyNS = "S" then put - field MyRadLatitude into field  
MyRadLatitude
  if field MyEW = "W" then put - field MyRadLongitude into field  
MyRadLongitude


Then, using function :

Function RFHaversine PVLat1,PVLong1,PVLat2,PVLong2
  --global  
LVRadiusOfTheEarth,LVLat1,LVLong1,LVLat2,LVLong2,LVInt1,LVInt2,LVWork1,L 
VWork2,LVWork3

  --
  -- V1 for Hypercard  - 2003/06/28 - 18:00   no atan2 function  
available in Hypercard.
  -- V2 for Revolution - 2006/02/24 - 11:23   use atan2 function  
available in Revolution.

  --
  -- Use Haversine two-argument Inverse Tangent Function to  
calculate

  -- the distance between two geographic locations (cities).
  --
  -- The two geographic locations represent cities or towns in my
  -- City Stack. The pre-calling sequence has already identified
  -- the two cities, and extracted their locations in Radians.
  --
  -- Input Parameters :
  --
  -- Latitude and Longitude of location 1 in Radians  
(PVLat1,PVLong1).
  -- Latitude and Longitude of location 2 in Radians  
(PVLat2,PVLong2).

  --
  -- The Haversine formula is :
  --
  -- dlon = lon2 - lon1  where lon1 and lon2 are longitudes of two  
cities.
  -- dlat = lat2 - lat1  where lat1 and lat2 are latitudes of two  
cities.

  -- a = (sin(dlat/2))^2 + cos(lat1) * cos(lat2) * (sin(dlon/2))^2
  -- c = 2 * atan2( sqrt(a), sqrt(1-a) )
  -- d = R * c   where R is the radius of the earth in  
kilometres.

  --
  set numberFormat to 0.  -- Heavy precision required here !
  put 6367 into LVRadiusOfTheEarth   -- Generally accepted Radius  
of the Earth

  put PVLat1 into LVLat1
  put PVLong1 into LVLong1
  put PVLat2 into LVLat2
  put PVLong2 into LVLong2
  put LVLong2 - LVLong1 into LVInt1
  put LVLat2 - LVLat1 into LVInt2
  put (sin(LVInt2/2))^2 + cos(LVLat1) * cos(LVLat2) * (sin(LVInt1/2))^2  
into LVWork1

  put 2 * atan2(sqrt(LVWork1),sqrt(1-LVWork1)) into LVWork2
  put LVRadiusOfTheEarth * LVWork2 into LVWork3
  --
  -- We now have the distance in kilometres in LVWork3.
  --
  put round(LVWork3,3) into LVWork3 -- Kilometres to 3 decimal  
points.

  return LVWork3
end RFHaversine

You can get the distance between your two points with :

put RFHaversine (LVRadLat1,LVRadLong1,LVRadLat2,LVRadLong2) into  
Distance


Either set the radius of the Earth to metres, or remove the
point in the kilometre answer field and "Bobs your Uncle !"

If anybody else is interested, I have a stack containing data
for 4000 cities and the possibility of calculating the distance
between any two cities, with up to 6 city stopovers if necessary.
(its got 4001 cards and is 1.6 Mb).

I hope this fills your requirements.

Best from Paris

-Francis

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: GPS coordinates to metres

2006-03-07 Thread Pierre Sahores

Hello Monte,

Do you mean the "centroid" or the "center" of you map ?

Wait for your response before more Hala, the very kindly GIS expert  
and friend i work with, will respond directly about this all.


Kind Regards,

Pierre


Hi

Has anyone here done work with GPS coordinates. I have a set of  
coordinates and a point at the centre of my map. I need to convert  
these to metres relative to the centre of my map.


The coordinates are in the form:

LatitudeLongitude
37.29464 126.8324167
37.294642   126.832415
37.294642   126.832415
37.294642   126.8324133
37.294642   126.8324133


Thanks for any help with this one

Cheers

--

Monte Goulding  BCompSci
Sweat Technologies  BAppSci (Hons)

InstallGadget - How to create an installer in 10 seconds
Download now from: http://www.sweattechnologies.com/InstallGadget
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your  
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution



--
Pierre Sahores
www.sahores-conseil.com


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: GPS coordinates to metres

2006-03-06 Thread Rishi Viner
> Has anyone here done work with GPS coordinates. I have a set of coordinates
> and a point at the centre of my map. I need to convert these to metres
> relative to the centre of my map.
>
> The coordinates are in the form:
>
> LatitudeLongitude
> 37.29464 126.8324167
> 37.294642   126.832415
> 37.294642   126.832415
> 37.294642   126.8324133
> 37.294642   126.8324133

Looks like you have decimal degrees for lat/long. You'll pobably need to 
convert to degrees, minutes and seconds. (60 seconds in a minute etc). Then 
you could convert from coordinates to Universal Transverse Mercator (UTM) 
grid coordinates, which are in metres. Thats the fun part. Read up on 
geodetic datum conversions. (Simple concept intro here: 
http://www.biodiversity.ea.gov.au/erin/tools/geo2amg.html ).
There are various gov surveying web sites that explain the maths. Thats all I 
have time for now. Hope it helps,

-- 
Rishi 
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


GPS coordinates to metres

2006-03-06 Thread Monte Goulding

Hi

Has anyone here done work with GPS coordinates. I have a set of coordinates 
and a point at the centre of my map. I need to convert these to metres 
relative to the centre of my map.


The coordinates are in the form:

LatitudeLongitude
37.29464 126.8324167
37.294642   126.832415
37.294642   126.832415
37.294642   126.8324133
37.294642   126.8324133


Thanks for any help with this one

Cheers

--

Monte Goulding  BCompSci
Sweat Technologies  BAppSci (Hons)

InstallGadget - How to create an installer in 10 seconds
Download now from: http://www.sweattechnologies.com/InstallGadget 


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution