Ok I ,m not 100% here but I feel I'm getting closer to solving my problem.
Got this handy little document online that helps with these sort of
equations,
I will post the full url's for anyone interested.
Distance between points
The great circle distance d between two points with coordinates {lat1,lon1}
and {lat2,lon2} is given by:
d=acos(sin(lat1)*sin(lat2)+cos(lat1)*cos(lat2)*cos(lon1-lon2))
A mathematically equivalent formula, which is less subject to rounding error
for short distances is:
d=2*asin(sqrt((sin((lat1-lat2)/2))^2 +
cos(lat1)*cos(lat2)*(sin((lon1-lon2)/2))^2))
So this is what I have done..
<!--- I need to get thefurthest west --->
<cfquery name="qry_westLon" datasource="#application.dsn#"
username="#application.gateway#" password="#application.key#">
SELECT MAX(Lon) as maxlon
FROM dbo.vehicles
WHERE vowner = 888
</cfquery>
<cfset paramWestLon = qry_westLon.maxlon>
<cfquery name="qry_westLonNowLat" datasource="#application.dsn#"
username="#application.gateway#" password="#application.key#">
SELECT lon, lat
FROM dbo.vehicles
WHERE lon = #paramWestLon# and vowner = 888
</cfquery>
<cfset paramWestLat = qry_westLonNowLat.lat>
<!--- * now I need to get the furthest east --->
<cfquery name="qry_eastLon" datasource="#application.dsn#"
username="#application.gateway#" password="#application.key#">
SELECT Min(Lon) as minlon
FROM dbo.vehicles
WHERE vowner = 888
</cfquery>
<cfset paramEastLon = qry_eastLon.minlon>
<cfquery name="qry_eastLonNowLat" datasource="#application.dsn#"
username="#application.gateway#" password="#application.key#">
SELECT lon, lat
FROM dbo.vehicles
WHERE lon = #paramEastLon# and vowner = 888
</cfquery>
<cfset paramEastLat = qry_westLonNowLat.lat>
<!--- * ok gat my variable for west longtitude(paramWestLon)
latitude(paramWestLat)
and east longtitude(paramEastLon)
latitude(paramEastLat)
* so now do my equation to get distance between
point --->
<cfset d =
acos(Sin(paramWestLat)*sin(paramEastLat)+cos(paramWestLat)*cos(paramEastLat)
*cos(paramWestLon-paramEastLon))>
<cfoutput>#d#</cfoutput>
I'm not sure if this will work but when I run this I get this error
An error occurred while evaluating the expression:
d =
acos(Sin(paramWestLat)*sin(paramEastLat)+cos(paramWestLat)*cos(paramEastLat)
*cos(paramWestLon-paramEastLon))
Error near line 30, column 8.
----------------------------------------------------------------------------
----
Parameter 1 of function Sin which is now "" must be a stk_real number
does it think my variable is a string, I'm not ashamed to say that I,m not
sure what 'must be a stk_real number' is telling me.
Many thanx in advance.
JMC
-----Original Message-----
From: Philip Arnold - ASP [mailto:[EMAIL PROTECTED]]
Sent: 15 March 2001 12:25
To: CF-Community
Subject: RE: longtitude and latitude
> Maybe, or maybe not, a cf question but I feel the audience is of the right
> kaliber of intelligence to be asking anyway!!
>
> I'm working with Longtitude and latitude co-ordinates at the moment,
>
> what I would like to do is work out the differnce in Kilometers (or miles)
> between two references i.e.
>
> Lontitude 5.48084768538759 and longtitude -5.9417692388158496
>
> I am pulling both co-ordinates from a cfquery and then setting a
> zoom level with a centre point depending on the distance between the
> two points.
>
> Any help on this matter would be appreciated....
OK, since Longtitude and Latitude don't have a globally set standard
distance between them
If you have a calculation for the global positioning, then I'm sure there
must be a way to do it
Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133
"Websites for the real world"
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists