ST_MakeLine(
ST_Point(25,45), ST_Point(25 + ST_Length('LINESTRING(25 45,75 100)'::Geometry) ,45))
); -- horizontal -- LINESTRING(25 45,99.33034 45)
-
+
-- control point
SELECT ST_AsText(
ST_SnapToGrid(
ST_MakeLine(
ST_Point(75,100), ST_Point(75 + ST_Length('LINESTRING(25 45,75 100)'::Geometry) ,100))
); -- horizontal -- LINESTRING(75 100,149.33034 100)
-
+
-- control point
SELECT ST_AsText(
ST_SnapToGrid(
-- LINESTRING(149.33034 100,148.97241 107.28565,147.90209 114.50113,146.12969 121.57695,143.67226 128.44498,140.55349 135.03907,136.8034 141.29571,132.4581 147.15465,127.55946 152.55946,122.15464 157.4581,116.29569 161.80338,110.03905 165.55347,103.44496 168.67223,96.57693 171.12965,89.5011 172.90205,82.28562 173.97236,74.99997 174.33027,67.71433 173.97235,60.49885 172.90203,53.42302 171.12962,46.55499 168.6722,39.96091 165.55342,33.70427 161.80333,27.84533 157.45804,22.44051 152.55939,17.54187 147.15457,13.19659 141.29563,9.44651 135.03898,6.32774 128.44489,3.87032 121.57686,2.09792 114.50103,1.02761 107.28555,0.6697 99.99991,1.02762 92.71426,2.09794 85.49878,3.87035 78.42295,6.32777 71.55493,9.44655 64.96084,13.19664 58.7042,17.54193 52.84526,22.44058 47.44045,25 45)
SELECT ST_AsText(ST_SnapToGrid(ST_CurveToLine('CIRCULARSTRING(149.33034 100, 136.8034 141.2957,25 45)',16),0.00001));
-
----------------------------------------------------------------------\r
--- Core types to access the PAGC address standardizer\r
--- Author: Stephen Woodbridge <woodbri@imaptools.com>\r
----------------------------------------------------------------------\r
-\r
-CREATE TYPE stdaddr AS (\r
- building text,\r
- house_num text,\r
- predir text,\r
- qual text,\r
- pretype text,\r
- name text,\r
- suftype text,\r
- sufdir text,\r
- ruralroute text,\r
- extra text,\r
- city text,\r
- state text,\r
- country text,\r
- postcode text,\r
- box text,\r
- unit text\r
-);\r
+---------------------------------------------------------------------
+-- Core types to access the PAGC address standardizer
+-- Author: Stephen Woodbridge <woodbri@imaptools.com>
+---------------------------------------------------------------------
+
+CREATE TYPE stdaddr AS (
+ building text,
+ house_num text,
+ predir text,
+ qual text,
+ pretype text,
+ name text,
+ suftype text,
+ sufdir text,
+ ruralroute text,
+ extra text,
+ city text,
+ state text,
+ country text,
+ postcode text,
+ box text,
+ unit text
+);
-CREATE EXTENSION address_standardizer;\r
+CREATE EXTENSION address_standardizer;
CREATE EXTENSION address_standardizer_data_us;
\ No newline at end of file
outstring text
);
copy test_parse_address (instring, outstring) from stdin;
-@@ sttype dirs dirs words$
+@@ sttype dirs dirs words$
123 oak ln e n mycity ny (123,"oak ln e",,"123 oak ln e","n mycity",NY,,,US)
123 oak lane east n mycity ny (123,"oak lane east",,"123 oak lane east","n mycity",NY,,,US)
123 oak ln e north mycity ny (123,"oak ln e",,"123 oak ln e","north mycity",NY,,,US)
-@@ sttype dirs dirs saint words$
+@@ sttype dirs dirs saint words$
123 oak ln e n st marie ny (123,"oak ln e",,"123 oak ln e","n st marie",NY,,,US)
123 oak lane east n st marie ny (123,"oak lane east",,"123 oak lane east","n st marie",NY,,,US)
123 oak ln e north st marie ny (123,"oak ln e",,"123 oak ln e","north st marie",NY,,,US)
123 oak ln e n saint marie ny (123,"oak ln e",,"123 oak ln e","n saint marie",NY,,,US)
123 oak lane east n saint marie ny (123,"oak lane east",,"123 oak lane east","n saint marie",NY,,,US)
123 oak ln e north saint marie ny (123,"oak ln e",,"123 oak ln e","north saint marie",NY,,,US)
-@@ sttype dirs saint words$
+@@ sttype dirs saint words$
123 oak ln e st marie ny (123,"oak ln",,"123 oak ln","e st marie",NY,,,US)
123 oak lane east st marie ny (123,"oak lane",,"123 oak lane","east st marie",NY,,,US)
123 oak ln e st marie ny (123,"oak ln",,"123 oak ln","e st marie",NY,,,US)
123 oak ln e saint marie ny (123,"oak ln",,"123 oak ln","e saint marie",NY,,,US)
123 oak lane east saint marie ny (123,"oak lane",,"123 oak lane","east saint marie",NY,,,US)
123 oak ln e saint marie ny (123,"oak ln",,"123 oak ln","e saint marie",NY,,,US)
-@@ sttype saint words$
+@@ sttype saint words$
123 oak ln st marie ny (123,"oak ln",,"123 oak ln","st marie",NY,,,US)
123 oak lane st marie ny (123,"oak lane",,"123 oak lane","st marie",NY,,,US)
123 oak ln st marie ny (123,"oak ln",,"123 oak ln","st marie",NY,,,US)
123 oak ln saint marie ny (123,"oak ln",,"123 oak ln","saint marie",NY,,,US)
123 oak lane saint marie ny (123,"oak lane",,"123 oak lane","saint marie",NY,,,US)
123 oak ln saint marie ny (123,"oak ln",,"123 oak ln","saint marie",NY,,,US)
-@@ sttype words$
+@@ sttype words$
123 oak ln marie ny (123,"oak ln",,"123 oak ln",marie,NY,,,US)
123 oak ln new marie ny (123,"oak ln",,"123 oak ln","new marie",NY,,,US)
-@@ === same as above but with commas ===
-@@ sttype dirs dirs words$
+@@ === same as above but with commas ===
+@@ sttype dirs dirs words$
123 oak ln e, n mycity ny (123,"oak ln e",,"123 oak ln e","n mycity",NY,,,US)
123 oak lane east, n mycity ny (123,"oak lane east",,"123 oak lane east","n mycity",NY,,,US)
123 oak ln e, north mycity ny (123,"oak ln e",,"123 oak ln e","north mycity",NY,,,US)
123 oak ln e n, mycity ny (123,"oak ln e n",,"123 oak ln e n",mycity,NY,,,US)
123 oak lane east n, mycity ny (123,"oak lane east n",,"123 oak lane east n",mycity,NY,,,US)
123 oak ln e north, mycity ny (123,"oak ln e north",,"123 oak ln e north",mycity,NY,,,US)
-@@ sttype dirs dirs saint words$
+@@ sttype dirs dirs saint words$
123 oak ln e, n st marie ny (123,"oak ln e",,"123 oak ln e","n st marie",NY,,,US)
123 oak lane east, n st marie ny (123,"oak lane east",,"123 oak lane east","n st marie",NY,,,US)
123 oak ln e, north st marie ny (123,"oak ln e",,"123 oak ln e","north st marie",NY,,,US)
123 oak ln e, n saint marie ny (123,"oak ln e",,"123 oak ln e","n saint marie",NY,,,US)
123 oak lane east, n saint marie ny (123,"oak lane east",,"123 oak lane east","n saint marie",NY,,,US)
123 oak ln e, north saint marie ny (123,"oak ln e",,"123 oak ln e","north saint marie",NY,,,US)
-@@ sttype dirs saint words$
+@@ sttype dirs saint words$
123 oak ln e, st marie ny (123,"oak ln e",,"123 oak ln e","st marie",NY,,,US)
123 oak lane east, st marie ny (123,"oak lane east",,"123 oak lane east","st marie",NY,,,US)
123 oak ln e, st marie ny (123,"oak ln e",,"123 oak ln e","st marie",NY,,,US)
123 oak ln e, saint marie ny (123,"oak ln e",,"123 oak ln e","saint marie",NY,,,US)
123 oak lane east, saint marie ny (123,"oak lane east",,"123 oak lane east","saint marie",NY,,,US)
123 oak ln e, saint marie ny (123,"oak ln e",,"123 oak ln e","saint marie",NY,,,US)
-@@ sttype saint words$
+@@ sttype saint words$
123 oak ln, st marie ny (123,"oak ln",,"123 oak ln","st marie",NY,,,US)
123 oak lane, st marie ny (123,"oak lane",,"123 oak lane","st marie",NY,,,US)
123 oak ln, st marie ny (123,"oak ln",,"123 oak ln","st marie",NY,,,US)
123 oak ln, saint marie ny (123,"oak ln",,"123 oak ln","saint marie",NY,,,US)
123 oak lane, saint marie ny (123,"oak lane",,"123 oak lane","saint marie",NY,,,US)
123 oak ln, saint marie ny (123,"oak ln",,"123 oak ln","saint marie",NY,,,US)
-@@ sttype words$
+@@ sttype words$
123 oak ln, marie ny (123,"oak ln",,"123 oak ln",marie,NY,,,US)
123 oak ln, new marie ny (123,"oak ln",,"123 oak ln","new marie",NY,,,US)
\.
INSERT INTO us_lex (seq, word, stdword, token) VALUES (1, 'ZERO', '0', 1);
INSERT INTO us_lex (seq, word, stdword, token) VALUES (1, 'ZNJA', 'ZANJA', 1);
-
-- needed set default back to original
ALTER TABLE us_lex ALTER COLUMN is_custom SET DEFAULT true;
INSERT INTO us_rules (rule) VALUES ('0 1 6 -1 1 5 5 -1 1 9');
INSERT INTO us_rules (rule) VALUES ('-1');
-
-- needed so entries added by users will default to custom
ALTER TABLE us_rules ALTER COLUMN is_custom SET DEFAULT true;
AND deptype = 'e' AND e.extname = 'postgis_tiger_geocoder'
ORDER BY sqladd;
-
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
----
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
-- the terms of the GNU General Public Licence. See the COPYING file.
--
-- Author: Regina Obe <lr@pcorp.us>
---
+--
-- This adds the tiger schema to search path
--- Functions in tiger are not schema qualified
+-- Functions in tiger are not schema qualified
-- so this is needed for them to work
SELECT postgis_extension_AddToSearchPath('tiger');
location VARCHAR,
stateAbbrev VARCHAR,
zip VARCHAR,
- parsed BOOLEAN,
- zip4 varchar,
+ parsed BOOLEAN,
+ zip4 varchar,
address_alphanumeric varchar);
-ALTER TYPE tiger.norm_addy ADD ATTRIBUTE zip4 varchar(4);\r
+ALTER TYPE tiger.norm_addy ADD ATTRIBUTE zip4 varchar(4);
ALTER TYPE tiger.norm_addy ADD ATTRIBUTE address_alphanumeric varchar;
\ No newline at end of file
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
----
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
-- the terms of the GNU General Public Licence. See the COPYING file.
--
-- Author: Regina Obe <lr@pcorp.us>
---
+--
-- This drops extension helper functions
-- and should be called at the end of the extension upgrade file
--- removes all postgis_topology functions from postgis_topology extension since they will be readded
+-- removes all postgis_topology functions from postgis_topology extension since they will be readded
-- during upgrade
SELECT postgis_extension_remove_objects('postgis_tiger_geocoder', 'FUNCTION');
SELECT postgis_extension_remove_objects('postgis_tiger_geocoder', 'AGGREGATE');
--- these introduced in PostGIS 2.4\r
-DO language plpgsql\r
-$$\r
- BEGIN\r
- ALTER TYPE tiger.norm_addy ADD ATTRIBUTE zip4 varchar;\r
- ALTER TYPE tiger.norm_addy ADD ATTRIBUTE address_alphanumeric varchar;\r
- EXCEPTION\r
- WHEN others THEN -- ignore the error probably cause it already exists\r
- END;\r
+-- these introduced in PostGIS 2.4
+DO language plpgsql
+$$
+ BEGIN
+ ALTER TYPE tiger.norm_addy ADD ATTRIBUTE zip4 varchar;
+ ALTER TYPE tiger.norm_addy ADD ATTRIBUTE address_alphanumeric varchar;
+ EXCEPTION
+ WHEN others THEN -- ignore the error probably cause it already exists
+ END;
$$;
\ No newline at end of file
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
----
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
-- the terms of the GNU General Public Licence. See the COPYING file.
--
-- Author: Regina Obe <lr@pcorp.us>
---
+--
-- This drops extension helper functions
-- and should be called at the end of the extension upgrade file
--- removes all postgis_topology functions from postgis_topology extension since they will be readded
+-- removes all postgis_topology functions from postgis_topology extension since they will be readded
-- during upgrade
SELECT postgis_extension_remove_objects('postgis_topology', 'FUNCTION');
SELECT postgis_extension_remove_objects('postgis_topology', 'AGGREGATE');
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#define CREATEFUNCTION CREATE OR REPLACE FUNCTION
# define _VOLATILE_STRICT VOLATILE STRICT
# define _VOLATILE VOLATILE
# define _STRICT STRICT
-#else
+#else
# define _IMMUTABLE_STRICT with(iscachable,isstrict)
# define _IMMUTABLE with(iscachable)
# define _STABLE_STRICT with(isstrict)
-# define _STABLE
+# define _STABLE
# define _VOLATILE_STRICT with(isstrict)
-# define _VOLATILE
+# define _VOLATILE
# define _STRICT with(isstrict)
-#endif
+#endif
#if USE_VERSION >= 73
# define HAS_SCHEMAS 1
#endif
-
-----------------------------------------------------------------------
-- LONG TERM LOCKING
-----------------------------------------------------------------------
'
LANGUAGE 'plpgsql' _VOLATILE_STRICT;
--- LockRow([schema], table, rowid, auth, [expires])
+-- LockRow([schema], table, rowid, auth, [expires])
-- Returns 1 if successfully obtained the lock, 0 otherwise
CREATEFUNCTION LockRow(text, text, text, text, timestamp)
RETURNS int
ret int;
mytoid oid;
myrec RECORD;
-
+
BEGIN
IF NOT LongTransactionsEnabled() THEN
RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
END IF;
- EXECUTE ''DELETE FROM authorization_table WHERE expires < now()'';
+ EXECUTE ''DELETE FROM authorization_table WHERE expires < now()'';
#ifdef HAS_SCHEMAS
SELECT c.oid INTO mytoid FROM pg_class c, pg_namespace n
-- RAISE NOTICE ''toid: %'', mytoid;
- FOR myrec IN SELECT * FROM authorization_table WHERE
+ FOR myrec IN SELECT * FROM authorization_table WHERE
toid = mytoid AND rid = myrid
LOOP
IF myrec.authid != authid THEN
#endif
LANGUAGE 'sql' _VOLATILE_STRICT;
-
CREATEFUNCTION AddAuth(text)
RETURNS BOOLEAN
AS '
okay := ''f'';
FOR myrec IN SELECT * FROM pg_class WHERE relname = ''temp_lock_have_table'' LOOP
okay := ''t'';
- END LOOP;
- IF (okay <> ''t'') THEN
+ END LOOP;
+ IF (okay <> ''t'') THEN
CREATE TEMP TABLE temp_lock_have_table (transid xid, lockcode text);
-- this will only work from pgsql7.4 up
-- ON COMMIT DELETE ROWS;
END;
'
LANGUAGE PLPGSQL;
-
-- CheckAuth( <schema>, <table>, <ridcolumn> )
--
-- TODO: check for an already existing trigger ?
- EXECUTE ''CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON ''
+ EXECUTE ''CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON ''
#ifdef HAS_SCHEMAS
|| quote_ident(schema) || ''.'' || quote_ident($2)
#else
LANGUAGE 'SQL';
CREATEFUNCTION CheckAuthTrigger()
- RETURNS trigger AS
+ RETURNS trigger AS
'@MODULE_FILENAME@', 'check_authorization'
LANGUAGE C;
CREATEFUNCTION GetTransactionID()
- RETURNS xid AS
+ RETURNS xid AS
'@MODULE_FILENAME@', 'getTransactionID'
LANGUAGE C;
-
--
-- Enable Long transactions support
--
--
-- Disable Long transactions support
--
--- (1) Drop any long_xact trigger
+-- (1) Drop any long_xact trigger
-- (2) Drop the authorization_table
-- (3) KEEP the authorized_tables view
--
END;
-
BEGIN;
-- Add authorization for row 2
--end build_history_table
-
--im open to suggestions for the names of the functions.
--just realized that one is build_history_table and the other create_...
CREATE OR REPLACE FUNCTION postgis_enable_history(p_schema text,p_table text,p_geometry_field text) returns boolean as
v_srid:= (SELECT srid FROM public.geometry_columns WHERE f_table_schema = p_schema AND f_table_name = p_table AND f_geometry_column = p_geometry_field);
v_gid:= (SELECT column_name FROM information_schema.key_column_usage WHERE table_schema = p_schema AND table_name = p_table);
--end sql
-
+
--generate sql for creating the historic table
v_table_sql:= 'CREATE TABLE ' || v_history_table ||
'(' ||
v_srid::text || ',' ||
quote_literal(v_geometry_type) || ');';
--end update geometry_columns
-
+
--insert into historic_tables
v_update_history_sql:='INSERT INTO public.historic_information(table_id,table_name,primary_field,geometry_field) VALUES (' ||
'DEFAULT,' ||
execute _postgis_create_history_indexes(p_schema,p_table,p_geometry_field);
return true;
-
+
END
$$
language 'plpgsql';
END
$$
-language 'plpgsql';
+language 'plpgsql';
--end add_insert_rule
--add_update_rule
-- ---------------------
-- -- !#@ ADAPTATION END
-
--
-- Streams
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T1
--- GEOMETRY_COLUMNS table/view is created/updated properly
+-- Conformance Item T1
+-- GEOMETRY_COLUMNS table/view is created/updated properly
-- For this test we will check to see that all of the feature tables are
-- represented by entries in the GEOMETRY_COLUMNS table/view
--
-- ANSWER: lakes, road_segments, divided_routes, buildings, forests, bridges,
-- named_places, streams, ponds, map_neatlines
--- *** ADAPTATION ALERT ***
+-- *** ADAPTATION ALERT ***
-- Since there are no quotes around the table names in the CREATE TABLEs,
-- they will be converted to upper case in many DBMSs, and therefore, the
-- answer to this query may be:
-- ANSWER: LAKES, ROAD_SEGMENTS, DIVIDED_ROUTES, BUILDINGS, FORESTS, BRIDGES,
-- NAMED_PLACES, STREAMS, PONDS, MAP_NEATLINES
--- *** ADAPTATION ALERT ***
+-- *** ADAPTATION ALERT ***
-- If the implementer made the adaptation concerning the buildings table
-- in sqltsch.sql, then the answer here may differ slightly.
---
+--
--
--================================
--
--
--
--================================
--- Conformance Item T2
--- GEOMETRY_COLUMNS table/view is created/updated properly
+-- Conformance Item T2
+-- GEOMETRY_COLUMNS table/view is created/updated properly
-- For this test we will check to see that the correct geometry columns for the
-- streams table is represented in the GEOMETRY_COLUMNS table/view
--
-- ANSWER: centerline
--- *** ADAPTATION ALERT ***
+-- *** ADAPTATION ALERT ***
-- Since there are no quotes around the table name, streams, in it's CREATE TABLE,
-- it will be converted to upper case in many DBMSs, and therefore, the WHERE
-- clause may have to be f_table_name = 'STREAMS'.
--
--
--================================
--- Conformance Item T3
--- GEOMETRY_COLUMNS table/view is created/updated properly
+-- Conformance Item T3
+-- GEOMETRY_COLUMNS table/view is created/updated properly
-- For this test we will check to see that the correct coordinate dimension
-- for the streams table is represented in the GEOMETRY_COLUMNS table/view
--
--- ANSWER: 2
--- *** ADAPTATION ALERT ***
+-- ANSWER: 2
+-- *** ADAPTATION ALERT ***
-- Since there are no quotes around the table name, streams, in it's CREATE TABLE,
-- it will be converted to upper case in many DBMSs, and therefore, the WHERE
-- clause may have to be f_table_name = 'STREAMS'.
--
--
--================================
--- Conformance Item T4
--- GEOMETRY_COLUMNS table/view is created/updated properly
+-- Conformance Item T4
+-- GEOMETRY_COLUMNS table/view is created/updated properly
-- For this test we will check to see that the correct value of srid for
-- the streams table is represented in the GEOMETRY_COLUMNS table/view
--
--- ANSWER: 101
--- *** ADAPTATION ALERT ***
+-- ANSWER: 101
+-- *** ADAPTATION ALERT ***
-- Since there are no quotes around the table name, streams, in it's CREATE TABLE,
-- it will be converted to upper case in many DBMSs, and therefore, the WHERE
-- clause may have to be f_table_name = 'STREAMS'.
-- PROJECTION["Traverse_Mercator"], PARAMETER["False_Easting", 500000.0],
-- PARAMETER["False_Northing", 0.0], PARAMETER["Central_Meridian", -99.0],
-- PARAMETER["Scale_Factor", 0.9996], PARAMETER["Latitude_of_origin", 0.0],
--- UNIT["Meter", 1.0]]'
+-- UNIT["Meter", 1.0]]'
--
--================================
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T6
+-- Conformance Item T6
-- Dimension(g Geometry) : Integer
-- For this test we will determine the dimension of Blue Lake.
--
--
--
--================================
--- Conformance Item T7
+-- Conformance Item T7
-- GeometryType(g Geometry) : String
-- For this test we will determine the type of Route 75.
--
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T8
+-- Conformance Item T8
-- AsText(g Geometry) : String
-- For this test we will determine the WKT representation of Goose Island.
--
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T9
+-- Conformance Item T9
-- AsBinary(g Geometry) : Blob
-- For this test we will determine the WKB representation of Goose Island.
-- We will test by applying AsText to the result of PolygonFromText to the
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T10
+-- Conformance Item T10
-- SRID(g Geometry) : Integer
-- For this test we will determine the SRID of Goose Island.
--
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T11
+-- Conformance Item T11
-- IsEmpty(g Geometry) : Integer
-- For this test we will determine whether the geometry of a
-- segment of Route 5 is empty.
WHERE name = 'Route 5' AND aliases = 'Main Street';
--
--================================
--- Conformance Item T12
+-- Conformance Item T12
-- IsSimple(g Geometry) : Integer
-- For this test we will determine whether the geometry of a
-- segment of Blue Lake is simple.
WHERE name = 'Blue Lake';
--
--================================
--- Conformance Item T13
+-- Conformance Item T13
-- Boundary(g Geometry) : Geometry
-- For this test we will determine the boundary of Goose Island.
-- NOTE: The boundary result is as defined in 3.12.3.2 of 96-015R1.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T14
+-- Conformance Item T14
-- Envelope(g Geometry) : Geometry
-- For this test we will determine the envelope of Goose Island.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T15
+-- Conformance Item T15
-- X(p Point) : Double Precision
-- For this test we will determine the X coordinate of Cam Bridge.
--
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T16
+-- Conformance Item T16
-- Y(p Point) : Double Precision
-- For this test we will determine the Y coordinate of Cam Bridge.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T17
+-- Conformance Item T17
-- StartPoint(c Curve) : Point
-- For this test we will determine the start point of road segment 102.
--
WHERE fid = 102;
--
--================================
--- Conformance Item T18
+-- Conformance Item T18
-- EndPoint(c Curve) : Point
-- For this test we will determine the end point of road segment 102.
--
WHERE fid = 102;
--
--================================
--- Conformance Item T19
+-- Conformance Item T19
-- IsClosed(c Curve) : Integer
-- For this test we will determine the boundary of Goose Island.
--
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T20
+-- Conformance Item T20
-- IsRing(c Curve) : Integer
-- For this test we will determine the boundary of Goose Island.
--
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T21
+-- Conformance Item T21
-- Length(c Curve) : Double Precision
-- For this test we will determine the length of road segment 106.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T22
+-- Conformance Item T22
-- NumPoints(l LineString) : Integer
-- For this test we will determine the number of points in road segment 102.
--
WHERE fid = 102;
--
--================================
--- Conformance Item T23
+-- Conformance Item T23
-- PointN(l LineString, n Integer) : Point
-- For this test we will determine the 1st point in road segment 102.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T24
+-- Conformance Item T24
-- Centroid(s Surface) : Point
-- For this test we will determine the centroid of Goose Island.
--
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T25
+-- Conformance Item T25
-- PointOnSurface(s Surface) : Point
-- For this test we will determine a point on Goose Island.
-- NOTE: For this test we will have to uses the Contains function
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T26
+-- Conformance Item T26
-- Area(s Surface) : Double Precision
-- For this test we will determine the area of Goose Island.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T27
+-- Conformance Item T27
-- ExteriorRing(p Polygon) : LineString
-- For this test we will determine the exteroir ring of Blue Lake.
--
WHERE name = 'Blue Lake';
--
--================================
--- Conformance Item T28
+-- Conformance Item T28
-- NumInteriorRings(p Polygon) : Integer
-- For this test we will determine the number of interior rings of Blue Lake.
--
WHERE name = 'Blue Lake';
--
--================================
--- Conformance Item T29
+-- Conformance Item T29
-- InteriorRingN(p Polygon, n Integer) : LineString
-- For this test we will determine the first interior ring of Blue Lake.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T30
+-- Conformance Item T30
-- NumGeometries(g GeometryCollection) : Integer
-- For this test we will determine the number of geometries in Route 75.
--
WHERE name = 'Route 75';
--
--================================
--- Conformance Item T31
+-- Conformance Item T31
-- GeometryN(g GeometryCollection, n Integer) : Geometry
-- For this test we will determine the second geometry in Route 75.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T32
+-- Conformance Item T32
-- IsClosed(mc MultiCurve) : Integer
-- For this test we will determine if the geometry of Route 75 is closed.
--
WHERE name = 'Route 75';
--
--================================
--- Conformance Item T33
+-- Conformance Item T33
-- Length(mc MultiCurve) : Double Precision
-- For this test we will determine the length of Route 75.
-- NOTE: This makes no semantic sense in our example...
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T34
+-- Conformance Item T34
-- Centroid(ms MultiSurface) : Point
-- For this test we will determine the centroid of the ponds.
--
WHERE fid = 120;
--
--================================
--- Conformance Item T35
+-- Conformance Item T35
-- PointOnSurface(ms MultiSurface) : Point
-- For this test we will determine a point on the ponds.
-- NOTE: For this test we will have to uses the Contains function
WHERE fid = 120;
--
--================================
--- Conformance Item T36
+-- Conformance Item T36
-- Area(ms MultiSurface) : Double Precision
-- For this test we will determine the area of the ponds.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T37
+-- Conformance Item T37
-- Equals(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of Goose Island is equal
-- to the same geometry as consructed from it's WKT representation.
WHERE name = 'Goose Island';
--
--================================
--- Conformance Item T38
+-- Conformance Item T38
-- Disjoint(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of Route 75 is disjoint
-- from the geometry of Ashton.
WHERE divided_routes.name = 'Route 75' AND named_places.name = 'Ashton';
--
--================================
--- Conformance Item T39
+-- Conformance Item T39
-- Touch(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of Cam Stream touches
-- the geometry of Blue Lake.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T40
+-- Conformance Item T40
-- Within(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of the house at 215 Main Street
-- is within Ashton.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T41
+-- Conformance Item T41
-- Overlap(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of Green Forest overlaps
-- the geometry of Ashton.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T42
+-- Conformance Item T42
-- Cross(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of road segment 102 crosses
-- the geometry of Route 75.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T43
+-- Conformance Item T43
-- Intersects(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of road segment 102 intersects
-- the geometry of Route 75.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T44
+-- Conformance Item T44
-- Contains(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine if the geometry of Green Forest contains
-- the geometry of Ashton.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T45
+-- Conformance Item T45
-- Relate(g1 Geometry, g2 Geometry, PatternMatrix String) : Integer
-- For this test we will determine if the geometry of Green Forest relates to
-- the geometry of Ashton using the pattern "TTTTTTTTT".
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T46
+-- Conformance Item T46
-- Distance(g1 Geometry, g2 Geometry) : Double Precision
-- For this test we will determine the distance between Cam Bridge and Ashton.
--
--//////////////////////////////////////////////////////////////////////////////
--
--================================
--- Conformance Item T47
+-- Conformance Item T47
-- Intersection(g1 Geometry, g2 Geometry) : Geometry
-- For this test we will determine the intersection between Cam Stream and
-- Blue Lake.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T48
+-- Conformance Item T48
-- Difference(g1 Geometry, g2 Geometry) : Geometry
-- For this test we will determine the difference between Ashton and
-- Green Forest.
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T49
+-- Conformance Item T49
-- Union(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine the union of Blue Lake and Goose Island
--
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T50
+-- Conformance Item T50
-- SymmetricDifference(g1 Geometry, g2 Geometry) : Integer
-- For this test we will determine the symmetric difference of Blue Lake
-- and Goose Island
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T51
+-- Conformance Item T51
-- Buffer(g Geometry, d Double Precision) : Geometry
-- For this test we will make a 15 meter buffer about Cam Bridge.
-- NOTE: This test we count the number of buildings contained in
-- -- !#@ ADAPTATION END
--
--================================
--- Conformance Item T52
+-- Conformance Item T52
-- ConvexHull(g Geometry) : Geometry
-- For this test we will determine the convex hull of Blue Lake
--
-- ---------------------
-- -- !#@ ADAPTATION END
-
--
--
--
END;
$_$ LANGUAGE plpgsql STABLE;
-
CREATE OR REPLACE FUNCTION geocode(
IN_ADDY NORM_ADDY,
max_results integer DEFAULT 10,
RETURN;
END IF;
-
-- There are a couple of different things to try, from the highest preference and falling back
-- to lower-preference options.
-- We start out with zip-code matching, where the zip code could possibly be in more than one
var_zip := array_agg(zip) FROM zip_lookup_base WHERE statefp = in_statefp AND lower(city) LIKE lower(in_city) || '%' ;
END IF;
IF var_debug THEN
- RAISE NOTICE 'var_zip: %, city: %', quote_nullable(var_zip), quote_nullable(in_city);
+ RAISE NOTICE 'var_zip: %, city: %', quote_nullable(var_zip), quote_nullable(in_city);
END IF;
var_sql := '
WITH
FROM (SELECT * FROM tiger.edges WHERE statefp = $1) AS e INNER JOIN a2 AS a ON (e.statefp = a.statefp AND a.tlid = e.tlid)
INNER JOIN e1 ON (e.statefp = e1.statefp
AND ARRAY[e.tnidf, e.tnidt] && ARRAY[e1.tnidf, e1.tnidt] )
-
+
WHERE (lower(e.fullname) = $7 or lower(a.name) LIKE $4 || ''%'')
ORDER BY CASE WHEN lower(a.name) = $4 THEN 0 ELSE 1 END + CASE WHEN lower(e.fullname) = $7 THEN 0 ELSE 1 END
LIMIT 5000
FROM generate_series(1,ST_NPoints(road)) As i
WHERE part > ST_LineLocatePoint(road,ST_PointN(road,i))
ORDER BY i DESC;
- IF npos < ST_NPoints(road) THEN
+ IF npos < ST_NPoints(road) THEN
az := ST_Azimuth (ST_PointN(road,npos), ST_PointN(road, npos + 1));
ELSE
az := ST_Azimuth (center_pt, ST_PointN(road, npos));
END IF;
END IF;
-
+
dir := CASE WHEN az < pi() THEN -1 ELSE 1 END;
--dir := 1;
var_dist := in_offset_m*CASE WHEN in_side = 'L' THEN -1 ELSE 1 END;
LANGUAGE sql IMMUTABLE
COST 5;
-
-- Generate script to drop all non-primary unique indexes on tiger and tiger_data tables
CREATE OR REPLACE FUNCTION drop_indexes_generate_script(tiger_data_schema text DEFAULT 'tiger_data')
RETURNS text AS
$$
LANGUAGE sql VOLATILE;
-
CREATE OR REPLACE FUNCTION install_missing_indexes() RETURNS boolean
AS
$$
$$
language plpgsql;
-
CREATE OR REPLACE FUNCTION drop_dupe_featnames_generate_script() RETURNS text
AS
$$
FROM ONLY ' || t.table_schema || '.' || t.table_name || ' As f
GROUP BY f.tlid, lower(f.fullname)
HAVING count(*) > 1;
-
+
DELETE FROM ' || t.table_schema || '.' || t.table_name || ' AS feat
WHERE EXISTS (SELECT tlid FROM dup WHERE feat.tlid = dup.tlid AND lower(feat.fullname) = dup.fname
AND feat.gid > dup.min_gid);
, ('use_pagc_address_parser', 'false', 'boolean','normalize', 'If set to true, will try to use the address_standardizer extension (via pagc_normalize_address) instead of tiger normalize_address built on')
, ('zip_penalty', '2', 'numeric','rating', 'As input to rating will add (ref_zip - tar_zip)*zip_penalty where ref_zip is input address and tar_zip is a target address candidate')
) f(name,setting,unit,category,short_desc);
-
- -- delete entries that are the same as default values
+
+ -- delete entries that are the same as default values
DELETE FROM geocode_settings As gc USING geocode_settings_default As gf WHERE gf.name = gc.name AND gf.setting = gc.setting;
END;
$$
-- Assume that the address begins with a digit, and extract it from
-- the input string.
addressString := substring(rawInput from E'^([0-9].*?)[ ,/.]');
-
+
-- try to pull full street number including non-digits like 1R
result.address_alphanumeric := substring(rawInput from E'^([0-9a-zA-Z].*?)[ ,/.]');
zipString := COALESCE(substring(rawInput from ws || '([0-9]{5})-[0-9]{0,4}$'),
substring(rawInput from ws || '([0-9]{2,5})$'),
substring(rawInput from ws || '([0-9]{6,14})$'));
-
+
result.zip4 := COALESCE(substring(rawInput from ws || '[0-9]{5}-([0-9]{0,4})$'),substring(rawInput from ws || '[0-9]{5}([0-9]{0,4})$'));
IF debug_flag THEN
END IF;
END IF;
-
IF debug_flag THEN
raise notice '% reduced street: %', clock_timestamp(), reducedStreet;
END IF;
-
+
-- The pre direction should be at the beginning of the fullStreet string.
-- The post direction should be at the beginning of the location string
-- if there is no internal address
RETURN NULL;
END IF;
- result := COALESCE(input.address_alphanumeric, cull_null(input.address::text))
+ result := COALESCE(input.address_alphanumeric, cull_null(input.address::text))
|| COALESCE(' ' || input.preDirAbbrev, '')
|| CASE WHEN is_pretype(input.streetTypeAbbrev) THEN ' ' || input.streetTypeAbbrev ELSE '' END
|| COALESCE(' ' || input.streetName, '')
$$
language plpgsql;
-
SELECT install_pagc_tables();
DELETE FROM pagc_gaz WHERE is_custom = false;
DELETE FROM pagc_lex WHERE is_custom = false;
INSERT INTO pagc_lex (id, seq, word, stdword, token, is_custom) VALUES (2936, 2, 'NORTH', 'NORTH', 1, false);
INSERT INTO pagc_lex (id, seq, word, stdword, token, is_custom) VALUES (2937, 2, 'SOUTH', 'SOUTH', 1, false);
-
SELECT pg_catalog.setval('pagc_lex_id_seq', (SELECT greatest((SELECT MAX(id) FROM pagc_lex),50000)), true);
-
-- set default to false so all we input will be treated as no custom --
ALTER TABLE tiger.pagc_rules ALTER COLUMN is_custom SET DEFAULT false;
INSERT INTO pagc_rules (id, rule) VALUES (1, '1 -1 5 -1 2 7');
SELECT '#1070a' As ticket, pprint_addy(addy) As address, ST_AsText(ST_SnapToGrid(geomout,0.00001)) As pt, rating FROM geocode('100 Federal Street, Boston, MA 02109',3, (SELECT ST_Union(the_geom) FROM place WHERE statefp = '25' AND name = 'Lynn')::geometry);
SELECT '#1070b' As ticket, pprint_addy(addy) As address, ST_AsText(ST_SnapToGrid(geomout,0.00001)) As pt, rating FROM geocode('100 Federal Street, MA',3, (SELECT ST_Union(the_geom) FROM place WHERE statefp = '25' AND name = 'Lynn')::geometry);
-
-- service roads and interstates
SELECT '#1112a' As ticket, pprint_addy((g).addy) As address, target, ST_AsText(ST_SnapToGrid((g).geomout, 0.00001)) As pt, (g).rating FROM (SELECT geocode(target,2) As g, target FROM (SELECT '8401 W 35W Service Dr NE, Blaine, MN 55449'::text As target) As f) As foo;
SELECT '#1112b' As ticket, pprint_addy((g).addy) As address, target, ST_AsText(ST_SnapToGrid((g).geomout, 0.00001)) As pt, (g).rating FROM (SELECT geocode(target,1) As g, target FROM (SELECT '8401 35W, Blaine, MN 55449'::text As target) As f) As foo;
INSERT INTO direction_lookup (name, abbrev) VALUES('E', 'E');
CREATE INDEX direction_lookup_abbrev_idx ON direction_lookup (abbrev);
-
-
-- Create secondary unit lookup table
DROP TABLE IF EXISTS tiger.secondary_unit_lookup;
CREATE TABLE secondary_unit_lookup (name VARCHAR(20) PRIMARY KEY, abbrev VARCHAR(5));
INSERT INTO secondary_unit_lookup (name, abbrev) VALUES ('UPPR', 'UPPR');
CREATE INDEX secondary_unit_lookup_abbrev_idx ON secondary_unit_lookup (abbrev);
-
-
-- Create state lookup table
DROP TABLE IF EXISTS tiger.state_lookup;
CREATE TABLE state_lookup (st_code INTEGER PRIMARY KEY, name VARCHAR(40) UNIQUE, abbrev VARCHAR(3) UNIQUE, statefp char(2) UNIQUE);
-- NOTE: fix later -- this is wrong for those - state code ones
UPDATE state_lookup SET statefp = lpad(st_code::text,2,'0');
-
-- Create street type lookup table
DROP TABLE IF EXISTS tiger.street_type_lookup;
CREATE TABLE street_type_lookup (name VARCHAR(50) PRIMARY KEY, abbrev VARCHAR(50), is_hw boolean NOT NULL DEFAULT false);
CREATE INDEX idx_addrfeat_zipl ON addrfeat USING btree(zipl);
CREATE INDEX idx_addrfeat_zipr ON addrfeat USING btree(zipr);
-
DROP TABLE IF EXISTS tiger.faces;
CREATE TABLE faces
(
$$
LANGUAGE sql VOLATILE;
-
-
DROP TABLE IF EXISTS loader_platform;
CREATE TABLE loader_platform(os varchar(50) PRIMARY KEY, declare_sect text, pgbin text, wget text, unzip_command text, psql text, path_sep text, loader text, environ_set_command text, county_process_command text);
GRANT SELECT ON TABLE loader_platform TO public;
'for /r %%z in (*${table_name}.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
post_load_process text, single_geom_mode boolean DEFAULT false,
insert_mode char(1) NOT NULL DEFAULT 'c',
pre_load_process text,columns_exclude text[], website_root_override text);
-
+
GRANT SELECT ON TABLE loader_lookuptables TO public;
-
+
-- put in explanatory comments of what each column is for
COMMENT ON COLUMN loader_lookuptables.lookup_name IS 'This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix';
COMMENT ON COLUMN loader_lookuptables.level_nation IS 'These are tables that contain all data for the whole US so there is just a single file';
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name};"
${psql} -c "INSERT INTO ${data_schema}.${lookup_name}_lookup(st_code, state, co_code, name) SELECT CAST(s.statefp as integer), s.abbrev, CAST(c.countyfp as integer), c.name FROM ${data_schema}.${lookup_name} As c INNER JOIN state_lookup As s ON s.statefp = c.statefp;"
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name}_lookup;" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(1, 'state_all', 'state', true, false, false,true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${lookup_name}(CONSTRAINT pk_${lookup_name} PRIMARY KEY (statefp),CONSTRAINT uidx_${lookup_name}_stusps UNIQUE (stusps), CONSTRAINT uidx_${lookup_name}_gid UNIQUE (gid) ) INHERITS(state); "',
'${psql} -c "ALTER TABLE ${staging_schema}.${state_abbrev}_${table_name} RENAME geoid TO cosbidfp;SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}'')); ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_countyfp ON ${data_schema}.${state_abbrev}_${lookup_name} USING btree(countyfp);"');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude, website_root_override )
-- this is a bit of a lie that its county. It's really state but works better with column routine
VALUES(4, 'zcta5', 'zcta510', true,true, false,false, false, 'a',
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"'
, ARRAY['gid','geoid','geoid10'], 'ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010');
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(6, 'faces', 'faces', true, true, false,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (gid)) INHERITS(${lookup_name});" ',
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_tlid_statefp ON ${data_schema}.${state_abbrev}_${table_name} USING btree (tlid,statefp);"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(8, 'edges', 'edges', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_lookup_base(zip,state,county,city, statefp) SELECT DISTINCT e.zipl, ''${state_abbrev}'', c.name,p.name,''${state_fips}'' FROM ${data_schema}.${state_abbrev}_edges AS e INNER JOIN tiger.county As c ON (e.countyfp = c.countyfp AND e.statefp = c.statefp AND e.statefp = ''${state_fips}'') INNER JOIN ${data_schema}.${state_abbrev}_faces AS f ON (e.tfidl = f.tfid OR e.tfidr = f.tfid) INNER JOIN ${data_schema}.${state_abbrev}_place As p ON(f.statefp = p.statefp AND f.placefp = p.placefp ) WHERE e.zipl IS NOT NULL;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_lookup_base ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_zip_lookup_base_citysnd ON ${data_schema}.${state_abbrev}_zip_lookup_base USING btree(soundex(city));" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addr', 'addr', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_state(zip,stusps,statefp) SELECT DISTINCT zip, ''${state_abbrev}'', ''${state_fips}'' FROM ${data_schema}.${state_abbrev}_${lookup_name} WHERE zip is not null;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_state ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp','fromarmid', 'toarmid']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addrfeat', 'addrfeat', false, true, false,true, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
END
$$ LANGUAGE 'plpgsql';
-
DELETE FROM loader_platform WHERE os IN ('sh', 'windows');
GRANT SELECT ON TABLE loader_platform TO public;
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql,path_sep,loader, environ_set_command, county_process_command)
'for /r %%z in (*${table_name}.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
TRUNCATE TABLE loader_lookuptables;
-
GRANT SELECT ON TABLE loader_lookuptables TO public;
-
+
-- put in explanatory comments of what each column is for
COMMENT ON COLUMN loader_lookuptables.lookup_name IS 'This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix';
COMMENT ON COLUMN loader_lookuptables.level_nation IS 'These are tables that contain all data for the whole US so there is just a single file';
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name};"
${psql} -c "INSERT INTO ${data_schema}.${lookup_name}_lookup(st_code, state, co_code, name) SELECT CAST(s.statefp as integer), s.abbrev, CAST(c.countyfp as integer), c.name FROM ${data_schema}.${lookup_name} As c INNER JOIN state_lookup As s ON s.statefp = c.statefp;"
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name}_lookup;" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(1, 'state_all', 'state', true, false, false,true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${lookup_name}(CONSTRAINT pk_${lookup_name} PRIMARY KEY (statefp),CONSTRAINT uidx_${lookup_name}_stusps UNIQUE (stusps), CONSTRAINT uidx_${lookup_name}_gid UNIQUE (gid) ) INHERITS(state); "',
'${psql} -c "ALTER TABLE ${staging_schema}.${state_abbrev}_${table_name} RENAME geoid TO cosbidfp;SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}'')); ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_countyfp ON ${data_schema}.${state_abbrev}_${lookup_name} USING btree(countyfp);"');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude, website_root_override )
-- this is a bit of a lie that its county. It's really state but works better with column routine
VALUES(4, 'zcta5', 'zcta510', true,true, false,false, false, 'a',
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"'
, ARRAY['gid','geoid','geoid10'], 'ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010');
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(6, 'faces', 'faces', true, true, false,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (gid)) INHERITS(${lookup_name});" ',
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_tlid_statefp ON ${data_schema}.${state_abbrev}_${table_name} USING btree (tlid,statefp);"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(8, 'edges', 'edges', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_lookup_base(zip,state,county,city, statefp) SELECT DISTINCT e.zipl, ''${state_abbrev}'', c.name,p.name,''${state_fips}'' FROM ${data_schema}.${state_abbrev}_edges AS e INNER JOIN tiger.county As c ON (e.countyfp = c.countyfp AND e.statefp = c.statefp AND e.statefp = ''${state_fips}'') INNER JOIN ${data_schema}.${state_abbrev}_faces AS f ON (e.tfidl = f.tfid OR e.tfidr = f.tfid) INNER JOIN ${data_schema}.${state_abbrev}_place As p ON(f.statefp = p.statefp AND f.placefp = p.placefp ) WHERE e.zipl IS NOT NULL;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_lookup_base ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_zip_lookup_base_citysnd ON ${data_schema}.${state_abbrev}_zip_lookup_base USING btree(soundex(city));" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addr', 'addr', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_state(zip,stusps,statefp) SELECT DISTINCT zip, ''${state_abbrev}'', ''${state_fips}'' FROM ${data_schema}.${state_abbrev}_${lookup_name} WHERE zip is not null;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_state ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp','fromarmid', 'toarmid']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addrfeat', 'addrfeat', false, true, false,true, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
END
$$ LANGUAGE 'plpgsql';
-
DELETE FROM loader_platform WHERE os IN ('sh', 'windows');
GRANT SELECT ON TABLE loader_platform TO public;
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql,path_sep,loader, environ_set_command, county_process_command)
'for /r %%z in (*${table_name}.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
TRUNCATE TABLE loader_lookuptables;
-
GRANT SELECT ON TABLE loader_lookuptables TO public;
-
+
-- put in explanatory comments of what each column is for
COMMENT ON COLUMN loader_lookuptables.lookup_name IS 'This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix';
COMMENT ON COLUMN loader_lookuptables.level_nation IS 'These are tables that contain all data for the whole US so there is just a single file';
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name};"
${psql} -c "INSERT INTO ${data_schema}.${lookup_name}_lookup(st_code, state, co_code, name) SELECT CAST(s.statefp as integer), s.abbrev, CAST(c.countyfp as integer), c.name FROM ${data_schema}.${lookup_name} As c INNER JOIN state_lookup As s ON s.statefp = c.statefp;"
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name}_lookup;" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(1, 'state_all', 'state', true, false, false,true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${lookup_name}(CONSTRAINT pk_${lookup_name} PRIMARY KEY (statefp),CONSTRAINT uidx_${lookup_name}_stusps UNIQUE (stusps), CONSTRAINT uidx_${lookup_name}_gid UNIQUE (gid) ) INHERITS(state); "',
'${psql} -c "ALTER TABLE ${staging_schema}.${state_abbrev}_${table_name} RENAME geoid TO cosbidfp;SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}'')); ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_countyfp ON ${data_schema}.${state_abbrev}_${lookup_name} USING btree(countyfp);"');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude, website_root_override )
-- this is a bit of a lie that its county. It's really state but works better with column routine
VALUES(4, 'zcta5', 'zcta510', true,true, false,false, false, 'a',
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"'
, ARRAY['gid','geoid','geoid10'], 'ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010');
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(6, 'faces', 'faces', true, true, false,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (gid)) INHERITS(${lookup_name});" ',
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_tlid_statefp ON ${data_schema}.${state_abbrev}_${table_name} USING btree (tlid,statefp);"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(8, 'edges', 'edges', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_lookup_base(zip,state,county,city, statefp) SELECT DISTINCT e.zipl, ''${state_abbrev}'', c.name,p.name,''${state_fips}'' FROM ${data_schema}.${state_abbrev}_edges AS e INNER JOIN tiger.county As c ON (e.countyfp = c.countyfp AND e.statefp = c.statefp AND e.statefp = ''${state_fips}'') INNER JOIN ${data_schema}.${state_abbrev}_faces AS f ON (e.tfidl = f.tfid OR e.tfidr = f.tfid) INNER JOIN ${data_schema}.${state_abbrev}_place As p ON(f.statefp = p.statefp AND f.placefp = p.placefp ) WHERE e.zipl IS NOT NULL;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_lookup_base ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_zip_lookup_base_citysnd ON ${data_schema}.${state_abbrev}_zip_lookup_base USING btree(soundex(city));" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addr', 'addr', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_state(zip,stusps,statefp) SELECT DISTINCT zip, ''${state_abbrev}'', ''${state_fips}'' FROM ${data_schema}.${state_abbrev}_${lookup_name} WHERE zip is not null;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_state ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp','fromarmid', 'toarmid']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addrfeat', 'addrfeat', false, true, false,true, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
CONSTRAINT enforce_geotype_geom CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL),
CONSTRAINT enforce_srid_geom CHECK (st_srid(the_geom) = 4269)
);
-
+
DROP TABLE IF EXISTS tiger.tabblock;
CREATE TABLE tabblock
(
END
$$ LANGUAGE 'plpgsql';
-
DELETE FROM loader_platform WHERE os IN ('sh', 'windows');
GRANT SELECT ON TABLE loader_platform TO public;
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql,path_sep,loader, environ_set_command, county_process_command)
'for /r %%z in (*${table_name}*.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
TRUNCATE TABLE loader_lookuptables;
-
GRANT SELECT ON TABLE loader_lookuptables TO public;
-
+
-- put in explanatory comments of what each column is for
COMMENT ON COLUMN loader_lookuptables.lookup_name IS 'This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix';
COMMENT ON COLUMN loader_lookuptables.level_nation IS 'These are tables that contain all data for the whole US so there is just a single file';
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', '{gid, uatyp10, tractce10, blockce10,suffix1ce,blockce,tractce}'::text[]);
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude )
VALUES(12, 'bg', 'bg', true,false, true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (bg_id)) INHERITS(tiger.${lookup_name});" ',
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name};"
${psql} -c "INSERT INTO ${data_schema}.${lookup_name}_lookup(st_code, state, co_code, name) SELECT CAST(s.statefp as integer), s.abbrev, CAST(c.countyfp as integer), c.name FROM ${data_schema}.${lookup_name} As c INNER JOIN state_lookup As s ON s.statefp = c.statefp;"
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name}_lookup;" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(1, 'state_all', 'state', true, false, false,true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${lookup_name}(CONSTRAINT pk_${lookup_name} PRIMARY KEY (statefp),CONSTRAINT uidx_${lookup_name}_stusps UNIQUE (stusps), CONSTRAINT uidx_${lookup_name}_gid UNIQUE (gid) ) INHERITS(state); "',
'${psql} -c "ALTER TABLE ${staging_schema}.${state_abbrev}_${table_name} RENAME geoid TO cosbidfp;SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}'')); ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_countyfp ON ${data_schema}.${state_abbrev}_${lookup_name} USING btree(countyfp);"');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude, website_root_override )
-- this is a bit of a lie that its county. It's really state but works better with column routine
VALUES(4, 'zcta5', 'zcta510', true,true, false,false, false, 'a',
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"'
, ARRAY['gid','geoid','geoid10'], 'ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010');
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(6, 'faces', 'faces', true, true, false,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (gid)) INHERITS(${lookup_name});" ',
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_tlid_statefp ON ${data_schema}.${state_abbrev}_${table_name} USING btree (tlid,statefp);"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(8, 'edges', 'edges', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_lookup_base(zip,state,county,city, statefp) SELECT DISTINCT e.zipl, ''${state_abbrev}'', c.name,p.name,''${state_fips}'' FROM ${data_schema}.${state_abbrev}_edges AS e INNER JOIN tiger.county As c ON (e.countyfp = c.countyfp AND e.statefp = c.statefp AND e.statefp = ''${state_fips}'') INNER JOIN ${data_schema}.${state_abbrev}_faces AS f ON (e.tfidl = f.tfid OR e.tfidr = f.tfid) INNER JOIN ${data_schema}.${state_abbrev}_place As p ON(f.statefp = p.statefp AND f.placefp = p.placefp ) WHERE e.zipl IS NOT NULL;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_lookup_base ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_zip_lookup_base_citysnd ON ${data_schema}.${state_abbrev}_zip_lookup_base USING btree(soundex(city));" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addr', 'addr', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_state(zip,stusps,statefp) SELECT DISTINCT zip, ''${state_abbrev}'', ''${state_fips}'' FROM ${data_schema}.${state_abbrev}_${lookup_name} WHERE zip is not null;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_state ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp','fromarmid', 'toarmid']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addrfeat', 'addrfeat', false, true, false,true, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
CONSTRAINT enforce_geotype_geom CHECK (geometrytype(the_geom) = 'MULTIPOLYGON'::text OR the_geom IS NULL),
CONSTRAINT enforce_srid_geom CHECK (st_srid(the_geom) = 4269)
);
-
+
DROP TABLE IF EXISTS tiger.tabblock;
CREATE TABLE tabblock
(
END
$$ LANGUAGE 'plpgsql';
-
DELETE FROM loader_platform WHERE os IN ('sh', 'windows');
GRANT SELECT ON TABLE loader_platform TO public;
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql,path_sep,loader, environ_set_command, county_process_command)
'for /r %%z in (*${table_name}*.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
TRUNCATE TABLE loader_lookuptables;
-
GRANT SELECT ON TABLE loader_lookuptables TO public;
-
+
-- put in explanatory comments of what each column is for
COMMENT ON COLUMN loader_lookuptables.lookup_name IS 'This is the table name to inherit from and suffix of resulting output table -- how the table will be named -- edges here would mean -- ma_edges , pa_edges etc. except in the case of national tables. national level tables have no prefix';
COMMENT ON COLUMN loader_lookuptables.level_nation IS 'These are tables that contain all data for the whole US so there is just a single file';
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', '{gid, uatyp10, uatype, tractce10, blockce10,suffix1ce,blockce,tractce}'::text[]);
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude )
VALUES(12, 'bg', 'bg', true,false, true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (bg_id)) INHERITS(tiger.${lookup_name});" ',
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name};"
${psql} -c "INSERT INTO ${data_schema}.${lookup_name}_lookup(st_code, state, co_code, name) SELECT CAST(s.statefp as integer), s.abbrev, CAST(c.countyfp as integer), c.name FROM ${data_schema}.${lookup_name} As c INNER JOIN state_lookup As s ON s.statefp = c.statefp;"
${psql} -c "VACUUM ANALYZE ${data_schema}.${lookup_name}_lookup;" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(1, 'state_all', 'state', true, false, false,true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${lookup_name}(CONSTRAINT pk_${lookup_name} PRIMARY KEY (statefp),CONSTRAINT uidx_${lookup_name}_stusps UNIQUE (stusps), CONSTRAINT uidx_${lookup_name}_gid UNIQUE (gid) ) INHERITS(tiger.state); "',
'${psql} -c "ALTER TABLE ${staging_schema}.${state_abbrev}_${table_name} RENAME geoid TO cosbidfp;SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}'')); ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_countyfp ON ${data_schema}.${state_abbrev}_${lookup_name} USING btree(countyfp);"');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, level_nation, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude, website_root_override )
-- this is a bit of a lie that its county. It's really state but works better with column routine
VALUES(4, 'zcta5', 'zcta510', true,true, false,false, false, 'a',
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"'
, ARRAY['gid','geoid','geoid10'], 'ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010');
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(6, 'faces', 'faces', true, true, false,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (gid)) INHERITS(tiger.${lookup_name});" ',
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_${lookup_name}_tlid_statefp ON ${data_schema}.${state_abbrev}_${table_name} USING btree (tlid,statefp);"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(8, 'edges', 'edges', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(tiger.${table_name});" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_lookup_base(zip,state,county,city, statefp) SELECT DISTINCT e.zipl, ''${state_abbrev}'', c.name,p.name,''${state_fips}'' FROM ${data_schema}.${state_abbrev}_edges AS e INNER JOIN tiger.county As c ON (e.countyfp = c.countyfp AND e.statefp = c.statefp AND e.statefp = ''${state_fips}'') INNER JOIN ${data_schema}.${state_abbrev}_faces AS f ON (e.tfidl = f.tfid OR e.tfidr = f.tfid) INNER JOIN ${data_schema}.${state_abbrev}_place As p ON(f.statefp = p.statefp AND f.placefp = p.placefp ) WHERE e.zipl IS NOT NULL;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_lookup_base ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "CREATE INDEX idx_${data_schema}_${state_abbrev}_zip_lookup_base_citysnd ON ${data_schema}.${state_abbrev}_zip_lookup_base USING btree(soundex(city));" ');
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addr', 'addr', true, true, false,false, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(tiger.${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
${psql} -c "INSERT INTO ${data_schema}.${state_abbrev}_zip_state(zip,stusps,statefp) SELECT DISTINCT zip, ''${state_abbrev}'', ''${state_fips}'' FROM ${data_schema}.${state_abbrev}_${lookup_name} WHERE zip is not null;"
${psql} -c "ALTER TABLE ${data_schema}.${state_abbrev}_zip_state ADD CONSTRAINT chk_statefp CHECK (statefp = ''${state_fips}'');"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', ARRAY['gid','statefp','fromarmid', 'toarmid']);
-
+
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process,columns_exclude )
VALUES(9, 'addrfeat', 'addrfeat', false, true, false,true, 'a',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${table_name} PRIMARY KEY (gid)) INHERITS(tiger.${table_name});ALTER TABLE ${data_schema}.${state_abbrev}_${lookup_name} ALTER COLUMN statefp SET DEFAULT ''${state_fips}'';" ',
END
$$ LANGUAGE 'plpgsql';
-
DELETE FROM loader_platform WHERE os IN ('sh', 'windows');
GRANT SELECT ON TABLE loader_platform TO public;
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql,path_sep,loader, environ_set_command, county_process_command)
'for /r %%z in (*${table_name}*.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
TRUNCATE TABLE loader_lookuptables;
-
GRANT SELECT ON TABLE loader_lookuptables TO public;
-- put in explanatory comments of what each column is for
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', '{gid, uatyp10, uatype, suffix1ce}'::text[]);
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude )
VALUES(12, 'bg', 'bg', false,false, true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (bg_id)) INHERITS(tiger.${lookup_name});" ',
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"'
, ARRAY['gid','geoid','geoid10'], 'ftp://ftp2.census.gov/geo/tiger/TIGER2010/ZCTA5/2010');**/
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process )
VALUES(6, 'faces', 'faces', true, true, false,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${table_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (gid)) INHERITS(tiger.${lookup_name});" ',
END
$$ LANGUAGE 'plpgsql';
-
DELETE FROM loader_platform WHERE os IN ('sh', 'windows');
GRANT SELECT ON TABLE loader_platform TO public;
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql,path_sep,loader, environ_set_command, county_process_command)
'for /r %%z in (*${table_name}*.dbf) do (${loader} -D -s 4269 -g the_geom -W "latin1" %%z tiger_staging.${state_abbrev}_${table_name} | ${psql} & ${psql} -c "SELECT loader_load_staged_data(lower(''${state_abbrev}_${table_name}''), lower(''${state_abbrev}_${lookup_name}''));")'
);
-
INSERT INTO loader_platform(os, wget, pgbin, declare_sect, unzip_command, psql, path_sep, loader, environ_set_command, county_process_command)
VALUES('sh', 'wget', '',
E'TMPDIR="${staging_fold}/temp/"
TRUNCATE TABLE loader_lookuptables;
-
GRANT SELECT ON TABLE loader_lookuptables TO public;
-- put in explanatory comments of what each column is for
${psql} -c "CREATE INDEX ${data_schema}_${state_abbrev}_${lookup_name}_the_geom_gist ON ${data_schema}.${state_abbrev}_${lookup_name} USING gist(the_geom);"
${psql} -c "vacuum analyze ${data_schema}.${state_abbrev}_${lookup_name};"', '{gid, uatyp10, uatype, suffix1ce}'::text[]);
-
INSERT INTO loader_lookuptables(process_order, lookup_name, table_name, load, level_county, level_state, single_geom_mode, insert_mode, pre_load_process, post_load_process, columns_exclude )
VALUES(12, 'bg', 'bg', false,false, true,false, 'c',
'${psql} -c "CREATE TABLE ${data_schema}.${state_abbrev}_${lookup_name}(CONSTRAINT pk_${state_abbrev}_${lookup_name} PRIMARY KEY (bg_id)) INHERITS(tiger.${lookup_name});" ',
, COALESCE(t.tfidr,0) As right_face, COALESCE(tl.tlid, t.tlid) AS next_left_edge, COALESCE(tr.tlid, t.tlid) As next_right_edge, t.orig_geom
FROM
te AS t LEFT JOIN te As tl ON (t.tnidf = tl.tnidt AND t.tfidl = tl.tfidl)
- LEFT JOIN te As tr ON (t.tnidt = tr.tnidf AND t.tfidr = tr.tfidr)
+ LEFT JOIN te As tr ON (t.tnidt = tr.tnidf AND t.tfidr = tr.tfidr)
';
EXECUTE var_sql USING var_statefp, var_rgeom, var_srid, var_precision;
GET DIAGNOSTICS var_rcnt = ROW_COUNT;
var_sql := 'CREATE INDEX idx_tmp_edge_next_left_edge ON tmp_edge USING btree (next_left_edge ); CREATE INDEX idx_tmp_edge_next_right_edge ON tmp_edge USING btree (next_right_edge);';
EXECUTE var_sql;
-
+
-- start load in faces
var_sql := 'INSERT INTO ' || quote_ident(toponame) || '.face(face_id, mbr)
SELECT f.tfid, ST_Envelope(ST_Transform(f.the_geom,$3)) As mbr
-- end load in faces
-- add remaining missing edges of present faces --
- var_sql := 'INSERT INTO tmp_edge(edge_id, geom, start_node, end_node, left_face, right_face, next_left_edge, next_right_edge, orig_geom)
+ var_sql := 'INSERT INTO tmp_edge(edge_id, geom, start_node, end_node, left_face, right_face, next_left_edge, next_right_edge, orig_geom)
WITH te AS
(SELECT tlid, ST_GeometryN(ST_SnapToGrid(ST_Transform(ST_LineMerge(the_geom),$2),$3),1) As geom, tnidf, tnidt, tfidl, tfidr, the_geom As orig_geom
FROM tiger.edges
OR tfidr IN(SELECT face_id FROM ' || quote_ident(toponame) || '.face) )
AND tlid NOT IN(SELECT edge_id FROM tmp_edge)
)
-
+
SELECT DISTINCT ON (t.tlid) t.tlid As edge_id,t.geom
, t.tnidf As start_node, t.tnidt As end_node, t.tfidl As left_face
, t.tfidr As right_face, tl.tlid AS next_left_edge, tr.tlid As next_right_edge, t.orig_geom
SELECT t.edge_id, t.geom, t.start_node, t.end_node, COALESCE(t.left_face,0) As left_face, COALESCE(t.right_face,0) As right_face, t.next_left_edge, t.next_right_edge
FROM
tmp_edge AS t
- WHERE t.edge_id NOT IN(SELECT edge_id FROM ' || quote_ident(toponame) || '.edge)
+ WHERE t.edge_id NOT IN(SELECT edge_id FROM ' || quote_ident(toponame) || '.edge)
';
EXECUTE var_sql USING var_statefp, var_rgeom;
GET DIAGNOSTICS var_rcnt = ROW_COUNT;
\i pagc_normalize/pagc_tables.sql
\i pagc_normalize/pagc_normalize_address.sql
-
---- Geocoder functions
-- General helpers
\i geocode/other_helper_functions.sql
-CREATE OR REPLACE FUNCTION tiger.standardize_tiger_data(param_states varchar[]) RETURNS void AS\r
-$$\r
--- fix park addresses, normalizer puts this in suftype\r
-UPDATE tiger.featnames SET name = replace(name,' Park', ''), suftypabrv = 'Park' where statefp IN (SELECT statefp FROM tiger.state_lookup WHERE abbrev = ANY(param_states) ) \r
- AND name ILIKE '% Park' AND suftypabrv is null;\r
-\r
-$$\r
+CREATE OR REPLACE FUNCTION tiger.standardize_tiger_data(param_states varchar[]) RETURNS void AS
+$$
+-- fix park addresses, normalizer puts this in suftype
+UPDATE tiger.featnames SET name = replace(name,' Park', ''), suftypabrv = 'Park' where statefp IN (SELECT statefp FROM tiger.state_lookup WHERE abbrev = ANY(param_states) )
+ AND name ILIKE '% Park' AND suftypabrv is null;
+
+$$
language 'sql';
\ No newline at end of file
RETURNS cstring
AS 'MODULE_PATHNAME','postgis_typmod_out'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
+
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION geography_in(cstring, oid, integer)
RETURNS geography
alignment = double
);
-
-
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION geography(geography, integer, boolean)
RETURNS geography
AS 'MODULE_PATHNAME','geography_enforce_typmod'
- LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
+ LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-- Availability: 1.5.0
CREATE CAST (geography AS geography) WITH FUNCTION geography(geography, integer, boolean) AS IMPLICIT;
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asText'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
+
-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
CREATE OR REPLACE FUNCTION ST_AsText(text)
RETURNS text AS
-- Changed: 2.4.0 Limit to only list things that are tables
CREATE OR REPLACE VIEW geography_columns AS
SELECT
- current_database() AS f_table_catalog,
- n.nspname AS f_table_schema,
- c.relname AS f_table_name,
+ current_database() AS f_table_catalog,
+ n.nspname AS f_table_schema,
+ c.relname AS f_table_name,
a.attname AS f_geography_column,
postgis_typmod_dims(a.atttypmod) AS coord_dimension,
postgis_typmod_srid(a.atttypmod) AS srid,
postgis_typmod_type(a.atttypmod) AS type
- FROM
- pg_class c,
- pg_attribute a,
- pg_type t,
+ FROM
+ pg_class c,
+ pg_attribute a,
+ pg_type t,
pg_namespace n
WHERE t.typname = 'geography'
AND a.attisdropped = false
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_consistent(internal,geography,int4)
- RETURNS bool
+CREATE OR REPLACE FUNCTION geography_gist_consistent(internal,geography,int4)
+ RETURNS bool
AS 'MODULE_PATHNAME' ,'gserialized_gist_consistent'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_compress(internal)
- RETURNS internal
+CREATE OR REPLACE FUNCTION geography_gist_compress(internal)
+ RETURNS internal
AS 'MODULE_PATHNAME','gserialized_gist_compress'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_penalty(internal,internal,internal)
- RETURNS internal
+CREATE OR REPLACE FUNCTION geography_gist_penalty(internal,internal,internal)
+ RETURNS internal
AS 'MODULE_PATHNAME' ,'gserialized_gist_penalty'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_picksplit(internal, internal)
- RETURNS internal
+CREATE OR REPLACE FUNCTION geography_gist_picksplit(internal, internal)
+ RETURNS internal
AS 'MODULE_PATHNAME' ,'gserialized_gist_picksplit'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_union(bytea, internal)
- RETURNS internal
+CREATE OR REPLACE FUNCTION geography_gist_union(bytea, internal)
+ RETURNS internal
AS 'MODULE_PATHNAME' ,'gserialized_gist_union'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_same(box2d, box2d, internal)
- RETURNS internal
+CREATE OR REPLACE FUNCTION geography_gist_same(box2d, box2d, internal)
+ RETURNS internal
AS 'MODULE_PATHNAME' ,'gserialized_gist_same'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_gist_decompress(internal)
- RETURNS internal
+CREATE OR REPLACE FUNCTION geography_gist_decompress(internal)
+ RETURNS internal
AS 'MODULE_PATHNAME' ,'gserialized_gist_decompress'
LANGUAGE 'c';
-- Availability: 1.5.0
-CREATE OR REPLACE FUNCTION geography_overlaps(geography, geography)
- RETURNS boolean
+CREATE OR REPLACE FUNCTION geography_overlaps(geography, geography)
+ RETURNS boolean
AS 'MODULE_PATHNAME' ,'gserialized_overlaps'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_overlaps,
COMMUTATOR = '&&',
RESTRICT = gserialized_gist_sel_nd,
- JOIN = gserialized_gist_joinsel_nd
+ JOIN = gserialized_gist_joinsel_nd
);
-- Availability: 2.2.0
);
-- Availability: 2.2.0
-CREATE OR REPLACE FUNCTION geography_gist_distance(internal, geography, int4)
- RETURNS float8
+CREATE OR REPLACE FUNCTION geography_gist_distance(internal, geography, int4)
+ RETURNS float8
AS 'MODULE_PATHNAME' ,'gserialized_gist_geog_distance'
LANGUAGE 'c';
-
-- Availability: 1.5.0
CREATE OPERATOR CLASS gist_geography_ops
DEFAULT FOR TYPE geography USING GIST AS
AS 'MODULE_PATHNAME', 'geography_gt'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
--- Availability: 1.5.0
+-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION geography_ge(geography, geography)
RETURNS bool
AS 'MODULE_PATHNAME', 'geography_ge'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
--- Availability: 1.5.0
+-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION geography_eq(geography, geography)
RETURNS bool
AS 'MODULE_PATHNAME', 'geography_eq'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
--- Availability: 1.5.0
+-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION geography_cmp(geography, geography)
RETURNS integer
AS 'MODULE_PATHNAME', 'geography_cmp'
OPERATOR 5 > ,
FUNCTION 1 geography_cmp (geography, geography);
-
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- Export Functions
-- Availability: 1.5.0
RETURNS text
AS 'MODULE_PATHNAME','geography_as_svg'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
+
-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
CREATE OR REPLACE FUNCTION ST_AsSVG(text)
RETURNS text AS
RETURNS float8
AS 'SELECT @extschema@._ST_Distance($1, $2, 0.0, true)'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
+
-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
CREATE OR REPLACE FUNCTION ST_Distance(text, text)
RETURNS float8 AS
$$ SELECT ST_DWithin($1::@extschema@.geometry, $2::@extschema@.geometry, $3); $$
LANGUAGE 'sql' IMMUTABLE _PARALLEL;
-
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- Distance/DWithin testing functions for cached operations.
-- For developer/tester use only.
AS 'MODULE_PATHNAME','geography_distance_uncached'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Calculate the distance in geographics *without* using the caching code line or tree code
CREATE OR REPLACE FUNCTION _ST_DistanceUnCached(geography, geography, boolean)
RETURNS float8
AS 'SELECT @extschema@._ST_DistanceUnCached($1, $2, 0.0, true)'
LANGUAGE 'sql' IMMUTABLE STRICT;
--- Calculate the distance in geographics using the circular tree code, but
+-- Calculate the distance in geographics using the circular tree code, but
-- *without* using the caching code line
CREATE OR REPLACE FUNCTION _ST_DistanceTree(geography, geography, float8, boolean)
RETURNS float8
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
--- Calculate the distance in geographics using the circular tree code, but
+-- Calculate the distance in geographics using the circular tree code, but
-- *without* using the caching code line
CREATE OR REPLACE FUNCTION _ST_DistanceTree(geography, geography)
RETURNS float8
RETURNS boolean
AS 'SELECT $1 OPERATOR(@extschema@.&&) @extschema@._ST_Expand($2,$3) AND $2 OPERATOR(@extschema@.&&) @extschema@._ST_Expand($1,$3) AND @extschema@._ST_DWithinUnCached($1, $2, $3, true)'
LANGUAGE 'sql' IMMUTABLE;
-
+
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- Availability: 1.5.0
AS 'MODULE_PATHNAME','geography_centroid'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
CREATE OR REPLACE FUNCTION ST_Centroid(text)
RETURNS geometry AS
AS 'MODULE_PATHNAME','gserialized_gidx_gidx_overlaps'
LANGUAGE 'c' IMMUTABLE STRICT;
-
-
-- Availability: 2.3.0
CREATE OPERATOR && (
LEFTARG = gidx,
-- Legacy functions without chip functions --
-- This is the full list including the legacy_minimal.sql (minimal)
--- so no need to install both legacy and the minimal
+-- so no need to install both legacy and the minimal
#include "legacy_minimal.sql.in"
--- start functions that in theory should never have been used or internal like stuff deprecated
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_addBBOX'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
CREATE OR REPLACE FUNCTION dropbbox(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_dropBBOX'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION hasbbox(geometry)
RETURNS bool
AS 'MODULE_PATHNAME', 'LWGEOM_hasBBOX'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Availability: 1.2.2 -- never deprecated but don't think anyone uses it
CREATE OR REPLACE FUNCTION getsrid(geometry)
RETURNS int4
AS 'MODULE_PATHNAME','LWGEOM_get_srid'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeometryFromText(text, int4)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_from_text'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeometryFromText(text)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_from_text'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromWKB(bytea)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_from_WKB'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromWKB(bytea, int)
RETURNS geometry
AS 'SELECT ST_SetSRID(ST_GeomFromWKB($1), $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION noop(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_noop'
LANGUAGE 'c' VOLATILE STRICT;
-
+
-- ESRI ArcSDE compatibility functions --
-- We are remiving these because we don't
--- think ESRI relies on them
+-- think ESRI relies on them
-- so their existence is pointless
-- Availability: 1.5.0
-- PostGIS equivalent function: none
CREATE OR REPLACE FUNCTION SE_EnvelopesIntersect(geometry,geometry)
RETURNS boolean
- AS $$
+ AS $$
SELECT $1 && $2
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
CREATE OR REPLACE FUNCTION SE_Is3D(geometry)
RETURNS bool
AS 'MODULE_PATHNAME', 'LWGEOM_hasz'
RETURNS bool
AS 'MODULE_PATHNAME', 'LWGEOM_hasm'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- PostGIS equivalent function: Z(geometry)
CREATE OR REPLACE FUNCTION SE_Z(geometry)
RETURNS float8
AS 'MODULE_PATHNAME','LWGEOM_z_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- PostGIS equivalent function: M(geometry)
CREATE OR REPLACE FUNCTION SE_M(geometry)
RETURNS float8
AS 'MODULE_PATHNAME','LWGEOM_m_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- PostGIS equivalent function: locate_between_measures(geometry, float8, float8)
CREATE OR REPLACE FUNCTION SE_LocateBetween(geometry, float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_locate_between_m'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- PostGIS equivalent function: locate_along_measure(geometry, float8)
CREATE OR REPLACE FUNCTION SE_LocateAlong(geometry, float8)
RETURNS geometry
AS $$ SELECT SE_LocateBetween($1, $2, $2) $$
LANGUAGE 'sql' IMMUTABLE STRICT;
-
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box2d(geometry)
RETURNS box2d
AND a.attname::varchar = gc.f_geometry_column
);
- GET DIAGNOSTICS foundschema = ROW_COUNT;
+ GET DIAGNOSTICS foundschema = ROW_COUNT;
-- no linkage to system table needed
return 'fixed:'||foundschema::text; **/
$$
LANGUAGE 'plpgsql' VOLATILE;
-
-
-- END MANAGEMENT FUNCTIONS --
-- Deprecation in 1.5.0
RETURNS bool
AS 'MODULE_PATHNAME', 'geometry_analyze'
LANGUAGE 'c' VOLATILE STRICT;
-
+
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_in(cstring)
RETURNS geometry
RETURNS cstring
AS 'MODULE_PATHNAME','LWGEOM_out'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_recv(internal)
RETURNS geometry
RETURNS bytea
AS 'MODULE_PATHNAME','LWGEOM_send'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_spheroid_in(cstring)
RETURNS spheroid
RETURNS cstring
AS 'MODULE_PATHNAME','ellipsoid_out'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
**/
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_lt(geometry, geometry)
RETURNS integer
AS 'MODULE_PATHNAME', 'lwgeom_cmp'
LANGUAGE 'c' IMMUTABLE STRICT;
-
--- end functions that in theory should never have been used
-
-- begin old ogc (and non-ST) names that have been replaced with new SQL-MM and SQL ST_ Like names --
-- AFFINE Functions --
-- Availability: 1.1.2
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_affine'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Availability: 1.1.2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Affine(geometry,float8,float8,float8,float8,float8,float8)
RETURNS geometry
AS 'SELECT st_affine($1, cos($2), 0, sin($2), 0, 1, 0, -sin($2), 0, cos($2), 0, 0, 0)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Availability: 1.1.0
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Scale(geometry,float8,float8,float8)
AS 'SELECT st_translate($1, $2, $3, 0)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
-- Availability: 1.1.0
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION TransScale(geometry,float8,float8,float8,float8)
LANGUAGE 'sql' IMMUTABLE STRICT;
-- END Affine functions
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AddPoint(geometry, geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_addpoint'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AddPoint(geometry, geometry, integer)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_addpoint'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Area(geometry)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','LWGEOM_area_polygon'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- this is an alias for 'area(geometry)'
-- there is nothing such an 'area3d'...
-- Deprecation in 1.2.3
RETURNS FLOAT8
AS 'MODULE_PATHNAME', 'LWGEOM_area_polygon'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsEWKB(geometry)
RETURNS BYTEA
AS 'MODULE_PATHNAME','WKBFromLWGEOM'
LANGUAGE 'c' IMMUTABLE STRICT;
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsEWKB(geometry,text)
RETURNS bytea
AS 'MODULE_PATHNAME','WKBFromLWGEOM'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsEWKT(geometry)
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asEWKT'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- AsGML(geom) / precision=15 version=2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsGML(geometry)
RETURNS TEXT
AS 'SELECT _ST_AsGML(2, $1, 15, 0, null, null)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsGML(geometry, int4)
RETURNS TEXT
AS 'SELECT _ST_AsGML(2, $1, $2, 0, null, null)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- AsKML(geom, precision) / version=2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsKML(geometry, int4)
RETURNS TEXT
AS 'SELECT _ST_AsKML(2, ST_transform($1,4326), $2, null)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- AsKML(geom) / precision=15 version=2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsKML(geometry)
RETURNS TEXT
AS 'SELECT _ST_AsKML(2, ST_Transform($1,4326), 15, null)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- AsKML(version, geom, precision)
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsKML(int4, geometry, int4)
RETURNS TEXT
AS 'SELECT _ST_AsKML($1, ST_Transform($2,4326), $3, null)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsHEXEWKB(geometry)
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asHEXEWKB'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsHEXEWKB(geometry, text)
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asHEXEWKB'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsSVG(geometry)
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asSVG'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsSVG(geometry,int4)
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asSVG'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsSVG(geometry,int4,int4)
RETURNS TEXT
RETURNS float8
AS 'MODULE_PATHNAME', 'LWGEOM_azimuth'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION BdPolyFromText(text, integer)
RETURNS geometry
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION boundary(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','boundary'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION buffer(geometry,float8,integer)
RETURNS geometry
AS 'SELECT ST_Buffer($1, $2, $3)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION buffer(geometry,float8)
RETURNS geometry
AS 'MODULE_PATHNAME','buffer'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION BuildArea(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'ST_BuildArea'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- This is also available w/out GEOS
CREATE OR REPLACE FUNCTION Centroid(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Contains(geometry,geometry)
RETURNS boolean
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION convexhull(geometry)
RETURNS geometry
RETURNS boolean
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION distance(geometry,geometry)
RETURNS float8
AS 'MODULE_PATHNAME', 'LWGEOM_mindistance2d'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION difference(geometry,geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','difference'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Dimension(geometry)
RETURNS int4
AS 'MODULE_PATHNAME', 'LWGEOM_dimension'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION disjoint(geometry,geometry)
RETURNS boolean
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION distance_sphere(geometry,geometry)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','LWGEOM_distance_sphere'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION distance_spheroid(geometry,geometry,spheroid)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','LWGEOM_distance_ellipsoid'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Dump(geometry)
RETURNS SETOF geometry_dump
AS 'MODULE_PATHNAME', 'LWGEOM_dump'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION DumpRings(geometry)
RETURNS SETOF geometry_dump
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_envelope'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Expand(box2d,float8)
RETURNS box2d
AS 'MODULE_PATHNAME', 'BOX2D_expand'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Expand(box3d,float8)
RETURNS box3d
AS 'MODULE_PATHNAME', 'BOX3D_expand'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Expand(geometry,float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_expand'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
CREATE AGGREGATE Extent(
sfunc = ST_combine_bbox,
basetype = geometry,
finalfunc = box2d,
stype = box3d
);
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Find_Extent(text,text) RETURNS box2d AS
$$
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION EndPoint(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_endpoint_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ExteriorRing(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_exteriorring_polygon'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_2d(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_2d'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- an alias for force_3dz
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_3d(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_3dz'
LANGUAGE 'c' IMMUTABLE STRICT;
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_3dm(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_3dm'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_3dz(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_3dz'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_4d(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_4d'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_Collection(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_collection'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ForceRHR(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_clockwise_poly'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomCollFromText(text, int4)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomCollFromText(text)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeometryN(geometry,integer)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_geometryn_collection'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomUnion(geometry,geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','geomunion'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Availability: 1.5.0 -- replaced with postgis_getbbox
CREATE OR REPLACE FUNCTION getbbox(geometry)
RETURNS box2d
AS 'MODULE_PATHNAME','LWGEOM_to_BOX2D'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION intersects(geometry,geometry)
RETURNS boolean
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsRing(geometry)
RETURNS boolean
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsSimple(geometry)
RETURNS boolean
AS 'MODULE_PATHNAME', 'issimple'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION length_spheroid(geometry, spheroid)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','LWGEOM_length_ellipsoid_linestring'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION length2d_spheroid(geometry, spheroid)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','LWGEOM_length2d_ellipsoid'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION length3d_spheroid(geometry, spheroid)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','LWGEOM_length_ellipsoid_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineMerge(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'linemerge'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION locate_along_measure(geometry, float8)
RETURNS geometry
AS $$ SELECT ST_locate_between_measures($1, $2, $2) $$
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakeBox2d(geometry, geometry)
RETURNS box2d
AS 'MODULE_PATHNAME', 'BOX2D_construct'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePolygon(geometry, geometry[])
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makepoly'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePolygon(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makepoly'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION multi(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_force_multi'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolyFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolyFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION InteriorRingN(geometry,integer)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_interiorringn_polygon'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION intersection(geometry,geometry)
RETURNS geometry
RETURNS boolean
AS 'MODULE_PATHNAME', 'LWGEOM_isclosed'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsEmpty(geometry)
RETURNS boolean
AS 'MODULE_PATHNAME', 'LWGEOM_isempty'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsValid(geometry)
RETURNS boolean
RETURNS FLOAT8
AS 'MODULE_PATHNAME', 'LWGEOM_length_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION line_interpolate_point(geometry, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_line_interpolate_point'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION line_locate_point(geometry, geometry)
RETURNS float8
AS 'MODULE_PATHNAME', 'LWGEOM_line_locate_point'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION line_substring(geometry, float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_line_substring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromText(text)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromText(text, int4)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromMultiPoint(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_line_from_mpoint'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineStringFromText(text)
RETURNS geometry
RETURNS geometry
AS 'SELECT LineFromText($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LinestringFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LinestringFromWKB(bytea)
RETURNS geometry
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_locate_between_m'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION M(geometry)
RETURNS float8
RETURNS box3d
AS 'MODULE_PATHNAME', 'BOX3D_construct'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION makeline_garray (geometry[])
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makeline_garray'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE AGGREGATE makeline (
BASETYPE = geometry,
STYPE = pgis_abs,
FINALFUNC = pgis_geometry_makeline_finalfn
);
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakeLine(geometry, geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makeline'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePoint(float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makepoint'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePoint(float8, float8, float8)
RETURNS geometry
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makepoint'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePointM(float8, float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makepoint3dm'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- This should really be deprecated -- 2011-01-04 robe
CREATE OR REPLACE FUNCTION max_distance(geometry,geometry)
RETURNS float8
AS 'MODULE_PATHNAME', 'LWGEOM_maxdistance2d_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION mem_size(geometry)
RETURNS int4
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromText(text)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromText(text, int4)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiLineFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiLineStringFromText(text)
RETURNS geometry
AS 'SELECT ST_MLineFromText($1)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiLineStringFromText(text, int4)
RETURNS geometry
AS 'SELECT MLineFromText($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPointFromText(text)
RETURNS geometry
AS 'SELECT MPointFromText($1)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPointFromText(text)
RETURNS geometry
AS 'SELECT MPointFromText($1)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPointFromText(text, int4)
RETURNS geometry
AS 'SELECT MPointFromText($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPointFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPointFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolygonFromText(text, int4)
RETURNS geometry
AS 'SELECT MPolyFromText($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolygonFromText(text)
RETURNS geometry
RETURNS integer
AS 'MODULE_PATHNAME','LWGEOM_numinteriorrings_polygon'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumInteriorRings(geometry)
RETURNS integer
AS 'MODULE_PATHNAME','LWGEOM_numinteriorrings_polygon'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION npoints(geometry)
RETURNS int4
AS 'MODULE_PATHNAME', 'LWGEOM_npoints'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION nrings(geometry)
RETURNS int4
AS 'MODULE_PATHNAME', 'LWGEOM_nrings'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumGeometries(geometry)
RETURNS int4
AS 'MODULE_PATHNAME', 'LWGEOM_numgeometries_collection'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumPoints(geometry)
RETURNS int4
AS 'MODULE_PATHNAME', 'LWGEOM_numpoints_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION overlaps(geometry,geometry)
RETURNS boolean
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- this is a fake (for back-compatibility)
-- uses 3d if 3d is available, 2d otherwise
-- Deprecation in 1.2.3
RETURNS FLOAT8
AS 'MODULE_PATHNAME', 'LWGEOM_perimeter_poly'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION perimeter2d(geometry)
RETURNS FLOAT8
AS 'MODULE_PATHNAME', 'LWGEOM_perimeter2d_poly'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION point_inside_circle(geometry,float8,float8,float8)
RETURNS bool
AS 'MODULE_PATHNAME', 'LWGEOM_inside_circle_point'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromText(text)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromWKB(bytea, int)
RETURNS geometry
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointN(geometry,integer)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_pointn_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointOnSurface(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE STRICT;
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromText(text)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromWKB(bytea)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolygonFromText(text, int4)
RETURNS geometry
AS 'SELECT PolyFromText($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolygonFromText(text)
RETURNS geometry
AS 'SELECT PolyFromText($1)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolygonFromWKB(bytea, int)
RETURNS geometry
ELSE NULL END
'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Polygonize_GArray (geometry[])
RETURNS geometry
CREATE OR REPLACE FUNCTION relate(geometry,geometry,text)
RETURNS boolean
AS 'MODULE_PATHNAME','relate_pattern'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION RemovePoint(geometry, integer)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_removepoint'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION reverse(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_reverse'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Segmentize(geometry, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_segmentize2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SetPoint(geometry, integer, geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_setpoint_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Availability: 1.1.0
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION shift_longitude(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_longitude_shift'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Simplify(geometry, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_simplify2d'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- SnapToGrid(input, size) # xsize=ysize=size, offsets=0
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SnapToGrid(geometry, float8, float8, float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_snaptogrid'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SnapToGrid(geometry, float8)
RETURNS geometry
AS 'SELECT ST_SnapToGrid($1, 0, 0, $2, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- SnapToGrid(input, point_offsets, xsize, ysize, zsize, msize)
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SnapToGrid(geometry, geometry, float8, float8, float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_snaptogrid_pointoff'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- SnapToGrid(input, xsize, ysize) # offsets=0
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SnapToGrid(geometry, float8, float8)
RETURNS geometry
AS 'SELECT ST_SnapToGrid($1, 0, 0, $2, $3)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Availability: 1.2.2 -- this should be deprecated (do not think anyone has ever used it)
CREATE OR REPLACE FUNCTION ST_MakeLine_GArray (geometry[])
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_makeline_garray'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION StartPoint(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_startpoint_linestring'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION symdifference(geometry,geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','symdifference'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION symmetricdifference(geometry,geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','symdifference'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION summary(geometry)
RETURNS text
RETURNS geometry
AS 'MODULE_PATHNAME','transform'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION touches(geometry,geometry)
RETURNS boolean
RETURNS boolean
AS 'SELECT ST_Within($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION X(geometry)
RETURNS float8
AS 'MODULE_PATHNAME','LWGEOM_x_point'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION xmax(box3d)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','BOX3D_xmax'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION xmin(box3d)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','BOX3D_xmin'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Y(geometry)
RETURNS float8
AS 'MODULE_PATHNAME','LWGEOM_y_point'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ymax(box3d)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','BOX3D_ymax'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ymin(box3d)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','BOX3D_ymin'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Z(geometry)
RETURNS float8
AS 'MODULE_PATHNAME','LWGEOM_z_point'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION zmax(box3d)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','BOX3D_zmax'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION zmin(box3d)
RETURNS FLOAT8
AS 'MODULE_PATHNAME','BOX3D_zmin'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION zmflag(geometry)
RETURNS smallint
AS 'MODULE_PATHNAME', 'LWGEOM_zmflag'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- end old ogc names that have been replaced with new SQL-MM names --
--- Start Aggregates and supporting functions --
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_collect'
LANGUAGE 'c' IMMUTABLE;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION combine_bbox(box2d,geometry)
RETURNS box2d
AS 'MODULE_PATHNAME', 'BOX2D_combine'
LANGUAGE 'c' IMMUTABLE;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION combine_bbox(box3d,geometry)
RETURNS box3d
RETURNS geometry
AS 'MODULE_PATHNAME','pgis_union_geometry_array'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION unite_garray (geometry[])
RETURNS geometry
AS 'MODULE_PATHNAME', 'pgis_union_geometry_array'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE AGGREGATE Extent3d(
sfunc = combine_bbox,
basetype = geometry,
stype = box3d
);
-
+
-- Deprecation in 1.2.3
CREATE AGGREGATE memcollect(
sfunc = ST_collect,
AS 'MODULE_PATHNAME','LWGEOM_length_ellipsoid_linestring'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
-
+
-- Renamed in 2.0.0 to ST_3DPerimeter
CREATE OR REPLACE FUNCTION ST_Perimeter3D(geometry)
RETURNS FLOAT8
-CREATE OPERATOR CLASS gist_geometry_ops\r
- FOR TYPE geometry USING GIST AS\r
- STORAGE box2df,\r
- OPERATOR 1 << ,\r
- OPERATOR 2 &< ,\r
- OPERATOR 3 && ,\r
- OPERATOR 4 &> ,\r
- OPERATOR 5 >> ,\r
- OPERATOR 6 ~= ,\r
- OPERATOR 7 ~ ,\r
- OPERATOR 8 @ ,\r
- OPERATOR 9 &<| ,\r
- OPERATOR 10 <<| ,\r
- OPERATOR 11 |>> ,\r
- OPERATOR 12 |&> ,\r
-\r
- OPERATOR 13 <-> FOR ORDER BY pg_catalog.float_ops,\r
- OPERATOR 14 <#> FOR ORDER BY pg_catalog.float_ops,\r
- FUNCTION 8 geometry_gist_distance_2d (internal, geometry, int4),\r
-\r
- FUNCTION 1 geometry_gist_consistent_2d (internal, geometry, int4),\r
- FUNCTION 2 geometry_gist_union_2d (bytea, internal),\r
- FUNCTION 3 geometry_gist_compress_2d (internal),\r
- FUNCTION 4 geometry_gist_decompress_2d (internal),\r
- FUNCTION 5 geometry_gist_penalty_2d (internal, internal, internal),\r
- FUNCTION 6 geometry_gist_picksplit_2d (internal, internal),\r
+CREATE OPERATOR CLASS gist_geometry_ops
+ FOR TYPE geometry USING GIST AS
+ STORAGE box2df,
+ OPERATOR 1 << ,
+ OPERATOR 2 &< ,
+ OPERATOR 3 && ,
+ OPERATOR 4 &> ,
+ OPERATOR 5 >> ,
+ OPERATOR 6 ~= ,
+ OPERATOR 7 ~ ,
+ OPERATOR 8 @ ,
+ OPERATOR 9 &<| ,
+ OPERATOR 10 <<| ,
+ OPERATOR 11 |>> ,
+ OPERATOR 12 |&> ,
+
+ OPERATOR 13 <-> FOR ORDER BY pg_catalog.float_ops,
+ OPERATOR 14 <#> FOR ORDER BY pg_catalog.float_ops,
+ FUNCTION 8 geometry_gist_distance_2d (internal, geometry, int4),
+
+ FUNCTION 1 geometry_gist_consistent_2d (internal, geometry, int4),
+ FUNCTION 2 geometry_gist_union_2d (bytea, internal),
+ FUNCTION 3 geometry_gist_compress_2d (internal),
+ FUNCTION 4 geometry_gist_decompress_2d (internal),
+ FUNCTION 5 geometry_gist_penalty_2d (internal, internal, internal),
+ FUNCTION 6 geometry_gist_picksplit_2d (internal, internal),
FUNCTION 7 geometry_gist_same_2d (geom1 geometry, geom2 geometry, internal);
RETURNS bytea
AS 'MODULE_PATHNAME','LWGEOM_asBinary'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsBinary(geometry,text)
RETURNS bytea
CREATE OR REPLACE FUNCTION AsText(geometry)
RETURNS TEXT
AS 'MODULE_PATHNAME','LWGEOM_asText'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Estimated_Extent(text,text,text) RETURNS box2d AS
'MODULE_PATHNAME', 'geometry_estimated_extent'
LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Estimated_Extent(text,text) RETURNS box2d AS
'MODULE_PATHNAME', 'geometry_estimated_extent'
LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromText(text, int4)
RETURNS geometry AS 'SELECT ST_GeomFromText($1, $2)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromText(text)
RETURNS geometry AS 'SELECT ST_GeomFromText($1)'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ndims(geometry)
RETURNS smallint
AS 'MODULE_PATHNAME', 'LWGEOM_ndims'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SetSRID(geometry,int4)
RETURNS geometry
AS 'MODULE_PATHNAME','LWGEOM_set_srid'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SRID(geometry)
RETURNS int4
AS 'MODULE_PATHNAME','LWGEOM_get_srid'
LANGUAGE 'c' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.5.0
-- hack to allow unknown to cast to geometry
-- so does not yield function is not unique
CREATE OR REPLACE FUNCTION ST_AsBinary(text)
RETURNS bytea
- AS
+ AS
$$ SELECT ST_AsBinary($1::geometry);$$
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.5.0
-- hack to allow unknown to cast to geometry
-- so does not yield function is not unique
CREATE OR REPLACE FUNCTION ST_AsText(bytea)
RETURNS text
- AS
+ AS
$$ SELECT ST_AsText($1::geometry);$$
LANGUAGE 'sql' IMMUTABLE STRICT;
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
#include "sqldefines.h"
-
-----------------------------------------------------------------------
-- LONG TERM LOCKING
-----------------------------------------------------------------------
-- returns the number of locks released
CREATE OR REPLACE FUNCTION UnlockRows(text)
RETURNS int
- AS $$
+ AS $$
DECLARE
ret int;
BEGIN
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
--- LockRow([schema], table, rowid, auth, [expires])
+-- LockRow([schema], table, rowid, auth, [expires])
-- Returns 1 if successfully obtained the lock, 0 otherwise
CREATE OR REPLACE FUNCTION LockRow(text, text, text, text, timestamp)
RETURNS int
- AS $$
+ AS $$
DECLARE
myschema alias for $1;
mytable alias for $2;
ret int;
mytoid oid;
myrec RECORD;
-
+
BEGIN
IF NOT LongTransactionsEnabled() THEN
RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
END IF;
- EXECUTE 'DELETE FROM authorization_table WHERE expires < now()';
+ EXECUTE 'DELETE FROM authorization_table WHERE expires < now()';
SELECT c.oid INTO mytoid FROM pg_class c, pg_namespace n
WHERE c.relname = mytable
-- RAISE NOTICE 'toid: %', mytoid;
- FOR myrec IN SELECT * FROM authorization_table WHERE
+ FOR myrec IN SELECT * FROM authorization_table WHERE
toid = mytoid AND rid = myrid
LOOP
IF myrec.authid != authid THEN
$$ SELECT LockRow(current_schema(), $1, $2, $3, $4); $$
LANGUAGE 'sql' VOLATILE STRICT;
-
CREATE OR REPLACE FUNCTION AddAuth(text)
RETURNS BOOLEAN
- AS $$
+ AS $$
DECLARE
lockid alias for $1;
okay boolean;
okay := 'f';
FOR myrec IN SELECT * FROM pg_class WHERE relname = 'temp_lock_have_table' LOOP
okay := 't';
- END LOOP;
- IF (okay <> 't') THEN
+ END LOOP;
+ IF (okay <> 't') THEN
CREATE TEMP TABLE temp_lock_have_table (transid xid, lockcode text);
-- this will only work from pgsql7.4 up
-- ON COMMIT DELETE ROWS;
END;
$$
LANGUAGE PLPGSQL;
-
-- CheckAuth( <schema>, <table>, <ridcolumn> )
--
--
CREATE OR REPLACE FUNCTION CheckAuth(text, text, text)
RETURNS INT
- AS $$
+ AS $$
DECLARE
schema text;
BEGIN
-- TODO: check for an already existing trigger ?
- EXECUTE 'CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON '
+ EXECUTE 'CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON '
|| quote_ident(schema) || '.' || quote_ident($2)
||' FOR EACH ROW EXECUTE PROCEDURE CheckAuthTrigger('
|| quote_literal($3) || ')';
LANGUAGE 'sql';
CREATE OR REPLACE FUNCTION CheckAuthTrigger()
- RETURNS trigger AS
+ RETURNS trigger AS
'MODULE_PATHNAME', 'check_authorization'
LANGUAGE C;
CREATE OR REPLACE FUNCTION GetTransactionID()
- RETURNS xid AS
+ RETURNS xid AS
'MODULE_PATHNAME', 'getTransactionID'
LANGUAGE C;
-
--
-- Enable Long transactions support
--
--
CREATE OR REPLACE FUNCTION EnableLongTransactions()
RETURNS TEXT
- AS $$
+ AS $$
DECLARE
"query" text;
exists bool;
--
CREATE OR REPLACE FUNCTION LongTransactionsEnabled()
RETURNS bool
-AS $$
+AS $$
DECLARE
rec RECORD;
BEGIN
--
-- Disable Long transactions support
--
--- (1) Drop any long_xact trigger
+-- (1) Drop any long_xact trigger
-- (2) Drop the authorization_table
-- (3) KEEP the authorized_tables view
--
CREATE OR REPLACE FUNCTION DisableLongTransactions()
RETURNS TEXT
- AS $$
+ AS $$
DECLARE
rec RECORD;
END
$$ LANGUAGE 'plpgsql';
-
-- Let the user know about a deprecated signature and its new name, if any
CREATE OR REPLACE FUNCTION _postgis_deprecate(oldname text, newname text, version text)
RETURNS void AS
storage = main
);
-
-- Availability: 2.0.0
-- Special cast for enforcing the typmod restrictions
CREATE OR REPLACE FUNCTION geometry(geometry, integer, boolean)
-- Availability: 2.0.0
CREATE CAST (geometry AS geometry) WITH FUNCTION geometry(geometry, integer, boolean) AS IMPLICIT;
-
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION geometry(point)
RETURNS geometry
alignment = double
);
-
-------------------------------------------------------------------
-- GIDX TYPE (INTERNAL ONLY)
-------------------------------------------------------------------
OPERATOR 5 > ,
FUNCTION 1 geometry_cmp (geom1 geometry, geom2 geometry);
-
--
-- Sorting operators for Btree
--
OPERATOR 1 = ,
FUNCTION 1 geometry_hash(geometry);
-
-----------------------------------------------------------------------------
-- GiST 2D GEOMETRY-over-GSERIALIZED INDEX
-----------------------------------------------------------------------------
AS 'MODULE_PATHNAME' ,'gserialized_gist_decompress_2d'
LANGUAGE 'c' _PARALLEL;
-
-----------------------------------------------------------------------------
-- Availability: 2.1.0
AS 'MODULE_PATHNAME', 'gserialized_gist_joinsel_nd'
LANGUAGE 'c' _PARALLEL;
-
-----------------------------------------------------------------------------
-- GEOMETRY Operators
-----------------------------------------------------------------------------
AS 'MODULE_PATHNAME' ,'gserialized_gist_decompress'
LANGUAGE 'c' _PARALLEL;
-
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- N-D GEOMETRY Operators
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
AS 'MODULE_PATHNAME', 'gserialized_gist_distance'
LANGUAGE 'c' _PARALLEL;
-
-- Availability: 2.0.0
CREATE OPERATOR CLASS gist_geometry_ops_nd
FOR TYPE geometry USING GIST AS
FUNCTION 6 geometry_gist_picksplit_nd (internal, internal),
FUNCTION 7 geometry_gist_same_nd (geometry, geometry, internal);
-
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_ShiftLongitude(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME', 'LWGEOM_hasBBOX'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
------------------------------------------------------------------------
-- DEBUG
------------------------------------------------------------------------
LANGUAGE 'sql' IMMUTABLE STRICT
COST 100;
-
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_length_spheroid(geometry, spheroid)
AS 'MODULE_PATHNAME', 'LWGEOM_angle'
LANGUAGE 'c' IMMUTABLE STRICT;
-
-
------------------------------------------------------------------------
-- MISC
------------------------------------------------------------------------
AS 'MODULE_PATHNAME', 'LWGEOM_dump_rings'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
-----------------------------------------------------------------------
-- ST_DumpPoints()
-----------------------------------------------------------------------
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
-
-------------------------------------------------------------------
-- SPATIAL_REF_SYS
-------------------------------------------------------------------
proj4text varchar(2048)
);
-
-----------------------------------------------------------------------
-- POPULATE_GEOMETRY_COLUMNS()
-----------------------------------------------------------------------
RETURN 'fail';
END IF;
-
-- Verify dimension
IF ( (new_dim >4) OR (new_dim <2) ) THEN
RAISE EXCEPTION 'invalid dimension';
RETURN 'fail';
END IF;
-
-- Verify SRID
IF ( new_srid_in > 0 ) THEN
IF new_srid_in > SRID_USR_MAX THEN
END IF;
END IF;
-
-- Verify schema
IF ( schema_name IS NOT NULL AND schema_name != '' ) THEN
sql := 'SELECT nspname FROM pg_namespace ' ||
END IF;
END IF;
-
-- Add geometry column to table
IF use_typmod THEN
sql := 'ALTER TABLE ' ||
BEGIN
-
-- Find, check or fix schema_name
IF ( schema_name != '' ) THEN
okay = false;
BEGIN
-
-- Find, check or fix schema_name
IF ( schema_name != '' ) THEN
okay = false;
END
$$ language plpgsql;
-
-- Changed: 2.4.0
CREATE OR REPLACE FUNCTION postgis_full_version() RETURNS text
AS $$
CREATE CAST (bytea AS geometry) WITH FUNCTION geometry(bytea) AS IMPLICIT;
CREATE CAST (geometry AS bytea) WITH FUNCTION bytea(geometry) AS IMPLICIT;
-
---------------------------------------------------------------
-- Algorithms
---------------------------------------------------------------
AS 'SELECT (@extschema@.ST_isValidDetail($1, $2)).valid'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
-- Requires GEOS >= 3.2.0
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION ST_HausdorffDistance(geom1 geometry, geom2 geometry)
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100; -- Guessed cost
-
--------------------------------------------------------------------------------
-- ST_CleanGeometry / ST_MakeValid
--------------------------------------------------------------------------------
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 1; -- reset cost, see #3675
-
--------------------------------------------------------------------------------
-- _ST_Voronoi
--------------------------------------------------------------------------------
LANGUAGE 'c' IMMUTABLE _PARALLEL
COST 1; -- reset cost, see #3675
-
CREATE OR REPLACE FUNCTION ST_VoronoiPolygons(g1 geometry, tolerance float8 DEFAULT 0.0, extend_to geometry DEFAULT NULL)
RETURNS geometry
AS $$ SELECT @extschema@._ST_Voronoi(g1, extend_to, tolerance, true) $$
$$
LANGUAGE 'sql' IMMUTABLE;
-
-- Availability: 1.2.2
-- Changed: 2.2.0 to use non-deprecated ST_CombineBBox (r13535)
-- Changed: 2.3.0 to support PostgreSQL 9.6
finalfunc = pgis_geometry_union_finalfn
);
-
-- Availability: 1.2.2
-- Changed: 2.4.0: marked parallel safe
CREATE AGGREGATE ST_Collect (geometry) (
FINALFUNC = pgis_geometry_makeline_finalfn
);
-
--------------------------------------------------------------------------------
-- Availability: 2.3.0
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 1; -- reset cost, see #3675
-
-- Availability: 2.3.0
CREATE OR REPLACE FUNCTION ST_GeometricMedian(g geometry, tolerance float8 DEFAULT NULL, max_iter int DEFAULT 10000, fail_if_not_converged boolean DEFAULT false)
RETURNS geometry
AS $$ SELECT @extschema@._ST_AsKML($1, @extschema@.ST_Transform($2,4326), $3, $4); $$
LANGUAGE 'sql' IMMUTABLE _PARALLEL;
-
-----------------------------------------------------------------------
-- GEOJSON OUTPUT
-- Availability: 1.3.4
AS 'MODULE_PATHNAME','postgis_libprotobuf_version'
LANGUAGE 'c' IMMUTABLE STRICT;
-
-----------------------------------------------------------------------
-- GEOBUF OUTPUT
-- Availability: 2.4.0
finalfunc = pgis_asgeobuf_finalfn
);
-
------------------------------------------------------------------------
-- GeoHash (geohash.org)
------------------------------------------------------------------------
'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
-- PostGIS equivalent function: PointFromText(text, int4)
-- TODO: improve this ... by not duplicating constructor time.
CREATE OR REPLACE FUNCTION ST_PointFromText(text, int4)
'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_MultiLineStringFromText(text)
RETURNS geometry
'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_MPointFromWKB(bytea)
RETURNS geometry
'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_MultiPolyFromWKB(bytea)
RETURNS geometry
'
LANGUAGE 'sql' IMMUTABLE STRICT _PARALLEL;
-
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_GeomCollFromWKB(bytea)
RETURNS geometry
#include "long_xact.sql.in"
#include "geography.sql.in"
-
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_DistanceSphere(geom1 geometry, geom2 geometry)
RETURNS FLOAT8
AND NOT c.relname = 'raster_columns'::name AND t.typname = 'geometry'::name
AND NOT pg_is_other_temp_schema(c.relnamespace) AND has_table_privilege(c.oid, 'SELECT'::text);
-
-- TODO: support RETURNING and raise a WARNING
CREATE OR REPLACE RULE geometry_columns_insert AS
ON INSERT TO geometry_columns
ON DELETE TO geometry_columns
DO INSTEAD NOTHING;
-
---------------------------------------------------------------
-- 3D-functions
---------------------------------------------------------------
LANGUAGE 'sql' IMMUTABLE _PARALLEL
COST 100;
-
---------------------------------------------------------------
-- SQL-MM
---------------------------------------------------------------
AS 'MODULE_PATHNAME', 'ST_InterpolatePoint'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL;
-
-- moved to separate file cause its invovled
#include "postgis_brin.sql.in"
)
;
-
var_resultgeom := @extschema@.ST_MakeLine(geom)
FROM @extschema@.ST_Dump(cavering) As foo;
AS $$SELECT @extschema@._ST_AsX3D(3,$1,$2,$3,'');$$
LANGUAGE 'sql' IMMUTABLE _PARALLEL;
-
-----------------------------------------------------------------------
-- ST_Angle
-----------------------------------------------------------------------
RETURNS float8 AS 'SELECT ST_Angle(St_StartPoint($1), ST_EndPoint($1), St_StartPoint($2), ST_EndPoint($2))'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
-- make views and spatial_ref_sys public viewable --
GRANT SELECT ON TABLE geography_columns TO public;
GRANT SELECT ON TABLE geometry_columns TO public;
'SELECT $2 OPERATOR(@extschema@.&&) $1;'
LANGUAGE SQL IMMUTABLE STRICT;
-
-- Availability: 2.3.0
CREATE OPERATOR ~ (
LEFTARG = geometry,
'SELECT $2 OPERATOR(@extschema@.&&&) $1;'
LANGUAGE SQL IMMUTABLE STRICT;
-
-- Availability: 2.3.0
CREATE OPERATOR &&& (
LEFTARG = geometry,
COMMUTATOR = &&&
);
-
-- Availability: 2.3.0
CREATE OPERATOR &&& (
LEFTARG = gidx,
DROP AGGREGATE IF EXISTS st_astwkbagg(geometry, integer, bigint, boolean); -- temporarely introduced before 2.2.0 final
DROP AGGREGATE IF EXISTS st_astwkbagg(geometry, integer, bigint, boolean, boolean); -- temporarely introduced before 2.2.0 final
-
-- BEGIN Management functions that now have default param for typmod --
DROP FUNCTION IF EXISTS AddGeometryColumn(varchar,varchar,varchar,varchar,integer,varchar,integer);
DROP FUNCTION IF EXISTS AddGeometryColumn(varchar,varchar,varchar,integer,varchar,integer);
--
---------------------------------------------------------------------------
-
--
-- New SFCGAL functions (meaning prototype not already provided by GEOS)
--
CREATE OR REPLACE FUNCTION postgis_sfcgal_version() RETURNS text
AS 'MODULE_PATHNAME'
LANGUAGE 'c' IMMUTABLE;
-
+
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_3DIntersection(geom1 geometry, geom2 geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','sfcgal_difference3D'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
-
+
-- Availability: 2.2
CREATE OR REPLACE FUNCTION ST_3DUnion(geom1 geometry, geom2 geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','sfcgal_union3D'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
-
+
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Tesselate(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','sfcgal_tesselate'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
-
+
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_3DArea(geometry)
RETURNS FLOAT8
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
--- Availability: 2.1.0
+-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Extrude(geometry, float8, float8, float8)
RETURNS geometry
AS 'MODULE_PATHNAME','sfcgal_extrude'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
--- Availability: 2.1.0
+-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_ForceLHR(geometry)
RETURNS geometry
AS 'MODULE_PATHNAME','sfcgal_force_lhr'
LANGUAGE 'c' IMMUTABLE STRICT _PARALLEL
COST 100;
-
+
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Orientation(geometry)
RETURNS INT4
AS 'MODULE_PATHNAME','sfcgal_approximate_medial_axis'
LANGUAGE 'c'
#endif // POSTGIS_SFCGAL_VERSION >= 12
- IMMUTABLE STRICT _PARALLEL
+ IMMUTABLE STRICT _PARALLEL
COST 100;
--- Availability: 2.2.0
+-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_IsPlanar(geometry)
RETURNS boolean
AS 'MODULE_PATHNAME','sfcgal_is_planar'
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.org/
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- metadata table
-DROP VIEW geography_columns;
+DROP VIEW geography_columns;
-- indexes
DROP OPERATOR FAMILY gist_geography_ops USING gist CASCADE;
--
-- Text hacks to over-ride implicit casting issues with GEOMETRY
--- TODO Remove for 2.0
+-- TODO Remove for 2.0
--
DROP FUNCTION IF EXISTS ST_AsText(text);
DROP FUNCTION IF EXISTS ST_AsBinary(text);
DROP FUNCTION IF EXISTS geography(geometry);
DROP FUNCTION IF EXISTS geometry(geography);
-DROP FUNCTION IF EXISTS geography_gist_consistent(internal,geometry,int4);
-DROP FUNCTION IF EXISTS geography_gist_compress(internal);
-DROP FUNCTION IF EXISTS geography_gist_penalty(internal,internal,internal);
-DROP FUNCTION IF EXISTS geography_gist_picksplit(internal, internal);
-DROP FUNCTION IF EXISTS geography_gist_union(bytea, internal);
-DROP FUNCTION IF EXISTS geography_gist_same(box2d, box2d, internal);
-DROP FUNCTION IF EXISTS geography_gist_decompress(internal);
+DROP FUNCTION IF EXISTS geography_gist_consistent(internal,geometry,int4);
+DROP FUNCTION IF EXISTS geography_gist_compress(internal);
+DROP FUNCTION IF EXISTS geography_gist_penalty(internal,internal,internal);
+DROP FUNCTION IF EXISTS geography_gist_picksplit(internal, internal);
+DROP FUNCTION IF EXISTS geography_gist_union(bytea, internal);
+DROP FUNCTION IF EXISTS geography_gist_same(box2d, box2d, internal);
+DROP FUNCTION IF EXISTS geography_gist_decompress(internal);
DROP FUNCTION IF EXISTS geography_gist_selectivity (internal, oid, internal, int4);
DROP FUNCTION IF EXISTS geography_gist_join_selectivity(internal, oid, internal, smallint);
-DROP FUNCTION IF EXISTS geography_overlaps(geography, geography);
+DROP FUNCTION IF EXISTS geography_overlaps(geography, geography);
DROP FUNCTION IF EXISTS geography_lt(geography, geography);
DROP FUNCTION IF EXISTS geography_le(geography, geography);
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-----------------------------------------------------------------------
-- LONG TERM LOCKING
-----------------------------------------------------------------------
--
---------------------------------------------------------------------------
-
--
-- New SFCGAL functions (meaning prototype not already provided by GEOS)
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-------------------------------------------------------------------------------
END
$$ LANGUAGE 'plpgsql';
-
------------------------------------------------------------------------------
-- RASTER Type
------------------------------------------------------------------------------
$$
LANGUAGE 'plpgsql' IMMUTABLE _PARALLEL;
-
CREATE OR REPLACE FUNCTION st_min4ma(matrix float[][], nodatamode text, variadic args text[])
RETURNS float AS
$$
AS 'MODULE_PATHNAME', 'RASTER_nMapAlgebra'
LANGUAGE 'c' IMMUTABLE _PARALLEL;
-
-
CREATE OR REPLACE FUNCTION st_mapalgebra(
rastbandargset rastbandarg[],
callbackfunc regprocedure,
END;
$$ LANGUAGE 'plpgsql' VOLATILE STRICT;
-
-- Availability: 2.4.0
CREATE OR REPLACE FUNCTION st_makeemptycoverage(tilewidth int, tileheight int, width int, height int, upperleftx float8, upperlefty float8, scalex float8, scaley float8, skewx float8, skewy float8, srid int4 DEFAULT 0)
RETURNS SETOF RASTER AS $$
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE _PARALLEL;
-
-------------------------------------------------------------------
-- Debugging
-------------------------------------------------------------------
AS 'MODULE_PATHNAME', 'RASTER_noop'
LANGUAGE 'c' STABLE STRICT;
-
-------------------------------------------------------------------
-- END
-------------------------------------------------------------------
DROP AGGREGATE IF EXISTS ST_Union(raster, text, text, text, double precision);
DROP AGGREGATE IF EXISTS ST_Union(raster, record[]);
-
DROP FUNCTION IF EXISTS ST_Intersects(raster,boolean,geometry);
DROP FUNCTION IF EXISTS ST_Intersects(geometry,raster,boolean);
DROP FUNCTION IF EXISTS ST_Intersects(raster,geometry);
-- This section is take add / drop things like CASTS, TYPES etc. that have changed
-- Since these are normally excluded from sed upgrade generator
-- they must be explicitly added
--- So that they can immediately be recreated.
+-- So that they can immediately be recreated.
-- It is not run thru the sed processor to prevent it from being stripped
-- Note: We put these in separate file from drop since the extension module has
-- to add additional logic to drop them from the extension as well
DROP FUNCTION IF EXISTS ST_MapAlgebra(raster, integer, text, text, nodatavaluerepl text);
DROP FUNCTION IF EXISTS ST_MapAlgebra(raster, pixeltype text, expression text, nodatavaluerepl text);
-
--signatures or arg names changed
DROP FUNCTION IF EXISTS ST_MapAlgebraExpr(raster, integer, text, text, text);
DROP FUNCTION IF EXISTS ST_MapAlgebraExpr(raster, text, text, text);
DROP FUNCTION IF EXISTS ST_MapalgebraFct(raster, regprocedure);
-DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, text, regprocedure, VARIADIC text[]);
-DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, text, regprocedure);
+DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, text, regprocedure, VARIADIC text[]);
+DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, text, regprocedure);
DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, regprocedure, VARIADIC text[]);
DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, regprocedure, variadic text[]);
-DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, text, regprocedure, VARIADIC text[]);
-DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, text, regprocedure);
+DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, text, regprocedure, VARIADIC text[]);
+DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, text, regprocedure);
DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, regprocedure, variadic text[]);
DROP FUNCTION IF EXISTS ST_MapalgebraFct(raster, integer, regprocedure);
DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, raster, regprocedure, text, text, VARIADIC text[]);
DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, integer, raster, integer, regprocedure, text, text, VARIADIC text[]);
DROP FUNCTION IF EXISTS ST_MapAlgebraFctNgb(raster, integer, text, integer, integer, regprocedure, text, VARIADIC text[]);
-
--dropped functions
DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, raster, regprocedure, VARIADIC text[]);
-- signature changed
DROP FUNCTION IF EXISTS st_bandpixeltype(raster, integer);
-
-- function no longer exists
DROP FUNCTION IF EXISTS st_value(raster, integer, integer, integer);
DROP FUNCTION IF EXISTS st_value(raster, integer, integer);
DROP FUNCTION IF EXISTS st_bandmetadata(raster, VARIADIC int[]);
--change to use default parameters
-DROP FUNCTION IF EXISTS ST_PixelAsPolygons(raster);
+DROP FUNCTION IF EXISTS ST_PixelAsPolygons(raster);
DROP FUNCTION IF EXISTS ST_PixelAsPolygons(raster,integer);
-- TYPE summarystats removed in version 2.1.0
SELECT asbinary(_MapAlgebraPartsGeom(nx, ny, x1, y1, w1, h1, x2, y2, w2, h2))
FROM X1W1X2W2() as (nx int, x1 int, w1 int, x2 int, w2 int), Y1H1Y2H2() as (ny int, y1 int, h1 int, y2 int, h2 int);
-
-- First series of zones covering raster 1
SELECT nx, ny, map[1], map[2], map[3], map[4],
asbinary(ST_MakeBox2D(ST_Point(10 * ny + map[1], -10 * nx + 5 - map[2]), ST_Point(10 * ny + map[1] + map[3], -10 * nx + 5 - (map[2] + map[4])))::geometry)
FINALFUNC=geomval_arealweightedfinal
);
-
SELECT id,
(aws).count,
(aws).distinctcount,
-- NOTE: The ST_DeleteBand function found in this file still need enhancement before being implemented in C.
-
-- NOTE: ST_DeleteBand(rast raster, band int) is dependent on
-- ST_AddBand(rast1 raster, rast2 raster, band int, index int)
-- to be found in the script/plpgsql folder
FROM srtm_22_03_tiled, rect3
WHERE st_intersects(rast, geom)
-
SELECT rid, id, ST_GeomExtent2RasterCoord(rast, geom)
FROM srtm_22_03_tiled, rect3
WHERE st_intersects(rast, geom)
-
SELECT (ext).x1, (ext).y1, (ext).x2, (ext).y2 FROM (SELECT ST_GeomExtent2RasterCoord(rast, geom) ext FROM srtm_22_03_tiled, rect3
WHERE st_intersects(rast, geom)) foo
\ No newline at end of file
--Create the raster receiving all the computed values. Initialize it to the new initial value.
newrast := ST_AddBand(newrast, newpixeltype, newinitialvalue, newnodatavalue);
-
-- Optimization: If expression is NULL, or all the pixels could be set in a one step, return the initialised raster now
IF expression IS NULL OR skipcomputation = 2 THEN
RETURN newrast;
--SELECT ST_Value(rast, 1, 2), ST_Value(ST_MapAlgebra(rast, 1, 'rast + 20', 'rast + 2', '2BUI'), 1, 2)
--FROM ST_TestRaster(0, 0, 101) rast;
-
--------------------------------------------------------------------
-- ST_SameAlignment
-- Determine if the raster coordinates are aligned.
$$
LANGUAGE 'plpgsql';
-
--------------------------------------------------------------------
-- ST_MapAlgebra (two raster version) variants
--------------------------------------------------------------------
AS 'SELECT ST_MapAlgebra($1, 1, $2, 1, $3, $4, NULL, NULL, NULL, NULL)'
LANGUAGE 'SQL' IMMUTABLE;
-
-- Variant 8
CREATE OR REPLACE FUNCTION ST_MapAlgebra(rast1 raster,
rast2 raster,
--SELECT ST_MapAlgebra(NULL, 1, NULL, 1, 'rast2', NULL, 'UNION', 0);
-
--Test rasters
CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8)
RETURNS raster AS
$$
LANGUAGE 'plpgsql';
-
CREATE OR REPLACE FUNCTION ST_TestRotatedRaster(ulx float8, uly float8)
RETURNS raster AS
$$
--SELECT (gv).val, ST_AsBinary((gv).geom)
--FROM (SELECT ST_PixelAsPolygons(ST_TestRaster(1, 1, 3)) gv) foo
-
-- 1) ST_Intersection and ST_Clip
--SELECT ST_MapAlgebra(rast1, rast2, 'rast1', '32BF', 'INTERSECTION')
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_MapAlgebra(rast1, rast2, 'rast1', '32BF', 'INTERSECTION')) gv
-- FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo) foo2
-
-- 2) ST_Intersection returning a two band raster
--SELECT ST_AddBand(ST_MapAlgebra(rast1, rast2, 'rast1', '32BF', 'INTERSECTION'), ST_MapAlgebra(rast1, rast2, 'rast2', '32BF', 'INTERSECTION'))
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_AddBand(ST_MapAlgebra(rast1, rast2, 'rast1', '32BF', 'INTERSECTION'), ST_MapAlgebra(rast1, rast2, 'rast2', '32BF', 'INTERSECTION')), 2) gv
-- FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo) foo2
-
-- 3) ST_Union
--SELECT ST_MapAlgebra(rast1, rast2, '(rast1 + rast2)/2::numeric', '32BF', 'UNION', 'rast2', 'rast1', NULL)
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_MapAlgebra(rast1, rast2, '(rast1 + rast2)/2::numeric', '32BF', 'UNION', 'rast2', 'rast1', NULL)) gv
-- FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo) foo2
-
-- 4) ST_Collect
--SELECT ST_MapAlgebra(rast1, rast2, 'rast2', '32BF', 'UNION', 'rast2', 'rast1', NULL)
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_MapAlgebra(rast1, rast2, 'rast2', '32BF', 'UNION', 'rast2', 'rast1', NULL)) gv
-- FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo) foo2
-
-- 5) ST_Difference making a mere geometric difference
--SELECT ST_MapAlgebra(rast1, rast2, 'CASE WHEN NOT rast2 IS NULL THEN NULL ELSE rast1 END', '32BF', 'FIRST', NULL, 'rast1', NULL)
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_MapAlgebra(rast1, rast2, 'CASE WHEN NOT rast2 IS NULL THEN NULL ELSE rast1 END', '32BF', 'FIRST', NULL, 'rast1', NULL)) gv
-- FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo) foo2
-
-- 6) ST_Difference making an arithmetic difference
--SELECT ST_MapAlgebra(rast1, rast2, 'rast1 - rast2', '32BF', 'FIRST', NULL, 'rast1', NULL)
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_MapAlgebra(rast1, rast2, 'rast1 - rast2', '32BF', 'FIRST', NULL, 'rast1', NULL)) gv
-- FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo) foo2
-
-- 7) ST_SymDifference making a mere geometric difference (commutative)
--SELECT ST_MapAlgebra(rast1, rast2, 'NULL', '32BF', 'UNION', 'rast2', 'rast1', NULL)
--FROM (SELECT ST_TestRaster(0, 0, 1) rast1, ST_TestRaster(1, 1, 3) rast2) foo
--FROM (SELECT ST_PixelAsPolygons(ST_MapAlgebra(rast1, rast2, 'NULL', '32BF', 'UNION', 'rast2', 'rast1', NULL)) gv
-- FROM (SELECT ST_TestRaster(1, 1, 3) rast1, ST_TestRaster(0, 0, 1) rast2) foo) foo2
-
-- 8) ST_SymDifference making an arithmetic difference (not commutative)
--Commutation 1
--SELECT ST_MapAlgebra(rast1, rast2, 'rast1 - rast2', '32BF', 'UNION', 'rast2', 'rast1', NULL)
--SELECT ST_MapAlgebra(rast1, rast2, 'rast1 - rast2', '32BF', 'UNION', 'rast2', 'rast1', NULL)
--FROM (SELECT ST_TestRaster(1, 1, 2) rast1, ST_TestRaster(0, 0, 1) rast2) foo
-
-- Other tests
-- UNION
-- ST_Height(rast)
--FROM (SELECT ST_MapAlgebra(ST_TestRaster(0, 0, 1), 1, ST_TestRaster(1, 0, 1), 1, '(rast1 + rast2)/3::float8', '64BF', 'INTERSECTION', '0'::text) AS rast) foo
-
-- FIRST -- Doesn't work...
--SELECT ST_Value(rast, 1, 1),
-- ST_Value(rast, 1, 2),
-- ST_Height(rast)
--FROM (SELECT ST_MapAlgebra(ST_TestRaster(0, 0, 1), 1, ST_TestRaster(1, 1, 1), 1, 'rast1 + rast2 + 2*rast2 + toto()', '8BSI', 'SECOND', NULL) AS rast) foo
-
-- INTERSECTION with rotated. -- Doesn't work...
--SELECT ST_IsEmpty(rast),
-- ST_Value(rast, 1, 1) AS "1, 1",
RETURN ST_MakeEmptyRaster(0, 0, 0, 0, 0, 0, 0, 0, newsrid);
END IF;
-
-- Compute the new ulx and uly
newulx := st_raster2worldcoordx(rast1, zcx - r1x + 1, zcy - r1y + 1);
newuly := st_raster2worldcoordy(rast1, zcx - r1x + 1, zcy - r1y + 1);
IF z11w > 0 AND z11h > 0 AND NOT ST_BandIsNodata(rast1, band1) AND NOT nodata2expr IS NULL THEN
IF upnodata2expr = 'RAST' THEN
-
-- IF rast1nodataval != nodatanodataval THEN
RAISE NOTICE 'ST_MapAlgebra2 222';
-- newrast := ST_SetValues(newrast, 1, z11x, z11y, z11w, z11h, nodatanodataval);
$$
LANGUAGE 'plpgsql';
-
CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8)
RETURNS raster AS
$$
$$
LANGUAGE 'plpgsql';
-
SELECT asbinary((gv).geom), (gv).val
FROM st_pixelaspolygons(ST_TestRaster(-10, 2, 1)) gv;
SELECT asbinary(pix.geom) as geom, pix.val
FROM st_pixelaspolygons(ST_MapAlgebra2(ST_TestRaster(0, 1, 1), 1, ST_TestRaster(1, 0, 1), 1, '(rast1 + rast2) / 2', NULL, 'union', '2*rast', 'rast', NULL), 1) as pix
-
-
-
$$
LANGUAGE 'plpgsql';
-
-- Test
SELECT ST_SetValues(ST_TestRaster(0, 0, 1), 2, 2, 1, 1, 0)
SELECT ST_AsBinary((pix).geom), (pix).val
FROM (SELECT ST_PixelAsPolygons(ST_SetValues(ST_TestRaster(0, 0, 1), 2, 1, 3, 1, ST_TestRaster(3, 0, 3))) as pix) foo
-
-
$$
LANGUAGE 'plpgsql';
-
-- Redefine ST_TestRaster()
CREATE OR REPLACE FUNCTION ST_TestRaster(ulx float8, uly float8, val float8)
RETURNS raster AS
-- Test ST_TileAsGeom
SELECT ST_TileAsGeom(ST_TestRaster(0, 0, 1), 10, 10);
-
-- Other tests
SELECT ST_Tile(ST_AddBand(ST_MakeEmptyRaster(48, 63, 0, 0, 0.001, -0.001, 0, 0, 4269), '8BSI'::text, 0, -2), 10, 10, true, -10);
$$
LANGUAGE 'plpgsql';
-
CREATE OR REPLACE FUNCTION MapAlgebra4Union(rast1 rastexpr,
rast2 raster,
p_expression text,
SELECT ST_TestRaster(0, 3, 3) AS rast
) foi) foo
-
-- Explicit implementation of 'MEAN' to make sure directly passing expressions works properly
SELECT ST_AsBinary((rast).geom), (rast).val
FROM (SELECT ST_PixelAsPolygons(ST_Union(rast, '[rast1.val] + [rast2.val]'::text, '[rast2.val]'::text, '[rast1.val]'::text, NULL::double precision,
SELECT ST_TestRaster(-1, 0, 6) AS rast
) foi) foo
-
SELECT ST_AsBinary((rast).geom), (rast).val
FROM (SELECT ST_PixelAsPolygons(ST_Union(rast), 1) AS rast
FROM (SELECT ST_TestRaster(0, 0, 1) AS rast UNION ALL SELECT ST_TestRaster(2, 0, 2)
) foi
) foo
-
SELECT ST_AsBinary((rast).geom), (rast).val
FROM (SELECT ST_PixelAsPolygons(ST_Union(rast, 'mean'), 1) AS rast
FROM (SELECT ST_TestRaster(0, 0, 1) AS rast UNION ALL SELECT ST_TestRaster(1, 0, 2) UNION ALL SELECT ST_TestRaster(0, 1, 6)
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', initvalue, nodataval);
-
INSERT INTO test_raster_columns VALUES (rid, rast);
RETURN;
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', initvalue, nodataval);
-
INSERT INTO test_raster_columns VALUES (rid, rast);
RETURN;
expr := replace(skip_expr, '[v]'::text, value::text);
EXECUTE 'SELECT (' || expr || ')::boolean' INTO result;
END IF;
-
+
IF result IS TRUE THEN
values[1][y][x] := value;
END IF;
--- Test of "ST_AddBand".
-----------------------------------------------------------------------
-
-----------------------------------------------------------------------
--- ST_AddBand
-----------------------------------------------------------------------
FROM rt_band_properties_test
WHERE b1nodatavalue != st_bandnodatavalue(rast, 1) or b2nodatavalue != st_bandnodatavalue(rast, 2);
-
-----------------------------------------------------------------------
--- ST_BandIsNoData
-----------------------------------------------------------------------
FROM rt_band_properties_test
WHERE id = 3;
-
-----------------------------------------------------------------------
--- ST_SetBandIsNoData
-----------------------------------------------------------------------
DROP TABLE o_8_res1;
DROP TABLE o_4_res1;
DROP TABLE o_2_res1;
--- Keep the source table
-
+-- Keep the source table
-- Test overview with table in schema
---
+--
CREATE SCHEMA oschm;
-- offset the schema tableto distinguish it from original
--- let it be small to reduce time cost.
+-- let it be small to reduce time cost.
CREATE TABLE oschm.res1 AS SELECT
ST_AddBand(
ST_MakeEmptyRaster(10, 10, x, y, 1, -1, 0, 0, 0)
-- Create overview for table in public schema with explict path
-- at same factor of schema table
SELECT ST_CreateOverview('public.res1', 'r', 8)::text = 'public.o_8_res1';
-
+
-- Reset the search_path
SET search_path to public;
-- and scale as schema table above using reset search path.
SELECT ST_CreateOverview('res1', 'r', 4)::text = 'o_4_res1';
--- Check scale and extent
+-- Check scale and extent
-- Offset means that original raster overviews won't match
-- extent and values only mach on schema table not public one
SELECT r_table_schema, r_table_name tab, r_raster_column c,
DROP TABLE o_4_res1;
DROP TABLE res1;
--- Reset the session environment
+-- Reset the session environment
-- possibly a bit harsh, but we had to set the search_path
-- and need to reset it back to default.
DISCARD ALL;
expr := replace(skip_expr, '[v]'::text, value::text);
EXECUTE 'SELECT (' || expr || ')::boolean' INTO result;
END IF;
-
+
IF result IS TRUE THEN
values[y][x] := value;
END IF;
SELECT (ST_DumpValues(ST_AddBand(ST_MakeEmptyRaster(0, 0, 0, 0, 1), ARRAY[ROW(NULL, '8BUI', 255, 0),ROW(NULL, '16BUI', 1, 2)]::addbandarg[]))).*;
-
-- #3086
DROP TABLE IF EXISTS raster_tile;
CREATE TABLE raster_tile AS
expr := replace(skip_expr, '[v]'::text, value::text);
EXECUTE 'SELECT (' || expr || ')::boolean' INTO result;
END IF;
-
+
IF result IS TRUE THEN
values[1][y][x] := value;
END IF;
(10,make_value_array(3,3,3.14,12)),
(11,make_value_array(3,3,2.11,11));
-
SELECT
id,
val,
FROM rt_properties_test
WHERE id = 2;
-
SELECT
replace(st_georeference(rast)::text, E'\n', E'EOL'),
replace(st_georeference(rast)::text, E'\n', E'EOL') =
FROM rt_properties_test
WHERE id = 5;
-
-----------------------------------------------------------------------
-- st_setgeoreference (error conditions)
-----------------------------------------------------------------------
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', 1, 0);
-
INSERT INTO raster_geos_rast VALUES (rid, rast);
RETURN;
ON r1.rid != r2.rid
WHERE r2.rid = 0;
-
SELECT
'2.1',
r1.rid,
ipx float8;
ipy float8;
BEGIN
-
+
-- compute some sizes
-- each tile extent width is extent.width / gridRows
scalex = ((ST_xmax(extent)-ST_xmin(extent))/gridCols)/tileWidth;
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', initvalue, nodataval);
-
INSERT INTO raster_intersection VALUES (rid, rast);
RETURN;
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', 1, 0);
-
INSERT INTO raster_intersects_rast VALUES (rid, rast);
RETURN;
expr := replace(skip_expr, '[v]'::text, value::text);
EXECUTE 'SELECT (' || expr || ')::boolean' INTO result;
END IF;
-
+
IF result IS TRUE THEN
values[1][y][x] := value;
END IF;
(18, make_value_array(3, 3, 1, 1, '[v] > 8'))
;
-
SELECT
id,
val,
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', initvalue, nodataval);
-
INSERT INTO raster_mapalgebra VALUES (rid, rast);
RETURN;
from raster_nmapalgebra_mask_in) AS f
ORDER BY rid, (dv).nband;
-
-
select st_mapalgebra(rast,1,'raster_nmapalgebra_test(double precision[], int[], text[])'::regprocedure,ARRAY[[1,1],[1,1],[1,1]]::double precision[],true) from raster_nmapalgebra_mask_in;
select st_mapalgebra(rast,1,'raster_nmapalgebra_test(double precision[], int[], text[])'::regprocedure,ARRAY[[1,1,1],[1,1,1]]::double precision[],true) from raster_nmapalgebra_mask_in;
from raster_nmapalgebra_mask_in) As f
ORDER BY rid, (dv).nband;
-
select st_mapalgebra(rast,1,'raster_nmapalgebra_test(double precision[], int[], text[])'::regprocedure,ARRAY[[.5,.5],[.5,.5],[.5,.5]]::double precision[],true) from raster_nmapalgebra_mask_in;
select st_mapalgebra(rast,1,'raster_nmapalgebra_test(double precision[], int[], text[])'::regprocedure,ARRAY[[.5,.5,.5],[.5,.5,.5]]::double precision[],true) from raster_nmapalgebra_mask_in;
rast := ST_MakeEmptyRaster(width, height, ul_x, ul_y, 1, 1, skew_x, skew_y, 0);
rast := ST_AddBand(rast, 1, '8BUI', initvalue, nodataval);
-
INSERT INTO raster_mapalgebra VALUES (rid, rast);
RETURN;
$$
LANGUAGE 'plpgsql' IMMUTABLE;
-
--
--Test rasters
--
$$
LANGUAGE 'plpgsql' IMMUTABLE;
-
--
--Test rasters
--
rast := ST_MakeEmptyRaster(width, height, 0, 0, 1, -1, 0, 0, 0);
rast := ST_AddBand(rast, 1, '8BUI', 1, 0);
-
valset := array_fill(0., ARRAY[height, width]);
FOR y IN 1..height LOOP
FOR x IN 1..width LOOP
SELECT
ST_PixelOfValue(
rast,
- 2
+ 2
) AS pixval
FROM raster_pixelofvalue
) foo;
--- (Objective B03a)
-----------------------------------------------------------------------
-
-----------------------------------------------------------------------
--- ST_SetSRID
-----------------------------------------------------------------------
FROM rt_properties_test
WHERE (srid+1) != st_srid(st_setsrid(rast,srid+1));
-
-----------------------------------------------------------------------
--- ST_SetScale
-----------------------------------------------------------------------
(skewx+2) != st_skewx(st_setskew(rast,skewx+2)) OR
(skewy+3) != st_skewy(st_setskew(rast,skewy+3));
-
-----------------------------------------------------------------------
--- ST_SetUpperLeft
-----------------------------------------------------------------------
ipy
), 0) != 1;
-
-----------------------------------------------------------------------
-- Test 6 - ST_WorldTorastercoordy(rast raster, pt geometry)
-----------------------------------------------------------------------
(st_isvaliddetail(orig)).valid
FROM clean_cases;
-
SELECT '#1719.1', ST_AsEWKT(ST_MakeValid('POINT(0 0)'));
SELECT '#1719.2', ST_AsEWKT(ST_MakeValid('GEOMETRYCOLLECTION(POINT(0 0),MULTIPOINT(3 4,5 2),LINESTRING(4 4, 4 4),POLYGON((0 0,10 10,0 10,10 0,0 0)))'));
SELECT '#1719.3', ST_AsEWKT(ST_MakeValid('MULTIPOINT(3 4,5 2)'));
50 60, 125 100, 175 150))'),
ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
) As geom;
-
+
SELECT
'ST_ConcaveHull Lines 0.80', ST_Within(geom,ST_ConcaveHull(
geom, 0.80) ) As encloses_geom,
-
-- Semantic of tolerance depends on the `toltype` argument, which can be:
-- 0: Tolerance is number of segments per quadrant
-- 1: Tolerance is max distance between curve and line
1 -- Symmetric
), 2));
-
'LINESTRING EMPTY'::geometry as empty
) SELECT 'ST_Length(empty) == 0', ST_Length(empty) FROM inp;
-
-- Operators
-- same box, see http://trac.osgeo.org/postgis/ticket/1453
analyze c2;
analyze p;
-
-- #3391.1
with e as ( select ST_EstimatedExtent('c1','g') as e )
select '#3391.1', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
select '#3391.3', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
round(st_ymin(e.e)::numeric, 2), round(st_ymax(e.e)::numeric, 2) from e;
-
insert into c1 values ('Point(0 0)'::geometry);
insert into c1 values ('Point(1 1)'::geometry);
select '#3391.6', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
round(st_ymin(e.e)::numeric, 2), round(st_ymax(e.e)::numeric, 2) from e;
-
insert into c2 values ('Point(0 0)'::geometry);
insert into c2 values ('Point(-1 -1)'::geometry);
select '#3391.9', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
round(st_ymin(e.e)::numeric, 2), round(st_ymax(e.e)::numeric, 2) from e;
-
insert into p values ('Point(1 1)'::geometry);
insert into p values ('Point(2 2)'::geometry);
analyze c2;
analyze p;
-
-- #3391.13
with e as ( select ST_EstimatedExtent('public','p','g','t') as e )
select '#3391.13', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
select '#3391.16', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
round(st_ymin(e.e)::numeric, 2), round(st_ymax(e.e)::numeric, 2) from e;
-
insert into c1 values ('Point(0 0)'::geometry);
insert into c1 values ('Point(1 1)'::geometry);
select '#3391.20', round(st_xmin(e.e)::numeric, 2), round(st_xmax(e.e)::numeric, 2),
round(st_ymin(e.e)::numeric, 2), round(st_ymax(e.e)::numeric, 2) from e;
-
drop table p cascade;
--
SELECT 'frechet_ls_ls_3', st_frechetdistance(
'LINESTRING (0 0, 100 0)'::geometry,
'LINESTRING (0 0, 50 50, 100 0)'::geometry);
--- 70.7106781186548
+-- 70.7106781186548
-- rechet with densification
SELECT 'frechetdensify_ls_ls', st_frechetdistance(
('geog_covers_poly_line_out', 'POLYGON((0 40, 40 40, 40 0, 0 0, 0 40))', 'LINESTRING (-10 -40, -40 -40, -40 -10, -10 -10)')
) AS u(c, g1, g2);
-
-- poly in poly (reversed arguments)
SELECT c, ST_CoveredBy(g1::geography, g2::geography) FROM
( VALUES
-- Written by Olivier Courtin - Oslandia
--
-
--
-- spatial_ref_sys datas
--
--- EPSG 27582 : NTF (Paris) / France II (deprecated)
INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (27582,'EPSG',27582,'PROJCS["NTF (Paris) / France II (deprecated)",GEOGCS["NTF (Paris)",DATUM["Nouvelle_Triangulation_Francaise_Paris",SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,AUTHORITY["EPSG","7011"]],TOWGS84[-168,-60,320,0,0,0,0],AUTHORITY["EPSG","6807"]],PRIMEM["Paris",2.33722917,AUTHORITY["EPSG","8903"]],UNIT["grad",0.01570796326794897,AUTHORITY["EPSG","9105"]],AUTHORITY["EPSG","4807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Lambert_Conformal_Conic_1SP"],PARAMETER["latitude_of_origin",52],PARAMETER["central_meridian",0],PARAMETER["scale_factor",0.99987742],PARAMETER["false_easting",600000],PARAMETER["false_northing",2200000],AUTHORITY["EPSG","27582"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=lcc +lat_1=46.8 +lat_0=46.8 +lon_0=0 +k_0=0.99987742 +x_0=600000 +y_0=2200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ');
-
-
-
-- Empty Geometry
SELECT 'empty_geom', ST_AsEWKT(ST_GeomFromGML(NULL));
-- ERROR: Not a GML Geometry
SELECT 'xml_3', ST_AsEWKT(ST_GeomFromGML('<foo/>'));
-
-
--
-- Point
--
-- srsName handle
SELECT 'point_4', ST_AsEWKT(ST_GeomFromGML('<gml:Point srsName="EPSG:4326"><gml:pos>1 2</gml:pos></gml:Point>'));
-
-
--
-- LineString
--
-- XML not elements handle
SELECT 'linestring_6', ST_AsEWKT(ST_GeomFromGML(' <!-- --> <gml:LineString> <!-- --> <gml:coordinates>1,2 3,4</gml:coordinates></gml:LineString>'));
-
-
-
--
-- Curve
--
SELECT 'curve_15', ST_AsEWKT(ST_GeomFromGML('<gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension="3">1 2 3 4 5 6</gml:posList></gml:LineStringSegment><gml:LineStringSegment><gml:posList srsDimension="2">4 5 7 8</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve>'));
SELECT 'curve_16', ST_AsEWKT(ST_GeomFromGML('<gml:Curve><gml:segments><gml:LineStringSegment><gml:posList srsDimension="2">1 2 3 4</gml:posList></gml:LineStringSegment><gml:LineStringSegment><gml:posList srsDimension="3">3 4 5 6 7 8</gml:posList></gml:LineStringSegment></gml:segments></gml:Curve>'));
-
-
-
--
-- Polygon
--
SELECT 'polygon_18', ST_AsEWKT(ST_GeomFromGML('<gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension="3">1 2 3 4 5 6 7 8 9 1 2 3</gml:posList></gml:LinearRing></gml:exterior><gml:interior><gml:LinearRing><gml:posList srsDimension="2">10 11 12 13 14 15 10 11</gml:posList></gml:LinearRing></gml:interior></gml:Polygon>'));
SELECT 'polygon_19', ST_AsEWKT(ST_GeomFromGML('<gml:Polygon><gml:exterior><gml:LinearRing><gml:posList srsDimension="2">1 2 3 4 5 6 1 2</gml:posList></gml:LinearRing></gml:exterior><gml:interior><gml:LinearRing><gml:posList srsDimension="3">7 8 9 10 11 12 13 14 15 7 8 9</gml:posList></gml:LinearRing></gml:interior></gml:Polygon>'));
-
-
--
-- LinearRing
--
-- XML not elements handle
SELECT 'linearring_8', ST_AsEWKT(ST_GeomFromGML(' <!-- --> <gml:LinearRing> <!-- --> <gml:posList>1 2 3 4 5 6 1 2</gml:posList> <!-- --> </gml:LinearRing>'));
-
--
-- Triangle
--
-- ERROR: interpolation not planar
SELECT 'triangle_11', ST_AsEWKT(ST_GeomFromGML('<gml:Triangle interpolation="not_planar"><gml:exterior><gml:LinearRing><gml:coordinates>1,2 3,4 5,6 1,2</gml:coordinates></gml:LinearRing></gml:exterior></gml:Triangle>'));
-
-
--
-- Surface
--
-- ERROR: interior but no exterior
SELECT 'surface_23', ST_AsEWKT(ST_GeomFromGML('<gml:Surface><gml:patches><gml:PolygonPatch><gml:interior><gml:LinearRing><gml:coordinates>1,2 3,4 5,6 1,2</gml:coordinates></gml:LinearRing></gml:interior></gml:PolygonPatch></gml:patches></gml:Surface>'));
-
--
-- MultiPoint
--
-- Empty pointMembers
SELECT 'mpoint_10', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPoint><gml:pointMembers></gml:pointMembers></gml:MultiPoint>'));
-
--
-- MultiLineString
--
-- Mixed srsName
SELECT 'mline_9', ST_AsEWKT(ST_GeomFromGML('<gml:MultiLineString srsName="EPSG:27582"><gml:lineStringMember><gml:LineString><gml:coordinates>1,2 3,4</gml:coordinates></gml:LineString></gml:lineStringMember><gml:lineStringMember><gml:LineString srsName="EPSG:27562"><gml:coordinates>400000,5000000 400010,5000010</gml:coordinates></gml:LineString></gml:lineStringMember></gml:MultiLineString>'));
-
--
-- MultiCurve
--
SELECT 'mcurve_12', ST_AsEWKT(ST_GeomFromGML('<gml:MultiCurve><gml:curveMembers></gml:curveMembers></gml:MultiCurve>'));
-
--
-- MultiPolygon
--
SELECT 'mpoly_4', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPolygon><gml:polygonMember></gml:polygonMember></gml:MultiPolygon>'));
SELECT 'mpoly_5', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPolygon></gml:MultiPolygon>'));
-
-- XML not elements handle
SELECT 'mpoly_6', ST_AsEWKT(ST_GeomFromGML(' <!-- --> <gml:MultiPolygon> <!-- --> <gml:polygonMember> <!-- --> <gml:Polygon> <!-- --> <gml:outerBoundaryIs> <!-- --> <gml:LinearRing> <!-- --> <gml:coordinates>1,2 3,4 5,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember> <!-- --> <gml:polygonMember> <!-- --> <gml:Polygon> <!-- --> <gml:outerBoundaryIs> <!-- --> <gml:LinearRing> <!-- --> <gml:coordinates>7,8 9,10 11,12 7,8</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>'));
-- Mixed srsName
SELECT 'mpoly_9', ST_AsEWKT(ST_GeomFromGML('<gml:MultiPolygon srsName="EPSG:27582"><gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>1,2 3,4 5,6 1,2</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember><gml:polygonMember><gml:Polygon srsName="EPSG:27562"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>400000,5000000 400010,5000010 400020,5000020 400000,5000000</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>400100,5000100 400110,5000110 400120,5000120 400100,5000100</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>'));
-
-
-
--
-- MultiSurface
--
-- Empty surfaceMembers
SELECT 'msurface_12', ST_AsEWKT(ST_GeomFromGML('<gml:MultiSurface><gml:surfaceMembers></gml:surfaceMembers></gml:MultiSurface>'));
-
--
-- PolyhedralSurface
--
-- ERROR: interpolation not planar
SELECT 'polyhedralsurface_25', ST_AsEWKT(ST_GeomFromGML('<gml:PolyhedralSurface><gml:polygonPatches><gml:PolygonPatch interpolation="not_planar"><gml:exterior><gml:LinearRing><gml:posList srsDimension="3">1 2 3 4 5 6 7 8 9 1 2 3</gml:posList></gml:LinearRing></gml:exterior></gml:PolygonPatch></gml:polygonPatches></gml:PolyhedralSurface>'));
-
--
-- Tin and TriangulatedSurface
--
SELECT 'tin_18', ST_AsEWKT(ST_GeomFromGML('<gml:TriangulatedSurface><gml:trianglePatches><gml:Triangle><gml:exterior><gml:LinearRing><gml:posList srsDimension="3">1 2 3 4 5 6 7 8 9 1 2 3</gml:posList></gml:LinearRing></gml:exterior></gml:Triangle></gml:trianglePatches></gml:TriangulatedSurface>'));
-
-
--
-- GeometryCollection
--
-- Mixed srsName
SELECT 'collection_14', ST_AsEWKT(ST_GeomFromGML('<gml:MultiGeometry srsName="EPSG:27582"><gml:geometryMember><gml:Point><gml:coordinates>1,2</gml:coordinates></gml:Point></gml:geometryMember><gml:geometryMember><gml:MultiGeometry><gml:geometryMember><gml:MultiGeometry srsName="EPSG:27562"><gml:geometryMember><gml:Point><gml:coordinates>400000,5000000</gml:coordinates></gml:Point></gml:geometryMember></gml:MultiGeometry></gml:geometryMember></gml:MultiGeometry></gml:geometryMember></gml:MultiGeometry>'));
-
-
-
--
-- srsName
--
-- Reverse axis with severals multi geometry types
-- TODO
-
-
--
-- GML Namespace
--
-- Explicit GML namespace (no prefix)
SELECT 'ns_13', ST_AsEWKT(ST_GeomFromGML('<Point srsName="EPSG:4326" xmlns="http://www.opengis.net/gml"><coordinates>1,2</coordinates></Point>'));
-
--
-- Coordinates (simple)
--
-- ERROR: Junk
SELECT 'coordinates_17', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:coordinates>!@#$%^*()"</gml:coordinates></gml:LineString>'));
-
-
--
-- Coordinates (cs,ts,decimal)
--
SELECT 'coordinates_cs_17', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:coordinates cs="." ts=";" decimal=".">1.1.2.2;3.3.4,4</gml:coordinates></gml:LineString>'));
SELECT 'coordinates_cs_18', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:coordinates cs="." ts=";" decimal=";">1;1.2;2;3;3.4,4</gml:coordinates></gml:LineString>'));
-
-- XML Entity substitution
SELECT 'coordinates_cs_19', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:coordinates ts="," cs=" ">1 2,3 4</gml:coordinates></gml:LineString>'));
-
-
-
--
-- pos
--
-- ERROR: 4 dimensions
SELECT 'pos_17', ST_AsEWKT(ST_GeomFromGML('<gml:Point><gml:pos srsDimension="4">1 2 3 4</gml:pos></gml:Point>'));
-
--
-- posList
--
-- ERROR: Junk
SELECT 'poslist_18', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:posList>!@#$%^*()"</gml:posList></gml:LineString>'));
-
-
--
-- Generic data
--
-- Mixed pos, posList, pointProperty, pointRep
SELECT 'data_2', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:pos>1 2</gml:pos><gml:posList>3 4 5 6</gml:posList><gml:pointProperty><gml:Point><gml:pos>7 8</gml:pos></gml:Point></gml:pointProperty><gml:pointRep><gml:Point><gml:coordinates>9,10</gml:coordinates></gml:Point></gml:pointRep></gml:LineString>'));
-
-
-
--
-- XLink
--
-- ERROR circular ref
SELECT 'xlink_23', ST_AsEWKT(ST_GeomFromGML('<gml:MultiGeometry gml:id="mg1" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink"><gml:geometryMember><gml:Point><gml:pos>1 2</gml:pos></gml:Point></gml:geometryMember><gml:geometryMember><gml:MultiGeometry xlink:type="simple" xlink:href="#mg1"/></gml:geometryMember></gml:MultiGeometry>'));
-
-
--
-- Bijective PostGIS GML test
--
-- Collection GML 3 - 3D & SRID lat/lon
SELECT 'gml_61', ST_AsEWKT(ST_GeomFromGML(ST_AsGML(3, ST_AsEWKT('SRID=4326;GEOMETRYCOLLECTION(POINT(1 2 3))'), 16)));
-
-
-
-
--
-- coord
--
-- XML not elements handle
SELECT 'coord_16', ST_AsEWKT(ST_GeomFromGML('<gml:LineString><gml:coord> <!-- --> <gml:X>1</gml:X> <!-- --> <gml:Y>2</gml:Y> <!-- --> </gml:coord> <!-- --> <gml:coord> <!-- --> <gml:X>3</gml:X> <!-- --> <gml:Y>4</gml:Y></gml:coord></gml:LineString>'));
-
--
-- Double
--
-- ERROR: Junk
SELECT 'double_31', ST_AsEWKT(ST_GeomFromGML('<gml:Point><gml:pos>1 $0%@#$^%#</gml:pos></gml:Point>'));
-
-
-
--
-- Delete inserted spatial data
--
-- Written by Olivier Courtin - Oslandia
--
-
--
-- spatial_ref_sys datas
--
-- EPSG 4326 : WGS 84
INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (4326,'EPSG',4326,'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]','+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
-
-- Empty Geometry
SELECT 'empty_geom', ST_AsEWKT(ST_GeomFromKML(NULL));
-- ERROR: Not a KML Geometry
SELECT 'xml_3', ST_AsEWKT(ST_GeomFromKML('<foo/>'));
-
-
--
-- Point
--
-- ERROR: empty point
SELECT 'point_error_2', ST_AsEWKT(ST_GeomFromKML('<kml:Point></kml:Point>'));
-
-
--
-- LineString
--
-- XML not elements handle
SELECT 'linestring_5', ST_AsEWKT(ST_GeomFromKML(' <!-- --> <kml:LineString> <!-- --> <kml:coordinates>1,2 3,4</kml:coordinates></kml:LineString>'));
-
-
-
--
-- Polygon
--
-- 3 rings
SELECT 'polygon_15', ST_AsEWKT(ST_GeomFromKML('<kml:Polygon><kml:outerBoundaryIs><kml:LinearRing><kml:coordinates>1,2 3,4 5,6 1,2</kml:coordinates></kml:LinearRing></kml:outerBoundaryIs><kml:innerBoundaryIs><kml:LinearRing><kml:coordinates>7,8 9,10 11,12 7,8</kml:coordinates></kml:LinearRing></kml:innerBoundaryIs><kml:innerBoundaryIs><kml:LinearRing><kml:coordinates>13,14 15,16 17,18 13,14</kml:coordinates></kml:LinearRing></kml:innerBoundaryIs></kml:Polygon>'));
-
-
-
--
-- MultiGeometry
--
-- XML not elements handle
SELECT 'multi_10', ST_AsEWKT(ST_GeomFromKML(' <!-- --> <kml:MultiGeometry> <!-- --> <kml:Point> <!-- --> <kml:coordinates>1,2</kml:coordinates></kml:Point> <!-- --> <kml:LineString><kml:coordinates>3,4 5,6</kml:coordinates></kml:LineString> <!-- --> <kml:Polygon><kml:outerBoundaryIs><kml:LinearRing><kml:coordinates>7,8 9,10 11,12 7,8</kml:coordinates></kml:LinearRing></kml:outerBoundaryIs></kml:Polygon></kml:MultiGeometry>'));
-
-
-
--
-- KML Namespace
--
-- Ignore other namespace attribute
-- TODO SELECT 'ns_11', ST_AsEWKT(ST_GeomFromKML('<kml:Point foo:srsName="EPSG:4326" xmlns:foo="http://foo.net" xmlns:gml="http://www.opengis.net/gml"><kml:coordinates>1,2</kml:coordinates><foo:coordinates>3,4</foo:coordinates></kml:Point>'));
-
-
-
--
-- Coordinates
--
-- ERROR: Junk
SELECT 'coordinates_17', ST_AsEWKT(ST_GeomFromKML('<kml:LineString><kml:coordinates>!@#$%^*()"</kml:coordinates></kml:LineString>'));
-
-
-
-
-
-
-
--
-- Bijective PostGIS KML test
--
-- Multipolygon - 3D
SELECT 'kml_12', ST_AsEWKT(ST_GeomFromKML(ST_AsKML(ST_AsEWKT('SRID=4326;MULTIPOLYGON(((1 2 3,4 5 6,7 8 9,1 2 3)),((10 11 12,13 14 15,16 17 18,10 11 12)))'))));
-
--
-- Double
--
SELECT 'mixed_dims_1', ST_AsEWKT(ST_GeomFromKML('<kml:Point><kml:coordinates>1,2 1,2,3</kml:coordinates></kml:Point>'));
SELECT 'mixed_dims_2', ST_AsEWKT(ST_GeomFromKML('<kml:Point><kml:coordinates>1,2,3 1,2</kml:coordinates></kml:Point>'));
-
-
-
-
--
-- Delete inserted spatial data
--
-- Not affected by old timeout
SELECT '1',ST_AsText(ST_Segmentize('LINESTRING(0 0,4 0)'::geometry, 2));
-
DROP FUNCTION _timecheck(text, interval);
-- Not affected by old timeout
SELECT '1', ST_NPoints(ST_Buffer('POINT(4 0)'::geometry, 2, 1));
-
DROP FUNCTION _timecheck(text, interval);
select ST_Relate(g,g) from _inputs WHERE id = 1; -- 6+ seconds
SELECT _timecheck('relate', '200ms');
-
DROP FUNCTION _timecheck(text, interval);
SELECT 'collection', ST_IsCollection('GEOMETRYCOLLECTION(POINT(0 0))');
SELECT 'collection+', ST_IsCollection('GEOMETRYCOLLECTION(POINT(0 0), POINT(42 42))');
-
select '5r', ST_IsValidReason(
'POLYGON ((70 250, 40 500, 100 400, 70 250, 80 350, 60 350, 70 250))' , 1);
-
-- max(st_z(the_geom)) as maxz, max(st_m(the_geom)) as maxm
--FROM test;
-
SELECT '<<->> idx', qnodes('select * from test order by the_geom <<->> ST_MakePoint(0,0) LIMIT 1');
SELECT '<<->> res1',num,
(the_geom <<->> 'LINESTRING(0 0,5 5)'::geometry)::numeric(10,2),
ST_astext(the_geom) from test
order by the_geom <<->> 'POINT(631 729 25023 -25022)'::geometry LIMIT 1;
-
-- Cleanup
DROP FUNCTION qnodes(text);
--- create table\r
-CREATE TABLE knn_recheck_geom(gid serial primary key, geom geometry);\r
-INSERT INTO knn_recheck_geom(gid,geom)\r
-SELECT ROW_NUMBER() OVER(ORDER BY x,y) AS gid, ST_Point(x*0.777,y*0.887) As geom\r
-FROM generate_series(-100,1000, 7) AS x CROSS JOIN generate_series(-300,1000,9) As y;\r
-\r
-INSERT INTO knn_recheck_geom(gid, geom)\r
-SELECT 500000 + i, ST_Translate('LINESTRING(-100 300, 500 700, 400 123, 500 10000, 1 1)'::geometry, i*2000,0)\r
-FROM generate_series(0,10) i;\r
-\r
-INSERT INTO knn_recheck_geom(gid, geom)\r
-SELECT 500100 + i, ST_Translate('POLYGON((100 800, 100 700, 400 123, 405 124, 100 800))'::geometry,0,i*2000)\r
-FROM generate_series(0,3) i;\r
-\r
-\r
-INSERT INTO knn_recheck_geom(gid,geom)\r
-SELECT 600000 + ROW_NUMBER() OVER(ORDER BY gid) AS gid, ST_Translate(ST_Buffer(geom,8,15 ),100,300) As geom\r
-FROM knn_recheck_geom\r
-WHERE gid IN(1000, 10000, 2000,3000);\r
-\r
-\r
--- without index order should match st_distance order --\r
--- point check\r
-\r
-SELECT '#1' As t, gid, ST_Distance( 'POINT(-305 998.5)'::geometry, geom)::numeric(10,2)\r
-FROM knn_recheck_geom\r
-ORDER BY 'POINT(-305 998.5)'::geometry <-> geom LIMIT 5;\r
-\r
--- linestring check\r
-SELECT '#2' As t, gid, ST_Distance( 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry, geom)::numeric(12,4)\r
-FROM knn_recheck_geom\r
-ORDER BY 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry <-> geom LIMIT 5;\r
-\r
--- lateral check before index\r
-SELECT '#3' As t, a.gid, b.gid As match, ST_Distance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)\r
-FROM knn_recheck_geom As a \r
- LEFT JOIN \r
- LATERAL ( SELECT gid, geom, a.geom <-> g.geom As knn_dist\r
- FROM knn_recheck_geom As g WHERE a.gid <> g.gid ORDER BY a.geom <-> g.geom LIMIT 5) As b ON true\r
- WHERE a.gid IN(1,500101)\r
-ORDER BY a.gid, true_rn, b.gid;\r
-\r
--- create index and repeat\r
-CREATE INDEX idx_knn_recheck_geom_gist ON knn_recheck_geom USING gist(geom);\r
-vacuum analyze knn_recheck_geom;\r
-\r
-set enable_seqscan = false;\r
-SELECT '#1' As t, gid, ST_Distance( 'POINT(-305 998.5)'::geometry, geom)::numeric(10,2)\r
-FROM knn_recheck_geom\r
-ORDER BY 'POINT(-305 998.5)'::geometry <-> geom LIMIT 5;\r
-\r
--- linestring check\r
-SELECT '#2' As t, gid, ST_Distance( 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry, geom)::numeric(12,4)\r
-FROM knn_recheck_geom\r
-ORDER BY 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry <-> geom LIMIT 5;\r
-\r
--- lateral check before index\r
-SELECT '#3' As t, a.gid, b.gid As match, ST_Distance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)\r
-FROM knn_recheck_geom As a \r
- LEFT JOIN \r
- LATERAL ( SELECT gid, geom, a.geom <-> g.geom As knn_dist\r
- FROM knn_recheck_geom As g WHERE a.gid <> g.gid ORDER BY a.geom <-> g.geom LIMIT 5) As b ON true\r
- WHERE a.gid IN(1,500101)\r
-ORDER BY a.gid, true_rn, b.gid;\r
-\r
-DROP TABLE knn_recheck_geom;\r
-\r
--- geography tests\r
-DELETE FROM spatial_ref_sys where srid = 4326;\r
-INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text") \r
- VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');\r
--- create table\r
-CREATE TABLE knn_recheck_geog(gid serial primary key, geog geography);\r
-INSERT INTO knn_recheck_geog(gid,geog)\r
-SELECT ROW_NUMBER() OVER(ORDER BY x,y) AS gid, ST_Point(x*1.11,y*0.95)::geography As geog\r
-FROM generate_series(-100,100, 1) AS x CROSS JOIN generate_series(-90,90,1) As y;\r
-\r
-INSERT INTO knn_recheck_geog(gid, geog)\r
-SELECT 500000, 'LINESTRING(-95 -10, -93 -10.5, -90 -10.6, -95 -10.5, -95 -10)'::geography;\r
-\r
-INSERT INTO knn_recheck_geog(gid, geog)\r
-SELECT 500001, 'POLYGON((-95 10, -95.6 10.5, -95.9 10.75, -95 10))'::geography;\r
-\r
-INSERT INTO knn_recheck_geog(gid,geog)\r
-SELECT 600000 + ROW_NUMBER() OVER(ORDER BY gid) AS gid, ST_Buffer(geog,1000) As geog\r
-FROM knn_recheck_geog\r
-WHERE gid IN(1000, 10000, 2000, 2614, 40000);\r
-\r
-\r
-SELECT '#1g' As t, gid, ST_Distance( 'POINT(-95 -10)'::geography, geog, false)::numeric(12,4) ,\r
- ('POINT(-95 -10)'::geography <-> geog )::numeric(12,4)\r
-FROM knn_recheck_geog\r
-ORDER BY 'POINT(-95 -10)'::geography <-> geog LIMIT 5;\r
-\r
-SELECT '#2g' As t, gid, ST_Distance( 'LINESTRING(75 10, 75 12, 80 20)'::geography, geog, false)::numeric(12,4),\r
- ('LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog)::numeric(12,4) As knn_dist\r
-FROM knn_recheck_geog\r
-ORDER BY 'LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog LIMIT 5;\r
-\r
--- lateral check before index\r
-SELECT '#3g' As t, a.gid, ARRAY(SELECT gid\r
- FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY ST_Distance(a.geog, g.geog, false) LIMIT 5) = ARRAY(SELECT gid\r
- FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY a.geog <-> g.geog LIMIT 5) As dist_order_agree\r
-FROM knn_recheck_geog As a \r
- WHERE a.gid IN(500000,500010,1000)\r
-ORDER BY a.gid;\r
-\r
-\r
--- create index and repeat\r
-CREATE INDEX idx_knn_recheck_geog_gist ON knn_recheck_geog USING gist(geog);\r
-vacuum analyze knn_recheck_geog;\r
-set enable_seqscan = false;\r
-\r
-SELECT '#1g' As t, gid, ST_Distance( 'POINT(-95 -10)'::geography, geog, false)::numeric(12,4) ,\r
- ('POINT(-95 -10)'::geography <-> geog )::numeric(12,4)\r
-FROM knn_recheck_geog\r
-ORDER BY 'POINT(-95 -10)'::geography <-> geog LIMIT 5;\r
-\r
-SELECT '#2g' As t, gid, ST_Distance( 'LINESTRING(75 10, 75 12, 80 20)'::geography, geog, false)::numeric(12,4),\r
- ('LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog)::numeric(12,4) As knn_dist\r
-FROM knn_recheck_geog\r
-ORDER BY 'LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog LIMIT 5;\r
-\r
-SELECT '#3g' As t, a.gid, ARRAY(SELECT g.gid\r
- FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY ST_Distance(a.geog, g.geog, false) LIMIT 5) = ARRAY(SELECT gid\r
- FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY a.geog <-> g.geog LIMIT 5) As dist_order_agree\r
-FROM knn_recheck_geog As a \r
- WHERE a.gid IN(500000,500010,1000)\r
-ORDER BY a.gid;\r
-\r
-DROP TABLE knn_recheck_geog;\r
-\r
---\r
--- Delete inserted spatial data\r
---\r
-DELETE FROM spatial_ref_sys WHERE srid = 4326;\r
-\r
---now the nd operator tests\r
--- create table and load\r
-CREATE TABLE knn_recheck_geom_nd(gid serial primary key, geom geometry);\r
-INSERT INTO knn_recheck_geom_nd(gid,geom)\r
-SELECT ROW_NUMBER() OVER(ORDER BY x,y,z) AS gid, ST_MakePoint(x*0.777,y*0.887,z*1.05) As geom\r
-FROM generate_series(-100,1000, 7) AS x , \r
- generate_series(-300,1000,9) As y,\r
- generate_series(1005,10000,5555) As z ;\r
-\r
- -- 3d lines\r
-INSERT INTO knn_recheck_geom_nd(gid, geom)\r
-SELECT 500000 + i, ST_Translate('LINESTRING(-100 300 500, 500 700 600, 400 123 0, 500 10000 -1234, 1 1 5000)'::geometry, i*2000,0)\r
-FROM generate_series(0,10) i;\r
-\r
-\r
--- 3d polygons\r
-INSERT INTO knn_recheck_geom_nd(gid, geom)\r
-SELECT 500100 + i, ST_Translate('POLYGON((100 800 5678, 100 700 5678, 400 123 5678, 405 124 5678, 100 800 5678))'::geometry,0,i*2000)\r
-FROM generate_series(0,3) i;\r
-\r
--- polyhedral surface --\r
-INSERT INTO knn_recheck_geom_nd(gid,geom)\r
-SELECT 600000 + row_number() over(), ST_Translate(the_geom,100, 450,1000) As the_geom\r
- FROM (VALUES ( ST_GeomFromText(\r
-'PolyhedralSurface( \r
-((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), \r
-((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)), \r
-((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1)) \r
-)') ) ,\r
-( ST_GeomFromText(\r
-'PolyhedralSurface( \r
-((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)), \r
-((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)) )') ) )\r
-As foo(the_geom) ;\r
-\r
--- without index order should match st_3ddistance order --\r
--- point check\r
-SELECT '#1nd-3' As t, gid, ST_3DDistance( 'POINT(-305 998.5 1000)'::geometry, geom)::numeric(12,4) As dist3d,\r
-('POINT(-305 998.5 1000)'::geometry <<->> geom)::numeric(12,4) As dist_knn\r
-FROM knn_recheck_geom_nd\r
-ORDER BY 'POINT(-305 998.5 1000)'::geometry <<->> geom LIMIT 5;\r
-\r
--- linestring check \r
-SELECT '#2nd-3' As t, gid, ST_3DDistance( 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry::geometry, geom)::numeric(12,4),\r
- ('MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom)::numeric(12,4) As knn_dist\r
-FROM knn_recheck_geom_nd\r
-ORDER BY 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom LIMIT 5;\r
-\r
--- lateral test\r
-SELECT '#3nd-3' As t, a.gid, b.gid As match, ST_3DDistance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)\r
-FROM knn_recheck_geom_nd As a \r
- LEFT JOIN \r
- LATERAL ( SELECT gid, geom, a.geom <<->> g.geom As knn_dist\r
- FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true\r
- WHERE a.gid IN(1,600001)\r
-ORDER BY a.gid, true_rn, b.gid;\r
-\r
--- create index and repeat\r
-CREATE INDEX idx_knn_recheck_geom_nd_gist ON knn_recheck_geom_nd USING gist(geom gist_geometry_ops_nd);\r
-vacuum analyze knn_recheck_geom_nd;\r
-set enable_seqscan = false;\r
--- point check\r
-SELECT '#1nd-3' As t, gid, ST_3DDistance( 'POINT(-305 998.5 1000)'::geometry, geom)::numeric(12,4) As dist3d,\r
-('POINT(-305 998.5 1000)'::geometry <<->> geom)::numeric(12,4) As dist_knn\r
-FROM knn_recheck_geom_nd\r
-ORDER BY 'POINT(-305 998.5 1000)'::geometry <<->> geom LIMIT 5;\r
-\r
--- linestring check \r
-SELECT '#2nd-3' As t, gid, ST_3DDistance( 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry::geometry, geom)::numeric(12,4),\r
- ('MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom)::numeric(12,4) As knn_dist\r
-FROM knn_recheck_geom_nd\r
-ORDER BY 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom LIMIT 5;\r
-\r
--- lateral test\r
-SELECT '#3nd-3' As t, a.gid, b.gid As match, ST_3DDistance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)\r
-FROM knn_recheck_geom_nd As a \r
- LEFT JOIN \r
- LATERAL ( SELECT gid, geom, a.geom <<->> g.geom As knn_dist\r
- FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true\r
- WHERE a.gid IN(1,600001)\r
-ORDER BY a.gid, true_rn, b.gid;\r
-\r
-\r
-DROP TABLE knn_recheck_geom_nd;\r
-\r
--- #3573\r
-SELECT '#3573', 'POINT M (0 0 13)'::geometry <<->> 'LINESTRING M (0 0 5, 0 1 6)'::geometry;\r
-\r
--- #3418\r
-CREATE TABLE test_wo (geo geometry);\r
-INSERT INTO test_wo VALUES \r
- ('0101000020E61000007D91D0967329E4BF6631B1F9B8D64A40'::geometry), \r
- ('0101000020E6100000E2AFC91AF510C1BFCDCCCCCCCCAC4A40'::geometry);\r
-CREATE INDEX ON TEST_WO USING GIST (GEO);\r
-analyze test_wo;\r
-SET enable_seqscan = false;\r
-SELECT '#3418' As ticket, '0101000020E610000092054CE0D6DDE5BFCDCCCCCCCCAC4A40'::geometry <-> geo, ST_Distance('0101000020E610000092054CE0D6DDE5BFCDCCCCCCCCAC4A40'::geometry, geo) \r
-FROM test_wo ORDER BY geo <->\r
-('0101000020E610000092054CE0D6DDE5BFCDCCCCCCCCAC4A40'::geometry);\r
-DROP TABLE test_wo;\r
-set enable_seqscan to default;\r
+-- create table
+CREATE TABLE knn_recheck_geom(gid serial primary key, geom geometry);
+INSERT INTO knn_recheck_geom(gid,geom)
+SELECT ROW_NUMBER() OVER(ORDER BY x,y) AS gid, ST_Point(x*0.777,y*0.887) As geom
+FROM generate_series(-100,1000, 7) AS x CROSS JOIN generate_series(-300,1000,9) As y;
+
+INSERT INTO knn_recheck_geom(gid, geom)
+SELECT 500000 + i, ST_Translate('LINESTRING(-100 300, 500 700, 400 123, 500 10000, 1 1)'::geometry, i*2000,0)
+FROM generate_series(0,10) i;
+
+INSERT INTO knn_recheck_geom(gid, geom)
+SELECT 500100 + i, ST_Translate('POLYGON((100 800, 100 700, 400 123, 405 124, 100 800))'::geometry,0,i*2000)
+FROM generate_series(0,3) i;
+
+
+INSERT INTO knn_recheck_geom(gid,geom)
+SELECT 600000 + ROW_NUMBER() OVER(ORDER BY gid) AS gid, ST_Translate(ST_Buffer(geom,8,15 ),100,300) As geom
+FROM knn_recheck_geom
+WHERE gid IN(1000, 10000, 2000,3000);
+
+
+-- without index order should match st_distance order --
+-- point check
+
+SELECT '#1' As t, gid, ST_Distance( 'POINT(-305 998.5)'::geometry, geom)::numeric(10,2)
+FROM knn_recheck_geom
+ORDER BY 'POINT(-305 998.5)'::geometry <-> geom LIMIT 5;
+
+-- linestring check
+SELECT '#2' As t, gid, ST_Distance( 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry, geom)::numeric(12,4)
+FROM knn_recheck_geom
+ORDER BY 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry <-> geom LIMIT 5;
+
+-- lateral check before index
+SELECT '#3' As t, a.gid, b.gid As match, ST_Distance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)
+FROM knn_recheck_geom As a
+ LEFT JOIN
+ LATERAL ( SELECT gid, geom, a.geom <-> g.geom As knn_dist
+ FROM knn_recheck_geom As g WHERE a.gid <> g.gid ORDER BY a.geom <-> g.geom LIMIT 5) As b ON true
+ WHERE a.gid IN(1,500101)
+ORDER BY a.gid, true_rn, b.gid;
+
+-- create index and repeat
+CREATE INDEX idx_knn_recheck_geom_gist ON knn_recheck_geom USING gist(geom);
+vacuum analyze knn_recheck_geom;
+
+set enable_seqscan = false;
+SELECT '#1' As t, gid, ST_Distance( 'POINT(-305 998.5)'::geometry, geom)::numeric(10,2)
+FROM knn_recheck_geom
+ORDER BY 'POINT(-305 998.5)'::geometry <-> geom LIMIT 5;
+
+-- linestring check
+SELECT '#2' As t, gid, ST_Distance( 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry, geom)::numeric(12,4)
+FROM knn_recheck_geom
+ORDER BY 'MULTILINESTRING((-95 -300, 100 200, 100 323),(-50 2000, 30 6000))'::geometry <-> geom LIMIT 5;
+
+-- lateral check before index
+SELECT '#3' As t, a.gid, b.gid As match, ST_Distance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)
+FROM knn_recheck_geom As a
+ LEFT JOIN
+ LATERAL ( SELECT gid, geom, a.geom <-> g.geom As knn_dist
+ FROM knn_recheck_geom As g WHERE a.gid <> g.gid ORDER BY a.geom <-> g.geom LIMIT 5) As b ON true
+ WHERE a.gid IN(1,500101)
+ORDER BY a.gid, true_rn, b.gid;
+
+DROP TABLE knn_recheck_geom;
+
+-- geography tests
+DELETE FROM spatial_ref_sys where srid = 4326;
+INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","proj4text")
+ VALUES (4326,'EPSG',4326,'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ');
+-- create table
+CREATE TABLE knn_recheck_geog(gid serial primary key, geog geography);
+INSERT INTO knn_recheck_geog(gid,geog)
+SELECT ROW_NUMBER() OVER(ORDER BY x,y) AS gid, ST_Point(x*1.11,y*0.95)::geography As geog
+FROM generate_series(-100,100, 1) AS x CROSS JOIN generate_series(-90,90,1) As y;
+
+INSERT INTO knn_recheck_geog(gid, geog)
+SELECT 500000, 'LINESTRING(-95 -10, -93 -10.5, -90 -10.6, -95 -10.5, -95 -10)'::geography;
+
+INSERT INTO knn_recheck_geog(gid, geog)
+SELECT 500001, 'POLYGON((-95 10, -95.6 10.5, -95.9 10.75, -95 10))'::geography;
+
+INSERT INTO knn_recheck_geog(gid,geog)
+SELECT 600000 + ROW_NUMBER() OVER(ORDER BY gid) AS gid, ST_Buffer(geog,1000) As geog
+FROM knn_recheck_geog
+WHERE gid IN(1000, 10000, 2000, 2614, 40000);
+
+
+SELECT '#1g' As t, gid, ST_Distance( 'POINT(-95 -10)'::geography, geog, false)::numeric(12,4) ,
+ ('POINT(-95 -10)'::geography <-> geog )::numeric(12,4)
+FROM knn_recheck_geog
+ORDER BY 'POINT(-95 -10)'::geography <-> geog LIMIT 5;
+
+SELECT '#2g' As t, gid, ST_Distance( 'LINESTRING(75 10, 75 12, 80 20)'::geography, geog, false)::numeric(12,4),
+ ('LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog)::numeric(12,4) As knn_dist
+FROM knn_recheck_geog
+ORDER BY 'LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog LIMIT 5;
+
+-- lateral check before index
+SELECT '#3g' As t, a.gid, ARRAY(SELECT gid
+ FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY ST_Distance(a.geog, g.geog, false) LIMIT 5) = ARRAY(SELECT gid
+ FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY a.geog <-> g.geog LIMIT 5) As dist_order_agree
+FROM knn_recheck_geog As a
+ WHERE a.gid IN(500000,500010,1000)
+ORDER BY a.gid;
+
+
+-- create index and repeat
+CREATE INDEX idx_knn_recheck_geog_gist ON knn_recheck_geog USING gist(geog);
+vacuum analyze knn_recheck_geog;
+set enable_seqscan = false;
+
+SELECT '#1g' As t, gid, ST_Distance( 'POINT(-95 -10)'::geography, geog, false)::numeric(12,4) ,
+ ('POINT(-95 -10)'::geography <-> geog )::numeric(12,4)
+FROM knn_recheck_geog
+ORDER BY 'POINT(-95 -10)'::geography <-> geog LIMIT 5;
+
+SELECT '#2g' As t, gid, ST_Distance( 'LINESTRING(75 10, 75 12, 80 20)'::geography, geog, false)::numeric(12,4),
+ ('LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog)::numeric(12,4) As knn_dist
+FROM knn_recheck_geog
+ORDER BY 'LINESTRING(75 10, 75 12, 80 20)'::geography <-> geog LIMIT 5;
+
+SELECT '#3g' As t, a.gid, ARRAY(SELECT g.gid
+ FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY ST_Distance(a.geog, g.geog, false) LIMIT 5) = ARRAY(SELECT gid
+ FROM knn_recheck_geog As g WHERE a.gid <> g.gid ORDER BY a.geog <-> g.geog LIMIT 5) As dist_order_agree
+FROM knn_recheck_geog As a
+ WHERE a.gid IN(500000,500010,1000)
+ORDER BY a.gid;
+
+DROP TABLE knn_recheck_geog;
+
+--
+-- Delete inserted spatial data
+--
+DELETE FROM spatial_ref_sys WHERE srid = 4326;
+
+--now the nd operator tests
+-- create table and load
+CREATE TABLE knn_recheck_geom_nd(gid serial primary key, geom geometry);
+INSERT INTO knn_recheck_geom_nd(gid,geom)
+SELECT ROW_NUMBER() OVER(ORDER BY x,y,z) AS gid, ST_MakePoint(x*0.777,y*0.887,z*1.05) As geom
+FROM generate_series(-100,1000, 7) AS x ,
+ generate_series(-300,1000,9) As y,
+ generate_series(1005,10000,5555) As z ;
+
+ -- 3d lines
+INSERT INTO knn_recheck_geom_nd(gid, geom)
+SELECT 500000 + i, ST_Translate('LINESTRING(-100 300 500, 500 700 600, 400 123 0, 500 10000 -1234, 1 1 5000)'::geometry, i*2000,0)
+FROM generate_series(0,10) i;
+
+
+-- 3d polygons
+INSERT INTO knn_recheck_geom_nd(gid, geom)
+SELECT 500100 + i, ST_Translate('POLYGON((100 800 5678, 100 700 5678, 400 123 5678, 405 124 5678, 100 800 5678))'::geometry,0,i*2000)
+FROM generate_series(0,3) i;
+
+-- polyhedral surface --
+INSERT INTO knn_recheck_geom_nd(gid,geom)
+SELECT 600000 + row_number() over(), ST_Translate(the_geom,100, 450,1000) As the_geom
+ FROM (VALUES ( ST_GeomFromText(
+'PolyhedralSurface(
+((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
+((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)), ((0 0 0, 1 0 0, 1 0 1, 0 0 1, 0 0 0)), ((1 1 0, 1 1 1, 1 0 1, 1 0 0, 1 1 0)),
+((0 1 0, 0 1 1, 1 1 1, 1 1 0, 0 1 0)), ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1))
+)') ) ,
+( ST_GeomFromText(
+'PolyhedralSurface(
+((0 0 0, 0 0 1, 0 1 1, 0 1 0, 0 0 0)),
+((0 0 0, 0 1 0, 1 1 0, 1 0 0, 0 0 0)) )') ) )
+As foo(the_geom) ;
+
+-- without index order should match st_3ddistance order --
+-- point check
+SELECT '#1nd-3' As t, gid, ST_3DDistance( 'POINT(-305 998.5 1000)'::geometry, geom)::numeric(12,4) As dist3d,
+('POINT(-305 998.5 1000)'::geometry <<->> geom)::numeric(12,4) As dist_knn
+FROM knn_recheck_geom_nd
+ORDER BY 'POINT(-305 998.5 1000)'::geometry <<->> geom LIMIT 5;
+
+-- linestring check
+SELECT '#2nd-3' As t, gid, ST_3DDistance( 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry::geometry, geom)::numeric(12,4),
+ ('MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom)::numeric(12,4) As knn_dist
+FROM knn_recheck_geom_nd
+ORDER BY 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom LIMIT 5;
+
+-- lateral test
+SELECT '#3nd-3' As t, a.gid, b.gid As match, ST_3DDistance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)
+FROM knn_recheck_geom_nd As a
+ LEFT JOIN
+ LATERAL ( SELECT gid, geom, a.geom <<->> g.geom As knn_dist
+ FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true
+ WHERE a.gid IN(1,600001)
+ORDER BY a.gid, true_rn, b.gid;
+
+-- create index and repeat
+CREATE INDEX idx_knn_recheck_geom_nd_gist ON knn_recheck_geom_nd USING gist(geom gist_geometry_ops_nd);
+vacuum analyze knn_recheck_geom_nd;
+set enable_seqscan = false;
+-- point check
+SELECT '#1nd-3' As t, gid, ST_3DDistance( 'POINT(-305 998.5 1000)'::geometry, geom)::numeric(12,4) As dist3d,
+('POINT(-305 998.5 1000)'::geometry <<->> geom)::numeric(12,4) As dist_knn
+FROM knn_recheck_geom_nd
+ORDER BY 'POINT(-305 998.5 1000)'::geometry <<->> geom LIMIT 5;
+
+-- linestring check
+SELECT '#2nd-3' As t, gid, ST_3DDistance( 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry::geometry, geom)::numeric(12,4),
+ ('MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom)::numeric(12,4) As knn_dist
+FROM knn_recheck_geom_nd
+ORDER BY 'MULTILINESTRING((-95 -300 5000, 105 451 1000, 100 323 200),(-50 2000 456, 30 6000 789))'::geometry <<->> geom LIMIT 5;
+
+-- lateral test
+SELECT '#3nd-3' As t, a.gid, b.gid As match, ST_3DDistance(a.geom, b.geom)::numeric(15,4) As true_rn, b.knn_dist::numeric(15,4)
+FROM knn_recheck_geom_nd As a
+ LEFT JOIN
+ LATERAL ( SELECT gid, geom, a.geom <<->> g.geom As knn_dist
+ FROM knn_recheck_geom_nd As g WHERE a.gid <> g.gid ORDER BY a.geom <<->> g.geom LIMIT 5) As b ON true
+ WHERE a.gid IN(1,600001)
+ORDER BY a.gid, true_rn, b.gid;
+
+
+DROP TABLE knn_recheck_geom_nd;
+
+-- #3573
+SELECT '#3573', 'POINT M (0 0 13)'::geometry <<->> 'LINESTRING M (0 0 5, 0 1 6)'::geometry;
+
+-- #3418
+CREATE TABLE test_wo (geo geometry);
+INSERT INTO test_wo VALUES
+ ('0101000020E61000007D91D0967329E4BF6631B1F9B8D64A40'::geometry),
+ ('0101000020E6100000E2AFC91AF510C1BFCDCCCCCCCCAC4A40'::geometry);
+CREATE INDEX ON TEST_WO USING GIST (GEO);
+analyze test_wo;
+SET enable_seqscan = false;
+SELECT '#3418' As ticket, '0101000020E610000092054CE0D6DDE5BFCDCCCCCCCCAC4A40'::geometry <-> geo, ST_Distance('0101000020E610000092054CE0D6DDE5BFCDCCCCCCCCAC4A40'::geometry, geo)
+FROM test_wo ORDER BY geo <->
+('0101000020E610000092054CE0D6DDE5BFCDCCCCCCCCAC4A40'::geometry);
+DROP TABLE test_wo;
+set enable_seqscan to default;
---
INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (2260,'EPSG',2260,'PROJCS["NAD83 / New York East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",38.83333333333334],PARAMETER["central_meridian",-74.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",492125],PARAMETER["false_northing",0],AUTHORITY["EPSG","2260"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=us-ft +no_defs ');
-
---
INSERT INTO "spatial_ref_sys" ("srid","auth_name","auth_srid","srtext","proj4text") VALUES (2260,'EPSG',2260,'PROJCS["NAD83 / New York East (ftUS)",GEOGCS["NAD83",DATUM["North_American_Datum_1983",SPHEROID["GRS 1980",6378137,298.257222101,AUTHORITY["EPSG","7019"]],AUTHORITY["EPSG","6269"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4269"]],UNIT["US survey foot",0.3048006096012192,AUTHORITY["EPSG","9003"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",38.83333333333334],PARAMETER["central_meridian",-74.5],PARAMETER["scale_factor",0.9999],PARAMETER["false_easting",492125],PARAMETER["false_northing",0],AUTHORITY["EPSG","2260"],AXIS["X",EAST],AXIS["Y",NORTH]]','+proj=tmerc +lat_0=38.83333333333334 +lon_0=-74.5 +k=0.9999 +x_0=150000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=us-ft +no_defs ');
-
-select address, short_name, color from loadedshp order by 1;\r
+select address, short_name, color from loadedshp order by 1;
UPDATE test_locks SET state = 'authorized' where id = 2;
END;
-
BEGIN;
-- Add authorization for row 2
ST_asBinary(geometry(wkb_ndr)) != ST_asBinary(geometry(wkb_xdr)) OR
ST_asBinary(geometry(wkt)) != ST_asBinary(geometry(wkb_xdr));
-
SELECT ST_extent(geometry(wkb_ndr)) from test_data;
SELECT ST_3DExtent(geometry(wkb_ndr)) from test_data WHERE ST_NDims(wkb_ndr) > 2;
SELECT ST_MemSize(ST_collect(ST_Force2d(geometry(wkb_ndr)))) from test_data;
DROP TABLE test_data;
-
SELECT '#3069', ST_Summary(PostGIS_Noop('SRID=4326;POINT(1 1)'::geometry));
SELECT '#3069', ST_Summary(PostGIS_Noop('SRID=4326;LINESTRING(1 1,0 0)'::geometry));
SELECT '#3069', replace(ST_Summary(PostGIS_Noop('SRID=4326;MULTIPOINT(1 1)'::geometry)),E'\n',' ');
'SRID=3857;POLYGON M EMPTY'::geometry
));
-
--- ST_Azimuth
SELECT 'ST_Azimuth_regular' , round(ST_Azimuth(geom1,geom2)::numeric,4)
FROM CAST('POINT(0 1)' AS geometry) AS geom1, CAST('POINT(1 0)' AS geometry) AS geom2 ;
order by count(*)
limit 1;
-
-- typmod checks
select 'typmod_point_4326', geometry_typmod_out(geometry_typmod_in('{Point,4326}'));
select 'typmod_point_0', geometry_typmod_out(geometry_typmod_in('{Point,0}'));
select '115', ST_3DPerimeter('MULTIPOLYGON( ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0)),( (0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0),(5 5 0, 7 5 0, 7 7 0, 5 7 0, 5 5 0) ) ,( (0 0 1, 10 0 1, 10 10 1, 0 10 1, 0 0 1),(5 5 1, 7 5 1, 7 7 1, 5 7 1, 5 5 1),(1 1 1,2 1 1, 2 2 1, 1 2 1, 1 1 1) ) )'::GEOMETRY) as value;
-
select '116', ST_length2d('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2) )'::GEOMETRY) as value;
select '117', ST_3dlength('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2) )'::GEOMETRY) as value;
select '118', ST_3dlength('MULTILINESTRING((0 0 0, 1 1 1),(0 0 0, 1 1 1, 2 2 2) )'::GEOMETRY) as value;
select '136', ST_Distance('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0));
-
-- postgis-users/2006-May/012174.html
select 'dist', ST_Distance(a,b), ST_Distance(b,a) from (
select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
) as foo;
-
--st_maxdistance
select 'st_maxdistance_134', st_maxdistance('POINT(1 2)', 'POINT(1 2)');
(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
) as foo;
-
-
--st_longestline
select 'st_longestline_134', st_astext(st_longestline('POINT(1 2)', 'POINT(1 2)'));
(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
) as foo;
-select 'distancetest1',
+select 'distancetest1',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
round(st_x(st_startpoint(st_shortestline(a,b)))::numeric, 10),
round(st_y(st_startpoint(st_shortestline(a,b)))::numeric, 10),
round(st_x(st_endpoint(st_shortestline(a,b)))::numeric, 10),
- round(st_y(st_endpoint(st_shortestline(a,b)))::numeric, 10),
+ round(st_y(st_endpoint(st_shortestline(a,b)))::numeric, 10),
st_astext(st_longestline(a,b)),
st_astext(st_longestline(b,a)) from (
select
ST_GeomFromText('LINESTRING(-10 20, 1 -2)') as b
) as foo;
-select 'distancepoly1',
+select 'distancepoly1',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
) as foo;
-select 'distancepoly2',
+select 'distancepoly2',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
) as foo;
-
-
-select 'distancepoly3',
+select 'distancepoly3',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
) as foo;
-
-select 'distancepoly4',
+select 'distancepoly4',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
) as foo;
-
-
-select 'distancepoly5',
+select 'distancepoly5',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,14 19,19 19,19 14,14 14))') as b
) as foo;
-
-
-
-select 'distancepoly6',
+select 'distancepoly6',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
--3D Distance functions
-
SELECT '3dDistancetest1',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'POINT(1 1 1)'::geometry as a, 'POINT(3 2 7)'::geometry as b
) as foo;
-
-
+
SELECT '3dDistancetest2',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'POINT(1 1 1)'::geometry as a, 'LINESTRING(0 0 0, 2 2 2)'::geometry as b
) as foo;
-
-
+
SELECT '3dDistancetest3',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'POINT(1 1 1)'::geometry as a, 'LINESTRING(5 2 6, -3 -2 4)'::geometry as b
) as foo;
-
-
+
SELECT '3dDistancetest4',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'LINESTRING(1 1 3, 5 7 8)'::geometry as a, 'POINT(1 1 1)'::geometry as b
) as foo;
-
+
SELECT '3dDistancetest5',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
SELECT '3dDistancetest6',
ST_3DDistance(a,b) FROM (
- SELECT 'LINESTRING(1 1 1 , 2 2 2)'::geometry as a, 'POLYGON((0 0 0, 2 2 2, 3 3 3, 0 0 0))'::geometry as b) as foo;
-
+ SELECT 'LINESTRING(1 1 1 , 2 2 2)'::geometry as a, 'POLYGON((0 0 0, 2 2 2, 3 3 3, 0 0 0))'::geometry as b) as foo;
-- 3D mixed dimmentionality #2034
--closestpoint with 2d as first point and 3d as second
select ST_AsText(ST_3DClosestPoint('POINT(0 0 0)', 'POINT(0 0)'));
select ST_AsText(ST_3DShortestLine('LINESTRING(2 1, 3 0)', 'LINESTRING(0 0 2, 3 3 -4)'));
-
-- Area of an empty polygon
select 'emptyPolyArea', st_area('POLYGON EMPTY');
)) AS geom
) AS q;
-
-- default values tests
SELECT 'D1', encode(ST_AsMVT(q, 'test', 4096, 'geom'), 'base64') FROM (SELECT 1 AS c1, 'abcd'::text AS c2,
ST_Normalize(ST_AsMVTGeom(ST_GeomFromText('POINT(25 17)'),
ORDER BY 1;
-- GROUP BY on empty
-SELECT '#3777', ST_AsText(geom), count(*)
-FROM (VALUES
+SELECT '#3777', ST_AsText(geom), count(*)
+FROM (VALUES
('POINT(0 0)'::geometry),
('POINT(0 0)'::geometry),
('POINT(0 0)'::geometry),
) AS f(geom)
GROUP BY geom ORDER BY 2;
-SELECT '#3777.1', ST_AsText(geom), count(*)
+SELECT '#3777.1', ST_AsText(geom), count(*)
FROM (VALUES
('POINT(0 0)'::geometry),
('POINT(0 0)'::geometry),
SELECT '417', ST_IsPolygonCW( 'MULTIPOLYGON (((0 0, 1 0, 1 1, 0 0)), ((100 0, 101 1, 101 0, 100 0)))');
SELECT '418', ST_IsPolygonCCW('MULTIPOLYGON (((0 0, 1 0, 1 1, 0 0)), ((100 0, 101 1, 101 0, 100 0)))');
-
INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (102189, '+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1.000000 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m +no_defs ');
-
--
-- GML
--
SELECT 'gml_prefix_03', ST_AsGML(2, geography(ST_GeomFromEWKT('SRID=4326;POINT(1 2)')), 0, 0, 'foo');
SELECT 'gml_prefix_04', ST_AsGML(3, geography(ST_GeomFromEWKT('SRID=4326;POINT(1 2)')), 0, 0, 'foo');
-
--
-- KML
--
-- National Astronomical Observatory of Colombia - Bogota, Colombia (Placemark)
SELECT 'kml_projection_01', ST_AsKML(geography(ST_GeomFromEWKT('SRID=102189;POINT(1000000 1000000)')), 3);
-
--
-- SVG
--
SELECT 'svg_precision_01', ST_AsSVG(geography(ST_GeomFromEWKT('POINT(1.1111111 1.1111111)')), 1, -2);
SELECT 'svg_precision_02', ST_AsSVG(geography(ST_GeomFromEWKT('POINT(1.1111111 1.1111111)')), 1, 19);
-
--
-- GeoJSON
--
SELECT 'geojson_options_15', ST_AsGeoJSON(geography(ST_GeomFromEWKT('LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 7);
SELECT 'geojson_options_16', ST_AsGeoJSON(geography(ST_GeomFromEWKT('SRID=4326;LINESTRING(1 1, 2 2, 3 3, 4 4)')), 0, 7);
-
--
-- Delete inserted spatial data
--
--- EPSG 1021892 : Bogota 1975 / Colombia Bogota zone (deprecated)
INSERT INTO "spatial_ref_sys" ("srid", "proj4text") VALUES (102189, '+proj=tmerc +lat_0=4.599047222222222 +lon_0=-74.08091666666667 +k=1.000000 +x_0=1000000 +y_0=1000000 +ellps=intl +towgs84=307,304,-318,0,0,0,0 +units=m +no_defs ');
-
--
-- GML
--
SELECT 'svg_precision_01', ST_AsSVG(ST_GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, -2);
SELECT 'svg_precision_02', ST_AsSVG(ST_GeomFromEWKT('POINT(1.1111111 1.1111111)'), 1, 19);
-
--
-- GeoJSON
--
-- ST_Dimension on 3D: invalid polyedron (redundant point inside each face)
SELECT 'dimension_08', ST_Dimension('POLYHEDRALSURFACE(((0 0 0,1 0 0,1 0 0,0 0 0)),((0 0 1,1 0 1,1 0 1,0 0 1)),((0 0 2,1 0 2,1 0 2,0 0 2)),((0 0 3,1 0 3,1 0 3,0 0 3)))'::geometry);
-
-- ST_NumPatches
SELECT 'numpatches_01', ST_NumPatches('POLYHEDRALSURFACE EMPTY'::geometry);
SELECT 'numpatches_02', ST_NumPatches('POLYHEDRALSURFACE(((0 0,0 0,0 1,0 0)))'::geometry);
-- postgres
--- regression test for postGIS
-
-
--- assume datatypes already defined
-
-
--- basic datatypes (correct)
select '1',ST_asewkt('POINT( 1 2 )'::GEOMETRY) as geom;
select '34',ST_asewkt('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) )'::GEOMETRY) as geom;
select '35',ST_asewkt('MULTIPOLYGON( ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0)),( (0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0),(5 5 0, 7 5 0, 7 7 0, 5 7 0, 5 5 0) ) ,( (0 0 1, 10 0 1, 10 10 1, 0 10 1, 0 0 1),(5 5 1, 7 5 1, 7 7 1, 5 7 1, 5 5 1),(1 1 1,2 1 1, 2 2 1, 1 2 1, 1 1 1) ) )'::GEOMETRY) as geom;
-
select '36',ST_asewkt('GEOMETRYCOLLECTION(MULTIPOINT( 1 2))'::GEOMETRY);
select '37',ST_asewkt('GEOMETRYCOLLECTION(MULTIPOINT( 1 2 3))'::GEOMETRY);
select '38',ST_asewkt('GEOMETRYCOLLECTION(MULTIPOINT( 1 2 3, 5 6 7, 8 9 10, 11 12 13))'::GEOMETRY);
select '57', ST_asewkt('POLYGON( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7) )'::GEOMETRY);
select '58', ST_asewkt('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2,) )'::GEOMETRY);
-
--- funny results
select '59',ST_asewkt('POINT(1 2 3, 4 5 6)'::GEOMETRY);
--select '63',ST_asewkt('POINT( -1e700 0)'::GEOMETRY);
select '64',ST_asewkt('MULTIPOINT(1 1, 2 2'::GEOMETRY);
-
--- is_same() testing
select '65','POINT(1 1)'::GEOMETRY ~= 'POINT(1 1)'::GEOMETRY as bool;
select '73','MULTIPOINT(1 2 3, 4 5 6)'::GEOMETRY ~= 'GEOMETRYCOLLECTION(MULTIPOINT(1 2 3, 4 5 6))'::GEOMETRY as bool;
select '73a',ST_OrderingEquals('MULTIPOINT(1 2 3, 4 5 6)'::GEOMETRY,'GEOMETRYCOLLECTION(MULTIPOINT(1 2 3, 4 5 6))'::GEOMETRY) as bool;
-
select '74','LINESTRING(1 1,2 2)'::GEOMETRY ~= 'POINT(1 1)'::GEOMETRY as bool;
select '74a',ST_OrderingEquals('LINESTRING(1 1,2 2)'::GEOMETRY,'POINT(1 1)'::GEOMETRY) as bool;
select '75','LINESTRING(1 1, 2 2)'::GEOMETRY ~= 'LINESTRING(2 2, 1 1)'::GEOMETRY as bool;
---selection
-
-
--- TOAST testing
-- create a table with data that will be TOASTed (even after compression)
create table TEST(a GEOMETRY, b GEOMETRY);
\i regress_biginsert.sql
-
---test basic ops on this
select '121',box3d(a) as box3d_a, box3d(b) as box3d_b from TEST;
DROP TABLE "test";
-
-- Test node splits in geometry and geography with null-filled, empty-filled, and mixed collections of rows
-- Previous issues showed crashing behaviour, so if we don't crash, we're golden.
-- Name: test Type: TABLE DATA Owner: postgres
--
-
COPY "test" FROM stdin;
1 POINT(529.522339 509.260284)
2 POINT(395.286469 439.218109)
--- postgis-devel/2006-January/001951.html
with substr as (
select ST_LineSubstring(ST_geomfromewkt('SRID=4326;LINESTRING(0 0 0 0, 1 1 1 1, 2 2 2 2, 3 3 3 3, 4 4 4 4)'), 0.5, 0.8) as ln
-)
+)
select 'line_substring_1', ST_SRID(ln), ST_AsText(ln) from substr;
select 'line_substring_2', ST_AsText(ST_LineSubstring('LINESTRING(0 0 0 0, 1 1 1 1, 2 2 2 2, 3 3 3 3, 4 4 4 4)', 0.5, 0.75));
('containsproperly104', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POINT(0 12)')
) AS v(c,ply,pt);
-
-- PIP - point vertically aligned with polygon vertex, poly first
SELECT 'intersects105', ST_Intersects(p, ST_GeomFromText('POINT(521513 5377804)', 32631)) FROM
( VALUES
(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631))
) AS v(p);
-
-- PIP - point vertically aligned with polygon vertex, poly first
SELECT 'contains105', ST_Contains(p, ST_GeomFromText('POINT(521513 5377804)', 32631)) FROM
( VALUES
(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631))
) AS v(p);
-
SELECT c, ST_Intersects(p1, p2) AS intersects_p1p2, ST_Intersects(p2, p1) AS intersects_p2p1 FROM
( VALUES
('intersects200', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))'),
('types114', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'LINESTRING(0 0, 0 10, 10 10, 10 0)')
) AS v(c,p1,p2);
-
SELECT 'intersects310', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) FROM ( VALUES
('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)')
) AS v(p);
10 10
\.
-
-- Check for error messages
create table no_stats ( g geometry, id integer );
create table no_stats_join ( g geometry, id integer );
SELECT 17, ST_AsText(ST_RemoveRepeatedPoints('MULTIPOINT(0 0, 0 0, 1 1, 4 4)'::geometry,2));
SELECT 18, ST_AsText(ST_RemoveRepeatedPoints('POLYGON((-215922 5325694,-218080 5321866,-218693 5322119,-216112 5325812,-215922 5325694))'::geometry, 10000));
-
SELECT ST_asewkt(ST_removepoint('LINESTRING(0 0 0 0, 1 1 1 1, 2 2 2 2, 3 3 3 3, 4 4 4 4, 5 5 5 5, 6 6 6 6, 7 7 7 7)', 2));
SELECT ST_asewkt(ST_removepoint('LINESTRING(0 0 0 0, 1 1 1 1, 2 2 2 2, 3 3 3 3, 4 4 4 4, 5 5 5 5, 6 6 6 6, 7 7 7 7)', 4));
-
50 60, 125 100, 175 150))'),
ST_Buffer(ST_GeomFromText('POINT(110 170)'), 20)
) As geom;
-
+
SELECT
'ST_ConcaveHull Lines 0.80', ST_Within(geom,ST_ConcaveHull(
geom, 0.80) ) As encloses_geom,
'LINESTRING EMPTY'::geometry as empty
) SELECT 'ST_Length(empty) == 0', ST_Length(empty) FROM inp;
-
-- Operators
-- same box, see http://trac.osgeo.org/postgis/ticket/1453
)
SELECT 'geog_precision_pazafir', _ST_DistanceUnCached(pt.point, ply.polygon), ST_Distance(pt.point, ply.polygon) FROM pt, ply;
-
-- Clean up spatial_ref_sys
DELETE FROM spatial_ref_sys WHERE srid = 4326;
select '115', ST_3DPerimeter('MULTIPOLYGON( ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0)),( (0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0),(5 5 0, 7 5 0, 7 7 0, 5 7 0, 5 5 0) ) ,( (0 0 1, 10 0 1, 10 10 1, 0 10 1, 0 0 1),(5 5 1, 7 5 1, 7 7 1, 5 7 1, 5 5 1),(1 1 1,2 1 1, 2 2 1, 1 2 1, 1 1 1) ) )'::GEOMETRY) as value;
-
select '116', ST_length2d('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2) )'::GEOMETRY) as value;
select '117', ST_3dlength('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2) )'::GEOMETRY) as value;
select '118', ST_3dlength('MULTILINESTRING((0 0 0, 1 1 1),(0 0 0, 1 1 1, 2 2 2) )'::GEOMETRY) as value;
select '136', ST_Distance('POINT(0 0)', ST_translate('POINT(0 0)', 5, 12, 0));
-
-- postgis-users/2006-May/012174.html
select 'dist', ST_Distance(a,b), ST_Distance(b,a) from (
select 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))'::geometry as a,
(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
) as foo;
-
--st_maxdistance
select 'st_maxdistance_134', st_maxdistance('POINT(1 2)', 'POINT(1 2)');
(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
) as foo;
-
-
--st_longestline
select 'st_longestline_134', st_astext(st_longestline('POINT(1 2)', 'POINT(1 2)'));
(15 5, 15 8, 17 8, 17 5, 15 5))'::geometry as b
) as foo;
-select 'distancetest1',
+select 'distancetest1',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
round(st_x(st_startpoint(st_shortestline(a,b)))::numeric, 10),
round(st_y(st_startpoint(st_shortestline(a,b)))::numeric, 10),
round(st_x(st_endpoint(st_shortestline(a,b)))::numeric, 10),
- round(st_y(st_endpoint(st_shortestline(a,b)))::numeric, 10),
+ round(st_y(st_endpoint(st_shortestline(a,b)))::numeric, 10),
st_astext(st_longestline(a,b)),
st_astext(st_longestline(b,a)) from (
select
ST_GeomFromText('LINESTRING(-10 20, 1 -2)') as b
) as foo;
-select 'distancepoly1',
+select 'distancepoly1',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('MULTIPOLYGON(((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,19 14,19 19,14 19,14 14)),((33 35,33 40, 35 40, 35 35, 33 35)))') as b
) as foo;
-select 'distancepoly2',
+select 'distancepoly2',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1, -1 25, 25 25, 25 -1, -1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
) as foo;
-
-
-select 'distancepoly3',
+select 'distancepoly3',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
) as foo;
-
-select 'distancepoly4',
+select 'distancepoly4',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
) as foo;
-
-
-select 'distancepoly5',
+select 'distancepoly5',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
ST_GeomFromText('POLYGON((-1 -1,-1 25, 25 25,25 -1,-1 -1), (14 14,19 14,19 19,14 19,14 14))') as b
) as foo;
-
-
-
-select 'distancepoly6',
+select 'distancepoly6',
ST_Distance(a, b),
st_maxdistance(a, b),
st_astext(st_shortestline(a,b)),
--3D Distance functions
-
SELECT '3dDistancetest1',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'POINT(1 1 1)'::geometry as a, 'POINT(3 2 7)'::geometry as b
) as foo;
-
-
+
SELECT '3dDistancetest2',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'POINT(1 1 1)'::geometry as a, 'LINESTRING(0 0 0, 2 2 2)'::geometry as b
) as foo;
-
-
+
SELECT '3dDistancetest3',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'POINT(1 1 1)'::geometry as a, 'LINESTRING(5 2 6, -3 -2 4)'::geometry as b
) as foo;
-
-
+
SELECT '3dDistancetest4',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
ST_ASEWKT(ST_3DLongestline(a,b)) FROM (
SELECT 'LINESTRING(1 1 3, 5 7 8)'::geometry as a, 'POINT(1 1 1)'::geometry as b
) as foo;
-
+
SELECT '3dDistancetest5',
ST_3DDistance(a,b),
ST_3DMaxDistance(a,b),
SELECT '3dDistancetest6',
ST_3DDistance(a,b) FROM (
- SELECT 'LINESTRING(1 1 1 , 2 2 2)'::geometry as a, 'POLYGON((0 0 0, 2 2 2, 3 3 0, 0 0 0))'::geometry as b) as foo;
+ SELECT 'LINESTRING(1 1 1 , 2 2 2)'::geometry as a, 'POLYGON((0 0 0, 2 2 2, 3 3 0, 0 0 0))'::geometry as b) as foo;
-- Area of an empty polygon
select 'emptyPolyArea', st_area('POLYGON EMPTY');
SET postgis.backend = 'sfcgal';
--- regression test for postGIS
-
-
--- assume datatypes already defined
-
-
--- basic datatypes (correct)
select '1',ST_asewkt('POINT( 1 2 )'::GEOMETRY) as geom;
select '34',ST_asewkt('MULTIPOLYGON( ((0 0, 10 0, 10 10, 0 10, 0 0)),( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7, 5 5) ) )'::GEOMETRY) as geom;
select '35',ST_asewkt('MULTIPOLYGON( ((0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0)),( (0 0 0, 10 0 0, 10 10 0, 0 10 0, 0 0 0),(5 5 0, 7 5 0, 7 7 0, 5 7 0, 5 5 0) ) ,( (0 0 1, 10 0 1, 10 10 1, 0 10 1, 0 0 1),(5 5 1, 7 5 1, 7 7 1, 5 7 1, 5 5 1),(1 1 1,2 1 1, 2 2 1, 1 2 1, 1 1 1) ) )'::GEOMETRY) as geom;
-
select '36',ST_asewkt('GEOMETRYCOLLECTION(MULTIPOINT( 1 2))'::GEOMETRY);
select '37',ST_asewkt('GEOMETRYCOLLECTION(MULTIPOINT( 1 2 3))'::GEOMETRY);
select '38',ST_asewkt('GEOMETRYCOLLECTION(MULTIPOINT( 1 2 3, 5 6 7, 8 9 10, 11 12 13))'::GEOMETRY);
select '57', ST_asewkt('POLYGON( (0 0, 10 0, 10 10, 0 10, 0 0),(5 5, 7 5, 7 7 , 5 7) )'::GEOMETRY);
select '58', ST_asewkt('MULTILINESTRING((0 0, 1 1),(0 0, 1 1, 2 2,) )'::GEOMETRY);
-
--- funny results
select '59',ST_asewkt('POINT(1 2 3, 4 5 6)'::GEOMETRY);
--select '63',ST_asewkt('POINT( -1e700 0)'::GEOMETRY);
select '64',ST_asewkt('MULTIPOINT(1 1, 2 2'::GEOMETRY);
-
--- is_same() testing
select '65','POINT(1 1)'::GEOMETRY ~= 'POINT(1 1)'::GEOMETRY as bool;
select '73','MULTIPOINT(1 2 3, 4 5 6)'::GEOMETRY ~= 'GEOMETRYCOLLECTION(MULTIPOINT(1 2 3, 4 5 6))'::GEOMETRY as bool;
select '73a',ST_OrderingEquals('MULTIPOINT(1 2 3, 4 5 6)'::GEOMETRY,'GEOMETRYCOLLECTION(MULTIPOINT(1 2 3, 4 5 6))'::GEOMETRY) as bool;
-
select '74','LINESTRING(1 1,2 2)'::GEOMETRY ~= 'POINT(1 1)'::GEOMETRY as bool;
select '74a',ST_OrderingEquals('LINESTRING(1 1,2 2)'::GEOMETRY,'POINT(1 1)'::GEOMETRY) as bool;
select '75','LINESTRING(1 1, 2 2)'::GEOMETRY ~= 'LINESTRING(2 2, 1 1)'::GEOMETRY as bool;
select '81','POINT(1 1)'::GEOMETRY << 'POINT(2 1)'::GEOMETRY as bool;
select '82','POINT(2 1)'::GEOMETRY << 'POINT(1 1)'::GEOMETRY as bool;
-
select '83','POINT(1 1)'::GEOMETRY &> 'POINT(1 1)'::GEOMETRY as bool;
select '84','POINT(1 1)'::GEOMETRY &> 'POINT(2 1)'::GEOMETRY as bool;
select '85','POINT(2 1)'::GEOMETRY &> 'POINT(1 1)'::GEOMETRY as bool;
select '104','MULTIPOINT(0 0, 7 7)'::GEOMETRY @ 'MULTIPOINT(0 0, 10 10)'::GEOMETRY as bool;
select '105','MULTIPOINT(-0.0001 0, 7 7)'::GEOMETRY @ 'MULTIPOINT(0 0, 10 10)'::GEOMETRY as bool;
-
-
--- function testing
--- conversion function
---selection
-
-
--- TOAST testing
-- create a table with data that will be TOASTed (even after compression)
create table TEST(a GEOMETRY, b GEOMETRY);
\i regress_biginsert.sql
-
---test basic ops on this
select '121',box3d(a) as box3d_a, box3d(b) as box3d_b from TEST;
select '180', ST_AsText('GEOMETRYCOLLECTION EMPTY');
select '181', ST_AsText('GEOMETRYCOLLECTION(TRIANGLE EMPTY,TIN EMPTY)');
-
-- Drop test table
DROP table test;
('containsproperly104', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POINT(0 12)')
) AS v(c,ply,pt);
-
-- PIP - point vertically aligned with polygon vertex, poly first
SELECT 'intersects105', ST_Intersects(p, ST_GeomFromText('POINT(521513 5377804)', 32631)) FROM
( VALUES
(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631))
) AS v(p);
-
-- PIP - point vertically aligned with polygon vertex, poly first
SELECT 'contains105', ST_Contains(p, ST_GeomFromText('POINT(521513 5377804)', 32631)) FROM
( VALUES
(ST_GeomFromText('POLYGON((521526 5377783, 521482 5377811, 521494 5377832, 521539 5377804, 521526 5377783))', 32631))
) AS v(p);
-
SELECT c, ST_Intersects(p1, p2) AS intersects_p1p2, ST_Intersects(p2, p1) AS intersects_p2p1 FROM
( VALUES
('intersects200', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'POLYGON((2 2, 2 3, 3 3, 3 2, 2 2))'),
('types114', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', 'LINESTRING(0 0, 0 10, 10 10, 10 0)')
) AS v(c,p1,p2);
-
SELECT 'intersects310', ST_intersects('POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))', p) FROM ( VALUES
('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)'),('LINESTRING(1 10, 9 10, 9 8)')
) AS v(p);
INSERT INTO spatial_ref_sys (srid,proj4text) VALUES (32707,'+proj=utm +zone=7 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ');
-
-- #2 --
SELECT '#2', ST_AsText(ST_Union(g)) FROM
( VALUES
SELECT '#11', round(ST_Distance (a.g, ST_Intersection(b.g, a.g))) AS distance
FROM (SELECT '01020000000200000050E8303FC2E85141B017CFC05A825541000000E0C0E85141000000205C825541'::geometry AS g) a,
(SELECT 'LINESTRING(4694792.35840419 5638508.89950758,4694793.20840419 5638506.34950758)'::geometry AS g) b;
-
+
-- #21 --
SELECT '#21', ST_AsEWKT(ST_Locate_Along_Measure(g, 4566)) FROM
( VALUES
( ST_LineToCurve(ST_Boundary(ST_Buffer(ST_Point(1,2), 3))) )
) AS v(g);
-
-- #168 --
SELECT '#168', ST_NPoints(g), ST_AsText(g), ST_isValidReason(g)
FROM ( VALUES
As pca,
ST_Covers(geometry(geography(poly.the_geom)),
geometry(geography(pt.the_geom))) As gm_to_gg_gm_pca
-
+
FROM (SELECT ST_GeomFromEWKT('SRID=4326;POLYGON((-119.5434 34.9438,-119.5437 34.9445,-119.5452 34.9442,-119.5434 34.9438))') As the_geom)
As poly
CROSS JOIN
SELECT '#681f', ST_AsGML(ST_GeomFromText('MULTIPOLYGON EMPTY', 4326));
SELECT '#681g', ST_AsGML(ST_GeomFromText('GEOMETRYCOLLECTION EMPTY', 4326));
-
-- #682 --
SELECT '#682', ST_AsText(ST_Buffer(ST_GeomFromText('POLYGON EMPTY',4326) , 0.5));
-- #804
SELECT '#804', ST_AsGML(3, 'SRID=4326;POINT(0 0)'::geometry, 0, 1);
-
-- #845
SELECT '#845', ST_Intersects('POINT(169.69960846592 -46.5061209281002)'::geometry, 'POLYGON((169.699607857174 -46.5061218662,169.699607857174 -46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526 -46.5061218662,169.699607857174 -46.5061218662))'::geometry);
ST_Equals(s, st_collect(s, e))
FROM inp;
-
-- #1023 --
select '#1023', 'POINT(10 4)'::geometry = 'POINT(10 4)'::geometry;
select '#1023.a', 'POINT(10 4)'::geometry = 'POINT(10 5)'::geometry;
-- st_AsText POLYGON((0 0,10 0,10 10,0 0))
-
-- #1344
select '#1344', octet_length(ST_AsEWKB(st_makeline(g))) FROM ( values ('POINT(0 0)'::geometry ) ) as foo(g);
SELECT '010B0000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
SELECT '010C0000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
-
-- #1453
SELECT '#1453.1', ST_OrderingEquals('POINT EMPTY', 'POINT EMPTY');
SELECT '#1453.2', ST_OrderingEquals('POINT EMPTY', 'POINT Z EMPTY');
'010100000001000000004065C0041AD965BE5554C0'::geometry as b
) SELECT '#1791', round(ST_Azimuth(a,b)*10)/10 from inp;
-
-- #1799 --
SELECT '#1799', ST_Segmentize('LINESTRING(0 0, 10 0)'::geometry, 0);
-- #2028 --
SELECT '#2028', ST_AsText(ST_Multi('TRIANGLE((0 0, 0 1, 1 1, 0 0))'));
-
-- #2035 START ------------------------------------------------------------
-- Simple geographic table, with single point.
DROP TABLE "city";
-- #2035 END --------------------------------------------------------------
-
-- #2084 --
SELECT '#2048', num, ST_Within('POINT(-54.394 56.522)', "the_geom"), ST_CoveredBy('POINT(-54.394 56.522)', "the_geom")
FROM ( VALUES
SELECT '#2110.2', 'POINT EMPTY'::geometry = 'POINT EMPTY'::geometry;
SELECT '#2110.3', 'POINT(0 0)'::geometry = 'POINT(0 0)'::geometry;
-
SELECT '#2145',
round(ST_Length(St_Segmentize(ST_GeographyFromText('LINESTRING(-89.3000030518 28.2000007629,-89.1999969482 89.1999969482,-89.1999969482 89.1999969482)'), 10000))::numeric,0);
-
-- Clean up
DELETE FROM spatial_ref_sys;
'SRID=4326;MULTISURFACE(CURVEPOLYGON(CIRCULARSTRING(-2 0 0 0,-1 -1 1 2,0 0 2 4,1 -1 3 6,2 0 4 8,0 2 2 4,-2 0 0 0),(-1 0 1 2,0 0.5 2 4,1 0 3 6,0 1 3 4,-1 0 1 2)),((7 8 7 8,10 10 5 5,6 14 3 1,4 11 4 6,7 8 7 8)))',
'010C0000E0E610000002000000010A0000C00200000001080000C00700000000000000000000C0000000000000000000000000000000000000000000000000000000000000F0BF000000000000F0BF000000000000F03F00000000000000400000000000000000000000000000000000000000000000400000000000001040000000000000F03F000000000000F0BF000000000000084000000000000018400000000000000040000000000000000000000000000010400000000000002040000000000000000000000000000000400000000000000040000000000000104000000000000000C000000000000000000000000000000000000000000000000001020000C005000000000000000000F0BF0000000000000000000000000000F03F00000000000000400000000000000000000000000000E03F00000000000000400000000000001040000000000000F03F0000000000000000000000000000084000000000000018400000000000000000000000000000F03F00000000000008400000000000001040000000000000F0BF0000000000000000000000000000F03F000000000000004001030000C001000000050000000000000000001C4000000000000020400000000000001C400000000000002040000000000000244000000000000024400000000000001440000000000000144000000000000018400000000000002C400000000000000840000000000000F03F00000000000010400000000000002640000000000000104000000000000018400000000000001C4000000000000020400000000000001C400000000000002040');
-
-
SELECT id, CASE WHEN ewkt = ST_asEWKT(serialized::geometry) THEN 'pass' ELSE 'fail' END AS result FROM serialize_test ORDER BY id;
SELECT id, CASE WHEN ST_asEWKB(geomFromEWKT(ewkt)) = serialized THEN 'pass' ELSE 'fail' END AS result FROM serialize_test ORDER BY id;
SELECT '#3522', ST_AsText(ST_Subdivide(ST_GeomFromText('POINT(1 1)',4326),10));
-
with inverted_geom as (
select ST_Difference(
ST_Expand('SRID=3857;POINT(0 0)' :: geometry, 20000000),
SELECT 'invalid', ST_DistanceCPA('LINESTRING(0 0 0, 1 0 0)'::geometry
,'LINESTRING(0 0 3 0, 1 0 2 1)'::geometry);
-
----------------------------------------
--
-- ST_CPAWithin
INSERT INTO spatial_ref_sys (srid,proj4text) VALUES (32707,'+proj=utm +zone=7 +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs ');
-
-- #2 --
SELECT '#2', ST_AsText(ST_Union(g)) FROM
( VALUES
( ST_LineToCurve(ST_Boundary(ST_Buffer(ST_Point(1,2), 3))) )
) AS v(g);
-
-- #168 --
SELECT '#168', ST_NPoints(g), ST_AsText(g), ST_isValidReason(g)
FROM ( VALUES
SELECT '#681f', ST_AsGML(ST_GeomFromText('MULTIPOLYGON EMPTY', 4326));
SELECT '#681g', ST_AsGML(ST_GeomFromText('GEOMETRYCOLLECTION EMPTY', 4326));
-
-- #682 --
SELECT '#682', encode(ST_AsEWKB(ST_Buffer(ST_GeomFromText('POLYGON EMPTY',4326) , 0.5), 'ndr'),'hex');
-- #804
SELECT '#804', ST_AsGML(3, 'SRID=4326;POINT(0 0)'::geometry, 0, 1);
-
-- #845
SELECT '#845', ST_Intersects('POINT(169.69960846592 -46.5061209281002)'::geometry, 'POLYGON((169.699607857174 -46.5061218662,169.699607857174 -46.5061195965597,169.699608806526 -46.5061195965597,169.699608806526 -46.5061218662,169.699607857174 -46.5061218662))'::geometry);
ST_Equals(s, st_collect(s, e))
FROM inp;
-
-- #1023 --
select '#1023', 'POINT(10 4)'::geometry = 'POINT(10 4)'::geometry;
select '#1023.a', 'POINT(10 4)'::geometry = 'POINT(10 5)'::geometry;
-- st_AsText POLYGON((0 0,10 0,10 10,0 0))
-
-- #1344
select '#1344', octet_length(ST_AsEWKB(st_makeline(g))) FROM ( values ('POINT(0 0)'::geometry ) ) as foo(g);
SELECT '010B0000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
SELECT '010C0000400200000001040000400100000001010000400000000000000000000000000000000000000000000000000101000040000000000000F03F000000000000F03F000000000000F03F'::geometry;
-
-- #1453
SELECT '#1453.1', ST_OrderingEquals('POINT EMPTY', 'POINT EMPTY');
SELECT '#1453.2', ST_OrderingEquals('POINT EMPTY', 'POINT Z EMPTY');
'010100000001000000004065C0041AD965BE5554C0'::geometry as b
) SELECT '#1791', round(ST_Azimuth(a,b)*10)/10 from inp;
-
-- #1799 --
SELECT '#1799', ST_Segmentize('LINESTRING(0 0, 10 0)'::geometry, 0);
-- #2028 --
SELECT '#2028', ST_AsText(ST_Multi('TRIANGLE((0 0, 0 1, 1 1, 0 0))'));
-
-- #2035 START ------------------------------------------------------------
-- Simple geographic table, with single point.
DROP TABLE "city";
-- #2035 END --------------------------------------------------------------
-
-- #2084 --
SELECT '#2084', num, ST_Within('POINT(-54.394 56.522)', "the_geom"), ST_CoveredBy('POINT(-54.394 56.522)', "the_geom")
FROM ( VALUES
SELECT '#2110.2', 'POINT EMPTY'::geometry = 'POINT EMPTY'::geometry;
SELECT '#2110.3', 'POINT(0 0)'::geometry = 'POINT(0 0)'::geometry;
-
SELECT '#2145',
round(ST_Length(St_Segmentize(ST_GeographyFromText('LINESTRING(-89.3000030518 28.2000007629,-89.1999969482 89.1999969482,-89.1999969482 89.1999969482)'), 10000))::numeric,0);
SELECT '#2168', ST_Distance(g1,g2)::numeric(16,8) As dist_g1_g2, ST_Distance(g2,g1)::numeric(16,8) AS dist_g2_g1,ST_Distance(g1,g2) - ST_Distance(g2,g1)
FROM (SELECT 'POINT(18.5107234 54.7587757)'::geography As g1, 'POINT(18.58218 54.7344227)'::geography As g2) As a;
-
-- #2556 --
CREATE TABLE images (id integer, name varchar, extent geography(POLYGON,4326));
WITH v AS ( SELECT 'TRIANGLE((0 0, 1 1, 1 0, 0 0))'::geometry AS g FROM generate_series(1,3) )
SELECT '#2692c', ST_AsText(st_collect(g)) FROM v;
-
SELECT '#2704', ST_AsText(ST_GeomFromGML('<?xml version="1.0"?>
<gml:Polygon xmlns:gml="http://www.opengis.net/gml/3.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
</innerBoundaryIs>
</Polygon>');
-
-
-- #3437
WITH
mp AS (SELECT ST_Collect(ST_MakePoint(-c, c*c)) AS geom FROM generate_series(1, 5) c),
-- #3930
SELECT '#3930', round(1000*st_area(st_minimumboundingcircle('MULTIPOLYGON (((-76.5442733764648 34.5878295898438, -76.5551452636719 34.6106605529785, -76.5377502441406 34.6139221191406, -76.4844818115234 34.6976318359375, -76.4322967529297 34.760684967041, -76.3746795654297 34.8128700256348, -76.2877044677734 34.877010345459, -76.4692611694336 34.6932830810547, -76.5442733764648 34.5878295898438)), ((-76.0170059204102 35.0694351196289, -75.9756927490234 35.1161842346191, -75.8539352416992 35.1672821044922, -75.7637023925781 35.1922836303711, -75.8115386962891 35.1640205383301, -75.9039459228516 35.1324920654297, -76.0028762817383 35.0694351196289, -76.0170059204102 35.0694351196289)), ((-76.0271682739258 36.5567169189453, -75.998664855957 36.5566520690918, -75.9119186401367 36.5425300598145, -75.9248046875 36.4739761352539, -75.9772796630859 36.4780158996582, -75.9762878417969 36.5179252624512, -76.0271682739258 36.5567169189453)), ((-75.4912185668945 35.6704978942871, -75.5336227416992 35.768856048584, -75.4569778442383 35.6173973083496, -75.5262985229492 35.2279167175293, -75.7492904663086 35.189826965332, -75.6915664672852 35.2349891662598, -75.521484375 35.2813568115234, -75.4754180908203 35.5644950866699, -75.4912185668945 35.6704978942871)), ((-83.9379959106445 34.9893913269043, -83.9885482788086 34.9890670776367, -84.1182403564453 34.988224029541, -84.3238525390625 34.9890098571777, -84.2910385131836 35.2105445861816, -84.225944519043 35.261604309082, -84.1797256469727 35.2409896850586, -84.1016464233398 35.2455520629883, -84.0427780151367 35.272575378418, -84.0308609008789 35.2925224304199, -84.0292053222656 35.3252906799316, -84.0063095092773 35.372859954834, -84.0126495361328 35.4076232910156, -83.954704284668 35.4554595947266, -83.9100112915039 35.4764785766602, -83.8812255859375 35.5105857849121, -83.8302001953125 35.5190620422363, -83.77587890625 35.552604675293, -83.6728744506836 35.5649719238281, -83.6138610839844 35.5717391967773, -83.56103515625 35.55517578125, -83.5057983398438 35.5595512390137, -83.4582901000977 35.5972785949707, -83.387092590332 35.6252174377441, -83.3430252075195 35.6532592773438, -83.2984161376953 35.6563262939453, -83.2591247558594 35.6910095214844, -83.253303527832 35.7007064819336, -83.2438507080078 35.7182159423828, -83.1853485107422 35.7288856506348, -83.1436614990234 35.7626838684082, -83.1181869506836 35.7638092041016, -83.0599594116211 35.7825775146484, -82.9870071411133 35.7739906311035, -82.9627532958984 35.7918510437012, -82.9068222045898 35.8722152709961, -82.9140701293945 35.9278678894043, -82.8959732055664 35.9483604431152, -82.8562698364258 35.9474258422852, -82.8086700439453 35.9208717346191, -82.7764434814453 35.9565734863281, -82.7735977172852 35.9875030517578, -82.7632293701172 35.9995460510254, -82.6438903808594 36.0517234802246, -82.628044128418 36.0543403625488, -82.6044006347656 36.0429878234863, -82.5922317504883 36.0224494934082, -82.6058044433594 36.003547668457, -82.5993041992188 35.9632987976074, -82.5541458129883 35.9561080932617, -82.5069351196289 35.972541809082, -82.4751968383789 35.9931755065918, -82.4084243774414 36.0753173828125, -82.3738555908203 36.0986976623535, -82.3119277954102 36.1221504211426, -82.2623062133789 36.1203765869141, -82.2077331542969 36.1470146179199, -82.154052734375 36.1396217346191, -82.1180801391602 36.0962562561035, -82.0777587890625 36.1001396179199, -82.0204544067383 36.129711151123, -81.9331130981445 36.2633209228516, -81.9111557006836 36.2907524108887, -81.8305740356445 36.3346557617188, -81.7304916381836 36.3293418884277, -81.7094573974609 36.3337249755859, -81.7403793334961 36.3618583679199, -81.7410736083984 36.3917846679688, -81.6982803344727 36.4717788696289, -81.7027969360352 36.5193405151367, -81.6699981689453 36.5896492004395, -81.3452987670898 36.5728645324707, -80.9034423828125 36.5652122497559, -80.8381576538086 36.5634384155273, -80.6110534667969 36.5572967529297, -80.4353103637695 36.5510444641113, -80.048095703125 36.5471343994141, -80.024055480957 36.5450248718262, -79.7174453735352 36.5478897094727, -79.5102996826172 36.5476570129395, -79.2170639038086 36.5497817993164, -79.1443252563477 36.5460586547852, -78.7966995239258 36.5435333251953, -78.7373886108398 36.5460739135742, -78.4588088989258 36.5414810180664, -78.3212509155273 36.5455322265625, -78.0516662597656 36.5524749755859, -77.8988571166992 36.5529441833496, -77.7639312744141 36.5534400939941, -77.3200531005859 36.5539169311523, -77.1773529052734 36.5562858581543, -76.9241333007812 36.5541458129883, -76.921630859375 36.5541572570801, -76.5635833740234 36.5552520751953, -76.49755859375 36.5558128356934, -76.3302536010742 36.5560569763184, -76.1273956298828 36.5571632385254, -76.0459594726562 36.5569534301758, -76.0332107543945 36.5143737792969, -76.091064453125 36.5035667419434, -75.97607421875 36.4362144470215, -75.9697647094727 36.4151191711426, -76.0016098022461 36.4189147949219, -75.9512557983398 36.3654708862305, -75.9281234741211 36.4232444763184, -75.9245910644531 36.3509483337402, -75.8000564575195 36.1128158569336, -75.7988510131836 36.0728187561035, -75.8551635742188 36.1056671142578, -75.9137649536133 36.244800567627, -75.9575119018555 36.2594528198242, -75.9419326782227 36.2943382263184, -76.0089721679688 36.3195953369141, -75.9571838378906 36.1937713623047, -75.9813385009766 36.1697273254395, -76.1831665039062 36.3152389526367, -76.2189025878906 36.2966079711914, -76.1127090454102 36.1744194030762, -76.1419372558594 36.1476898193359, -76.234977722168 36.1633605957031, -76.2989273071289 36.2142295837402, -76.275505065918 36.1103706359863, -76.4805297851562 36.0797920227051, -76.4204254150391 36.0586051940918, -76.5230102539062 36.0071678161621, -76.5940017700195 36.0101318359375, -76.6490173339844 36.0657081604004, -76.6332092285156 36.0371170043945, -76.6901550292969 36.0496101379395, -76.7265090942383 36.1568222045898, -76.6887359619141 36.2945175170898, -76.7766418457031 36.3583297729492, -76.9240798950195 36.3924446105957, -76.7413482666016 36.3151664733887, -76.7074966430664 36.2661323547363, -76.7450637817383 36.2339172363281, -76.7606735229492 36.1445922851562, -76.6937637329102 35.9929695129395, -76.7411270141602 35.9366264343262, -76.6972198486328 35.9415435791016, -76.4094696044922 35.977466583252, -76.3714828491211 35.9323425292969, -76.2137680053711 35.9768753051758, -76.0896377563477 35.9629135131836, -76.0260467529297 35.9204254150391, -76.0759124755859 35.7568016052246, -76.0430679321289 35.6838493347168, -76.1673049926758 35.6968421936035, -76.1047439575195 35.6636390686035, -76.0212097167969 35.6690940856934, -75.9878540039062 35.892707824707, -75.8180541992188 35.9235191345215, -75.7489624023438 35.8693389892578, -75.7293701171875 35.6651725769043, -75.779052734375 35.578685760498, -75.8914947509766 35.6312675476074, -76.052978515625 35.4146041870117, -76.1816177368164 35.3415336608887, -76.4988021850586 35.4162178039551, -76.5337524414062 35.4501991271973, -76.4584350585938 35.5044250488281, -76.4465255737305 35.5508651733398, -76.5189437866211 35.5776443481445, -76.4925384521484 35.5417861938477, -76.6381988525391 35.520336151123, -76.6287689208984 35.4378967285156, -76.7053756713867 35.4119338989258, -77.1037673950195 35.5501861572266, -76.9831848144531 35.4365005493164, -76.6949005126953 35.3504257202148, -76.6145172119141 35.2729187011719, -76.5912094116211 35.3120803833008, -76.5409774780273 35.3036880493164, -76.5071258544922 35.2487678527832, -76.6400909423828 35.1725196838379, -76.605224609375 35.1385612487793, -76.6242218017578 35.0643501281738, -76.6780090332031 35.0240859985352, -76.8494644165039 34.9822196960449, -76.9414901733398 35.0274276733398, -76.943244934082 35.0700340270996, -77.0478820800781 35.092155456543, -77.1046752929688 35.0879859924316, -77.1105880737305 35.0660362243652, -77.0011901855469 35.0528869628906, -76.9131088256836 34.9364700317383, -76.6470489501953 34.9063339233398, -76.6700592041016 34.9699974060059, -76.5297775268555 34.9746360778809, -76.4450302124023 35.016658782959, -76.4240570068359 34.9462471008301, -76.364013671875 34.9431114196777, -76.3294067382812 34.9759559631348, -76.3147125244141 34.9488143920898, -76.4699020385742 34.7850608825684, -76.6253128051758 34.7197532653809, -77.0505294799805 34.698917388916, -77.1489562988281 34.764331817627, -77.12939453125 34.6849136352539, -77.1566009521484 34.6606369018555, -77.5386352539062 34.4570083618164, -77.5867614746094 34.4209365844727, -77.6097259521484 34.4350433349609, -77.6026153564453 34.4126281738281, -77.7505264282227 34.305046081543, -77.864387512207 34.1927375793457, -77.894401550293 34.0691795349121, -77.9267578125 34.0620346069336, -77.9607315063477 34.1892433166504, -77.9585266113281 33.9925804138184, -78.0348052978516 33.9142913818359, -78.579719543457 33.8819923400879, -78.6557159423828 33.948673248291, -79.0745010375977 34.304573059082, -79.4471435546875 34.6190605163574, -79.4559707641602 34.634090423584, -79.6675033569336 34.8006629943848, -79.6859588623047 34.8052558898926, -79.9199523925781 34.807918548584, -80.3252792358398 34.8147621154785, -80.5615463256836 34.8152275085449, -80.8000640869141 34.8161125183105, -80.7856521606445 34.9406394958496, -80.8401641845703 35.0020179748535, -80.8947143554688 35.0597343444824, -80.9277954101562 35.1012496948242, -81.0398864746094 35.0372009277344, -81.0655517578125 35.0664825439453, -81.0284423828125 35.1054077148438, -81.0490417480469 35.1320114135742, -81.0493011474609 35.1515312194824, -81.3228225708008 35.1637573242188, -81.362174987793 35.1628532409668, -81.7653579711914 35.1824722290039, -81.8705902099609 35.1831169128418, -81.9714431762695 35.1882820129395, -82.2101745605469 35.1931266784668, -82.2783279418945 35.1950073242188, -82.3207702636719 35.1841888427734, -82.3508605957031 35.1926727294922, -82.3601226806641 35.1829490661621, -82.3713760375977 35.1827239990234, -82.3896102905273 35.2082405090332, -82.4379196166992 35.1695594787598, -82.4667434692383 35.1735000610352, -82.5246353149414 35.1545600891113, -82.5700302124023 35.1494903564453, -82.6544952392578 35.119457244873, -82.6860504150391 35.1214637756348, -82.6880340576172 35.0978012084961, -82.6973571777344 35.0912322998047, -82.7713470458984 35.0854225158691, -82.8876953125 35.0553703308105, -83.0072784423828 35.0242042541504, -83.1062850952148 35.0002784729004, -83.5130081176758 34.9920234680176, -83.5494155883789 34.9895362854004, -83.9379959106445 34.9893913269043)), ((-75.7731552124023 36.2292556762695, -75.5449676513672 35.7883605957031, -75.7027359008789 36.049861907959, -75.7408676147461 36.0503234863281, -75.7831726074219 36.2251930236816, -75.901985168457 36.5561981201172, -75.8781661987305 36.5558738708496, -75.7731552124023 36.2292556762695)))')));
-
-- Clean up
DELETE FROM spatial_ref_sys;
select g,encode(ST_AsTWKB(g::geometry,p),'hex') from
(select 'MULTIPOLYGON(((1 1, 1 20, 20 20, 20 1, 1 1),(3 3,3 4, 4 4,4 3,3 3)),((-1 1, -1 20, -20 20, -20 1, -1 1),(-3 3,-3 4, -4 4,-4 3,-3 3)))'::text g, 0 p) foo;
-
--GEOMETRYCOLLECTION
select st_astext(st_collect(g::geometry)), encode(ST_AsTWKB(ST_Collect(g::geometry),0),'hex') from
(
select 'LINESTRING(2 2, 3 3)'::text g
) foo;
-
select st_astext(st_collect(g::geometry)), encode(ST_AsTWKB(ST_Collect(g::geometry),0),'hex') from
(
select 'MULTIPOINT((1 1),(2 2))'::text g
END;
-- }
-
IF NOT hasgeog THEN
RETURN NEXT;
CONTINUE;
'POINT ZM (0 0 0)' -- broken, misses an ordinate value
::text as g ) as foo;
-
-
-
SELECT g,
ST_AsText(g::geometry),
ST_OrderingEquals(g::geometry, St_GeomFromText(ST_AsText(g::geometry))) FROM ( SELECT
'POINT((0 0))'
::text as g ) as foo;
-
-
-- MULTIPOINT --
SELECT g,
'MULTIPOINT ZM ((0 0 0 0), (2 0 0 0))'
::text as g ) as foo;
-
-- LINESTRING --
SELECT g,
'LINESTRING ZM (0 0 0 0, 1 1 0 0)'
::text as g ) as foo;
-
-- MULTILINESTRING --
SELECT g,
'MULTILINESTRING ZM ((0 0 0 0, 2 0 0 0), (1 1 0 0, 2 2 0 0))'
::text as g ) as foo;
-
-- POLYGON --
SELECT g,
'POLYGON ZM ((0 0 0 2,10 0 0 2,10 10 0 2,0 10 0 2,0 0 0 2),(2 2 0 2,2 5 0 2,5 5 0 2,5 2 0 2,2 2 0 2))'
::text as g ) as foo;
-
-
-- MULTIPOLYGON --
SELECT g,
'MULTIPOLYGON ZM (((0 0 2 5,10 0 2 5,10 10 2 5,0 10 2 5,0 0 2 5),(2 2 2 5,2 5 2 5,5 5 2 5,5 2 2 5,2 2 2 5)))'
::text as g ) as foo;
-
-- GEOMETRYCOLLECTION --
SELECT g,
'CIRCULARSTRING ZM (0 0 0 0, 1 1 0 0, 1 2 3 4)'
::text as g ) as foo;
-
-- COMPOUNDCURVE --
SELECT g, -- invalid (missing point)
'MULTICURVE ZM ((5 5 1 3, 3 5 2 2, 3 3 3 1, 0 3 1 1), CIRCULARSTRING ZM (0 0 0 0, 0.2 1 3 -2, 0.5 1.4 1 2), COMPOUNDCURVE ZM (CIRCULARSTRING ZM (0 0 0 0,1 1 1 2,1 0 0 1),(1 0 0 1,0 1 5 4)))'
::text as g ) as foo;
-
-- MULTISURFACE --
SELECT g,
'POLYHEDRALSURFACE ZM (((0 0 0 0,0 0 1 0,0 1 0 2,0 0 0 0)),((0 0 0 0,0 1 0 0,1 0 0 4,0 0 0 0)),((0 0 0 0,1 0 0 0,0 0 1 6,0 0 0 0)),((1 0 0 0,0 1 0 0,0 0 1 0,1 0 0 0)))'
::text as g ) as foo;
-
-- TRIANGLE --
SELECT g, -- invalid (non-closed ring)
'TRIANGLE ZM ((1 2 3 -1,4 5 6 -2,7 8 9 -3,1 2 3 -1))'
::text as g ) as foo;
-
-- TIN --
SELECT g, -- invalid (non-closed ring)
'TIN ZM ( ((0 0 0 0, 0 0 1 0, 0 1 0 4, 0 0 0 0)), ((0 0 0 1, 0 1 0 2, 1 1 0 3, 0 0 0 1)) )'
::text as g ) as foo;
-
RAISE DEBUG ' edge % lf:%(%) rf:%(%)' , rec.signed_edge_id, rec.lf, rec.left_face, rec.rf, rec.right_face;
#endif
-
IF rec.left_face = ANY (all_faces) AND NOT rec.left_face = ANY (shell_faces) THEN
shell_faces := shell_faces || rec.left_face;
END IF;
EXECUTE 'SET search_path TO ' || old_search_path;
-
ELSIF tg.type = 4 THEN -- collection
RAISE EXCEPTION 'Collection TopoGeometries are not supported by AsTopoJSON';
END IF;
-
gml = gml || '>';
gml = gml || topology._AsGMLEdge(rec2.edge_id,
nsprefix_in, precision,
options, idprefix, gmlver);
-
gml = gml || '</' || nsprefix || 'directedEdge>';
END LOOP;
END LOOP;
END IF;
-
RETURN gml;
END
$$ LANGUAGE 'sql' VOLATILE; -- writes into visited table
-- } AsGML(TopoGeometry, nsprefix, precision, options)
-
--{
--
-- API FUNCTION
$$ LANGUAGE 'sql' VOLATILE; -- writes into visited table
-- } AsGML(TopoGeometry, visited_table, nsprefix)
-
--{
--
-- API FUNCTION
|| ') ';
END IF;
-
--
-- Set left_face/right_face of any contained edge
--
IF tg1.type = 1 THEN -- [multi]point
-
IF tg2.type = 1 THEN -- point/point
---------------------------------------------------------
--
--
---------------------------------------------------------
-
ELSIF tg2.type = 2 THEN -- point/line
---------------------------------------------------------
--
RAISE EXCEPTION 'Invalid TopoGeometry type %', tg2.type;
END IF;
-
ELSIF tg1.type = 3 THEN -- [multi]polygon
IF tg2.type = 3 THEN -- polygon/polygon
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
--
--
-- Returns return the integer ID if there is a face on the Point.
--
--- When the Point is even a Node it raise an exception.
+-- When the Point is even a Node it raise an exception.
-- This case is testable with the GetNodeByPoint(atopology, apoint, tol)
--
-- If there isn't any face in the Point, GetFaceByPoint return 0.
edge integer
);
-
--{
-- Topo-Geo and Topo-Net 3: Routine Details
-- X.3.5
LANGUAGE 'c' VOLATILE;
--} ST_RemEdgeModFace
-
--{
-- Topo-Geo and Topo-Net 3: Routine Details
-- X.3.16
LANGUAGE 'c' STABLE;
--} ST_GetFaceGeometry
-
--{
-- Topo-Geo and Topo-Net 3: Routine Details
-- X.3.1
RAISE DEBUG 'Merged edges: %', ST_NumGeometries(nodededges);
#endif
-
--
-- Collect input points and input lines endpoints
--
PERFORM topology.ST_AddIsoNode(atopology, 0, rec.geom);
END LOOP;
-
FOR rec IN SELECT geom FROM ST_Dump(nodededges)
LOOP
SELECT topology.GetNodeByPoint(atopology, st_startpoint(rec.geom), 0)
#endif
EXECUTE sql;
-
RETURN tg;
END
RAISE DEBUG '%', sql;
EXECUTE sql INTO geom;
-
ELSIF tg.type = 2 THEN -- [multi]line -- }{
sql :=
alayer, atopology;
END IF;
-
--
-- Check type compatibility and create empty TopoGeometry
-- 1:puntal, 2:lineal, 3:areal, 4:collection
alayer := layer_id(tg);
atopology := topology_info.name;
-
-- Get tolerance, if 0 was given
tolerance := COALESCE( NULLIF(atolerance, 0), topology._st_mintolerance(topology_info.name, ageom) );
alayer, atopology;
END IF;
-
--
-- Check type compatibility and set TopoGeometry type
-- 1:puntal, 2:lineal, 3:areal, 4:collection
SELECT AddGeometryColumn('features','city_streets','the_geom',-1,'MULTILINESTRING',2);
SELECT AddGeometryColumn('features','traffic_signs','the_geom',-1,'MULTIPOINT',2);
-
-
--ALTER TABLE features.city_streets ADD the_geom geometry;
UPDATE features.city_streets set the_geom =
st_multi(topology.Geometry(feature));
--ORA---- 5. Initialize topology
--ORA---- 6. Load feature tables using the SDO_TOPO_GEOMETRY constructor.
-
BEGIN;
-- 3. Create feature tables
CREATE TABLE features.traffic_signs ( -- Traffic signs (selected nodes)
feature_name VARCHAR PRIMARY KEY) with oids;
-
-
-- 4. Associate feature tables with the topology.
-- Add the three topology geometry layers to the CITY_DATA topology.
-- Any order is OK.
--NOTYET---- 5. Initialize topology metadata.
--NOTYET--EXECUTE topology.INITIALIZE_METADATA('CITY_DATA');
-
-- 6. Load feature tables using the CreateTopoGeom constructor.
-- Each topology feature can consist of one or more objects (face, edge, node)
-- of an appropriate type. For example, a land parcel can consist of one face,
--ORA---- 2. Load (normally bulk-load) topology data
--ORA---- (node, edge, and face tables).
-
BEGIN;
--- 1. Create the topology.
---
+-- 1. Create the topology.
+--
-- NOTE:
-- Returns topology id... which depend on how many
-- topologies where created in the regress database
-- so we just check it's a number greater than 0
---
+--
SELECT topology.CreateTopology('city_data', @SRID@) > 0;
-- 2. Load topology data (node, edge, and face tables).
-- 2B. Insert data into <topology_name>.NODE table.
-- N1
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(1, 'SRID=@SRID@;POINT(8 30)', NULL);
-- N2
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(2, 'SRID=@SRID@;POINT(25 30)', NULL);
-- N3
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(3, 'SRID=@SRID@;POINT(25 35)', NULL);
-- N4
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(4, 'SRID=@SRID@;POINT(20 37)', 2);
-- N5
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(5, 'SRID=@SRID@;POINT(36 38)', NULL);
-- N6
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(6, 'SRID=@SRID@;POINT(57 33)', NULL);
-- N7
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(7, 'SRID=@SRID@;POINT(41 40)', NULL);
-- N8
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(8, 'SRID=@SRID@;POINT(9 6)', NULL);
-- N9
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(9, 'SRID=@SRID@;POINT(21 6)', NULL);
-- N10
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(10, 'SRID=@SRID@;POINT(35 6)', NULL);
-- N11
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(11, 'SRID=@SRID@;POINT(47 6)', NULL);
-- N12
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(12, 'SRID=@SRID@;POINT(47 14)', NULL);
-- N13
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(13, 'SRID=@SRID@;POINT(35 14)', NULL);
-- N14
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(14, 'SRID=@SRID@;POINT(21 14)', NULL);
-- N15
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(15, 'SRID=@SRID@;POINT(9 14)', NULL);
-- N16
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(16, 'SRID=@SRID@;POINT(9 22)', NULL);
-- N17
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(17, 'SRID=@SRID@;POINT(21 22)', NULL);
-- N18
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(18, 'SRID=@SRID@;POINT(35 22)', NULL);
-- N19
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(19, 'SRID=@SRID@;POINT(47 22)', NULL);
-- N20
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(20, 'SRID=@SRID@;POINT(4 31)', NULL);
-- N21
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(21, 'SRID=@SRID@;POINT(9 35)', NULL);
-- N22
-INSERT INTO city_data.node(node_id, geom, containing_face)
+INSERT INTO city_data.node(node_id, geom, containing_face)
VALUES(22, 'SRID=@SRID@;POINT(13 35)', NULL);
-- UPDATE Node id sequence
#if DO_POINT_POINT_INTERSECTS
--- Detect intersections between traffic_signs
+-- Detect intersections between traffic_signs
SELECT 'POINT/POINT INTERSECTS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.traffic_signs a, features.traffic_signs b
WHERE a.oid < b.oid AND @SCHEMA@intersects(a.@COLUMN@, b.@COLUMN@);
#endif
-
#if DO_POINT_LINE_INTERSECTS
-- Detect intersections between city_streets and traffic_signs
SELECT 'POINT/LINE INTERSECTS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.traffic_signs a, features.city_streets b
WHERE @SCHEMA@intersects(a.@COLUMN@, b.@COLUMN@);
#endif
-
#if DO_LINE_LINE_INTERSECTS
-- Detect intersections between city_streets
SELECT 'LINE/LINE INTERSECTS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.city_streets a, features.city_streets b
WHERE a.oid < b.oid AND @SCHEMA@intersects(a.@COLUMN@, b.@COLUMN@);
#endif
SELECT 'POINT/POLY INTERSECTS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.traffic_signs a, features.land_parcels b
WHERE @SCHEMA@intersects(a.@COLUMN@, b.@COLUMN@);
#endif
SELECT 'LINE/POLY INTERSECTS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.city_streets a, features.land_parcels b
WHERE @SCHEMA@intersects(a.@COLUMN@, b.@COLUMN@);
#endif
SELECT 'POLY/POLY INTERSECTS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.land_parcels a, features.land_parcels b
WHERE a.oid < b.oid AND @SCHEMA@intersects(a.@COLUMN@, b.@COLUMN@);
#endif
SELECT 'POINT/POINT EQUALS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.traffic_signs a, features.traffic_signs b
WHERE a.oid < b.oid AND @SCHEMA@equals(a.@COLUMN@, b.@COLUMN@);
SELECT 'LINE/LINE EQUALS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.city_streets a, features.city_streets b
WHERE a.oid < b.oid AND @SCHEMA@equals(a.@COLUMN@, b.@COLUMN@);
SELECT 'POLYGON/POLYGON EQUALS' as operation;
-SELECT a.feature_name, b.feature_name FROM
+SELECT a.feature_name, b.feature_name FROM
features.land_parcels a, features.land_parcels b
WHERE a.oid < b.oid AND @SCHEMA@equals(a.@COLUMN@, b.@COLUMN@);
--ORA---- 7. Query the data.
--ORA---- 8. Optionally, edit data using the PL/SQL or Java API.
-
BEGIN;
-- 7. Query the data.
SELECT feature_name,ST_AsText(topology.geometry(feature))
FROM features.big_parcels;
-
--NOTYET--
--NOTYET--/* Window is city_streets */
--NOTYET--SELECT a.feature_name, b.feature_name
SELECT 'e7', topology.addEdge('tt', 'LINESTRING(20 10, 20 0)');
SELECT 'e8', topology.addEdge('tt', 'LINESTRING(20 0, 10 0)');
-
-- Register a face with no holes
SELECT 'f1', topology.addFace('tt', 'POLYGON((0 0, 0 10, 10 10, 10 0, 0 0))');
-- ... and verify the edge was split
SELECT 'post-p5', edge_id, ST_AsText(geom) FROM nodes.edge ORDER BY edge_id;
-
-- And same against a closed edge
INSERT INTO nodes.face VALUES(nextval('nodes.face_face_id_seq'), 'POLYGON((0 20, 10 20, 10 30, 0 30, 0 20))');
INSERT INTO nodes.edge VALUES(nextval('nodes.edge_data_edge_id_seq'),2,2,2,-2,1,0,
-- Ask for a point where there isn't an edge
select topology.GetEdgeByPoint('schema_topo',ST_GeomFromText('POINT(5 5.5)'), 0::float8) = 0;
-
-- Failing cases (should all raise exceptions) -------
-- Ask for Point in a Node
-- Ask for a Point with a tollerance too high
select topology.GetEdgeByPoint('schema_topo',ST_GeomFromText('POINT(5 5)'), 2::float8);
-
SELECT topology.DropTopology('schema_topo');
select 'F5',topology.addFace('schema_topo', 'POLYGON((4 7,6 7,6 10,4 10,4 7))');
select 'F6',topology.addFace('schema_topo', 'POLYGON((8 12,8 14,10 14,10 12,8 12))');
-
-- ask for a Point with tolerance zero
select 't1', topology.GetFaceByPoint('schema_topo',ST_GeomFromText('POINT(7 7)'), 0::float8)::int;
select 't2', topology.GetFaceByPoint('schema_topo',ST_GeomFromText('POINT(12 8)'), 0::float8)::int;
-- ask for a Point where there isn't a Face
select 't8', topology.GetFaceByPoint('schema_topo',ST_GeomFromText('POINT(5 14)'), 0::float8)::int;
-
-- Failing cases (should all raise exceptions) -------
-- Ask for Point in a Node (2 or more faces)
-- Ask for a Point with a tollerance too high (2 or more faces)
select 'e2', topology.GetFaceByPoint('schema_topo',ST_GeomFromText('POINT(6 13)'), 1::float8)::int;
-
SELECT topology.DropTopology('schema_topo');
-- Ask for a point where there isn't a node
select topology.GetNodeByPoint('schema_topo',ST_GeomFromText('POINT(5 5.5)'), 0::float8) = 0;
-
-- Failing cases (should all raise exceptions) -------
-- Ask for a Point with a tollerance too high
select topology.GetNodeByPoint('schema_topo',ST_GeomFromText('POINT(4 7)'), 5::float8);
-
SELECT topology.DropTopology('schema_topo');
--- } GML2 output
-
SELECT topology.DropTopology('city_data');
DROP SCHEMA features CASCADE;
DELETE FROM spatial_ref_sys where srid = 4326;
-- on different faces (TODO req. nodes contained in face)
-
-------------------------------------------------------------
-- ST_AddIsoNode (2)
-------------------------------------------------------------
INSERT INTO city_data.fc VALUES ('F5,N4',
topology.CreateTopoGeom('city_data', 4, 2, '{{5,3},{4,1}}'));
-
---------------------------------------------------------------------
-- Now add some edges splitting faces...
---------------------------------------------------------------------
SELECT 'F'||face_id, st_astext(mbr) FROM city_data.face ORDER BY face_id;
-
---------------------------------------------------------------------
-- Cleanups
---------------------------------------------------------------------
INSERT INTO city_data.fc VALUES ('F5,N4',
topology.CreateTopoGeom('city_data', 4, 2, '{{5,3},{4,1}}'));
-
---------------------------------------------------------------------
-- Now add some edges splitting faces...
---------------------------------------------------------------------
-- See http://trac.osgeo.org/postgis/ticket/978
SELECT topology.ST_AddIsoEdge('tt', 6, 7, 'LINESTRING(20 10, 30 10)');
-
-- Edge intersection (geometry intersects an edge)
SELECT topology.ST_AddIsoEdge('tt',
3, 6, 'LINESTRING(5 0, 20 10)');
-- TODO: check closed edge (not-isolated I guess...)
-- on different faces (TODO req. nodes contained in face)
-
SELECT topology.DropTopology('tt');
\i load_topology.sql
-
-- NULL exceptions
select ST_AddIsoNode(NULL, 0, 'POINT(1 4)');
select ST_AddIsoNode('tt', 0, NULL);
\i load_topology.sql
-
-- good one
SELECT 'T1', topology.ST_ChangeEdgeGeom('city_data', 25,
'LINESTRING(9 35, 11 33, 13 35)');
END;
$$ LANGUAGE 'plpgsql';
-
-- Invalid geometries
select null from ( select topology.CreateTopology('t', 4326) > 0 ) as ct;
select topology.st_createtopogeo('t', null); -- Invalid geometry
DROP TABLE t;
-
-
DROP FUNCTION check_changes();
SELECT DropTopology('city_data');
DELETE FROM spatial_ref_sys where srid = 4326;
-------------------------------------------------------------------------
-------------------------------------------------------------------------
-
-- TODO: test registered but unexistent topology
-- TODO: test registered but corrupted topology
-- (missing node, edge, relation...)
DROP TABLE t;
-
DROP FUNCTION check_changes();
SELECT DropTopology('city_data');
DELETE FROM spatial_ref_sys where srid = 4326;
INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
-- Import city_data
\i load_topology-4326.sql
SELECT * FROM check_faces('bogus');
-- }
-
-- Remove isolated edge
SELECT 'RM(25)', topology.ST_RemEdgeModFace('city_data', 25);
SELECT * FROM check_nodes('RM(25)/nodes');
SELECT * FROM check_faces('RM(15)/faces');
SELECT save_edges(); SELECT save_faces(); SELECT save_nodes();
-
-- Universe flooding existing single-edge (closed) face
-- with dangling edge starting from the closing node and
-- going inside.
SELECT topology.DropTopology('city_data');
-
-------------------------------------------------------------------------
-- Now test in presence of features
-------------------------------------------------------------------------
DROP FUNCTION check_nodes(text);
DELETE FROM spatial_ref_sys where srid = 4326;
-
INSERT INTO spatial_ref_sys ( auth_name, auth_srid, srid, proj4text ) VALUES ( 'EPSG', 4326, 4326, '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' );
-
-- Import city_data
\i load_topology-4326.sql
FROM city_data.node;
$$ LANGUAGE 'sql';
-
CREATE OR REPLACE FUNCTION check_nodes(lbl text)
RETURNS TABLE (l text, o text, node_id int,
containing_face int)
SELECT * FROM check_faces('bogus');
-- }
-
-- Remove isolated edge
SELECT 'RN(25)', topology.ST_RemEdgeNewFace('city_data', 25);
SELECT * FROM check_nodes('RN(25)/nodes');
SELECT * FROM check_faces('RN(15)/faces');
SELECT save_edges(); SELECT save_faces(); SELECT save_nodes();
-
-- Universe flooding existing single-edge (closed) face
-- with dangling edge starting from the closing node and
-- going inside.
SELECT topology.DropTopology('city_data');
-
-------------------------------------------------------------------------
-- Now test in presence of features
-------------------------------------------------------------------------
DROP FUNCTION check_nodes(text);
DELETE FROM spatial_ref_sys where srid = 4326;
-
$$ LANGUAGE 'plpgsql';
-- }
-
-- Invalid calls
SELECT 'invalid', TopoGeo_addLineString('city_data', 'SRID=4326;MULTILINESTRING((36 26, 38 30))');
SELECT 'invalid', TopoGeo_addLineString('city_data', 'SRID=4326;POINT(36 26)');
$$ LANGUAGE 'plpgsql';
-- }
-
-- Invalid calls
SELECT 'invalid', TopoGeo_addPolygon('city_data', 'MULTILINESTRING((36 26, 38 30))');
SELECT 'invalid', TopoGeo_addPolygon('city_data', 'POINT(36 26)');
SELECT id, 'dup', id, ST_Length(TopoGeom_addElement(g, '{2,2}')) FROM tt.f_line WHERE id = 1;
SELECT id, 'mis', id, ST_Length(TopoGeom_remElement(g, '{1,2}')) FROM tt.f_line WHERE id = 1;
-
DROP TABLE tt.f_line;
select droptopology('tt');
select totopogeom('TRIANGLE ((0 0, 0 9, 9 0, 0 0))'::geometry, 'tt', 4); -- TODO: support !
select totopogeom('CIRCULARSTRING(0 0, 1 1, 1 0)'::geometry, 'tt', 3); -- Unsupported feature type
-
-- Convert a point
with inp as ( select 'POINT(0 0)' ::geometry as g)
select St_AsText(g), ST_Equals(totopogeom(g, 'tt', 1)::geometry, g) from inp;
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
---
+--
--
-- PostGIS - Spatial Types for PostgreSQL
-- http://postgis.net
-- the terms of the GNU General Public Licence. See the COPYING file.
--
-- Author: Sandro Santilli <strk@kbt.io>
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- STATUS:
-- We have PostGIS-specific objects and SQL/MM objects.
-- PostGIS-specific objects have no prefix, SQL/MM ones
-- have the ``ST_' prefix.
---
+--
-- [PostGIS-specific]
--
-- TABLE topology
-- the topology.topology table.
-- TODO: add triggers (or rules, or whatever) enforcing
-- precision to the edge and node tables.
---
+--
-- FUNCTION DropTopology(name)
-- Delete a topology removing reference from the
-- topology.topology table
-- Done, can be modified to include explicit sequences or
-- more constraints. Very noisy due to implicit index creations
-- for primary keys and sequences for serial fields...
---
+--
-- ST_CreateTopoGeo
-- Complete
---
+--
-- ST_AddIsoNode
-- Complete
---
+--
-- ST_RemoveIsoNode
-- Complete
---
+--
-- ST_MoveIsoNode
-- Complete
---
+--
-- ST_AddIsoEdge
-- Complete
--
-- ST_RemoveIsoEdge
-- Complete, exceptions untested
---
+--
-- ST_ChangeEdgeGeom
-- Complete
--
-- ST_AddEdgeModFace
-- Complete
-- Also updates the Relation table
---
+--
-- ST_GetFaceEdges
-- Complete
--
-- ST_NewEdgeHeal
-- Complete
-- Also updates the Relation table
---
+--
-- ST_GetFaceGeometry
-- Implemented using ST_BuildArea()
---
+--
-- ST_RemEdgeNewFace
-- Complete
-- Also updates the Relation table
---
+--
-- ST_RemEdgeModFace
-- Complete
-- Also updates the Relation table
---
+--
-- ST_ValidateTopoGeo
-- Unimplemented (probably a wrapper around ValidateTopology)
---
---
+--
+--
-- Uninstalling previous installation isn't really a good habit ...
-- Let people decide about that
#include "../postgis/sqldefines.h"
-
CREATE SCHEMA topology;
COMMENT ON SCHEMA topology IS 'PostGIS Topology schema';
--RAISE NOTICE 'LayerTrigger called % % at % level', TG_WHEN, TG_OP, TG_LEVEL;
-
IF TG_OP = 'INSERT' THEN
RAISE EXCEPTION 'LayerTrigger not meant to be called on INSERT';
ELSIF TG_OP = 'UPDATE' THEN
RAISE EXCEPTION 'The topology.layer table cannot be updated';
END IF;
-
-- Check for existance of any feature column referencing
-- this layer
FOR rec IN SELECT * FROM pg_namespace n, pg_class c, pg_attribute a
END LOOP;
END LOOP;
-
-- Get topology name
SELECT name FROM topology.topology INTO toponame
WHERE id = OLD.topology_id;
LANGUAGE 'plpgsql' VOLATILE STRICT;
--} LayerTrigger()
-
--{
-- Layer table.
-- Stores topology layer informations
--} Layer table.
--
--- Type returned by ValidateTopology
+-- Type returned by ValidateTopology
--
CREATE TYPE topology.ValidateTopology_ReturnType AS (
error varchar,
--
-- TopoElement domain
---
+--
-- This is an array of two elements: element_id and element_type.
--
-- When used to define _simple_ TopoGeometries,
CONSTRAINT lower_dimension CHECK (
array_lower(VALUE, 1) = 1
);
-ALTER DOMAIN topology.TopoElement DROP CONSTRAINT
+ALTER DOMAIN topology.TopoElement DROP CONSTRAINT
#if POSTGIS_PGSQL_VERSION >= 92
IF EXISTS
#endif
type_range;
ALTER DOMAIN topology.TopoElement ADD
CONSTRAINT type_range CHECK (
- VALUE[2] > 0
+ VALUE[2] > 0
);
--
--RAISE NOTICE 'RelationTrigger called % % on %.relation for a %', TG_WHEN, TG_OP, toponame, TG_LEVEL;
-
IF TG_OP = 'DELETE' THEN
RAISE EXCEPTION 'RelationTrigger not meant to be called on DELETE';
END IF;
--
-- Element is a Node
--
- IF NEW.element_type = 1
+ IF NEW.element_type = 1
THEN
ok = false;
FOR rec IN EXECUTE 'SELECT node_id FROM '
--
-- Element is an Edge
--
- ELSIF NEW.element_type = 2
+ ELSIF NEW.element_type = 2
THEN
ok = false;
FOR rec IN EXECUTE 'SELECT edge_id FROM '
--
-- Element is a Face
--
- ELSIF NEW.element_type = 3
+ ELSIF NEW.element_type = 3
THEN
IF NEW.element_id = 0 THEN
RAISE EXCEPTION 'Face % cannot be associated with any feature', NEW.element_id;
END IF;
END IF;
-
+
RETURN NEW;
END;
$$
-- Add new TopoGeometry column in schema.table
--
EXECUTE 'ALTER TABLE ' || quote_ident(schema)
- || '.' || quote_ident(tbl)
+ || '.' || quote_ident(tbl)
|| ' ADD COLUMN ' || quote_ident(col)
|| ' topology.TopoGeometry;';
-
--
-- See if child id exists and extract its level
--
quote_ident(toponame) || '.layer_id_seq'
) || ')' INTO STRICT newlayer_id;
- EXECUTE 'INSERT INTO '
+ EXECUTE 'INSERT INTO '
'topology.layer(topology_id, '
'layer_id, level, child_id, schema_name, '
'table_name, feature_column, feature_type) '
|| quote_literal(col) || ','
|| intltype || ');';
-
--
-- Create a sequence for TopoGeometries in this new layer
--
-- Add constraints on TopoGeom column
--
EXECUTE 'ALTER TABLE ' || quote_ident(schema)
- || '.' || quote_ident(tbl)
+ || '.' || quote_ident(tbl)
|| ' ADD CONSTRAINT "check_topogeom_' || col || '" CHECK ('
'topology_id(' || quote_ident(col) || ') = ' || topoid
|| ' AND '
--
#if 0
--
- -- Add dependency of the topogeom sequence on the feature column
+ -- Add dependency of the topogeom sequence on the feature column
-- This is a dirty hack ...
--
query = 'INSERT INTO pg_catalog.pg_depend SELECT '
' AND fsub.attname = ' || quote_literal(col)
|| ' AND scat.relname = ''pg_class'' '
' AND snsp.nspname = ' || quote_literal(toponame)
- || ' AND sobj.relnamespace = snsp.oid '
+ || ' AND sobj.relnamespace = snsp.oid '
' AND sobj.relname = '
' ''topogeo_s_' || newlayer_id || ''' ';
RAISE EXCEPTION 'No layer registered on %.%.%',
schema,tbl,col;
END IF;
-
+
-- Clean up the topology schema
BEGIN
-- Cleanup the relation table
EXIT;
END LOOP;
-
IF ok THEN
-- Set feature column to NULL to bypass referential integrity
-- checks
$$
LANGUAGE 'sql' VOLATILE;
-
--{
-- CreateTopoGeom(topology_name, topogeom_type, layer_id, elements)
--
-- Create a TopoGeometry object from Topology elements.
--- The elements parameter is a two-dimensional array.
+-- The elements parameter is a two-dimensional array.
-- Every element of the array is either a Topology element represented by
-- (id, type) or a TopoGeometry element represented by (id, layer).
-- The actual semantic depends on the TopoGeometry layer, either at
-- level 0 (elements are topological primitives) or higer (elements
-- are TopoGeoms from child layer).
---
+--
-- @param toponame Topology name
--
-- @param tg_type Spatial type of geometry
-- @param layer_id Layer identifier
--
-- @param tg_objs Array of components
---
+--
-- Return a topology.TopoGeometry object.
--
CREATE OR REPLACE FUNCTION topology.CreateTopoGeom(toponame varchar, tg_type integer, layer_id integer, tg_objs topology.TopoElementArray)
SELECT SRID FROM topology.topology WHERE name = $1;
$$ LANGUAGE 'sql' STABLE STRICT;
--} GetTopologySRID(toponame)
-
-
--{
-- GetTopoGeomElementArray(toponame, layer_id, topogeom_id)
RAISE EXCEPTION 'Layer % does not exist', layerid;
END IF;
-
query = 'SELECT abs(element_id) as element_id, element_type FROM '
|| quote_ident(toponame) || '.relation WHERE '
' layer_id = ' || layerid
ret = '{' || rec.element_id || ',' || rec.element_type || '}';
RETURN NEXT ret;
END IF;
-
+
END LOOP;
RETURN;
-- Geometry(TopoGeometry)
--
-- Construct a Geometry from a TopoGeometry.
---
+--
-- }{
CREATE OR REPLACE FUNCTION topology.Geometry(topogeom topology.TopoGeometry)
RETURNS Geometry
|| ') = pr.element_type ';
--RAISE DEBUG '%', query;
EXECUTE sql INTO geom;
-
+
ELSIF topogeom.type = 3 THEN -- [multi]polygon -- }{
sql := 'SELECT st_multi(st_union('
'topology.ST_GetFaceGeometry('
|| quote_literal(toponame) || ','
- || 'element_id))) as g FROM '
+ || 'element_id))) as g FROM '
|| quote_ident(toponame)
|| '.relation WHERE topogeo_id = '
|| topogeom.id || ' AND layer_id = '
ELSIF topogeom.type = 2 THEN -- [multi]line -- }{
- sql :=
+ sql :=
'SELECT st_multi(ST_LineMerge(ST_Collect(e.geom))) as g FROM '
|| quote_ident(toponame) || '.edge e, '
|| quote_ident(toponame) || '.relation r '
|| ' AND r.element_type = 2 '
' AND abs(r.element_id) = e.edge_id';
EXECUTE sql INTO geom;
-
+
ELSIF topogeom.type = 1 THEN -- [multi]point -- }{
sql :=
sql := 'WITH areas AS ( SELECT ST_Union('
'topology.ST_GetFaceGeometry('
|| quote_literal(toponame) || ','
- || 'element_id)) as g FROM '
+ || 'element_id)) as g FROM '
|| quote_ident(toponame)
|| '.relation WHERE topogeo_id = '
|| topogeom.id || ' AND layer_id = '
LANGUAGE 'plpgsql' VOLATILE STRICT;
--} Geometry(TopoGeometry)
--- 7.3+ explicit cast
+-- 7.3+ explicit cast
CREATE CAST (topology.TopoGeometry AS Geometry) WITH FUNCTION topology.Geometry(topology.TopoGeometry) AS IMPLICIT;
--{
RETURN NEXT retrec;
END LOOP;
- -- Scan all edges
+ -- Scan all edges
FOR rec IN EXECUTE 'SELECT e.geom, e.edge_id as id1, e.left_face, e.right_face FROM '
|| quote_ident(toponame) || '.edge e ORDER BY edge_id'
LOOP
ELSIF ST_RelateMatch(rec.im, 'F01FFF102') THEN
-- second line (g2) is open, first (g1) is closed
-- second boundary has puntual intersection with first interior
- --
+ --
-- compute intersection, check it equals first endpoint
IF ST_Equals(ST_Intersection(rec.g2, rec.g1),
ST_StartPoint(rec.g1))
ELSIF ST_RelateMatch(rec.im, '0F1FFF1F2') THEN
-- both lines are closed (boundary intersects nothing)
-- they have puntual intersection between interiors
- --
+ --
-- compute intersection, check it's a single point
-- and equals first StartPoint _and_ second StartPoint
IF ST_Equals(ST_Intersection(rec.g1, rec.g2),
END LOOP;
-- Check for edge start_node geometry mis-match
- -- TODO: move this in the first edge table scan
+ -- TODO: move this in the first edge table scan
FOR rec IN EXECUTE 'SELECT e.edge_id as id1, n.node_id as id2 FROM '
|| quote_ident(toponame) || '.edge e, '
|| quote_ident(toponame) || '.node n '
END LOOP;
-- Check for edge end_node geometry mis-match
- -- TODO: move this in the first edge table scan
+ -- TODO: move this in the first edge table scan
FOR rec IN EXECUTE 'SELECT e.edge_id as id1, n.node_id as id2 FROM '
|| quote_ident(toponame) || '.edge e, '
|| quote_ident(toponame) || '.node n '
'face_check USING gist (geom);';
-- Build a btree index on id
- EXECUTE 'CREATE INDEX "face_check_bt" ON '
+ EXECUTE 'CREATE INDEX "face_check_bt" ON '
'face_check (face_id);';
-- Scan the table looking for NULL geometries
RETURN NEXT retrec;
END LOOP;
-
-- Scan the table looking for overlap or containment
-- TODO: also check for MBR consistency
FOR rec IN EXECUTE
RETURN NEXT retrec;
END IF;
- -- Face 1 is within face 2
+ -- Face 1 is within face 2
IF ST_RelateMatch(rec.im, 'T*F**F***') THEN
retrec.error = 'face within face';
retrec.id1 = rec.id1;
--
-- Create a topology schema, add a topology info record
-- in the topology.topology relation, return it's numeric
--- id.
+-- id.
--
CREATE OR REPLACE FUNCTION topology.CreateTopology(atopology varchar, srid integer, prec float8, hasZ boolean)
RETURNS integer
topology_id = rec.nextval;
END LOOP;
-
EXECUTE 'CREATE SCHEMA ' || quote_ident(atopology);
-------------{ face CREATION
- EXECUTE
+ EXECUTE
'CREATE TABLE ' || quote_ident(atopology) || '.face ('
'face_id SERIAL,'
' CONSTRAINT face_primary_key PRIMARY KEY(face_id)'
');';
- -- Add mbr column to the face table
+ -- Add mbr column to the face table
EXECUTE
'SELECT AddGeometryColumn('||quote_literal(atopology)
||',''face'',''mbr'','||quote_literal(srid)
-------------} END OF face CREATION
-
--------------{ node CREATION
- EXECUTE
+ EXECUTE
'CREATE TABLE ' || quote_ident(atopology) || '.node ('
'node_id SERIAL,'
--|| 'geom GEOMETRY,'
');';
- -- Add geometry column to the node table
+ -- Add geometry column to the node table
EXECUTE
'SELECT AddGeometryColumn('||quote_literal(atopology)
||',''node'',''geom'','||quote_literal(srid)
--------------{ edge CREATION
-- edge_data table
- EXECUTE
+ EXECUTE
'CREATE TABLE ' || quote_ident(atopology) || '.edge_data ('
'edge_id SERIAL NOT NULL PRIMARY KEY,'
'start_node INTEGER NOT NULL,'
' DEFERRABLE INITIALLY DEFERRED'
');';
- -- Add geometry column to the edge_data table
+ -- Add geometry column to the edge_data table
EXECUTE
'SELECT AddGeometryColumn('||quote_literal(atopology)
||',''edge_data'',''geom'','||quote_literal(srid)
||',''LINESTRING'',' || ndims || ')';
-
-- edge standard view (select rule)
EXECUTE 'CREATE VIEW ' || quote_ident(atopology)
|| '.edge AS SELECT '
--------------} END OF edge CREATION
- --------------{ layer sequence
+ --------------{ layer sequence
EXECUTE 'CREATE SEQUENCE '
|| quote_ident(atopology) || '.layer_id_seq;';
--------------} layer sequence
--------------{ relation CREATION
--
- EXECUTE
+ EXECUTE
'CREATE TABLE ' || quote_ident(atopology) || '.relation ('
' topogeo_id integer NOT NULL, '
' layer_id integer NOT NULL, '
' element_type integer NOT NULL, '
' UNIQUE(layer_id,topogeo_id,element_id,element_type));';
- EXECUTE
+ EXECUTE
'CREATE TRIGGER relation_integrity_checks '
'BEFORE UPDATE OR INSERT ON '
|| quote_ident(atopology) || '.relation FOR EACH ROW '
||topology_id||','||quote_literal(atopology)||')';
--------------} END OF relation CREATION
-
------- Default (world) face
EXECUTE 'INSERT INTO ' || quote_ident(atopology) || '.face(face_id) VALUES(0);';
|| quote_ident(atopology)
|| '.edge_data (end_node);';
- -- TODO: consider also adding an index on node.containing_face
+ -- TODO: consider also adding an index on node.containing_face
------- Add record to the "topology" metadata table
EXECUTE 'INSERT INTO topology.topology '
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
--
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--- These are reserved for functions where the they are changed to use default args
+-- These are reserved for functions where the they are changed to use default args
-- This is installed after the new functions are installed
-- We don't have any of these yet for topology
--- The reason we put these after install is
+-- The reason we put these after install is
-- you can't drop a function that is used by sql functions
--- without forcing a drop on those as well which may cause issues with user functions.
+-- without forcing a drop on those as well which may cause issues with user functions.
-- This allows us to CREATE OR REPLACE those in general topology.sql
-- without dropping them.
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
--
---
+--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- These are functions where the argument names may have changed --
-- so have to be dropped before upgrade can happen for 9.0+ --
my $time = POSIX::strftime("%c", localtime);
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
-print "-- \n";
-print "-- PostGIS - Spatial Types for PostgreSQL \n";
-print "-- http://postgis.net \n";
-print "-- \n";
-print "-- This is free software; you can redistribute and/or modify it under \n";
-print "-- the terms of the GNU General Public Licence. See the COPYING file. \n";
-print "-- \n";
+print "--\n";
+print "-- PostGIS - Spatial Types for PostgreSQL\n";
+print "-- http://postgis.net\n";
+print "--\n";
+print "-- This is free software; you can redistribute and/or modify it under\n";
+print "-- the terms of the GNU General Public Licence. See the COPYING file.\n";
+print "--\n";
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
-print "-- \n";
+print "--\n";
print "-- Generated on: " . $time . "\n";
print "-- by: " . $0 . "\n";
print "-- from: " . $ARGV[0] . "\n";
-print "-- \n";
+print "--\n";
print "-- Do not edit manually, your changes will be lost.\n";
-print "-- \n";
+print "--\n";
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
print "\n";
my $time = POSIX::strftime("%c", localtime);
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
-print "-- \n";
-print "-- PostGIS - Spatial Types for PostgreSQL \n";
-print "-- http://postgis.net \n";
-print "-- \n";
-print "-- This is free software; you can redistribute and/or modify it under \n";
-print "-- the terms of the GNU General Public Licence. See the COPYING file. \n";
-print "-- \n";
+print "--\n";
+print "-- PostGIS - Spatial Types for PostgreSQL\n";
+print "-- http://postgis.net\n";
+print "--\n";
+print "-- This is free software; you can redistribute and/or modify it under\n";
+print "-- the terms of the GNU General Public Licence. See the COPYING file.\n";
+print "--\n";
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
-print "-- \n";
+print "--\n";
print "-- Generated on: " . $time . "\n";
print "-- by: " . $0 . "\n";
print "-- for: " . $extname . "\n";
print "-- from: " . ( @ARGV ? $ARGV[0] : '-' ) . "\n";
-print "-- \n";
+print "--\n";
print "-- Do not edit manually, your changes will be lost.\n";
-print "-- \n";
+print "--\n";
print "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --\n";
print "\n";