Make City Location Files

[Home]   [Puzzles & Projects]    [Delphi Techniques]   [Math topics]   [Library]   [Utilities]




Search WWW


As of October, 2016, Embarcadero is offering a free release of Delphi (Delphi 10.1 Berlin Starter Edition ).     There are a few restrictions, but it is a welcome step toward making more programmers aware of the joys of Delphi.  They do say "Offer may be withdrawn at any time", so don't delay if you want to check it out.  Please use the feedback link to let me know if the link stops working.


Support DFF - Shop

 If you shop at Amazon anyway,  consider using this link. 


We receive a few cents from each purchase.  Thanks


Support DFF - Donate

 If you benefit from the website,  in terms of knowledge, entertainment value, or something otherwise useful, consider making a donation via PayPal  to help defray the costs.  (No PayPal account necessary to donate via credit card.)  Transaction is secure.

Mensa Daily Puzzlers

For over 15 years Mensa Page-A-Day calendars have provided several puzzles a year for my programming pleasure.  Coding "solvers" is most fun, but many programs also allow user solving, convenient for "fill in the blanks" type.  Below are Amazon  links to the two most recent years.

Mensa 365 Puzzlers  Calendar 2017

Mensa 365 Puzzlers Calendar 2018

(Hint: If you can wait, current year calendars are usually on sale in January.)


Feedback:  Send an e-mail with your comments about this program (or anything else).

Search only





I recently updated our Traveling Salesman Program to replace pixel city locations with more useful latitude/longitude coordinates.  In the process I found myself in need of a "master" file of cities and their locations to simplify extracting a subset for map display of a subset for a particular TSP problem.  (There are on the order of 50,000 US cities making it impractical to display them all.)


Searching the web for a master file did not yield any usable results, but I did find a master "zip code" file at   One minor problem with using this file, is that the mapping is not unique.  In fact the same city name may map to multiple zip codes and a single zip code can have multiple "city" names  associated with it.  For example, 72 different zip codes all can be referred to as Pittsburgh,  many of them have alternate names.  Zip code 15235 for example officially refers to  Pleasant Hills and West Mifflin as well as Pittsburgh and several abbreviations of these names.   My solution was to average the coordinates for all records which could officially refer to each city name and retain that one averaged record for my output file.


The program itself should be easy to use, my master file, 'free-zipcode-database-abbreviated.csv' contains only the first few fields we need from the master zip code file downloaded from the site referenced above. This is simple a space saving measure (2.5mb for the abbreviated file compared to 12.5mb for the full file).  The abbreviated file is read and summarized by city at startup time.  The results are listed in the a list box on the left side of the form.  A city list to save may be built by clicking on city records from this list.  Selected records are added to the right side list box.  You may also load your own list (or a list previously built by this program). Only first two fields (Cityname and State Id) separated by commas are used from this input file.  Records have latitudes and longitudes in decimal degrees  added from the right side list box if a match is  found.  These are saved as 3rd and 4th comma separated fields if the left side list is saved.      


Clicking on the right side list entry will add that entry to the left side list if it is not already there.  Clicking an entry in the left side list will remove it. 


Input file names are save in a an "init" file, makeCityLocation.ini and become the default names for future runs.  The initial file names reflect the files included in the downloads below: 'free-zipcode-database-abbreviated.csv' and 'CityList.txt'.



Running/Exploring the Program 


Download Source

Download Executable


Created: August 24, 2011

Modified: May 11, 2018

  [Feedback]   [Newsletters (subscribe/view)] [About me]
Copyright 2000-2018, Gary Darby    All rights reserved.