X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=makefile;h=155910a68c03a8598a64c5d987999dadca886fb8;hb=0e8428f00f565a3e1791e19098ab59442972fa09;hp=693b1c0b6d7af025f24ff0024d6d74e696e776b0;hpb=98eb1ef7be81064a5e6af3cd1b332b72d8173fe7;p=dead%2Fcensus-tools.git diff --git a/makefile b/makefile index 693b1c0..155910a 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,15 @@ 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_DATA_URL='http://www2.census.gov/geo/tiger/TIGER2009/24_MARYLAND/tl_2009_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. # .PHONY : test data @@ -28,14 +35,11 @@ clean: # data, so the filenames are hard-coded. Easy enough to change. # data: - mkdir -p data/census-2000-block/maryland/ - if [ ! -f data/census-2000-block/maryland/tl_2008_24_tabblock00.shp ]; then \ - wget -O tiger.zip $(TIGER_DATA_URL); \ - unzip tiger.zip; \ - rm tiger.zip; \ - unzip srv/ftp/geo/tiger/TIGER2008/24_MARYLAND/tl_2008_24_tabblock00.zip \ - -d ./data/census-2000-block/maryland/; \ - rm -rf srv; \ + mkdir -p data/census2000/maryland/block + if [ ! -f data/census2000/maryland/block/tl_2009_24_tabblock00.shp ]; then \ + wget -O tmp.zip $(TIGER_DATA_URL); \ + unzip tmp.zip -d ./data/census2000/maryland/block; \ + rm tmp.zip; \ fi; @@ -43,8 +47,8 @@ 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. The lwpostgis.sql file contains the geometry +# 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. # @@ -57,22 +61,23 @@ 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 \ + $(PG_BINDIR)/shp2pgsql -I \ -s $(TIGER_SRID) \ - data/census-2000-block/maryland/tl_2008_24_tabblock00.shp \ - tiger \ + data/census2000/maryland/block/tl_2009_24_tabblock00.shp \ + tiger_blocks \ | psql -U $(DB_USER) -d $(DB_NAME) psql -d $(DB_NAME) \