Changes between Version 47 and Version 48 of InstallationGuidelines/PostgreSQL
- Timestamp:
- 03/11/11 21:10:43 (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
InstallationGuidelines/PostgreSQL
v47 v48 150 150 If using PostGIS, then once the tables have been created: 151 151 {{{ 152 su postgres 153 psql 154 \d sahana 155 # Ensure all POINTs have WKT entries 152 cat << EOF > "/tmp/geometry.sql" 156 153 UPDATE public.gis_location SET wkt = 'POINT (' || lon || ' ' || lat || ')' WHERE gis_feature_type = 1; 157 # Add geometry Column158 154 SELECT AddGeometryColumn( 'public', 'gis_location', 'the_geom', 4326, 'GEOMETRY', 2 ); 159 # Populate existing entries160 155 UPDATE public.gis_location SET the_geom = ST_SetSRID(ST_GeomFromText(wkt), 4326); 161 exit 156 EOF 157 su -c - postgres "psql -q -d sahana -f /tmp/geometry.sql" 162 158 }}} 163 159 (if using Windows can use the Query Editor that comes with pgAdmin III) … … 165 161 Ensure that future entries auto-populate properly: 166 162 {{{ 167 su postgres 168 psql 169 \d sahana 163 cat << EOF > "/tmp/autopopulate.sql" 170 164 CREATE OR REPLACE FUNCTION s3_update_geometry() 171 RETURNS "trigger" AS 172 $BODY$ 165 RETURNS "trigger" AS \$$ 173 166 DECLARE 174 167 BEGIN 175 176 168 if (NEW.wkt != '') then 177 178 169 NEW.the_geom = SetSRID(GeomFromText(NEW.wkt), 4326); 170 end if; 179 171 180 172 RETURN NEW; 181 173 END; 182 $BODY$ 183 LANGUAGE 'plpgsql' VOLATILE; 174 \$$ LANGUAGE 'plpgsql' VOLATILE; 184 175 ALTER FUNCTION s3_update_geometry() OWNER TO sahana; 185 176 CREATE TRIGGER s3_locations_update … … 189 180 EXECUTE PROCEDURE s3_update_geometry(); 190 181 191 exit 182 EOF 183 su -c - postgres "psql -q -d sahana -f /tmp/autopopulate.sql" 192 184 }}} 193 185