SHAPELY_URL=http://pypi.python.org/packages/source/S/Shapely/Shapely-1.0.14.tar.gz
-# 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`
+# Dark magic. We set these makefile variables to be the result of the
+# 'shell' function. The shell function, in turn, executes a Python
+# script which determines the locations of these files.
+SHP2PGSQL := $(shell bin/find_file_paths --root /usr --single shp2pgsql)
+POSTGIS_SQL := $(shell bin/find_file_paths --root /usr lwpostgis.sql postgis.sql)
+SPATIAL_REF_SYS_SQL := $(shell bin/find_file_paths --root /usr spatial_ref_sys.sql)
# Necessary to run test/data without prerequisites.
#
# The table already exists, so we can append to it, and we don't have
# to create the GiST index.
for state in data/census2000/*; do \
- $(PG_BINDIR)/shp2pgsql \
+ $(SHP2PGSQL) \
-a \
-s $(TIGER_SRID) \
-D \
- $$state/blocks/*.shp \
+ $$state/blocks/*.shp \
tiger_blocks \
| psql -U $(DB_USER) -d $(DB_NAME); \
done;
for state in data/census2000/*; do \
for shapefile in $$state/lines/*.shp; do \
echo "Importing $$shapefile."; \
- $(PG_BINDIR)/shp2pgsql \
+ $(SHP2PGSQL) \
-a \
-s $(TIGER_SRID) \
$$shapefile \
done; \
done;
- bin/sf1blocks2sql src/Tests/Fixtures/SummaryFile1/mdgeo.uf1 sf1_blocks \
- | psql -U postgres -d $(DB_NAME) \
- > /dev/null
+# Summary File 1
+#
+# Run all of the geo (uf1) files through the import script. This has
+# to happen after the blocks import since we impose a foreign key
+# restriction.
+ for state in data/census2000/*; do \
+ bin/sf1blocks2sql $$state/sf1/*.uf1 sf1_blocks \
+ | psql -U postgres -d $(DB_NAME) \
+ > /dev/null; \
+ done;
createdb -U $(DB_USER) $(DB_NAME)
createlang -U $(DB_USER) plpgsql $(DB_NAME)
- psql -d $(DB_NAME) \
- -U $(DB_USER) \
- -f $(PG_SHAREDIR)/contrib/postgis.sql \
+ psql -d $(DB_NAME) \
+ -U $(DB_USER) \
+ -f $(POSTGIS_SQL) \
> /dev/null
- psql -d $(DB_NAME) \
- -U $(DB_USER) \
- -f $(PG_SHAREDIR)/contrib/spatial_ref_sys.sql \
+ psql -d $(DB_NAME) \
+ -U $(DB_USER) \
+ -f $(SPATIAL_REF_SYS_SQL) \
> /dev/null
# table already exist makes importing via shp2pgsql much easier.
# Any blocks file will work as an argument.
tiger_blocks_table:
- $(PG_BINDIR)/shp2pgsql \
+ $(SHP2PGSQL) \
-p \
-I \
-s $(TIGER_SRID) \
- data/census2000/maryland/blocks/tl_2009_24_tabblock00.shp \
+ data/census2000/maryland/blocks/tl_2009_24_tabblock00.shp \
tiger_blocks \
| psql -U postgres -d $(DB_NAME) \
> /dev/null
# Prepare the tiger_lines table, and create the GiST index on its
# geometry column. Any lines shapefile will do here.
tiger_lines_table:
- $(PG_BINDIR)/shp2pgsql \
+ $(SHP2PGSQL) \
-p \
-I \
-s $(TIGER_SRID) \