Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calculate diving km from zip to zip 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
411
0
16
IT
How to calculate diving distance km from lat/long to lat/long, or from zip code to zip code, withouth API Google, Possible?
Tks.

note:
1) I just have Bing Key, in other case
2) Naturally zip are in Italian state.
 
But calculating distance between lat/long coords isn't what the OP asked ...

Ok, so zip codes in Italy are NOT regularly laid out, so you cannot do this without some sort of mapping application that converts the zip code to coordinates, between which you CAN calculate the distance (the bit spamjim has provided a google search for)

But remember, that is an as the crow flies calculation, not the actual distance by road (or on foot or whatever).

But you say you have a Bing key, in which case you can use the Bing mapping API - in particular the Bing Maps Distance Matrix API may be of interest. Only problem here is you need to make calls to convert the zip to long/lat for start and destination, and then pass the results to the Distance Matrix APi.

An alternative is to use the Routing API, which allows us to pass in the zip codes direct;y, and then simply extract the traveldistance from the data returned, and the call is relatively easy, eg:

[pre][/pre]
 
strongm said:
But calculating distance between lat/long coords isn't what the OP asked

It is exactly what was asked. The question, including spelling error, was copied directly into a Google query.

"Crow flight" calculations are assumed as we're dealing with generalized postal codes. Most postal code databases (accessible from the postal services) mark the latitude/longitude of the center of each postal code. There will never be any street address accuracy for driving directions.

The premise of this question seems odd as VB is typically used for a distributed program. The mapping APIs being discussed are not intended to be shared to the many users of a distributed VB program.
 
Well, we'll let the OP decide - to me it was pretty clear that what they really wanted was the (d[r]iving) distance between zips with lat/long a second best (presumably because they guessed that zips might be tricky), thje subject line being "calculate diving km from zip to zip", which is pretty explicit ..

However you can do it with zip codes (bing maps puts a bounding box around the zip code, and then calculates the central point to give a lat/long), as you could see if you were able to run the API code I provided above (but you'll need an API key, which the Op suggests they have)

As for not using it in VB, which you seem to be suggesting ... not sure I follow your argument here. It isn't as if the API is secret or hidden or private. And anyway, there's no reason why you would necessarily have to reveal them to users of the program.
 
It isn't so much about secrecy of the API key. The concern is the uncontrolled use of the API key. It is possible that a few users of the distributed VB app could abuse API access (if it is contained within the VB app), hit a query limit and lock out all other users of the VB app.

Most use of online mapping technology is implemented at a server level where a developer/admin has more control. A VB app (if one is really necessary) could query sal21's server, where the API authorization and mapping calculations happen.
 
Well, even the free bing maps API key is good for 50000 transactions per24 hours (and the enterprise even more). And Bing introduced referrer security rules to help prevent abuse. And Microsoft certainly specifically advertise the keys as being available for use in Windows applications.

Appreciate that individuals may have personal preferences about this sort of thing, though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top