View previous topic :: View next topic |
Author |
Message |
Mouli Beginner
Joined: 07 Jun 2003 Posts: 18 Topics: 7
|
Posted: Wed May 13, 2009 9:30 am Post subject: Geo Access |
|
|
Hi All,
Do we have any tool or utility available that can calculate distance between two zip codes?. The zip code will be called from the Cobol program.
Does IBM has any product or is it something doable in mainframe?
Thanks for your Help
Mouli _________________ Regards,
Mouli |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed May 13, 2009 9:35 pm Post subject: |
|
|
Mouli,
Finally got around to look at this question. I think it can be done. Based on the formula described here
http://www.meridianworlddata.com/Distance-Calculation.asp
Get the latitude and longitude of the cities in question in decimal degrees. North and South America, Longitude will always be a negative number.
There are tons of places on the net to get the Longitude and latitudes in decimal degrees like this
http://www.census.gov/tiger/tms/gazetteer/zcta5.txt
The latitude and longitude are at the very end (last 2 fields).
Latitude (decimal degrees) First character is blank or "-" denoting North or South latitude respectively
Longitude (decimal degrees) First character is blank or "-" denoting East or West longitude respectively
I used Denver and san jose as samples (untested code). This will give you the distance in miles. If you want in Kilometers change the constant 3963.0 to 6378.8 as the radius of the earth is assumed to be 6,378.8 kilometers, or 3,963.0 miles.
Code: |
WORKING-STORAGE SECTION.
01 WS-LAT1 COMP-2.
01 WS-LAT2 COMP-2.
01 WS-LON1 COMP-2.
01 WS-LON2 COMP-2.
01 WS-DISTANCE COMP-2.
MOVE 39.749107 TO WS-LAT1
MOVE 37.329765 TO WS-LAT2
MOVE -104.994591 TO WS-LON1
MOVE -121.792111 TO WS-LON2
COMPUTE WS-DISTANCE = 3963.0 *
FUNCTION ACOS(FUNCTION SIN(WS-LAT1 / 57.29577951) *
FUNCTION SIN(WS-LAT2 / 57.29577951) +
FUNCTION COS(WS-LAT1 / 57.29577951) *
FUNCTION COS(WS-LAT2 / 57.29577951) *
FUNCTION COS((WS-LON2 / 57.29577951) -
(WS-LON1 / 57.29577951)))
DISPLAY WS-DISTANCE
|
|
|
Back to top |
|
 |
Mouli Beginner
Joined: 07 Jun 2003 Posts: 18 Topics: 7
|
Posted: Thu May 14, 2009 11:15 am Post subject: |
|
|
Thanks Kolusu. I looked at the website (http://www.meridianworlddata.com/Distance-Calculation.asp) before posting my question and yes it is basicallly our old mathematics formula for two distance..
SQRT((X2-X1)2 + (Y2-Y1)2) (Read as whole square)
Also thanks for the lat and log values for the US zipcodes. I dont have this information before.
The calculation what is being mentioned is purely a mathematics. But it doesnt reflect about the short distance (I know my question was not talking about the Shortest distance intially).
To be more clear, We are looking for some mainframe based solution which should give us the Shortest Distance between two zip codes. When i say the shortest distance i mean the Driving distance. Take a example of Best Buy shop. If we give our zip code, it will tell all the nearest Best Buy shops for our zip code. I think they are using the GPS techonlogy to get this information. But still this is also one such software. Can this be done in our mainframe world ?. Am i asking too much from a Compute Giant !.
Anyway ideas, thoughts comments are Welcome !
Thanks
Mouli _________________ Regards,
Mouli |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu May 14, 2009 11:22 am Post subject: |
|
|
Mouli wrote: | To be more clear, We are looking for some mainframe based solution which should give us the Shortest Distance between two zip codes. When i say the shortest distance i mean the Driving distance.
|
Shortest distance does NOT translate to driving distance. By using the above the formula you are indeed getting the shortest distance (Air Miles). If you are interested only in driving distance , then you better call a java program from cobol which in turn would call google maps and then return the distance for you.
Kolusu |
|
Back to top |
|
 |
|
|