X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=makefile;h=5384ded55875ebdf6de7e85eb0a656d0191aba41;hb=935a6ead0912829a7e0f153aa7aac7494977e69c;hp=2c20ffc4f90989ffa09bfa4b0172e54e900ff17e;hpb=b6cea827835222aa38004dd599e24c3ecc5c596b;p=dead%2Fcensus-tools.git diff --git a/makefile b/makefile index 2c20ffc..5384ded 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,14 @@ -DB_NAME='census2000' +DB_NAME='census' DB_USER='postgres' TIGER_DATA_URL='http://www2.census.gov/cgi-bin/shapefiles/multi-file-download?files=24_MARYLAND%2Ftl_2008_24_tabblock00.zip' +TIGER_SRID='4269' +# Starting with PostGIS 1.4.0, these paths are calculated at install +# time using the pg_config utility. Rather than try to guess where +# PostGIS will wind up installed, we can just check the output of +# pg_config ourselves. +PG_BINDIR=`pg_config --bindir` +PG_SHAREDIR=`pg_config --sharedir` # Necessary to run test/data without prerequisites. # @@ -43,9 +50,10 @@ data: # the DB_NAME database (or schema, whatever). Then, it adds PL/pgSQL # support to the database. # -# At that point, we import the two PostGIS files, lwpostgis.sql and -# spatial_ref_sys.sql. These are magic as far as I'm concerned, but -# PostGIS requires them. +# At that point, we import the two PostGIS files, postgis.sql and +# spatial_ref_sys.sql. The postgis.sql file contains the geometry +# functions, while spatial_ref_sys.sql contains a table of SRIDs, and +# their associated properties. PostGIS requires both. # # Then, we import the Tiger data using shp2pgsql. The shapefiles # should exist, since this task depends on the "data" task, which @@ -56,20 +64,24 @@ data: # of the sf1blocks2sql script. # db: data - dropdb -U $(DB_USER) $(DB_NAME) + # Ignore the result of dropdb when it fails. + dropdb -U $(DB_USER) $(DB_NAME) || true createdb -U $(DB_USER) $(DB_NAME) createlang -U $(DB_USER) plpgsql $(DB_NAME) psql -d $(DB_NAME) \ -U $(DB_USER) \ - -f /usr/share/postgresql/contrib/lwpostgis.sql + -f $(PG_SHAREDIR)/contrib/postgis.sql psql -d $(DB_NAME) \ -U $(DB_USER) \ - -f /usr/share/postgresql/contrib/spatial_ref_sys.sql + -f $(PG_SHAREDIR)/contrib/spatial_ref_sys.sql - shp2pgsql -I data/census-2000-block/maryland/tl_2008_24_tabblock00.shp tiger \ - | psql -U $(DB_USER) -d $(DB_NAME) + $(PG_BINDIR)/shp2pgsql -I \ + -s $(TIGER_SRID) \ + data/census-2000-block/maryland/tl_2008_24_tabblock00.shp \ + tiger \ + | psql -U $(DB_USER) -d $(DB_NAME) psql -d $(DB_NAME) \ -U $(DB_USER) \