--- /dev/null
+--$Id$
+--
+-- PostGIS - Spatial Types for PostgreSQL
+-- http://www.postgis.org
+--
+-- Copyright (C) 2010, 2011 Regina Obe and Leo Hsu
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--
+-- Author: Regina Obe and Leo Hsu <lr@pcorp.us>
+--
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+--
+SELECT tiger.SetSearchPathForInstall('tiger');
+
+CREATE OR REPLACE FUNCTION install_geocode_settings()
+ RETURNS void AS
+$$
+DECLARE var_temp text;
+BEGIN
+ var_temp := tiger.SetSearchPathForInstall('tiger'); /** set setach path to have tiger in front **/
+ IF NOT EXISTS(SELECT table_name FROM information_schema.columns WHERE table_schema = 'tiger' AND table_name = 'geocode_settings') THEN
+ CREATE TABLE geocode_settings(name text primary key, setting text, unit text, category text, short_desc text);
+ END IF;
+ --add missing settings
+ INSERT INTO geocode_settings(name,setting,unit,category,short_desc)
+ SELECT f.*
+ FROM
+ (VALUES ('debug_geocode_address', 'false', 'boolean','debug', 'outputs debug information in notice log such as queries when geocode_addresss is called if true')
+ , ('debug_geocode_intersection', 'false', 'boolean','debug', 'outputs debug information in notice log such as queries when geocode_intersection is called if true')
+ , ('debug_normalize_address', 'false', 'boolean','debug', 'outputs debug information in notice log such as queries and intermediate expressions when normalize_address is called if true')
+ , ('debug_reverse_geocode', 'false', 'boolean','debug', 'if true, outputs debug information in notice log such as queries and intermediate expressions when reverse_geocode')
+ ) f(name,setting,unit,category,short_desc)
+ WHERE f.name NOT IN(SELECT name FROM geocode_settings);
+END;
+$$
+language plpgsql;
+
+SELECT install_geocode_settings(); /** create the table if it doesn't exist **/
+
+CREATE OR REPLACE FUNCTION get_geocode_setting(setting_name text)
+RETURNS text AS
+$$
+SELECT setting FROM geocode_settings WHERE name = $1;
+$$
+language sql STABLE;
+
+CREATE OR REPLACE FUNCTION set_geocode_setting(setting_name text, setting_value text)
+RETURNS text AS
+$$
+UPDATE geocode_settings SET setting = $2 WHERE name = $1
+ RETURNING setting;
+$$
+language sql VOLATILE;
-- the below call will put tiger schema in front so all objects in this script
-- will get created in search path
SELECT tiger.SetSearchPathForInstall('tiger');
+--this is used currently for debugging
+\i geocode_settings.sql
--this will fail if the column already exists which is fine
ALTER TABLE state_lookup ADD COLUMN statefp char(2);
UPDATE state_lookup SET statefp = lpad(st_code::text,2,'0') WHERE statefp IS NULL;
DROP FUNCTION IF EXISTS interpolate_from_address(integer, integer, integer, geometry); /**don't need this since got collapes into varchar version **/
-- this will fail if already exists, that is fine. can't use IF NOT EXISTS until 9.1
-
+SELECT tiger.SetSearchPathForInstall('tiger');
CREATE TABLE addrfeat
(
gid serial not null primary key,
SELECT name, abbrev, false
FROM temp_types As t
WHERE t.name NOT IN(SELECT name FROM street_type_lookup);
-
+
+SELECT tiger.SetSearchPathForInstall('tiger');
-- new census loader
\i census_loader.sql
--create parent tables for census