]> gitweb.michael.orlitzky.com - dead/census-tools.git/blobdiff - makefile
Added the "lib" makefile task.
[dead/census-tools.git] / makefile
index b7ef3c24eea0b7dae47d776351dd2e0fd3527e25..691e1943f3c230abebaac57f100f0df6b1fe1f2d 100644 (file)
--- a/makefile
+++ b/makefile
@@ -1,6 +1,7 @@
 DB_NAME=census
 DB_USER=postgres
 TIGER_SRID=4269
+SHAPELY_URL=http://svn.gispython.org/svn/gispy/Shapely/trunk
 
 # Root folder for the shapefiles.
 TIGER_ROOT=http://www2.census.gov/geo/tiger/TIGER2009
@@ -28,18 +29,28 @@ PG_SHAREDIR=`pg_config --sharedir`
 
 # 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                \
+               cd lib/Shapely;                    \
+               svn update;                        \
+       else                                       \
+               svn co $(SHAPELY_URL) lib/Shapely; \
+       fi;
+
+
 # Remove byte-compiled python code.
 #
 clean:
@@ -129,13 +140,15 @@ db: data newdb tiger_blocks_table tiger_lines_table sf1_blocks_table
 # 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;
 
@@ -203,3 +216,8 @@ tiger_lines_table:
                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