5 # URLs for the TIGER/Line block-level shapefiles.
6 TIGER_ROOT=http://www2.census.gov/geo/tiger/TIGER2009
7 MD_BLOCKS_URL=$(TIGER_ROOT)/24_MARYLAND/tl_2009_24_tabblock00.zip
8 VA_BLOCKS_URL=$(TIGER_ROOT)/51_VIRGINIA/tl_2009_51_tabblock00.zip
9 PA_BLOCKS_URL=$(TIGER_ROOT)/42_PENNSYLVANIA/tl_2009_42_tabblock00.zip
10 NY_BLOCKS_URL=$(TIGER_ROOT)/36_NEW_YORK/tl_2009_36_tabblock00.zip
12 # Starting with PostGIS 1.4.0, these paths are calculated at install
13 # time using the pg_config utility. Rather than try to guess where
14 # PostGIS will wind up installed, we can just check the output of
15 # pg_config ourselves.
16 PG_BINDIR=`pg_config --bindir`
17 PG_SHAREDIR=`pg_config --sharedir`
19 # Necessary to run test/data without prerequisites.
24 # The default task, since it comes first in the list.
33 # Remove byte-compiled python code.
36 find ./ -name '*.pyc' -print0 | xargs -0 rm -f
39 # Download the shapefiles from Tiger if they don't already exist.
40 # For now, we're only dealing with the Census 2000 Maryland Block
41 # data, so the filenames are hard-coded. Easy enough to change.
45 tiger_blocks: md_blocks va_blocks pa_blocks ny_blocks
48 mkdir -p data/census2000/maryland/block
49 if [ ! -f data/census2000/maryland/block/tl_2009_24_tabblock00.shp ]; \
51 wget -O mdblocks.zip $(MD_BLOCKS_URL); \
52 unzip mdblocks.zip -d ./data/census2000/maryland/block; \
57 mkdir -p data/census2000/virginia/block
58 if [ ! -f data/census2000/virginia/block/tl_2009_51_tabblock00.shp ]; \
60 wget -O vablocks.zip $(VA_BLOCKS_URL); \
61 unzip vablocks.zip -d ./data/census2000/virginia/block; \
66 mkdir -p data/census2000/pennsylvania/block
67 if [ ! -f data/census2000/pennsylvania/block/tl_2009_42_tabblock00.shp ]; \
69 wget -O pablocks.zip $(PA_BLOCKS_URL); \
70 unzip pablocks.zip -d ./data/census2000/pennsylvania/block; \
75 mkdir -p data/census2000/new_york/block
76 if [ ! -f data/census2000/new_york/block/tl_2009_36_tabblock00.shp ]; \
78 wget -O nyblocks.zip $(NY_BLOCKS_URL); \
79 unzip nyblocks.zip -d ./data/census2000/new_york/block; \
84 # This task does a couple of things. First, it drops and re-creates
85 # the DB_NAME database (or schema, whatever). Then, it adds PL/pgSQL
86 # support to the database.
88 # At that point, we import the two PostGIS files, postgis.sql and
89 # spatial_ref_sys.sql. The postgis.sql file contains the geometry
90 # functions, while spatial_ref_sys.sql contains a table of SRIDs, and
91 # their associated properties. PostGIS requires both.
93 # Then, we import the Tiger data using shp2pgsql. The shapefiles
94 # should exist, since this task depends on the "data" task, which
95 # downloads said shapefiles.
97 # Finally, we create the table for the demographic data (obtained from
98 # the geographic header records), and populate that table with the output
99 # of the sf1blocks2sql script.
102 # Ignore the result of dropdb when it fails.
103 dropdb -U $(DB_USER) $(DB_NAME) || true
104 createdb -U $(DB_USER) $(DB_NAME)
105 createlang -U $(DB_USER) plpgsql $(DB_NAME)
109 -f $(PG_SHAREDIR)/contrib/postgis.sql
113 -f $(PG_SHAREDIR)/contrib/spatial_ref_sys.sql
118 $(PG_BINDIR)/shp2pgsql \
122 data/census2000/maryland/block/tl_2009_24_tabblock00.shp \
124 | psql -U $(DB_USER) -d $(DB_NAME)
129 $(PG_BINDIR)/shp2pgsql -a \
133 data/census2000/virginia/block/tl_2009_51_tabblock00.shp \
135 | psql -U $(DB_USER) -d $(DB_NAME)
138 # Pennsylvania Blocks
140 $(PG_BINDIR)/shp2pgsql -a \
144 data/census2000/pennsylvania/block/tl_2009_42_tabblock00.shp \
146 | psql -U $(DB_USER) -d $(DB_NAME)
151 $(PG_BINDIR)/shp2pgsql -a \
155 data/census2000/new_york/block/tl_2009_36_tabblock00.shp \
157 | psql -U $(DB_USER) -d $(DB_NAME)
162 -f sql/create-sf1_blocks-table.sql
164 bin/sf1blocks2sql src/Tests/Fixtures/SummaryFile1/mdgeo.uf1 sf1_blocks \
165 | psql -U postgres -d $(DB_NAME) > /dev/null