Solved

Distance between postcodes using google api

Posted on 2009-04-14
7
774 Views
Last Modified: 2012-05-06
Anybody have any information on how to do what theaa.com do here http://www.theaa.com/route-planner/index.jsp or freemaptools do here - http://www.freemaptools.com/distance-between-uk-postcodes.htm ?

Thanks
0
Comment
Question by:suroma
  • 3
  • 3
7 Comments
 
LVL 8

Expert Comment

by:rweil
ID: 24221433
You appear to have two separate problems:

1) Getting the end point locations
2) displaying the distance and directions once you have the end points

For task 1 there is not enough information in your question on where your data is coming from or what kind of data you want to display.

Task 2 can be solved by looking at the tutorials at http://econym.googlepages.com/index.htm.  In particular part 4 will show how to display locations and get locations
0
 
LVL 8

Accepted Solution

by:
rweil earned 300 total points
ID: 24221461
To get the straight line distance between the two points.
see http://www.experts-exchange.com/Databases/GIS_GPS/Q_20383758.html

or to get other comments, in the search box type -  
        distance between latitude longitudes
0
 

Author Comment

by:suroma
ID: 24743894
I am looking to get a distance between 2 postcodes. At the moment I am using a database of lat/long points for the main part e.g. TQ4 .... or TQ9 .... However this falls down when i try to get the distance between TQ9 6TT and TQ9 7TY which the current method returns 0.
0
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
LVL 8

Expert Comment

by:rweil
ID: 24744569
What are the latitude/longitude values?

What formula are you using to get the distance?
0
 

Author Comment

by:suroma
ID: 25558499
Here are the values for the TQ postcodes
TQ1      292000      64700
TQ10      270800      59900
TQ11      273600      66200
TQ12      285800      71200
TQ13      278400      78500
TQ14      293300      73400
TQ2      290500      65000
TQ3      288200      61600
TQ4      288500      59400
TQ5      291800      55800
TQ6      287000      50900
TQ7      273000      44100
TQ8      273700      39000
TQ9      280000      58800

An here is the stored proceedure
-- Get X & Y coords of home outcode
	UPDATE @tableVariable SET
		homeX = pc.x,
		homeY = pc.y
	FROM
		@tableVariable t
		INNER JOIN tblPostCodes pc ON SUBSTRING(t.postCodeHome,1,4) = pc.outcode
 
	-- Get X & Y coords of destination outcode
	UPDATE @tableVariable SET
		destinationX = pc.x,
		destinationY = pc.y
	FROM
		@tableVariable t
		INNER JOIN tblPostCodes pc ON t.itemOutcode = pc.outcode
	
	-- Calculate the distance & add to table
	UPDATE @tableVariable SET
		distance = (sqrt((power((destinationX - homeX),2)) + (power((destinationY - homeY),2)))) / 1609.344

Open in new window

0
 
LVL 1

Assisted Solution

by:ajGurkha
ajGurkha earned 200 total points
ID: 30159306
maybe there is type conversion error in your distance calculation. Possibly the power function treats inputs and outpus as a short integer. Try casting each portion of the calculation to a decimal.
0
 

Author Closing Comment

by:suroma
ID: 32900368
Not complete but no longer a priority to complete.
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Auto-indent certain lines in Notepad++ 10 144
remove computer from using logon script 17 45
Need to combine two scripts 2 40
Merging text files strings with filename 18 39
Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question