From: Regina Obe Date: Sat, 28 May 2011 11:18:24 +0000 (+0000) Subject: fix for #995 handling lower level fips. Also many fixes for #908 sh tiger loader... X-Git-Tag: 2.0.0alpha1~1536 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b45540056d46bf8ed580881be928f3b9b9d17b46;p=postgis fix for #995 handling lower level fips. Also many fixes for #908 sh tiger loader profile. Testing now and will close out if confirmed its fixed. Also put in a note in the .sh and .bat that for PostgreSQL 9.1+ have to install fuzzystrmatch with the CREATE EXTENSION syntax git-svn-id: http://svn.osgeo.org/postgis/trunk@7278 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/extras/tiger_geocoder/tiger_2010/README b/extras/tiger_geocoder/tiger_2010/README index 078acbde2..d2f913b00 100644 --- a/extras/tiger_geocoder/tiger_2010/README +++ b/extras/tiger_geocoder/tiger_2010/README @@ -35,11 +35,9 @@ first opening up a commandline and executing the file. That will keep the window open for you to see the error. ---To generate a linux script (We haven't tested the linux script yet so may need some changes) +--To generate a linux script SELECT loader_generate_script(ARRAY['DC','RI'], 'sh'); - - 9. Copy and paste the generated script into a .bat or .sh file and put in gisdata folder you created and then run it. 10. Test out the geocoder run this query diff --git a/extras/tiger_geocoder/tiger_2010/create_geocode.bat b/extras/tiger_geocoder/tiger_2010/create_geocode.bat index c9bc8aa1f..f4bdb3e6c 100644 --- a/extras/tiger_geocoder/tiger_2010/create_geocode.bat +++ b/extras/tiger_geocoder/tiger_2010/create_geocode.bat @@ -4,9 +4,11 @@ set PGHOST=localhost set PGUSER=postgres set PGPASSWORD=yourpasswordhere set THEDB=geocoder -set PGBIN=C:\Program Files\PostgreSQL\8.4\bin -set PGCONTRIB=C:\Program Files\PostgreSQL\8.4\share\contrib +set PGBIN=C:\Program Files\PostgreSQL\9.0\bin +set PGCONTRIB=C:\Program Files\PostgreSQL\9.0\share\contrib "%PGBIN%\psql" -d "%THEDB%" -f "%PGCONTRIB%\fuzzystrmatch.sql" +REM If you are using PostgreSQL 9.1 or above, use the extension syntax instead as shown below +REM "%PGBIN%\psql" -d "%THEDB%" -c "CREATE EXTENSION fuzzystrmatch" "%PGBIN%\psql" -d "%THEDB%" -c "CREATE SCHEMA tiger" "%PGBIN%\psql" -d "%THEDB%" -f "tables\lookup_tables_2010.sql" "%PGBIN%\psql" -d "%THEDB%" -c "CREATE SCHEMA tiger_data" diff --git a/extras/tiger_geocoder/tiger_2010/create_geocode.sh b/extras/tiger_geocoder/tiger_2010/create_geocode.sh index 43ca96abb..b518764d0 100644 --- a/extras/tiger_geocoder/tiger_2010/create_geocode.sh +++ b/extras/tiger_geocoder/tiger_2010/create_geocode.sh @@ -7,7 +7,9 @@ PGPASSWORD=yourpasswordhere THEDB=geocoder PSQL_CMD=/usr/bin/psql PGCONTRIB=/usr/share/postgresql/contrib +#if you are on 9.1+ use the CREATE EXTENSION syntax instead ${PSQL_CMD} -d "${THEDB}" -f "${PGCONTRIB}/fuzzystrmatch.sql" +#${PSQL_CMD} -d "${THEDB}" -c "CREATE EXTENSION fuzzystrmatch" ${PSQL_CMD} -d "${THEDB}" -c "CREATE SCHEMA tiger" ${PSQL_CMD} -d "${THEDB}" -f "tables/lookup_tables_2010.sql" ${PSQL_CMD} -d "${THEDB}" -c "CREATE SCHEMA tiger_data" diff --git a/extras/tiger_geocoder/tiger_2010/tiger_loader.sql b/extras/tiger_geocoder/tiger_2010/tiger_loader.sql index 7d7ed793b..799c56cb7 100644 --- a/extras/tiger_geocoder/tiger_2010/tiger_loader.sql +++ b/extras/tiger_geocoder/tiger_2010/tiger_loader.sql @@ -54,22 +54,22 @@ STATEDIR="${staging_fold}/${website_root}/${state_fold}" TMPDIR="${staging_fold}/temp/" UNZIPTOOL=unzip WGETTOOL="/usr/bin/wget" -PGBIN="/usr/bin" -PGPORT=5432 -PGHOST=localhost -PGUSER=postgres -PGPASSWORD=yourpasswordhere -PGDATABASE=geocoder -PSQL=psql -SHP2PGSQL=shp2pgsql +PGBIN="/usr/pgsql-9.0/bin" +export PGPORT=5432 +export PGHOST=localhost +export PGUSER=postgres +export PGPASSWORD=yourpasswordhere +export PGDATABASE=geocoder +PSQL=${PGBIN}/psql +SHP2PGSQL=${PGBIN}/shp2pgsql ', E'rm -f ${TMPDIR}/*.* ${PSQL} -c "DROP SCHEMA tiger_staging CASCADE;" ${PSQL} -c "CREATE SCHEMA tiger_staging;" cd $STATEDIR -for z in *.zip do $UNZIPTOOL -o -d $TMPDIR $z -for z in */*.zip do $UNZIPTOOL -o -d $TMPDIR $z -cd $TMPDIR', '${PSQL}', '/', '${SHP2PGSQL}', 'export ', -'for z in *${table_name}.dbf do +for z in *.zip; do $UNZIPTOOL -o -d $TMPDIR $z; done +for z in */*.zip; do $UNZIPTOOL -o -d $TMPDIR $z; done +cd $TMPDIR;\n', '${PSQL}', '/', '${SHP2PGSQL}', 'export ', +'for z in *${table_name}.dbf; do ${loader} -s 4269 -g the_geom -W "latin1" $z ${staging_schema}.${state_abbrev}_${table_name} | ${psql} ${PSQL} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));" done'); @@ -219,8 +219,8 @@ SELECT ARRAY[platform.psql, variables.data_schema, variables.staging_schema, variables.staging_fold, s.state_fold,variables.website_root, s.state_abbrev, s.state_fips::text]) AS shell_code FROM loader_variables As variables - CROSS JOIN (SELECT name As state, abbrev As state_abbrev, st_code As state_fips, - st_code || '_' + CROSS JOIN (SELECT name As state, abbrev As state_abbrev, lpad(st_code::text,2,'0') As state_fips, + lpad(st_code::text,2,'0') || '_' || replace(name, ' ', '_') As state_fold FROM state_lookup) As s CROSS JOIN loader_platform As platform WHERE $1 @> ARRAY[state_abbrev::text] -- If state is contained in list of states input generate script for it