2012-12-11 21:47:53.437879+01 by Dan Lyke 0 comments
The PostGIS-users mailing list just had an announcement from Jack Varga for the GeoNames for PostGIS utility which grabs the GeoNames database and updates your local database appropriately.
If using geonames you may find this useful. Checks timestamps, downloads most current, creates database (includes schema), indexes, clusters, and assigns ownership. Documentation included. Currently only grabs US postal codes but easily adaptable to grab any country's postal codes. Makes a nice foundation for a simple location based service.
The email suggested that you could combine this with the Indexed Nearest Neighbour Search in PostGIS to do something like find the 10 nearest hotels to Boulder:
SELECT name, fcode FROM geonames WHERE fcode = 'HTL' ORDER BY geom <-> st_setsrid(st_makepoint(-105.27997,40.01789),4326) LIMIT 10;