From 9dd73a73e5e4f4df6cd3d270494fb88e96c1d914 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Tue, 6 Jun 2017 14:33:21 +0700 Subject: [PATCH 01/10] add combobox for selecting crs --- PyQt4Dialogs.py | 63 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 57 insertions(+), 6 deletions(-) diff --git a/PyQt4Dialogs.py b/PyQt4Dialogs.py index 8fb0bc3..25297d4 100755 --- a/PyQt4Dialogs.py +++ b/PyQt4Dialogs.py @@ -183,25 +183,43 @@ def __init__(self): None, Qt.WindowStaysOnTopHint) # initialize ui self.connection = None + self.crs = None self.setup_ui() self.populate_database_choices() + self.populate_crs_choices() def get_database_connection(self): return self.connection + def get_crs(self): + return self.crs + def populate_database_choices(self): """ Populate database connection choices """ self.cmbbx_conn.clear() settings = QSettings() settings.beginGroup('PostgreSQL/connections') - self.cmbbx_conn.addItem(_from_utf8("")) - self.cmbbx_conn.setItemText(0, QApplication.translate( - "DatabaseConnectionDialog", "", None)) for index, database in enumerate(settings.childGroups()): - self.cmbbx_conn.addItem(_from_utf8("")) - self.cmbbx_conn.setItemText(index + 1, QApplication.translate( - "DatabaseConnectionDialog", database, None)) + self.cmbbx_conn.addItem(database) + + def populate_crs_choices(self): + """ Populate crs choices. + """ + crs_options = [ + { + 'auth_id': 32631, + 'crs_name': 'WGS 84 / UTM zone 31N' + }, + { + 'auth_id': 32632, + 'crs_name': 'WGS 84 / UTM zone 32N' + } + ] + + for index, crs_option in enumerate(crs_options): + self.combobox_crs.addItem(crs_option['crs_name']) + self.combobox_crs.setItemData(index, crs_option, Qt.UserRole) def test_database_connection(self): """ Test database connection has necessary tables @@ -214,6 +232,17 @@ def test_database_connection(self): "Please select a database connection") else: self.connection = connection + + crs_index = self.combobox_crs.currentIndex() + if not bool(self.combobox_crs.itemData(crs_index, Qt.UserRole)): + QMessageBox.information( + self, + "Coordinate Reference System (CRS)", + "Please select a Coordinate Reference System (CRS)") + else: + self.crs = self.combobox_crs.itemData(crs_index, Qt.UserRole) + + if self.connection and self.crs: self.accept() def setup_ui(self): @@ -258,6 +287,13 @@ def setup_ui(self): self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.formLayout.setLayout( 1, QFormLayout.FieldRole, self.horizontalLayout) + # crs combobox start here + self.label_crs = QLabel(self) + self.label_crs.setObjectName(_from_utf8("label_crs")) + self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_crs) + self.combobox_crs = QComboBox(self) + self.combobox_crs.setObjectName(_from_utf8("combobox_crs")) + self.formLayout.setWidget(2, QFormLayout.FieldRole, self.combobox_crs) self.verticalLayout.addSpacerItem(QSpacerItem(50, 10)) self.btnbx_options = XQDialogButtonBox(self) self.btnbx_options.setOrientation(Qt.Horizontal) @@ -278,6 +314,11 @@ def setup_ui(self): "Connection: ", None )) + self.label_crs.setText(QApplication.translate( + "DatabaseConnectionDialog", + "CRS: ", + None + )) self.lbl_instr.setText(QApplication.translate( "DatabaseConnectionDialog", "A database connection has not yet been selected or " @@ -285,6 +326,16 @@ def setup_ui(self): "define a new connection.", None )) + self.btn_new_conn.setToolTip(QApplication.translate( + "DatabaseConnectionDialog", + "Add new PostgreSQL connection", + None + )) + self.btn_refresh_conn.setToolTip(QApplication.translate( + "DatabaseConnectionDialog", + "Refresh available PostgreSQL connection", + None + )) # connect ui widgets self.btnbx_options.accepted.connect(self.test_database_connection) self.btnbx_options.rejected.connect(self.reject) From 2815e143c6946c95f4beb8d2a68d46c9bc9abd73 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Tue, 6 Jun 2017 14:35:11 +0700 Subject: [PATCH 02/10] set layer's crs added by the plugin to the selected crs --- plugin.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index 1e4e2d1..b8450a3 100644 --- a/plugin.py +++ b/plugin.py @@ -162,7 +162,7 @@ def remove_plugin_toolbar(self): self.iface.mainWindow().removeToolBar(self.plugin_toolbar) self.plugin_toolbar.hide() - def set_database_connection(self, connection=None): + def set_database_connection(self, connection=None, crs=None): """ Create a database connection """ # fetch settings @@ -171,6 +171,7 @@ def set_database_connection(self, connection=None): settings_plugin.beginGroup(metadata.name().replace(" ", "_")) settings_postgis.beginGroup('PostgreSQL/connections') self.connection = connection + self.crs = crs if not bool(self.connection): # fetch pre-chosen database connection self.connection = settings_plugin.value("DatabaseConnection", None) @@ -178,13 +179,15 @@ def set_database_connection(self, connection=None): if bool(self.connection): if self.connection not in settings_postgis.childGroups(): settings_plugin.setValue("DatabaseConnection", "") - connection = None + self.connection = None # fetch from user if necessary if not bool(self.connection): dialog = DatabaseConnectionDialog() dialog.show() if bool(dialog.exec_()): self.connection = dialog.get_database_connection() + self.crs = QgsCoordinateReferenceSystem( + dialog.get_crs().get('auth_id')) settings_plugin.setValue("DatabaseConnection", self.connection) # validate database connection if bool(self.connection): @@ -299,6 +302,8 @@ def refresh_layers(self): required_layer.layer = layer self.iface.legendInterface().setLayerVisible( layer, True) + if self.crs: + layer.setCrs(self.crs) self.iface.zoomToActiveLayer() def manage_beacons(self): @@ -345,9 +350,10 @@ def manage_database_connection(self): """ Action to select the db connection to work with. """ database_manager = DatabaseManager() - connection = database_manager.current_connection + connection = database_manager.get_current_connection() + crs = database_manager.get_current_crs() if connection: - self.set_database_connection(connection=connection) + self.set_database_connection(connection=connection, crs=crs) class DatabaseManager(): @@ -356,13 +362,23 @@ def __init__(self): self.dialog = DatabaseConnectionDialog() self.dialog.show() self.current_connection = None + self.current_crs = None if bool(self.dialog.exec_()): self.current_connection = self.dialog.get_database_connection() + self.current_crs = self.dialog.get_crs() settings_plugin = QSettings() settings_plugin.beginGroup(metadata.name().replace(" ", "_")) settings_plugin.setValue( "DatabaseConnection", self.current_connection) + def get_current_connection(self): + + return self.current_connection + + def get_current_crs(self): + + return self.current_crs + class BeaconManager(): From 3eff61b2b8ebfc536b30265ad8a574e48ba9114d Mon Sep 17 00:00:00 2001 From: myarjunar Date: Tue, 6 Jun 2017 14:56:26 +0700 Subject: [PATCH 03/10] set layer crs patch --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index b8450a3..2fdaa7d 100644 --- a/plugin.py +++ b/plugin.py @@ -171,7 +171,7 @@ def set_database_connection(self, connection=None, crs=None): settings_plugin.beginGroup(metadata.name().replace(" ", "_")) settings_postgis.beginGroup('PostgreSQL/connections') self.connection = connection - self.crs = crs + self.crs = QgsCoordinateReferenceSystem(crs.get('auth_id')) if not bool(self.connection): # fetch pre-chosen database connection self.connection = settings_plugin.value("DatabaseConnection", None) From 544b446650172570fa5302c8c0f05c06f7b9cf08 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Fri, 23 Jun 2017 19:12:19 +0700 Subject: [PATCH 04/10] add new ddl script from Admire --- scripts/database_setup.sql | 993 +++++++------------------------------ 1 file changed, 167 insertions(+), 826 deletions(-) diff --git a/scripts/database_setup.sql b/scripts/database_setup.sql index 81a9f91..993752e 100755 --- a/scripts/database_setup.sql +++ b/scripts/database_setup.sql @@ -1,15 +1,15 @@ --- Run the file to create a database ---psql -d gis -p 25432 -U username -h localhost -f sml_database_ddl.sql --variable=CRS=3857 --- where 3857 is the name of the coordinate reference system +-- Do not run the sql file as is. Replace :CRS with a custom crs before running +-- Create a database and run the following sql file -- -- PostgreSQL database dump -- --- Dumped from database version 9.5.6 --- Dumped by pg_dump version 9.5.6 +-- Dumped from database version 9.6.2 +-- Dumped by pg_dump version 9.6.2 SET statement_timeout = 0; SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SET check_function_bodies = false; @@ -17,48 +17,6 @@ SET client_min_messages = warning; SET row_security = off; --- --- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: --- - -CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: --- - -COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language'; - - --- --- Name: adminpack; Type: EXTENSION; Schema: -; Owner: --- - -CREATE EXTENSION IF NOT EXISTS adminpack WITH SCHEMA pg_catalog; - - --- --- Name: EXTENSION adminpack; Type: COMMENT; Schema: -; Owner: --- - -COMMENT ON EXTENSION adminpack IS 'administrative functions for PostgreSQL'; - - --- --- Name: hstore; Type: EXTENSION; Schema: -; Owner: --- - -CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public; - - --- --- Name: EXTENSION hstore; Type: COMMENT; Schema: -; Owner: --- - -COMMENT ON EXTENSION hstore IS 'data type for storing sets of (key, value) pairs'; - - -- -- Name: postgis; Type: EXTENSION; Schema: -; Owner: -- @@ -72,6 +30,7 @@ CREATE EXTENSION IF NOT EXISTS postgis WITH SCHEMA public; COMMENT ON EXTENSION postgis IS 'PostGIS geometry, geography, and raster spatial types and functions'; + SET search_path = public, pg_catalog; -- @@ -84,11 +43,11 @@ CREATE FUNCTION beardistinsert(arg_plan_no character varying, arg_bearing double DECLARE the_x double precision; the_y double precision; - the_geom geometry(Point,26332); + the_geom geometry(Point,:CRS); BEGIN SELECT x INTO the_x FROM beacons WHERE beacon = arg_beacon_from; SELECT y INTO the_y FROM beacons WHERE beacon = arg_beacon_from; - the_geom := pointfrombearinganddistance(the_x, the_y, arg_bearing, arg_distance, 3, 26332); + the_geom := pointfrombearinganddistance(the_x, the_y, arg_bearing, arg_distance, 3, :CRS); INSERT INTO beacons(beacon, y, x, "location", "name") VALUES(arg_beacon_to, st_y(the_geom), st_x(the_geom), arg_location, arg_name); INSERT INTO beardist(plan_no, bearing, distance, beacon_from, beacon_to) @@ -97,7 +56,6 @@ CREATE FUNCTION beardistinsert(arg_plan_no character varying, arg_bearing double $$; -ALTER FUNCTION public.beardistinsert(arg_plan_no character varying, arg_bearing double precision, arg_distance double precision, arg_beacon_from character varying, arg_beacon_to character varying, arg_location character varying, arg_name character varying) OWNER TO gavinfleming; -- -- Name: beardistupdate(character varying, double precision, double precision, character varying, character varying, character varying, character varying, integer); Type: FUNCTION; Schema: public; Owner: docker @@ -111,7 +69,7 @@ CREATE FUNCTION beardistupdate(arg_plan_no character varying, arg_bearing double the_id_beacons integer; the_x double precision; the_y double precision; - the_geom_ geometry(Point, 26332); + the_geom_ geometry(Point, :CRS); BEGIN SELECT i.id INTO the_id_beardist FROM ( SELECT bd.id, row_number() over(ORDER BY bd.id) -1 as index @@ -123,7 +81,7 @@ CREATE FUNCTION beardistupdate(arg_plan_no character varying, arg_bearing double SELECT gid INTO the_id_beacons FROM beacons b INNER JOIN beardist bd ON b.beacon = bd.beacon_to WHERE bd.id = the_id_beardist; SELECT x INTO the_x FROM beacons WHERE beacon = arg_beacon_from; SELECT y INTO the_y FROM beacons WHERE beacon = arg_beacon_from; - SELECT pointfrombearinganddistance(the_x, the_y, arg_bearing, arg_distance, 3, 26332) INTO the_geom_; + SELECT pointfrombearinganddistance(the_x, the_y, arg_bearing, arg_distance, 3, :CRS) INTO the_geom_; UPDATE beacons SET beacon = arg_beacon_to, y = st_y(the_geom_), @@ -142,7 +100,6 @@ CREATE FUNCTION beardistupdate(arg_plan_no character varying, arg_bearing double $$; -ALTER FUNCTION public.beardistupdate(arg_plan_no character varying, arg_bearing double precision, arg_distance double precision, arg_beacon_from character varying, arg_beacon_to character varying, arg_location character varying, arg_name character varying, arg_index integer) OWNER TO gavinfleming; -- -- Name: calc_point(); Type: FUNCTION; Schema: public; Owner: docker @@ -152,127 +109,123 @@ CREATE FUNCTION calc_point() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - NEW.the_geom:=ST_SetSRID(ST_MakePoint(new.x, new.y), 26332) ; + NEW.the_geom:=ST_SetSRID(ST_MakePoint(new.x, new.y), :CRS) ; RETURN NEW; END $$; -ALTER FUNCTION public.calc_point() OWNER TO gavinfleming; -- --- Name: fn_beacons_after_insert(); Type: FUNCTION; Schema: public; Owner: postgres +-- Name: fn_beacons_after_insert(); Type: FUNCTION; Schema: public; Owner: docker -- CREATE FUNCTION fn_beacons_after_insert() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO hist_beacons ( - gid, - beacon, - y, - x, - the_geom, - location, - name, - hist_user, - hist_action, - hist_time - ) VALUES ( - NEW."gid", - NEW."beacon", - NEW."y", - NEW."x", - NEW."the_geom", - NEW."location", - NEW."name", - NEW."last_modified_by", - 'INSERT', - NOW() + INSERT INTO hist_beacons ( + gid, + beacon, + y, + x, + the_geom, + location, + name, + hist_user, + hist_action, + hist_time + ) VALUES ( + NEW."gid", + NEW."beacon", + NEW."y", + NEW."x", + NEW."the_geom", + NEW."location", + NEW."name", + NEW."last_modified_by", + 'INSERT', + NOW() ); RETURN NEW; END; $$; -ALTER FUNCTION public.fn_beacons_after_insert() OWNER TO gavinfleming; -- --- Name: fn_beacons_before_delete(); Type: FUNCTION; Schema: public; Owner: postgres +-- Name: fn_beacons_before_delete(); Type: FUNCTION; Schema: public; Owner: docker -- CREATE FUNCTION fn_beacons_before_delete() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO hist_beacons ( - gid, - beacon, - y, - x, - the_geom, - location, - name, - hist_user, - hist_action, - hist_time - ) VALUES ( - OLD."gid", - OLD."beacon", - OLD."y", - OLD."x", - OLD."the_geom", - OLD."location", - OLD."name", - OLD."last_modified_by", - 'DELETE', - NOW() + INSERT INTO hist_beacons ( + gid, + beacon, + y, + x, + the_geom, + location, + name, + hist_user, + hist_action, + hist_time + ) VALUES ( + OLD."gid", + OLD."beacon", + OLD."y", + OLD."x", + OLD."the_geom", + OLD."location", + OLD."name", + OLD."last_modified_by", + 'DELETE', + NOW() ); RETURN OLD; END; $$; -ALTER FUNCTION public.fn_beacons_before_delete() OWNER TO gavinfleming; -- --- Name: fn_beacons_before_update(); Type: FUNCTION; Schema: public; Owner: postgres +-- Name: fn_beacons_before_update(); Type: FUNCTION; Schema: public; Owner: docker -- CREATE FUNCTION fn_beacons_before_update() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - INSERT INTO hist_beacons ( - gid, - beacon, - y, - x, - the_geom, - location, - name, - hist_user, - hist_action, - hist_time - ) VALUES ( - OLD."gid", - OLD."beacon", - OLD."y", - OLD."x", - OLD."the_geom", - OLD."location", - OLD."name", - NEW."last_modified_by", - 'EDIT', - NOW() + INSERT INTO hist_beacons ( + gid, + beacon, + y, + x, + the_geom, + location, + name, + hist_user, + hist_action, + hist_time + ) VALUES ( + OLD."gid", + OLD."beacon", + OLD."y", + OLD."x", + OLD."the_geom", + OLD."location", + OLD."name", + NEW."last_modified_by", + 'EDIT', + NOW() ); RETURN NEW; END; $$; -ALTER FUNCTION public.fn_beacons_before_update() OWNER TO gavinfleming; -- -- Name: fn_updateprintjobs(); Type: FUNCTION; Schema: public; Owner: docker @@ -282,18 +235,17 @@ CREATE FUNCTION fn_updateprintjobs() RETURNS trigger LANGUAGE plpgsql AS $$ BEGIN - IF NEW.created IS NOT NULL THEN - NEW.created = NEW.created + interval '2 hours'; + IF NEW.created IS NOT NULL THEN + NEW.created = NEW.created + interval '2 hours'; END IF; - IF NEW.done IS NOT NULL THEN - NEW.done = NEW.done + interval '2 hours'; + IF NEW.done IS NOT NULL THEN + NEW.done = NEW.done + interval '2 hours'; END IF; RETURN NEW; END; $$; -ALTER FUNCTION public.fn_updateprintjobs() OWNER TO gavinfleming; -- -- Name: parcel_lookup_availability_trigger(); Type: FUNCTION; Schema: public; Owner: docker @@ -310,7 +262,6 @@ CREATE FUNCTION parcel_lookup_availability_trigger() RETURNS trigger $$; -ALTER FUNCTION public.parcel_lookup_availability_trigger() OWNER TO gavinfleming; -- -- Name: parcel_lookup_define_parcel_trigger(); Type: FUNCTION; Schema: public; Owner: docker @@ -328,7 +279,6 @@ CREATE FUNCTION parcel_lookup_define_parcel_trigger() RETURNS trigger $$; -ALTER FUNCTION public.parcel_lookup_define_parcel_trigger() OWNER TO gavinfleming; -- -- Name: parcels_matview_refresh_row(integer); Type: FUNCTION; Schema: public; Owner: docker @@ -345,7 +295,6 @@ END $_$; -ALTER FUNCTION public.parcels_matview_refresh_row(integer) OWNER TO gavinfleming; -- -- Name: pointfrombearinganddistance(double precision, double precision, double precision, double precision, integer, integer); Type: FUNCTION; Schema: public; Owner: docker @@ -404,99 +353,17 @@ BEGIN END IF; dende := ddeltae + dstarte; dendn := ddeltan + dstartn; - RETURN ST_SetSRID(ST_MakePoint(round(dende::numeric, precision), round(dendn::numeric, precision)), 26332); + RETURN ST_SetSRID(ST_MakePoint(round(dende::numeric, precision), round(dendn::numeric, precision)), :CRS); END; END; $$; -ALTER FUNCTION public.pointfrombearinganddistance(dstarte double precision, dstartn double precision, dbearing double precision, ddistance double precision, "precision" integer, srid integer) OWNER TO gavinfleming; SET default_tablespace = ''; SET default_with_oids = false; --- --- Name: lut_poi_cat; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE lut_poi_cat ( - sc_name character varying(255), - sc_code numeric(10,0), - tc_name character varying(255), - tc_code numeric(10,0), - icon character varying(255), - id integer NOT NULL -); - - -ALTER TABLE lut_poi_cat OWNER TO gavinfleming; - --- --- Name: Ogun_state_id_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE "Ogun_state_id_seq" - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE "Ogun_state_id_seq" OWNER TO gavinfleming; - --- --- Name: Ogun_state_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE "Ogun_state_id_seq" OWNED BY lut_poi_cat.id; - - --- --- Name: ogunadmin; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE ogunadmin ( - gid integer NOT NULL, - iso_code character varying(3), - country character varying(75), - state character varying(75), - lg_name character varying(75), - hasc character varying(15), - type character varying(50), - remarks character varying(100), - "Shape_Leng" double precision, - "Shape_Area" double precision, - the_geom geometry(Polygon,26332), - sen_district integer, - lg_hq integer -); - - -ALTER TABLE ogunadmin OWNER TO gavinfleming; - --- --- Name: Ogunadmin_gid_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE "Ogunadmin_gid_seq" - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE "Ogunadmin_gid_seq" OWNER TO gavinfleming; - --- --- Name: Ogunadmin_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE "Ogunadmin_gid_seq" OWNED BY ogunadmin.gid; - - -- -- Name: allocation_cat; Type: TABLE; Schema: public; Owner: docker -- @@ -507,7 +374,6 @@ CREATE TABLE allocation_cat ( ); -ALTER TABLE allocation_cat OWNER TO gavinfleming; -- -- Name: allocation_cat_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -521,7 +387,6 @@ CREATE SEQUENCE allocation_cat_id_seq CACHE 1; -ALTER TABLE allocation_cat_id_seq OWNER TO gavinfleming; -- -- Name: allocation_cat_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -539,28 +404,13 @@ CREATE TABLE beacons ( beacon character varying(80) NOT NULL, y double precision NOT NULL, x double precision NOT NULL, - the_geom geometry(Point,26332) NOT NULL, + the_geom geometry(Point,:CRS) NOT NULL, location character varying(180), name character varying(100), last_modified_by character varying ); -ALTER TABLE beacons OWNER TO gavinfleming; - --- --- Name: beacons_extra; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE beacons_extra ( - gid integer, - beacon character varying(80), - planno character varying(180), - blockno character varying(180) -); - - -ALTER TABLE beacons_extra OWNER TO gavinfleming; -- -- Name: beacons_gid_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -574,7 +424,6 @@ CREATE SEQUENCE beacons_gid_seq CACHE 1; -ALTER TABLE beacons_gid_seq OWNER TO gavinfleming; -- -- Name: beacons_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -595,7 +444,6 @@ CREATE TABLE parcel_def ( ); -ALTER TABLE parcel_def OWNER TO gavinfleming; -- -- Name: parcel_lookup; Type: TABLE; Schema: public; Owner: docker @@ -619,7 +467,6 @@ CREATE TABLE parcel_lookup ( ); -ALTER TABLE parcel_lookup OWNER TO gavinfleming; -- -- Name: COLUMN parcel_lookup.plot_sn; Type: COMMENT; Schema: public; Owner: docker @@ -648,10 +495,9 @@ CREATE MATERIALIZED VIEW beacons_views AS WITH NO DATA; -ALTER TABLE beacons_views OWNER TO gavinfleming; -- --- Name: deeds; Type: TABLE; Schema: public; Owner: postgres +-- Name: deeds; Type: TABLE; Schema: public; Owner: docker -- CREATE TABLE deeds ( @@ -667,7 +513,6 @@ CREATE TABLE deeds ( ); -ALTER TABLE deeds OWNER TO gavinfleming; -- -- Name: schemes; Type: TABLE; Schema: public; Owner: docker @@ -680,7 +525,6 @@ CREATE TABLE schemes ( ); -ALTER TABLE schemes OWNER TO gavinfleming; -- -- Name: COLUMN schemes."Scheme"; Type: COMMENT; Schema: public; Owner: docker @@ -708,7 +552,7 @@ CREATE VIEW parcels AS ((((''::text) || (description.deeds_file)::text) || ''::text) AS deeds_file, description.private FROM (( SELECT vl.parcel_id, - (st_makepolygon(st_addpoint(st_makeline(vl.the_geom), st_startpoint(st_makeline(vl.the_geom)))))::geometry(Polygon,26332) AS the_geom + (st_makepolygon(st_addpoint(st_makeline(vl.the_geom), st_startpoint(st_makeline(vl.the_geom)))))::geometry(Polygon,:CRS) AS the_geom FROM ( SELECT pd.id, pd.parcel_id, pd.beacon, @@ -719,7 +563,7 @@ CREATE VIEW parcels AS ORDER BY pd.parcel_id, pd.sequence) vl GROUP BY vl.parcel_id HAVING (st_npoints(st_collect(vl.the_geom)) > 1)) parcel - LEFT JOIN ( SELECT p.parcel_id, + JOIN ( SELECT p.parcel_id, ((p.local_govt || (p.prop_type)::text) || p.parcel_id) AS parcel_number, p.allocation, p.block, @@ -737,7 +581,6 @@ CREATE VIEW parcels AS WHERE st_isvalid(parcel.the_geom); -ALTER TABLE parcels OWNER TO gavinfleming; -- -- Name: beacons_intersect; Type: MATERIALIZED VIEW; Schema: public; Owner: docker @@ -755,7 +598,6 @@ CREATE MATERIALIZED VIEW beacons_intersect AS WITH NO DATA; -ALTER TABLE beacons_intersect OWNER TO gavinfleming; -- -- Name: beardist; Type: TABLE; Schema: public; Owner: docker @@ -771,7 +613,6 @@ CREATE TABLE beardist ( ); -ALTER TABLE beardist OWNER TO gavinfleming; -- -- Name: beardist_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -785,7 +626,6 @@ CREATE SEQUENCE beardist_id_seq CACHE 1; -ALTER TABLE beardist_id_seq OWNER TO gavinfleming; -- -- Name: beardist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -825,7 +665,6 @@ CREATE VIEW bearing_labels AS JOIN beardist c USING (id)); -ALTER TABLE bearing_labels OWNER TO gavinfleming; -- -- Name: boundaries; Type: MATERIALIZED VIEW; Schema: public; Owner: docker @@ -844,7 +683,7 @@ CREATE MATERIALIZED VIEW boundaries AS ) SELECT row_number() OVER () AS id, boundaries.parcel_id, - (boundaries.geom)::geometry(LineString,26332) AS geom, + (boundaries.geom)::geometry(LineString,:CRS) AS geom, round((st_length(boundaries.geom))::numeric, 2) AS distance, round((degrees(st_azimuth(st_startpoint(boundaries.geom), st_endpoint(boundaries.geom))))::numeric, 2) AS bearing FROM boundaries @@ -852,7 +691,6 @@ CREATE MATERIALIZED VIEW boundaries AS WITH NO DATA; -ALTER TABLE boundaries OWNER TO gavinfleming; -- -- Name: boundary_labels; Type: MATERIALIZED VIEW; Schema: public; Owner: docker @@ -861,7 +699,7 @@ ALTER TABLE boundaries OWNER TO gavinfleming; CREATE MATERIALIZED VIEW boundary_labels AS SELECT row_number() OVER () AS id, b.id AS boundary_id, - (b.geom)::geometry(LineString,26332) AS geom, + (b.geom)::geometry(LineString,:CRS) AS geom, c.plan_no, c.bearing, c.distance, @@ -889,43 +727,9 @@ CREATE MATERIALIZED VIEW boundary_labels AS WITH NO DATA; -ALTER TABLE boundary_labels OWNER TO gavinfleming; - --- --- Name: conflict_cat; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE conflict_cat ( - conflict_cat integer NOT NULL, - description character varying NOT NULL -); - - -ALTER TABLE conflict_cat OWNER TO gavinfleming; - --- --- Name: conflict_cat_conflict_cat_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE conflict_cat_conflict_cat_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE conflict_cat_conflict_cat_seq OWNER TO gavinfleming; -- --- Name: conflict_cat_conflict_cat_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE conflict_cat_conflict_cat_seq OWNED BY conflict_cat.conflict_cat; - - --- --- Name: deeds_deed_sn_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- Name: deeds_deed_sn_seq; Type: SEQUENCE; Schema: public; Owner: docker -- CREATE SEQUENCE deeds_deed_sn_seq @@ -936,10 +740,9 @@ CREATE SEQUENCE deeds_deed_sn_seq CACHE 1; -ALTER TABLE deeds_deed_sn_seq OWNER TO gavinfleming; -- --- Name: deeds_deed_sn_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- Name: deeds_deed_sn_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker -- ALTER SEQUENCE deeds_deed_sn_seq OWNED BY deeds.deed_sn; @@ -962,10 +765,9 @@ CREATE MATERIALIZED VIEW derived_boundaries AS WITH NO DATA; -ALTER TABLE derived_boundaries OWNER TO gavinfleming; -- --- Name: hist_beacons; Type: TABLE; Schema: public; Owner: postgres +-- Name: hist_beacons; Type: TABLE; Schema: public; Owner: docker -- CREATE TABLE hist_beacons ( @@ -974,7 +776,7 @@ CREATE TABLE hist_beacons ( beacon character varying(80) NOT NULL, y double precision NOT NULL, x double precision NOT NULL, - the_geom geometry(Point,26332) NOT NULL, + the_geom geometry(Point,:CRS) NOT NULL, location character varying(180), name character varying(100), hist_user character varying, @@ -983,10 +785,9 @@ CREATE TABLE hist_beacons ( ); -ALTER TABLE hist_beacons OWNER TO gavinfleming; -- --- Name: hist_beacons_hist_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- Name: hist_beacons_hist_id_seq; Type: SEQUENCE; Schema: public; Owner: docker -- CREATE SEQUENCE hist_beacons_hist_id_seq @@ -997,10 +798,9 @@ CREATE SEQUENCE hist_beacons_hist_id_seq CACHE 1; -ALTER TABLE hist_beacons_hist_id_seq OWNER TO gavinfleming; -- --- Name: hist_beacons_hist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- Name: hist_beacons_hist_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker -- ALTER SEQUENCE hist_beacons_hist_id_seq OWNED BY hist_beacons.hist_id; @@ -1016,7 +816,6 @@ CREATE TABLE instrument_cat ( ); -ALTER TABLE instrument_cat OWNER TO gavinfleming; -- -- Name: instrument_cat_instrument_cat_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1030,7 +829,6 @@ CREATE SEQUENCE instrument_cat_instrument_cat_seq CACHE 1; -ALTER TABLE instrument_cat_instrument_cat_seq OWNER TO gavinfleming; -- -- Name: instrument_cat_instrument_cat_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1039,40 +837,6 @@ ALTER TABLE instrument_cat_instrument_cat_seq OWNER TO gavinfleming; ALTER SEQUENCE instrument_cat_instrument_cat_seq OWNED BY instrument_cat.instrument_cat; --- --- Name: lg_hqtrs; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE lg_hqtrs ( - hq_sn integer NOT NULL, - hq_code integer NOT NULL, - hq_desc text -); - - -ALTER TABLE lg_hqtrs OWNER TO gavinfleming; - --- --- Name: lg_hqtrs_hq_sn_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE lg_hqtrs_hq_sn_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE lg_hqtrs_hq_sn_seq OWNER TO gavinfleming; - --- --- Name: lg_hqtrs_hq_sn_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE lg_hqtrs_hq_sn_seq OWNED BY lg_hqtrs.hq_sn; - - -- -- Name: local_govt; Type: TABLE; Schema: public; Owner: docker -- @@ -1083,7 +847,6 @@ CREATE TABLE local_govt ( ); -ALTER TABLE local_govt OWNER TO gavinfleming; -- -- Name: local_govt_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1097,7 +860,6 @@ CREATE SEQUENCE local_govt_id_seq CACHE 1; -ALTER TABLE local_govt_id_seq OWNER TO gavinfleming; -- -- Name: local_govt_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1107,7 +869,7 @@ ALTER SEQUENCE local_govt_id_seq OWNED BY local_govt.id; -- --- Name: localmotclass_code_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- Name: localmotclass_code_seq; Type: SEQUENCE; Schema: public; Owner: docker -- CREATE SEQUENCE localmotclass_code_seq @@ -1118,10 +880,9 @@ CREATE SEQUENCE localmotclass_code_seq CACHE 1; -ALTER TABLE localmotclass_code_seq OWNER TO gavinfleming; -- --- Name: localrdclass_code_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- Name: localrdclass_code_seq; Type: SEQUENCE; Schema: public; Owner: docker -- CREATE SEQUENCE localrdclass_code_seq @@ -1132,92 +893,6 @@ CREATE SEQUENCE localrdclass_code_seq CACHE 1; -ALTER TABLE localrdclass_code_seq OWNER TO gavinfleming; - --- --- Name: official_gazzette; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE official_gazzette ( - gid integer NOT NULL, - "NAME" character varying(80), - "F_CLASS" character varying(80), - "F_DESIG" character varying(80), - "LAT" double precision, - "LONG" double precision, - "ADM1" character varying(80), - "ADM2" character varying(80), - the_geom geometry(Point), - settlement_type integer -); - - -ALTER TABLE official_gazzette OWNER TO gavinfleming; - --- --- Name: official_gazzette_gid_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE official_gazzette_gid_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE official_gazzette_gid_seq OWNER TO gavinfleming; - --- --- Name: official_gazzette_gid_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE official_gazzette_gid_seq OWNED BY official_gazzette.gid; - - --- --- Name: ogunroadnetwork; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE ogunroadnetwork ( - gid integer NOT NULL, - type character varying(14), - oneway character varying(4), - lanes numeric, - surface numeric(10,0), - postcode numeric(10,0), - str_type numeric(10,0), - a_name character varying(100), - rd_hrky character varying(1), - rdcode numeric(10,0), - str_name numeric(10,0), - the_geom geometry(MultiLineString,26332), - trafdir boolean DEFAULT true -); - - -ALTER TABLE ogunroadnetwork OWNER TO gavinfleming; - --- --- Name: ogunroadnetwork_gid_seq1; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE ogunroadnetwork_gid_seq1 - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE ogunroadnetwork_gid_seq1 OWNER TO gavinfleming; - --- --- Name: ogunroadnetwork_gid_seq1; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE ogunroadnetwork_gid_seq1 OWNED BY ogunroadnetwork.gid; - -- -- Name: parcel_def_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1231,7 +906,6 @@ CREATE SEQUENCE parcel_def_id_seq CACHE 1; -ALTER TABLE parcel_def_id_seq OWNER TO gavinfleming; -- -- Name: parcel_def_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1252,7 +926,6 @@ CREATE SEQUENCE parcel_lookup_id_seq CACHE 1; -ALTER TABLE parcel_lookup_id_seq OWNER TO gavinfleming; -- -- Name: parcel_lookup_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1273,7 +946,6 @@ CREATE SEQUENCE parcel_lookup_parcel_id_seq CACHE 1; -ALTER TABLE parcel_lookup_parcel_id_seq OWNER TO gavinfleming; -- -- Name: parcel_lookup_parcel_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1301,7 +973,7 @@ CREATE VIEW perimeters AS ((((''::text) || (description.deeds_file)::text) || ''::text) AS deeds_file, description.private FROM (( SELECT vl.parcel_id, - (st_makepolygon(st_addpoint(st_makeline(vl.the_geom), st_startpoint(st_makeline(vl.the_geom)))))::geometry(Polygon,26332) AS the_geom + (st_makepolygon(st_addpoint(st_makeline(vl.the_geom), st_startpoint(st_makeline(vl.the_geom)))))::geometry(Polygon,:CRS) AS the_geom FROM ( SELECT pd.id, pd.parcel_id, pd.beacon, @@ -1330,7 +1002,6 @@ CREATE VIEW perimeters AS WHERE st_isvalid(parcel.the_geom); -ALTER TABLE perimeters OWNER TO gavinfleming; -- -- Name: parcel_overlap_matviews; Type: MATERIALIZED VIEW; Schema: public; Owner: docker @@ -1356,7 +1027,6 @@ CREATE MATERIALIZED VIEW parcel_overlap_matviews AS WITH NO DATA; -ALTER TABLE parcel_overlap_matviews OWNER TO gavinfleming; -- -- Name: parcels_intersect; Type: MATERIALIZED VIEW; Schema: public; Owner: docker @@ -1382,7 +1052,6 @@ CREATE MATERIALIZED VIEW parcels_intersect AS WITH NO DATA; -ALTER TABLE parcels_intersect OWNER TO gavinfleming; -- -- Name: parcels_lines; Type: VIEW; Schema: public; Owner: docker @@ -1401,7 +1070,6 @@ CREATE VIEW parcels_lines AS GROUP BY a.parcel_id; -ALTER TABLE parcels_lines OWNER TO gavinfleming; -- -- Name: parcels_line_length; Type: VIEW; Schema: public; Owner: docker @@ -1424,7 +1092,6 @@ CREATE VIEW parcels_line_length AS WHERE (segments.geom IS NOT NULL); -ALTER TABLE parcels_line_length OWNER TO gavinfleming; -- -- Name: perimeters_original; Type: VIEW; Schema: public; Owner: docker @@ -1444,7 +1111,7 @@ CREATE VIEW perimeters_original AS description.owner, ((((''::text) || (description.deeds_file)::text) || ''::text) AS deeds_file FROM (( SELECT vl.parcel_id, - (st_makepolygon(st_addpoint(st_makeline(vl.the_geom), st_startpoint(st_makeline(vl.the_geom)))))::geometry(Polygon,26332) AS the_geom + (st_makepolygon(st_addpoint(st_makeline(vl.the_geom), st_startpoint(st_makeline(vl.the_geom)))))::geometry(Polygon,:CRS) AS the_geom FROM ( SELECT pd.id, pd.parcel_id, pd.beacon, @@ -1473,109 +1140,6 @@ CREATE VIEW perimeters_original AS LIMIT 1; -ALTER TABLE perimeters_original OWNER TO gavinfleming; - --- --- Name: pois; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE pois ( - id integer NOT NULL, - the_geom geometry(Point,4326), - serial_no integer, - bsn integer, - pc_name character varying, - pc_code integer, - sc_name character varying, - sc_code integer, - tc_name character varying, - tc_code integer, - entity character varying, - local_govt character varying, - latitude double precision, - longitude double precision, - altitude double precision, - site_condition character varying, - building_type character varying, - drainage character varying, - road_condition character varying, - road_surface character varying, - road_carriage character varying, - electricity character varying, - road_type character varying, - road_feature character varying, - street_furniture character varying, - refuse_disposal character varying, - area character varying, - location character varying, - street_name character varying -); - - -ALTER TABLE pois OWNER TO gavinfleming; - --- --- Name: pois_id_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE pois_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE pois_id_seq OWNER TO gavinfleming; - --- --- Name: pois_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE pois_id_seq OWNED BY pois.id; - - --- --- Name: pois_view; Type: MATERIALIZED VIEW; Schema: public; Owner: docker --- - -CREATE MATERIALIZED VIEW pois_view AS - SELECT DISTINCT ON (p.id) p.id, - p.the_geom AS geom, - p.serial_no, - p.bsn, - p.pc_name, - p.pc_code, - p.sc_name, - p.sc_code, - p.tc_name, - p.tc_code, - p.entity, - p.local_govt, - p.latitude, - p.longitude, - p.altitude, - p.site_condition, - p.building_type, - p.drainage, - p.road_condition, - p.road_surface, - p.road_carriage, - p.electricity, - p.road_type, - p.road_feature, - p.street_furniture, - p.refuse_disposal, - p.area, - p.location, - p.street_name, - l.icon - FROM (pois p - JOIN lut_poi_cat l USING (sc_code, tc_code)) - WITH NO DATA; - - -ALTER TABLE pois_view OWNER TO gavinfleming; -- -- Name: print_survey_details; Type: TABLE; Schema: public; Owner: docker @@ -1593,7 +1157,6 @@ CREATE TABLE print_survey_details ( ); -ALTER TABLE print_survey_details OWNER TO gavinfleming; -- -- Name: print_survey_details_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1607,7 +1170,6 @@ CREATE SEQUENCE print_survey_details_id_seq CACHE 1; -ALTER TABLE print_survey_details_id_seq OWNER TO gavinfleming; -- -- Name: print_survey_details_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1627,7 +1189,6 @@ CREATE TABLE prop_types ( ); -ALTER TABLE prop_types OWNER TO gavinfleming; -- -- Name: prop_types_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1641,7 +1202,6 @@ CREATE SEQUENCE prop_types_id_seq CACHE 1; -ALTER TABLE prop_types_id_seq OWNER TO gavinfleming; -- -- Name: prop_types_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1660,13 +1220,12 @@ CREATE TABLE reference_view ( ref_beacon character varying(20), scheme integer, parcel_id integer, - the_geom geometry(Point,26332), + the_geom geometry(Point,:CRS), x double precision, y double precision ); -ALTER TABLE reference_view OWNER TO gavinfleming; -- -- Name: schemes_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1680,7 +1239,6 @@ CREATE SEQUENCE schemes_id_seq CACHE 1; -ALTER TABLE schemes_id_seq OWNER TO gavinfleming; -- -- Name: schemes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1690,59 +1248,7 @@ ALTER SEQUENCE schemes_id_seq OWNED BY schemes.id; -- --- Name: sen_districts; Type: TABLE; Schema: public; Owner: docker --- - -CREATE TABLE sen_districts ( - sen_id integer NOT NULL, - sen_code integer NOT NULL, - sen_desc text -); - - -ALTER TABLE sen_districts OWNER TO gavinfleming; - --- --- Name: sen_district; Type: VIEW; Schema: public; Owner: docker --- - -CREATE VIEW sen_district AS - SELECT a.lg_name AS lga, - a.gid, - a.the_geom, - a.sen_district, - b.sen_desc AS senatorial_district, - c.hq_desc AS hqtrs - FROM ((ogunadmin a - JOIN sen_districts b ON ((a.sen_district = b.sen_code))) - JOIN lg_hqtrs c ON ((a.lg_hq = c.hq_code))); - - -ALTER TABLE sen_district OWNER TO gavinfleming; - --- --- Name: sen_districts_sen_id_seq; Type: SEQUENCE; Schema: public; Owner: docker --- - -CREATE SEQUENCE sen_districts_sen_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE sen_districts_sen_id_seq OWNER TO gavinfleming; - --- --- Name: sen_districts_sen_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker --- - -ALTER SEQUENCE sen_districts_sen_id_seq OWNED BY sen_districts.sen_id; - - --- --- Name: speed_code_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- Name: speed_code_seq; Type: SEQUENCE; Schema: public; Owner: docker -- CREATE SEQUENCE speed_code_seq @@ -1753,7 +1259,6 @@ CREATE SEQUENCE speed_code_seq CACHE 1; -ALTER TABLE speed_code_seq OWNER TO gavinfleming; -- -- Name: status_cat; Type: TABLE; Schema: public; Owner: docker @@ -1765,7 +1270,6 @@ CREATE TABLE status_cat ( ); -ALTER TABLE status_cat OWNER TO gavinfleming; -- -- Name: status_cat_status_cat_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1779,7 +1283,6 @@ CREATE SEQUENCE status_cat_status_cat_seq CACHE 1; -ALTER TABLE status_cat_status_cat_seq OWNER TO gavinfleming; -- -- Name: status_cat_status_cat_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1789,7 +1292,7 @@ ALTER SEQUENCE status_cat_status_cat_seq OWNED BY status_cat.status_cat; -- --- Name: str_type_strid_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- Name: str_type_strid_seq; Type: SEQUENCE; Schema: public; Owner: docker -- CREATE SEQUENCE str_type_strid_seq @@ -1800,7 +1303,6 @@ CREATE SEQUENCE str_type_strid_seq CACHE 1; -ALTER TABLE str_type_strid_seq OWNER TO gavinfleming; -- -- Name: survey; Type: TABLE; Schema: public; Owner: docker @@ -1815,7 +1317,6 @@ CREATE TABLE survey ( ); -ALTER TABLE survey OWNER TO gavinfleming; -- -- Name: survey_id_seq; Type: SEQUENCE; Schema: public; Owner: docker @@ -1829,7 +1330,6 @@ CREATE SEQUENCE survey_id_seq CACHE 1; -ALTER TABLE survey_id_seq OWNER TO gavinfleming; -- -- Name: survey_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: docker @@ -1853,172 +1353,107 @@ CREATE TABLE transactions ( ); -ALTER TABLE transactions OWNER TO gavinfleming; -- --- Name: allocation_cat; Type: DEFAULT; Schema: public; Owner: docker +-- Name: allocation_cat allocation_cat; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY allocation_cat ALTER COLUMN allocation_cat SET DEFAULT nextval('allocation_cat_id_seq'::regclass); -- --- Name: gid; Type: DEFAULT; Schema: public; Owner: docker +-- Name: beacons gid; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY beacons ALTER COLUMN gid SET DEFAULT nextval('beacons_gid_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: beardist id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist ALTER COLUMN id SET DEFAULT nextval('beardist_id_seq'::regclass); -- --- Name: conflict_cat; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY conflict_cat ALTER COLUMN conflict_cat SET DEFAULT nextval('conflict_cat_conflict_cat_seq'::regclass); - - --- --- Name: deed_sn; Type: DEFAULT; Schema: public; Owner: postgres +-- Name: deeds deed_sn; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY deeds ALTER COLUMN deed_sn SET DEFAULT nextval('deeds_deed_sn_seq'::regclass); -- --- Name: hist_id; Type: DEFAULT; Schema: public; Owner: postgres +-- Name: hist_beacons hist_id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY hist_beacons ALTER COLUMN hist_id SET DEFAULT nextval('hist_beacons_hist_id_seq'::regclass); -- --- Name: instrument_cat; Type: DEFAULT; Schema: public; Owner: docker +-- Name: instrument_cat instrument_cat; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY instrument_cat ALTER COLUMN instrument_cat SET DEFAULT nextval('instrument_cat_instrument_cat_seq'::regclass); -- --- Name: hq_sn; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY lg_hqtrs ALTER COLUMN hq_sn SET DEFAULT nextval('lg_hqtrs_hq_sn_seq'::regclass); - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: local_govt id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY local_govt ALTER COLUMN id SET DEFAULT nextval('local_govt_id_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY lut_poi_cat ALTER COLUMN id SET DEFAULT nextval('"Ogun_state_id_seq"'::regclass); - - --- --- Name: gid; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY official_gazzette ALTER COLUMN gid SET DEFAULT nextval('official_gazzette_gid_seq'::regclass); - - --- --- Name: gid; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY ogunadmin ALTER COLUMN gid SET DEFAULT nextval('"Ogunadmin_gid_seq"'::regclass); - - --- --- Name: gid; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY ogunroadnetwork ALTER COLUMN gid SET DEFAULT nextval('ogunroadnetwork_gid_seq1'::regclass); - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: parcel_def id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_def ALTER COLUMN id SET DEFAULT nextval('parcel_def_id_seq'::regclass); -- --- Name: parcel_id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup ALTER COLUMN parcel_id SET DEFAULT nextval('parcel_lookup_parcel_id_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY pois ALTER COLUMN id SET DEFAULT nextval('pois_id_seq'::regclass); - - --- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: print_survey_details id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY print_survey_details ALTER COLUMN id SET DEFAULT nextval('print_survey_details_id_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: prop_types id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY prop_types ALTER COLUMN id SET DEFAULT nextval('prop_types_id_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: schemes id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY schemes ALTER COLUMN id SET DEFAULT nextval('schemes_id_seq'::regclass); -- --- Name: sen_id; Type: DEFAULT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY sen_districts ALTER COLUMN sen_id SET DEFAULT nextval('sen_districts_sen_id_seq'::regclass); - - --- --- Name: status_cat; Type: DEFAULT; Schema: public; Owner: docker +-- Name: status_cat status_cat; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY status_cat ALTER COLUMN status_cat SET DEFAULT nextval('status_cat_status_cat_seq'::regclass); -- --- Name: id; Type: DEFAULT; Schema: public; Owner: docker +-- Name: survey id; Type: DEFAULT; Schema: public; Owner: docker -- ALTER TABLE ONLY survey ALTER COLUMN id SET DEFAULT nextval('survey_id_seq'::regclass); -- --- Name: Ogunadmin_pkey; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY ogunadmin - ADD CONSTRAINT "Ogunadmin_pkey" PRIMARY KEY (gid); - - --- --- Name: allocation_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: allocation_cat allocation_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY allocation_cat @@ -2026,7 +1461,7 @@ ALTER TABLE ONLY allocation_cat -- --- Name: beacons_beacon_key; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: beacons beacons_beacon_key; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beacons @@ -2034,7 +1469,7 @@ ALTER TABLE ONLY beacons -- --- Name: beacons_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: beacons beacons_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beacons @@ -2042,7 +1477,7 @@ ALTER TABLE ONLY beacons -- --- Name: beardist_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2050,15 +1485,7 @@ ALTER TABLE ONLY beardist -- --- Name: conflict_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY conflict_cat - ADD CONSTRAINT conflict_cat_pkey PRIMARY KEY (conflict_cat); - - --- --- Name: dkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- Name: deeds dkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY deeds @@ -2066,7 +1493,7 @@ ALTER TABLE ONLY deeds -- --- Name: hist_beacons_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- Name: hist_beacons hist_beacons_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY hist_beacons @@ -2074,15 +1501,7 @@ ALTER TABLE ONLY hist_beacons -- --- Name: hq_pkey; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY lg_hqtrs - ADD CONSTRAINT hq_pkey PRIMARY KEY (hq_code); - - --- --- Name: instrument_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: instrument_cat instrument_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY instrument_cat @@ -2090,7 +1509,7 @@ ALTER TABLE ONLY instrument_cat -- --- Name: local_govt_id_key; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: local_govt local_govt_id_key; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY local_govt @@ -2098,7 +1517,7 @@ ALTER TABLE ONLY local_govt -- --- Name: local_govt_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: local_govt local_govt_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY local_govt @@ -2106,31 +1525,7 @@ ALTER TABLE ONLY local_govt -- --- Name: lut_poi_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY lut_poi_cat - ADD CONSTRAINT lut_poi_cat_pkey PRIMARY KEY (id); - - --- --- Name: official_gazzette_pkey; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY official_gazzette - ADD CONSTRAINT official_gazzette_pkey PRIMARY KEY (gid); - - --- --- Name: ogunroadnetwork_pkey1; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY ogunroadnetwork - ADD CONSTRAINT ogunroadnetwork_pkey1 PRIMARY KEY (gid); - - --- --- Name: parcel_def_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_def parcel_def_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_def @@ -2138,7 +1533,7 @@ ALTER TABLE ONLY parcel_def -- --- Name: parcel_lookup_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_lookup_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup @@ -2146,15 +1541,7 @@ ALTER TABLE ONLY parcel_lookup -- --- Name: pois_pkey; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY pois - ADD CONSTRAINT pois_pkey PRIMARY KEY (id); - - --- --- Name: print_survey_details_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: print_survey_details print_survey_details_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY print_survey_details @@ -2162,7 +1549,7 @@ ALTER TABLE ONLY print_survey_details -- --- Name: prop_type_code_key; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: prop_types prop_type_code_key; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY prop_types @@ -2170,7 +1557,7 @@ ALTER TABLE ONLY prop_types -- --- Name: prop_type_id_key; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: prop_types prop_type_id_key; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY prop_types @@ -2178,7 +1565,7 @@ ALTER TABLE ONLY prop_types -- --- Name: prop_type_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: prop_types prop_type_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY prop_types @@ -2186,7 +1573,7 @@ ALTER TABLE ONLY prop_types -- --- Name: schemes_id_key; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: schemes schemes_id_key; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY schemes @@ -2194,7 +1581,7 @@ ALTER TABLE ONLY schemes -- --- Name: schemes_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: schemes schemes_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY schemes @@ -2202,15 +1589,7 @@ ALTER TABLE ONLY schemes -- --- Name: sen_key; Type: CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY sen_districts - ADD CONSTRAINT sen_key PRIMARY KEY (sen_code); - - --- --- Name: status_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: status_cat status_cat_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY status_cat @@ -2218,7 +1597,7 @@ ALTER TABLE ONLY status_cat -- --- Name: survey_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: survey survey_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY survey @@ -2226,7 +1605,7 @@ ALTER TABLE ONLY survey -- --- Name: survey_plan_no_key; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: survey survey_plan_no_key; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY survey @@ -2234,7 +1613,7 @@ ALTER TABLE ONLY survey -- --- Name: survey_plan_no_key1; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: survey survey_plan_no_key1; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY survey @@ -2242,7 +1621,7 @@ ALTER TABLE ONLY survey -- --- Name: transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: docker +-- Name: transactions transactions_pkey; Type: CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY transactions @@ -2313,14 +1692,14 @@ CREATE INDEX fki_transactions_survey_fkey ON transactions USING btree (survey); -- --- Name: hist_beacons_idx1; Type: INDEX; Schema: public; Owner: postgres +-- Name: hist_beacons_idx1; Type: INDEX; Schema: public; Owner: docker -- CREATE INDEX hist_beacons_idx1 ON hist_beacons USING btree (gid); -- --- Name: hist_beacons_idx2; Type: INDEX; Schema: public; Owner: postgres +-- Name: hist_beacons_idx2; Type: INDEX; Schema: public; Owner: docker -- CREATE INDEX hist_beacons_idx2 ON hist_beacons USING btree (hist_time); @@ -2354,13 +1733,6 @@ CREATE UNIQUE INDEX idp_parcel_overlap_matviews ON parcel_overlap_matviews USING CREATE UNIQUE INDEX idp_parcels_intersect ON parcels_intersect USING btree (parcel_id); --- --- Name: idp_pois_view; Type: INDEX; Schema: public; Owner: docker --- - -CREATE UNIQUE INDEX idp_pois_view ON pois_view USING btree (id); - - -- -- Name: idx_beacons_intersect_geom; Type: INDEX; Schema: public; Owner: docker -- @@ -2410,13 +1782,6 @@ CREATE INDEX idx_parcels_intersects_new_matviews_geom ON parcels_intersect USING CREATE INDEX ndx_schemes1 ON schemes USING gin (to_tsvector('english'::regconfig, (COALESCE(scheme_name, ''::character varying))::text)); --- --- Name: ogunroadnetwork_geom_gist; Type: INDEX; Schema: public; Owner: docker --- - -CREATE INDEX ogunroadnetwork_geom_gist ON ogunroadnetwork USING gist (the_geom); - - -- -- Name: parcel_over_idx; Type: INDEX; Schema: public; Owner: docker -- @@ -2424,13 +1789,6 @@ CREATE INDEX ogunroadnetwork_geom_gist ON ogunroadnetwork USING gist (the_geom); CREATE INDEX parcel_over_idx ON parcel_overlap_matviews USING gist (the_geom); --- --- Name: pois_over_idx; Type: INDEX; Schema: public; Owner: docker --- - -CREATE INDEX pois_over_idx ON pois_view USING gist (geom); - - -- -- Name: sidx_beacons_geom; Type: INDEX; Schema: public; Owner: docker -- @@ -2439,49 +1797,42 @@ CREATE INDEX sidx_beacons_geom ON beacons USING gist (the_geom); -- --- Name: sidx_pois_geom; Type: INDEX; Schema: public; Owner: docker --- - -CREATE INDEX sidx_pois_geom ON pois USING gist (the_geom); - - --- --- Name: insert_nodes_geom; Type: TRIGGER; Schema: public; Owner: docker +-- Name: beacons insert_nodes_geom; Type: TRIGGER; Schema: public; Owner: docker -- CREATE TRIGGER insert_nodes_geom BEFORE INSERT OR UPDATE ON beacons FOR EACH ROW EXECUTE PROCEDURE calc_point(); -- --- Name: parcel_lookup_define_parcel; Type: TRIGGER; Schema: public; Owner: docker +-- Name: parcel_def parcel_lookup_define_parcel; Type: TRIGGER; Schema: public; Owner: docker -- CREATE TRIGGER parcel_lookup_define_parcel BEFORE INSERT OR UPDATE ON parcel_def FOR EACH ROW EXECUTE PROCEDURE parcel_lookup_define_parcel_trigger(); -- --- Name: trg_beacons_after_insert; Type: TRIGGER; Schema: public; Owner: docker +-- Name: beacons trg_beacons_after_insert; Type: TRIGGER; Schema: public; Owner: docker -- CREATE TRIGGER trg_beacons_after_insert AFTER INSERT ON beacons FOR EACH ROW EXECUTE PROCEDURE fn_beacons_after_insert(); -- --- Name: trg_beacons_before_delete; Type: TRIGGER; Schema: public; Owner: docker +-- Name: beacons trg_beacons_before_delete; Type: TRIGGER; Schema: public; Owner: docker -- CREATE TRIGGER trg_beacons_before_delete BEFORE DELETE ON beacons FOR EACH ROW EXECUTE PROCEDURE fn_beacons_before_delete(); -- --- Name: trg_beacons_before_update; Type: TRIGGER; Schema: public; Owner: docker +-- Name: beacons trg_beacons_before_update; Type: TRIGGER; Schema: public; Owner: docker -- CREATE TRIGGER trg_beacons_before_update BEFORE UPDATE ON beacons FOR EACH ROW EXECUTE PROCEDURE fn_beacons_before_update(); -- --- Name: beardist_beacon_from_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_beacon_from_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2489,7 +1840,7 @@ ALTER TABLE ONLY beardist -- --- Name: beardist_beacon_from_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_beacon_from_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2497,7 +1848,7 @@ ALTER TABLE ONLY beardist -- --- Name: beardist_beacon_to_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_beacon_to_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2505,7 +1856,7 @@ ALTER TABLE ONLY beardist -- --- Name: beardist_beacon_to_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_beacon_to_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2513,7 +1864,7 @@ ALTER TABLE ONLY beardist -- --- Name: beardist_plan_no_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_plan_no_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2521,7 +1872,7 @@ ALTER TABLE ONLY beardist -- --- Name: beardist_plan_no_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: beardist beardist_plan_no_fkey1; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY beardist @@ -2529,15 +1880,7 @@ ALTER TABLE ONLY beardist -- --- Name: hq_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker --- - -ALTER TABLE ONLY ogunadmin - ADD CONSTRAINT hq_fkey FOREIGN KEY (lg_hq) REFERENCES lg_hqtrs(hq_code); - - --- --- Name: parcel_def_beacon_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_def parcel_def_beacon_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_def @@ -2545,7 +1888,7 @@ ALTER TABLE ONLY parcel_def -- --- Name: parcel_def_parcel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_def parcel_def_parcel_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_def @@ -2553,7 +1896,7 @@ ALTER TABLE ONLY parcel_def -- --- Name: parcel_lookup_allocation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_lookup_allocation_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup @@ -2561,7 +1904,7 @@ ALTER TABLE ONLY parcel_lookup -- --- Name: parcel_lookup_local_govt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_lookup_local_govt_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup @@ -2569,7 +1912,7 @@ ALTER TABLE ONLY parcel_lookup -- --- Name: parcel_lookup_prop_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_lookup_prop_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup @@ -2577,7 +1920,7 @@ ALTER TABLE ONLY parcel_lookup -- --- Name: parcel_lookup_scheme_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_lookup_scheme_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup @@ -2585,7 +1928,7 @@ ALTER TABLE ONLY parcel_lookup -- --- Name: parcel_lookup_status_cat_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: parcel_lookup parcel_lookup_status_cat_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY parcel_lookup @@ -2593,7 +1936,7 @@ ALTER TABLE ONLY parcel_lookup -- --- Name: survey_ref_beacon_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: survey survey_ref_beacon_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY survey @@ -2601,7 +1944,7 @@ ALTER TABLE ONLY survey -- --- Name: survey_scheme_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: survey survey_scheme_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY survey @@ -2609,7 +1952,7 @@ ALTER TABLE ONLY survey -- --- Name: transactions_instrument_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: transactions transactions_instrument_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY transactions @@ -2617,7 +1960,7 @@ ALTER TABLE ONLY transactions -- --- Name: transactions_parcel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: transactions transactions_parcel_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY transactions @@ -2625,7 +1968,7 @@ ALTER TABLE ONLY transactions -- --- Name: transactions_survey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker +-- Name: transactions transactions_survey_fkey; Type: FK CONSTRAINT; Schema: public; Owner: docker -- ALTER TABLE ONLY transactions @@ -2636,12 +1979,10 @@ ALTER TABLE ONLY transactions -- Name: public; Type: ACL; Schema: -; Owner: postgres -- -REVOKE ALL ON SCHEMA public FROM PUBLIC; -REVOKE ALL ON SCHEMA public FROM postgres; -GRANT ALL ON SCHEMA public TO postgres; -GRANT ALL ON SCHEMA public TO PUBLIC; + -- -- PostgreSQL database dump complete -- + From 7c0532e168d4da2a522646ab6793a28648282c83 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Fri, 23 Jun 2017 19:13:13 +0700 Subject: [PATCH 05/10] add utility to get path for data directory --- utilities.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/utilities.py b/utilities.py index e7a1594..6106117 100644 --- a/utilities.py +++ b/utilities.py @@ -27,6 +27,27 @@ def images_path(*args): return path +def data_path(*args): + """Get the path to our resources folder. + + .. versionadded:: 3.0 + + Note that in version 3.0 we removed the use of Qt Resource files in + favour of directly accessing on-disk resources. + + :param args List of path elements e.g. ['img', 'logos', 'image.png'] + :type args: list[str] + + :return: Absolute path to the resources folder. + :rtype: str + """ + path = os.path.dirname(__file__) + path = os.path.abspath( + os.path.join(path, 'data')) + for item in args: + path = os.path.abspath(os.path.join(path, item)) + + return path def get_ui_class(ui_file): """Get UI Python class from .ui file. From 5e0874b62f7f336ae60348c6167175a943fffae4 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Fri, 23 Jun 2017 19:14:24 +0700 Subject: [PATCH 06/10] fix reading credentials from user --- database.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/database.py b/database.py index 57432a8..6802432 100755 --- a/database.py +++ b/database.py @@ -44,7 +44,8 @@ def connect(self, parameters): if not hasattr(self, 'conn') or self.connection is None: if parameters.get("SERVICE"): self.connection = psycopg2.connect( - "service='{SERVICE}'".format( + "service='{SERVICE}' user='{USER}' " + "password='{PASSWORD}'".format( SERVICE=parameters["SERVICE"], USER=parameters["USER"], PASSWORD=parameters["PASSWORD"] From e2dfb13439380abf42c035ca87de263d13003d9f Mon Sep 17 00:00:00 2001 From: myarjunar Date: Fri, 23 Jun 2017 19:15:23 +0700 Subject: [PATCH 07/10] setup cogo schema if there is no cogo schema in the selected db --- PyQt4Dialogs.py | 133 +++++++++++++++++++++++++++++++++--------------- plugin.py | 9 ++-- 2 files changed, 97 insertions(+), 45 deletions(-) diff --git a/PyQt4Dialogs.py b/PyQt4Dialogs.py index 25297d4..f07fb60 100755 --- a/PyQt4Dialogs.py +++ b/PyQt4Dialogs.py @@ -23,7 +23,7 @@ from qgisToolbox import FeatureSelector from PyQt4Widgets import XQPushButton, XQDialogButtonBox from database import * -from utilities import images_path, get_ui_class +from utilities import images_path, get_ui_class, data_path UI_CLASS = get_ui_class("ui_pgnewconnection.ui") @@ -186,7 +186,6 @@ def __init__(self): self.crs = None self.setup_ui() self.populate_database_choices() - self.populate_crs_choices() def get_database_connection(self): return self.connection @@ -203,24 +202,6 @@ def populate_database_choices(self): for index, database in enumerate(settings.childGroups()): self.cmbbx_conn.addItem(database) - def populate_crs_choices(self): - """ Populate crs choices. - """ - crs_options = [ - { - 'auth_id': 32631, - 'crs_name': 'WGS 84 / UTM zone 31N' - }, - { - 'auth_id': 32632, - 'crs_name': 'WGS 84 / UTM zone 32N' - } - ] - - for index, crs_option in enumerate(crs_options): - self.combobox_crs.addItem(crs_option['crs_name']) - self.combobox_crs.setItemData(index, crs_option, Qt.UserRole) - def test_database_connection(self): """ Test database connection has necessary tables """ @@ -233,18 +214,98 @@ def test_database_connection(self): else: self.connection = connection - crs_index = self.combobox_crs.currentIndex() - if not bool(self.combobox_crs.itemData(crs_index, Qt.UserRole)): - QMessageBox.information( - self, - "Coordinate Reference System (CRS)", - "Please select a Coordinate Reference System (CRS)") - else: - self.crs = self.combobox_crs.itemData(crs_index, Qt.UserRole) - - if self.connection and self.crs: + if self.connection: + ok = self.test_database_schema() + if not ok: + return self.accept() + def test_database_schema(self): + """Test whether co-go schema is applied in the database.""" + query = "SELECT EXISTS (SELECT 1 AS result FROM pg_tables " \ + "WHERE schemaname = 'public' AND tablename = 'beacons')" + + settings_postgis = QSettings() + settings_postgis.beginGroup('PostgreSQL/connections') + max_attempts = 3 + is_credential_exist = True + + db_service = settings_postgis.value(self.connection + '/service') + db_host = settings_postgis.value(self.connection + '/host') + db_port = settings_postgis.value(self.connection + '/port') + db_name = settings_postgis.value(self.connection + '/database') + db_username = settings_postgis.value(self.connection + '/username') + db_password = settings_postgis.value(self.connection + '/password') + + uri = QgsDataSourceURI() + uri.setConnection( + db_host, + db_port, + db_name, + db_username, + db_password) + + if not db_username and not db_password: + msg = "Please enter the username and password." + for i in range(max_attempts): + ok, db_username, db_password = ( + QgsCredentials.instance().get( + uri.connectionInfo(), + db_username, + db_password, + msg + )) + + connection = None + if is_credential_exist: + if db_service: + connection = psycopg2.connect( + "service='{SERVICE}' user='{USER}' " + "password='{PASSWORD}'".format( + SERVICE=db_service, + USER=db_username, + PASSWORD=db_password + )) + else: + connection = psycopg2.connect( + "host='{HOST}' dbname='{NAME}' user='{USER}' " + "password='{PASSWORD}' port='{PORT}'".format( + HOST=db_host, + NAME=db_name, + USER=db_username, + PASSWORD=db_password, + PORT=db_port + )) + + if connection: + cursor = connection.cursor() + cursor.execute(query) + is_schema_valid = cursor.fetchall()[0][0] + del cursor + + if not is_schema_valid: + + message = ("WARNING: There is no cogo schema found in this " + "database. Please select CRS \nand click OK " + "button to setup cogo schema in this database.") + crs_options = { + 'WGS 84 / UTM zone 31N': 32631, + 'WGS 84 / UTM zone 32N': 32632 + } + items = crs_options.keys() + + item, ok = QInputDialog.getItem( + self, "Setup Database Schema", message, items, 0, False) + + if item and ok: + query = open(data_path("sml_database.sql"), "r").read() + query = query.replace(":CRS", "{CRS}") + cursor = connection.cursor() + cursor.execute(query.format(CRS=crs_options[item])) + connection.commit() + + return ok + def setup_ui(self): """ Initialize ui """ @@ -287,13 +348,6 @@ def setup_ui(self): self.horizontalLayout.setContentsMargins(0, 0, 0, 0) self.formLayout.setLayout( 1, QFormLayout.FieldRole, self.horizontalLayout) - # crs combobox start here - self.label_crs = QLabel(self) - self.label_crs.setObjectName(_from_utf8("label_crs")) - self.formLayout.setWidget(2, QFormLayout.LabelRole, self.label_crs) - self.combobox_crs = QComboBox(self) - self.combobox_crs.setObjectName(_from_utf8("combobox_crs")) - self.formLayout.setWidget(2, QFormLayout.FieldRole, self.combobox_crs) self.verticalLayout.addSpacerItem(QSpacerItem(50, 10)) self.btnbx_options = XQDialogButtonBox(self) self.btnbx_options.setOrientation(Qt.Horizontal) @@ -314,11 +368,6 @@ def setup_ui(self): "Connection: ", None )) - self.label_crs.setText(QApplication.translate( - "DatabaseConnectionDialog", - "CRS: ", - None - )) self.lbl_instr.setText(QApplication.translate( "DatabaseConnectionDialog", "A database connection has not yet been selected or " diff --git a/plugin.py b/plugin.py index 2fdaa7d..8765085 100644 --- a/plugin.py +++ b/plugin.py @@ -73,6 +73,7 @@ def __init__(self, iface): self.plugin_dir = os.path.dirname(os.path.realpath(__file__)) self.uri = None self.connection = None + self.crs = None self.database = None self.datetime = datetime.now() self.required_layers = [] @@ -171,7 +172,6 @@ def set_database_connection(self, connection=None, crs=None): settings_plugin.beginGroup(metadata.name().replace(" ", "_")) settings_postgis.beginGroup('PostgreSQL/connections') self.connection = connection - self.crs = QgsCoordinateReferenceSystem(crs.get('auth_id')) if not bool(self.connection): # fetch pre-chosen database connection self.connection = settings_plugin.value("DatabaseConnection", None) @@ -186,8 +186,9 @@ def set_database_connection(self, connection=None, crs=None): dialog.show() if bool(dialog.exec_()): self.connection = dialog.get_database_connection() - self.crs = QgsCoordinateReferenceSystem( - dialog.get_crs().get('auth_id')) + if dialog.get_crs(): + self.crs = QgsCoordinateReferenceSystem( + dialog.get_crs().get('auth_id')) settings_plugin.setValue("DatabaseConnection", self.connection) # validate database connection if bool(self.connection): @@ -225,6 +226,8 @@ def set_database_connection(self, connection=None, crs=None): error_message)) if not ok: break + else: + break else: msg = "Please enter the username and password." From 1a566b70be8a0bf0b5928e6de1e71d98d2268833 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Fri, 23 Jun 2017 19:27:36 +0700 Subject: [PATCH 08/10] fix get path utility --- PyQt4Dialogs.py | 5 +++-- utilities.py | 6 ++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/PyQt4Dialogs.py b/PyQt4Dialogs.py index f07fb60..9ae2471 100755 --- a/PyQt4Dialogs.py +++ b/PyQt4Dialogs.py @@ -23,7 +23,7 @@ from qgisToolbox import FeatureSelector from PyQt4Widgets import XQPushButton, XQDialogButtonBox from database import * -from utilities import images_path, get_ui_class, data_path +from utilities import images_path, get_ui_class, get_path UI_CLASS = get_ui_class("ui_pgnewconnection.ui") @@ -298,7 +298,8 @@ def test_database_schema(self): self, "Setup Database Schema", message, items, 0, False) if item and ok: - query = open(data_path("sml_database.sql"), "r").read() + query = open( + get_path("scripts","database_setup.sql"), "r").read() query = query.replace(":CRS", "{CRS}") cursor = connection.cursor() cursor.execute(query.format(CRS=crs_options[item])) diff --git a/utilities.py b/utilities.py index 6106117..37cc479 100644 --- a/utilities.py +++ b/utilities.py @@ -27,8 +27,8 @@ def images_path(*args): return path -def data_path(*args): - """Get the path to our resources folder. +def get_path(*args): + """Get the path to our specific folder from plugin folder. .. versionadded:: 3.0 @@ -42,8 +42,6 @@ def data_path(*args): :rtype: str """ path = os.path.dirname(__file__) - path = os.path.abspath( - os.path.join(path, 'data')) for item in args: path = os.path.abspath(os.path.join(path, item)) From 027e8077b42d006d7a17c818ec55d9b30f536fa8 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Wed, 28 Jun 2017 02:52:17 +0700 Subject: [PATCH 09/10] change setup db dialog text --- PyQt4Dialogs.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/PyQt4Dialogs.py b/PyQt4Dialogs.py index 9ae2471..860277c 100755 --- a/PyQt4Dialogs.py +++ b/PyQt4Dialogs.py @@ -285,9 +285,11 @@ def test_database_schema(self): if not is_schema_valid: - message = ("WARNING: There is no cogo schema found in this " - "database. Please select CRS \nand click OK " - "button to setup cogo schema in this database.") + message = ("WARNING: The selected database does not contain " + "tables and functions required for use of " + "the plugin. Please select a CRS and click " + "OK to procees setting up a database using " + "the chosen CRS.") crs_options = { 'WGS 84 / UTM zone 31N': 32631, 'WGS 84 / UTM zone 32N': 32632 From aa109b562125561b5068c0d5359d1189ec1100d9 Mon Sep 17 00:00:00 2001 From: myarjunar Date: Tue, 4 Jul 2017 14:33:21 +0700 Subject: [PATCH 10/10] add crs options --- PyQt4Dialogs.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PyQt4Dialogs.py b/PyQt4Dialogs.py index 860277c..6b13c06 100755 --- a/PyQt4Dialogs.py +++ b/PyQt4Dialogs.py @@ -292,7 +292,9 @@ def test_database_schema(self): "the chosen CRS.") crs_options = { 'WGS 84 / UTM zone 31N': 32631, - 'WGS 84 / UTM zone 32N': 32632 + 'Minna / UTM zone 31N': 26331, + 'WGS 84 / UTM zone 32N': 32632, + 'Minna / UTM zone 32N': 26332 } items = crs_options.keys()