Search code examples
vb.netgpslatitude-longitude

Is there a formula to change a latitude and longitude into a single number?


Can you tell me if there is a formula to change a latitude and longitude into a single number?

I plan to use this for a database table in software that provides routing for deliveries. The table row would have that number as well as the postal address. The database table would be sorted in ascending numeric order so the software can figure out which address the truck would need to go to first, second etc.

Please can you respond showing VB or VB.Net syntax so I can understand how it works?

For example I would use the following numbers for the latitude and longitude: Lat = 40.71412890 Long = -73.96140740

Additional Information:

I'm developing an Android app using Basic4Android. Basic4Android uses a VB or VB.Net syntax with SQLite as the database.

Part of this app will have route planning. I want to use this number as the first column in an SQLite table and the other columns will be for the address. If I do a query within the app that sorts the rows in numerical ascending order, I will be able to figure out which postal address are closest to each other so it will take less time for me to go from house to house.

For example, if the numbers were: 194580, 199300, 178221

I can go to postal address 178221 then to 194580 and finally to 199300 and I won't need to take the long way around town to do my deliveries after they were sorted.

As an alternative, I would be happy if there was an easy way to call a web service that returns maybe a json response that has the single number if I send a postal address to the web site. Basic4Android does have http services that can send requests to a web site.


Solution

  • I found I can get good results by adding the latitude and longitude of a particular address by not including the house number and sorting the results in the database table by the added number following by a 2nd sort on the house number in ascending order.

    I used this url to get the numbers I needed to add together:

    http://where.yahooapis.com/geocode?q=stedman+st,+lowell,+ma