DB_NAME=census
DB_USER=postgres
TIGER_SRID=4269
+SHAPELY_URL=http://pypi.python.org/packages/source/S/Shapely/Shapely-1.0.14.tar.gz
# Root folder for the shapefiles.
TIGER_ROOT=http://www2.census.gov/geo/tiger/TIGER2009
# Necessary to run test/data without prerequisites.
#
-.PHONY : test data
+.PHONY : test data lib
# The default task, since it comes first in the list.
#
-all: clean test
+all: clean lib test
test:
./bin/run_tests
+# Download or check out any third-party libraries.
+lib:
+ if [ ! -d lib/Shapely ]; then \
+ wget -O shapely.tar.gz $(SHAPELY_URL); \
+ tar -xvzf shapely.tar.gz -C lib/ ; \
+ rm shapely.tar.gz; \
+ mv lib/Shapely* lib/Shapely; \
+ fi;
+
+
# Remove byte-compiled python code.
#
clean:
# and leave -I out.
for state in data/census2000/*; do \
for shapefile in $$state/lines/*.shp; do \
+ echo "Importing $$shapefile."; \
$(PG_BINDIR)/shp2pgsql \
-a \
-s $(TIGER_SRID) \
- -D \
$$shapefile \
tiger_lines \
- | psql -U $(DB_USER) -d $(DB_NAME); \
+ | bin/filter-transactions \
+ | psql -U $(DB_USER) -d $(DB_NAME) \
+ > /dev/null; \
done; \
done;
tiger_lines \
| psql -U postgres -d $(DB_NAME) \
> /dev/null
+
+# Add a unique index on the "tlid" column.
+ psql -U postgres \
+ -d census \
+ -f sql/create_tlid_unique_index.sql