• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Track distance between two addresses

Explorer ,
May 12, 2006 May 12, 2006

Copy link to clipboard

Copied

Hello,

Doesn't anyone use or know of a web service that allows me to find the distance between two separate addresses?

Thanks!
James
TOPICS
Advanced techniques

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 12, 2006 May 12, 2006

Copy link to clipboard

Copied

jimmy.hunt wrote:
> Doesn't anyone use or know of a web service that allows me to find the
> distance between two separate addresses?

plenty:
http://mesaarcweb.esri.com/v2006/index.jsp
http://geocoder.us/
http://developer.yahoo.com/maps/rest/V1/geocode.html

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 12, 2006 May 12, 2006

Copy link to clipboard

Copied

are there any free ones? and when I say web services I mean web services with a wsdl link.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 12, 2006 May 12, 2006

Copy link to clipboard

Copied

jimmy.hunt wrote:
> are there any free ones? and when I say web services I mean web services with a wsdl link.

did you bother looking at those?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 13, 2006 May 13, 2006

Copy link to clipboard

Copied

This one is not free: http://mesaarcweb.esri.com/v2006/index.jsp
This is not a real web service: http://geocoder.us/
And this gives latitude, longitude marks: http://developer.yahoo.com/maps/rest/V1/geocode.html

I'm looking for a free web service that I can cfinvoke to find the distance between two addresses.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2006 May 13, 2006

Copy link to clipboard

Copied

jimmy.hunt wrote:
> This one is not free: http://mesaarcweb.esri.com/v2006/index.jsp

there's a free public ws. read again.

> This is not a real web service: http://geocoder.us/

well that would be news to the 1,000's of people using it, including me.
read again.

> And this gives latitude, longitude marks:
> http://developer.yahoo.com/maps/rest/V1/geocode.html

and from that you can't calculate distance?

> I'm looking for a free web service that I can cfinvoke to find the distance
> between two addresses.

you were just given 3. read again.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 13, 2006 May 13, 2006

Copy link to clipboard

Copied

OK. Great. I looked at them a little closer and you're right.

Thanks for your help.

James

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 13, 2006 May 13, 2006

Copy link to clipboard

Copied

if you want actual distances (ie via road network instead of flying like a bird)
you'll need to use the routing service from ESRI or yahoo. this ones uses ESRI's:

http://www.sustainablegis.com/projects/routing/



simple example for us geocoder:

<cfsilent>
<cfscript>
if (isdefined("form.address") AND len(trim(form.address))) {
geocoder=createObject("webservice"," http://geocoder.us/dist/eg/clients/GeoCoder.wsdl");
// of course you've signed up,right?
geocoder.setUsername("yourUserNameGoesHere");
geocoder.setPassword("yourPasswordGoesHere");
geocodeResults=geocoder.geocode_address(form.address);
}
</cfscript>
</cfsilent>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>US Geocoder Test</title>
</head>

<body>
<form action="usGeocoder.cfm" method="post">
<b>address to geocode</b>: <input type="text" name="address" value="601 Townsend
St. San Fransico, CA 94103" size="50" maxlength="150">
  
<input type="submit" value="geocode">
</form>
<cfif isDefined("variables.geocodeResults")>
<hr align="left" width="30%">
<cfoutput>
<cfloop index="i" from="1" to="#arrayLen(geocodeResults)#">
<!--- what went in, comes out? --->
#geocodeResults .getNumber()# #geocodeResults.getStreet()#,
#geocodeResults .getCity()# #geocodeResults.getState()#
#geocodeResults .getZip()# <b>:::</b> latitude: #geocodeResults.getLat()#,
longitude: #geocodeResults .get_Long()# <br>
</cfloop>
</cfoutput>
</cfif>
</body>
</html>


and distance function:

function calcDist(fromLong,fromLat,toLong,fromLat) {
var r=3963.0;
var unitFactor=1.00; //change to change output units, 1=miles
var distance=unitFactor * r * acos(sin(fromLat/57.2958) * sin(toLat/57.2958) +
cos(fromLat/57.2958) * cos(toLat/57.2958) * cos(toLong/57.2958-fromLong/57.2958));
return distance;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

When I try to run the GeoCoder portion of your sample code it gives me a 500 error when I click submit.

Any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

jimmy.hunt wrote:
> When I try to run the GeoCoder portion of your sample code it gives me a 500 error when I click submit.

what ver of cf?

post the *exact* code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

Here is the exact code minus my password. So it is exactly like yours except on the action I'm just submitting back to the same form (the index.cfm).

<cfsilent>
<cfscript>
if (isdefined("form.address") AND len(trim(form.address))) {
geocoder=createObject("webservice"," http://geocoder.us/dist/eg/clients/GeoCoder.wsdl");
// of course you've signed up,right?
geocoder.setUsername("James_H10");
geocoder.setPassword("myPassword");
geocodeResults=geocoder.geocode_address(form.address);
}
</cfscript>
</cfsilent>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>US Geocoder Test</title>
</head>

<body>
<form action="index.cfm" method="post">
<b>address to geocode</b>: <input type="text" name="address" value="601 Townsend
St. San Fransico, CA 94103" size="50" maxlength="150">
  
<input type="submit" value="geocode">
</form>
<cfif isDefined("variables.geocodeResults")>
<hr align="left" width="30%">
<cfoutput>
<cfloop index="i" from="1" to="#arrayLen(geocodeResults)#">
<!--- what went in, comes out? --->
#geocodeResults.getNumber()# #geocodeResults.getStreet()#,
#geocodeResults.getCity()# #geocodeResults.getState()#
#geocodeResults.getZip()# <b>:::</b> latitude: #geocodeResults.getLat()#,
longitude: #geocodeResults.get_Long()# <br>
</cfloop>
</cfoutput>
</cfif>
</body>
</html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

jimmy.hunt wrote:
> Here is the exact code minus my password. So it is exactly like yours except
> on the action I'm just submitting back to the same form (the index.cfm).

no, you changed it.

> <cfloop index="i" from="1" to="#arrayLen(geocodeResults)#">
> <!--- what went in, comes out? --->
> #geocodeResults.getNumber()# #geocodeResults.getStreet()#,
> #geocodeResults.getCity()# #geocodeResults.getState()#
> #geocodeResults.getZip()# <b>:::</b> latitude: #geocodeResults.getLat()#,
> longitude: #geocodeResults.get_Long()# <br>
> </cfloop>

geoCodeResults is an array. re-read the code i posted.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

I changed this part to use arrays and it worked:

<cfloop index="i" from="1" to="#arrayLen(geocodeResults)#">
<!--- what went in, comes out? --->
#geocodeResults .getNumber()# #geocodeResults.getStreet()#,
#geocodeResults .getCity()# #geocodeResults.getState()#
#geocodeResults .getZip()# <b>:::</b> latitude: #geocodeResults.getLat()#,
longitude: #geocodeResults .get_Long()# <br>
</cfloop>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

That is weird the is missing from the code. You probably posted it like that but the 's disappear. Very Strange!! Thanks Paul! Now for some reason this isn't working for me:

function calcDist(fromLong,fromLat,toLong,fromLat) {
var r=3963.0;
var unitFactor=1.00; //change to change output units, 1=miles
var distance=unitFactor * r * acos(sin(fromLat/57.2958) * sin(toLat/57.2958) +
cos(fromLat/57.2958) * cos(toLat/57.2958) * cos(toLong/57.2958-fromLong/57.2958));
return distance;
}

I wonder if everything came through properly for this code.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 14, 2006 May 14, 2006

Copy link to clipboard

Copied

jimmy.hunt wrote:
> function calcDist(fromLong,fromLat,toLong,fromLat) {

my typo obviously should be:

function calcDist(fromLong,fromLat,toLong,toLat) {

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 15, 2006 May 15, 2006

Copy link to clipboard

Copied

This isn't working. Any ideas?
Thanks!
James

alert(calcDist(-82.765, 28.876, -84.917, 39.942));
function calcDist(fromLong,fromLat,toLong,toLat) {
var r=3963.0;
var unitFactor=1.00; //change to change output units, 1=miles
var distance=unitFactor * r * acos(sin(fromLat/57.2958) * sin(toLat/57.2958) + cos(fromLat/57.2958) * cos(toLat/57.2958) * cos(toLong/57.2958-fromLong/57.2958));
return distance;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 15, 2006 May 15, 2006

Copy link to clipboard

Copied

LATEST
jimmy.hunt wrote:
> This isn't working. Any ideas?
> Thanks!
> James

that code was cfscript.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation