]> granicus.if.org Git - postgis/commitdiff
fix for #995 handling lower level fips. Also many fixes for #908 sh tiger loader...
authorRegina Obe <lr@pcorp.us>
Sat, 28 May 2011 11:18:24 +0000 (11:18 +0000)
committerRegina Obe <lr@pcorp.us>
Sat, 28 May 2011 11:18:24 +0000 (11:18 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7278 b70326c6-7e19-0410-871a-916f4a2858ee

extras/tiger_geocoder/tiger_2010/README
extras/tiger_geocoder/tiger_2010/create_geocode.bat
extras/tiger_geocoder/tiger_2010/create_geocode.sh
extras/tiger_geocoder/tiger_2010/tiger_loader.sql

index 078acbde2d72f50a240d1e6e1c89c147c285478e..d2f913b008209e45f57a1c6f66872012bae1fca7 100644 (file)
@@ -35,11 +35,9 @@ first opening up a commandline and executing the file.
 \r
 That will keep the window open for you to see the error.\r
 \r
---To generate a linux script (We haven't tested the linux script yet so may need some changes)\r
+--To generate a linux script\r
 SELECT loader_generate_script(ARRAY['DC','RI'], 'sh');\r
 \r
-\r
-\r
 9. Copy and paste the generated script into a .bat or .sh file and put in gisdata folder you created and then run it.\r
 \r
 10. Test out the geocoder run this query\r
index c9bc8aa1ffc6c734d34baf64a500dfd8f0af37ab..f4bdb3e6c2ec8d7f333aacba4cb32b9a9904011e 100644 (file)
@@ -4,9 +4,11 @@ set PGHOST=localhost
 set PGUSER=postgres\r
 set PGPASSWORD=yourpasswordhere\r
 set THEDB=geocoder\r
-set PGBIN=C:\Program Files\PostgreSQL\8.4\bin\r
-set PGCONTRIB=C:\Program Files\PostgreSQL\8.4\share\contrib\r
+set PGBIN=C:\Program Files\PostgreSQL\9.0\bin\r
+set PGCONTRIB=C:\Program Files\PostgreSQL\9.0\share\contrib\r
 "%PGBIN%\psql" -d "%THEDB%" -f "%PGCONTRIB%\fuzzystrmatch.sql"\r
+REM If you are using PostgreSQL 9.1 or above, use the extension syntax instead as shown below\r
+REM "%PGBIN%\psql"  -d "%THEDB%" -c "CREATE EXTENSION fuzzystrmatch" \r
 "%PGBIN%\psql"  -d "%THEDB%" -c "CREATE SCHEMA tiger"\r
 "%PGBIN%\psql"  -d "%THEDB%" -f "tables\lookup_tables_2010.sql"\r
 "%PGBIN%\psql"  -d "%THEDB%" -c "CREATE SCHEMA tiger_data"\r
index 43ca96abbfe35931e6167f25e9374e674713f6b0..b518764d033c64bacd8a3aa86d6f4e065d64aae2 100644 (file)
@@ -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"
index 7d7ed793b05a51eb0d590a163500b7c7b2775f0c..799c56cb7862c4658cfcc929c04f5d1249ea5282 100644 (file)
@@ -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