CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011

    Finding distance between two cities

    I want to be able to get a rough distance estimate between two cities as well as finding out all the cities that are X miles within a certain city.

    I have a rough idea of how to do it using zip codes using the data from the Census Bureau, however I'm not sure how I would do this with cities.

    Is there a free database somewhere that has the city, state along with the zip code near the middle of the city?

  2. #2
    Join Date
    Jan 2006
    Fox Lake, IL

    Re: Finding distance between two cities

    Bing, and Google have MAPS that will do what you want. Depends, on, a specific route, or just as-the-crow-flies.

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  3. #3
    Join Date
    Feb 2011
    United States

    Re: Finding distance between two cities

    The data available from the US Geological Survey (USGS) may be of interest: http://geonames.usgs.gov/domestic/download_data.htm Cities seem to be generically refered to as "Populated Place" features.

    For locales outside of the US, you might use the information from the National Geospatial Intelligence Agency available at: http://earth-info.nga.mil/gns/html/cntry_files.html

    The datafiles for the USGS (I didn't look at the NGIA ones) contain a long/lat for each feature. Presumably you could implement distance measures based on those (which I sure are described elsewhere; distance along a sphere is a solved problem - though if memory serves, last time I looked into it, I decided it was a bit of a complicated pain in the ***...)

    I hope that helps!
    Best Regards,

    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.