Prepare for PostGISΒΆ
Install PostGIS
Postgis setup is described here:
Spatially enabling a PostgreSQL database needs the following steps from the command line:
createlang plpgsql [yourdatabase] psql -d [yourdatabase] -f lwpostgis.sql psql -d [yourdatabase] -f spatial_ref_sys.sql
Creating the tile table:
CREATE TABLE tiles0(location CHAR(64) NOT NULL ,data BYTEA,CONSTRAINT tiles0_PK PRIMARY KEY(location)) Creating the spatial table CREATE TABLE spatial0 (location CHAR(64) NOT NULL ,CONSTRAINT spatial0_PK PRIMARY KEY(location))
or creating all in one table:
CREATE TABLE spatial0 (location CHAR(64) NOT NULL ,CONSTRAINT spatial0_PK PRIMARY KEY(location))
Now register the geometry attribute, the third value is the EPSG Code for your coordinate reference system, 4326 is WGS84:
SELECT AddGeometryColumn('spatial0','geom',4326,'MULTIPOLYGON',2)