#!/bin/bash #=============================================================================== # # FILE: getgeo.sh # # USAGE: ./getgeo.sh # # DESCRIPTION: run the script so that the geodata will be downloaded and inserted into your # database # # OPTIONS: --- # REQUIREMENTS: --- # BUGS: --- # NOTES: --- # AUTHOR: Andreas (aka Harpagophyt ) # COMPANY: http://forum.geonames.org/gforum/posts/list/926.page # VERSION: 1.4 # CREATED: 07/06/2008 # REVISION: 1.1 2008-06-07 replace COPY continentCodes through INSERT statements. # 1.2 2008-11-25 Adjusted by Bastiaan Wakkie in order to not unnessisarily # download. # 1.3 2011-08-07 Updated script with tree changes. Removes 2 obsolete records from "countryinfo" dump image, # updated timeZones table with raw_offset and updated postalcode to varchar(20). # 1.4 2012-03-31 Don Drake - Add FKs after data is loaded, also vacuum analyze tables to ensure FK lookups use PK # - Don't unzip text files # - added DROP TABLE # 1.5 2012-06-30 Furdui Marian - added CountryCode to TimeZones and updated geonames.alternatenames to varchar(8000) #=============================================================================== /bin/date WORKPATH="${HOME}/tmp/GIS/gisnames/geodata" TMPPATH="tmp" PCPATH="pc" PREFIX="_" DBHOST="127.0.0.1" DBPORT="5432" DBUSER="quadrocube" FILES="allCountries.zip" psql -U $DBUSER -h $DBHOST -p $DBPORT -c "CREATE DATABASE geonames WITH TEMPLATE = template0 ENCODING = 'UTF8';" psql -U $DBUSER -h $DBHOST -p $DBPORT geonames < point(40,40) from quad_point_tbl order by p <-> point(40,40) limit 500; explain (analyze on, buffers on) select *, p <-> point(40,40) from kd_point_tbl order by p <-> point(40,40) limit 500; explain (analyze on, buffers on) select *, p <-> point(40,40) from gist_point_tbl order by p <-> point(40,40) limit 500; explain (analyze on, buffers on) select *, p <-> point(40,40) from plain_point_tbl order by p <-> point(40,40) limit 500; EOT echo "'----- DONE" /bin/date