Skip to content

Instantly share code, notes, and snippets.

@Sharpie
Created December 6, 2012 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sharpie/4d943acc25f81b1ffe9c to your computer and use it in GitHub Desktop.
Save Sharpie/4d943acc25f81b1ffe9c to your computer and use it in GitHub Desktop.
PostGIS: GCC preprocessor vs. Apple Clang v421
diff --git a/gcc/postgis_extension/postgis--2.0.0--2.0.2.sql b/clang/postgis_extension/postgis--2.0.0--2.0.2.sql
index 2b555e1..f1e028a 100644
--- a/gcc/postgis_extension/postgis--2.0.0--2.0.2.sql
+++ b/clang/postgis_extension/postgis--2.0.0--2.0.2.sql
@@ -183,671 +183,671 @@ DROP FUNCTION IF EXISTS ST_MakeEnvelope(float8, float8, float8, float8);
DROP FUNCTION IF EXISTS ST_AsX3D(geometry, integer, integer);
DROP FUNCTION IF EXISTS UpdateGeometrySRID(varchar,varchar,varchar,varchar,integer);
CREATE OR REPLACE FUNCTION spheroid_in(cstring)
- RETURNS spheroid
- AS '$libdir/postgis-2.0','ellipsoid_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS spheroid
+ AS '$libdir/postgis-2.0','ellipsoid_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION spheroid_out(spheroid)
- RETURNS cstring
- AS '$libdir/postgis-2.0','ellipsoid_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','ellipsoid_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_in(cstring)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_out(geometry)
- RETURNS cstring
- AS '$libdir/postgis-2.0','LWGEOM_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','LWGEOM_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_typmod_in(cstring[])
- RETURNS integer
- AS '$libdir/postgis-2.0','geometry_typmod_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','geometry_typmod_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_typmod_out(integer)
- RETURNS cstring
- AS '$libdir/postgis-2.0','postgis_typmod_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','postgis_typmod_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_analyze(internal)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'geometry_analyze_2d'
- LANGUAGE 'c' VOLATILE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'geometry_analyze_2d'
+ LANGUAGE 'c' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION geometry_recv(internal)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_recv'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_recv'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_send(geometry)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_send'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_send'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry(geometry, integer, boolean)
- RETURNS geometry
- AS '$libdir/postgis-2.0','geometry_enforce_typmod'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','geometry_enforce_typmod'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP CAST IF EXISTS (geometry AS geometry);
CREATE CAST (geometry AS geometry) WITH FUNCTION geometry(geometry, integer, boolean) AS IMPLICIT;
CREATE OR REPLACE FUNCTION ST_X(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_x_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_x_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Y(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_y_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_y_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Z(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_z_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_z_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_M(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_m_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_m_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box3d_in(cstring)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box3d_out(box3d)
- RETURNS cstring
- AS '$libdir/postgis-2.0', 'BOX3D_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0', 'BOX3D_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box2d_in(cstring)
- RETURNS box2d
- AS '$libdir/postgis-2.0','BOX2D_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','BOX2D_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box2d_out(box2d)
- RETURNS cstring
- AS '$libdir/postgis-2.0','BOX2D_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','BOX2D_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box2df_in(cstring)
- RETURNS box2df
- AS '$libdir/postgis-2.0','box2df_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2df
+ AS '$libdir/postgis-2.0','box2df_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box2df_out(box2df)
- RETURNS cstring
- AS '$libdir/postgis-2.0','box2df_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','box2df_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION gidx_in(cstring)
- RETURNS gidx
- AS '$libdir/postgis-2.0','gidx_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS gidx
+ AS '$libdir/postgis-2.0','gidx_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION gidx_out(gidx)
- RETURNS cstring
- AS '$libdir/postgis-2.0','gidx_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','gidx_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_lt(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_lt'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_lt'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_le(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_le'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_le'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_gt(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_gt'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_gt'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_ge(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_ge'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_ge'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_eq(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_eq'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_eq'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_cmp(geom1 geometry, geom2 geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0', 'lwgeom_cmp'
- LANGUAGE 'c' IMMUTABLE STRICT;
-CREATE OR REPLACE FUNCTION geometry_gist_distance_2d(internal,geometry,int4)
- RETURNS float8
- AS '$libdir/postgis-2.0' ,'gserialized_gist_distance_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_consistent_2d(internal,geometry,int4)
- RETURNS bool
- AS '$libdir/postgis-2.0' ,'gserialized_gist_consistent_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_compress_2d(internal)
- RETURNS internal
- AS '$libdir/postgis-2.0','gserialized_gist_compress_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_penalty_2d(internal,internal,internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_penalty_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_picksplit_2d(internal, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_picksplit_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_union_2d(bytea, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_union_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_same_2d(geom1 geometry, geom2 geometry, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_same_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_decompress_2d(internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_decompress_2d'
- LANGUAGE 'c';
+ RETURNS integer
+ AS '$libdir/postgis-2.0', 'lwgeom_cmp'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION geometry_gist_distance_2d(internal,geometry,int4)
+ RETURNS float8
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_distance_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_consistent_2d(internal,geometry,int4)
+ RETURNS bool
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_consistent_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_compress_2d(internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0','gserialized_gist_compress_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_penalty_2d(internal,internal,internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_penalty_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_picksplit_2d(internal, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_picksplit_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_union_2d(bytea, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_union_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_same_2d(geom1 geometry, geom2 geometry, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_same_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_decompress_2d(internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_decompress_2d'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION geometry_gist_sel_2d (internal, oid, internal, int4)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'geometry_gist_sel_2d'
- LANGUAGE 'c';
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'geometry_gist_sel_2d'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION geometry_gist_joinsel_2d(internal, oid, internal, smallint)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'geometry_gist_joinsel_2d'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_overlaps(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0' ,'gserialized_overlaps_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-CREATE OR REPLACE FUNCTION geometry_same(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0' ,'gserialized_same_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-CREATE OR REPLACE FUNCTION geometry_distance_centroid(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0' ,'gserialized_distance_centroid_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-CREATE OR REPLACE FUNCTION geometry_distance_box(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0' ,'gserialized_distance_box_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'geometry_gist_joinsel_2d'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_overlaps(geom1 geometry, geom2 geometry)
+ RETURNS boolean
+ AS '$libdir/postgis-2.0' ,'gserialized_overlaps_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION geometry_same(geom1 geometry, geom2 geometry)
+ RETURNS boolean
+ AS '$libdir/postgis-2.0' ,'gserialized_same_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION geometry_distance_centroid(geom1 geometry, geom2 geometry)
+ RETURNS float8
+ AS '$libdir/postgis-2.0' ,'gserialized_distance_centroid_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION geometry_distance_box(geom1 geometry, geom2 geometry)
+ RETURNS float8
+ AS '$libdir/postgis-2.0' ,'gserialized_distance_box_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_contains(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_contains_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_contains_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_within(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_within_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_within_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_left(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_left_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_left_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_overleft(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_overleft_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_overleft_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_below(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_below_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_below_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_overbelow(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_overbelow_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_overbelow_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_overright(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_overright_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_overright_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_right(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_right_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_right_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_overabove(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_overabove_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_overabove_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry_above(geom1 geometry, geom2 geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'gserialized_above_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-CREATE OR REPLACE FUNCTION geometry_gist_consistent_nd(internal,geometry,int4)
- RETURNS bool
- AS '$libdir/postgis-2.0' ,'gserialized_gist_consistent'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_compress_nd(internal)
- RETURNS internal
- AS '$libdir/postgis-2.0','gserialized_gist_compress'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_penalty_nd(internal,internal,internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_penalty'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_picksplit_nd(internal, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_picksplit'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_union_nd(bytea, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_union'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_same_nd(geometry, geometry, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_same'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_gist_decompress_nd(internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_decompress'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geometry_overlaps_nd(geometry, geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0' ,'gserialized_overlaps'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'gserialized_above_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION geometry_gist_consistent_nd(internal,geometry,int4)
+ RETURNS bool
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_consistent'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_compress_nd(internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0','gserialized_gist_compress'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_penalty_nd(internal,internal,internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_penalty'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_picksplit_nd(internal, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_picksplit'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_union_nd(bytea, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_union'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_same_nd(geometry, geometry, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_same'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_gist_decompress_nd(internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_decompress'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geometry_overlaps_nd(geometry, geometry)
+ RETURNS boolean
+ AS '$libdir/postgis-2.0' ,'gserialized_overlaps'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_affine'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_affine'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Affine(geometry,float8,float8,float8,float8,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, $2, $3, 0, $4, $5, 0, 0, 0, 1, $6, $7, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, $2, $3, 0, $4, $5, 0, 0, 0, 1, $6, $7, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Rotate(geometry,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, 0, 0, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, 0, 0, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Rotate(geometry,float8,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, $3 - cos($2) * $3 + sin($2) * $4, $4 - sin($2) * $3 - cos($2) * $4, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, $3 - cos($2) * $3 + sin($2) * $4, $4 - sin($2) * $3 - cos($2) * $4, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Rotate(geometry,float8,geometry)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, ST_X($3) - cos($2) * ST_X($3) + sin($2) * ST_Y($3), ST_Y($3) - sin($2) * ST_X($3) - cos($2) * ST_Y($3), 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, ST_X($3) - cos($2) * ST_X($3) + sin($2) * ST_Y($3), ST_Y($3) - sin($2) * ST_X($3) - cos($2) * ST_Y($3), 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_RotateZ(geometry,float8)
- RETURNS geometry
- AS 'SELECT ST_Rotate($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Rotate($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_RotateX(geometry,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, 1, 0, 0, 0, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, 1, 0, 0, 0, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_RotateY(geometry,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;
+ 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;
CREATE OR REPLACE FUNCTION ST_Translate(geometry,float8,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, 1, 0, 0, 0, 1, 0, 0, 0, 1, $2, $3, $4)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, 1, 0, 0, 0, 1, 0, 0, 0, 1, $2, $3, $4)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Translate(geometry,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Translate($1, $2, $3, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Translate($1, $2, $3, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Scale(geometry,float8,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, $2, 0, 0, 0, $3, 0, 0, 0, $4, 0, 0, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, $2, 0, 0, 0, $3, 0, 0, 0, $4, 0, 0, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Scale(geometry,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Scale($1, $2, $3, 1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Scale($1, $2, $3, 1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Transscale(geometry,float8,float8,float8,float8)
- RETURNS geometry
- AS 'SELECT ST_Affine($1, $4, 0, 0, 0, $5, 0,
- 0, 0, 1, $2 * $4, $3 * $5, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_Affine($1, $4, 0, 0, 0, $5, 0,
+ 0, 0, 1, $2 * $4, $3 * $5, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Shift_Longitude(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_longitude_shift'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_longitude_shift'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_XMin(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_xmin'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_xmin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_YMin(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_ymin'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_ymin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ZMin(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_zmin'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_zmin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_XMax(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_xmax'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_xmax'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_YMax(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_ymax'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_ymax'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ZMax(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_zmax'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_zmax'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_expand(box2d,float8)
- RETURNS box2d
- AS '$libdir/postgis-2.0', 'BOX2D_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0', 'BOX2D_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_getbbox(geometry)
- RETURNS box2d
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakeBox2d(geom1 geometry, geom2 geometry)
- RETURNS box2d
- AS '$libdir/postgis-2.0', 'BOX2D_construct'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0', 'BOX2D_construct'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Combine_BBox(box2d,geometry)
- RETURNS box2d
- AS '$libdir/postgis-2.0', 'BOX2D_combine'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0', 'BOX2D_combine'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text,text) RETURNS box2d AS
- '$libdir/postgis-2.0', 'geometry_estimated_extent'
- LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
+ '$libdir/postgis-2.0', 'geometry_estimated_extent'
+ LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text) RETURNS box2d AS
- '$libdir/postgis-2.0', 'geometry_estimated_extent'
- LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
+ '$libdir/postgis-2.0', 'geometry_estimated_extent'
+ LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
CREATE OR REPLACE FUNCTION ST_find_extent(text,text,text) RETURNS box2d AS
$$
DECLARE
- schemaname alias for $1;
- tablename alias for $2;
- columnname alias for $3;
- myrec RECORD;
+ schemaname alias for $1;
+ tablename alias for $2;
+ columnname alias for $3;
+ myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") As extent FROM "' || schemaname || '"."' || tablename || '"' LOOP
- return myrec.extent;
- END LOOP;
+ FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") As extent FROM "' || schemaname || '"."' || tablename || '"' LOOP
+ return myrec.extent;
+ END LOOP;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_find_extent(text,text) RETURNS box2d AS
$$
DECLARE
- tablename alias for $1;
- columnname alias for $2;
- myrec RECORD;
+ tablename alias for $1;
+ columnname alias for $2;
+ myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") As extent FROM "' || tablename || '"' LOOP
- return myrec.extent;
- END LOOP;
+ FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") As extent FROM "' || tablename || '"' LOOP
+ return myrec.extent;
+ END LOOP;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_addbbox(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_addBBOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_addBBOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_dropbbox(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_dropBBOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_dropBBOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_hasbbox(geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'LWGEOM_hasBBOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'LWGEOM_hasBBOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_mem_size(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_mem_size'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_mem_size'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_summary(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0', 'LWGEOM_summary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'LWGEOM_summary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Npoints(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_npoints'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_npoints'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_nrings(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_nrings'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_nrings'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_3DLength(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Length2d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length2d_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length2d_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Length(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length2d_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length2d_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_3DLength_spheroid(geometry, spheroid)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_length_spheroid(geometry, spheroid)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_length2d_spheroid(geometry, spheroid)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_length2d_ellipsoid'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','LWGEOM_length2d_ellipsoid'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DPerimeter(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_perimeter_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_perimeter_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_perimeter2d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_perimeter2d_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_perimeter2d_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Perimeter(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_perimeter2d_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_perimeter2d_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_area2d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_area_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_area_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Area(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_area_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','LWGEOM_area_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_distance_spheroid(geom1 geometry, geom2 geometry,spheroid)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_distance_ellipsoid'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','LWGEOM_distance_ellipsoid'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Distance(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_mindistance2d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_mindistance2d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_point_inside_circle(geometry,float8,float8,float8)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'LWGEOM_inside_circle_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'LWGEOM_inside_circle_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_azimuth(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_azimuth'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_azimuth'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_force_2d(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_force_3dz(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_force_3d(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_force_3dm(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_3dm'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_3dm'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_force_4d(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_4d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_4d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_force_collection(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_collection'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_collection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_CollectionExtract(geometry, integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_CollectionExtract'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_CollectionExtract'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_CollectionHomogenize(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_CollectionHomogenize'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_CollectionHomogenize'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Multi(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_multi'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_multi'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Expand(box3d,float8)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Expand(geometry,float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Envelope(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_envelope'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_envelope'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Reverse(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_reverse'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_reverse'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ForceRHR(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_clockwise_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_clockwise_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_noop(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_noop'
- LANGUAGE 'c' VOLATILE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_noop'
+ LANGUAGE 'c' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION ST_zmflag(geometry)
- RETURNS smallint
- AS '$libdir/postgis-2.0', 'LWGEOM_zmflag'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS smallint
+ AS '$libdir/postgis-2.0', 'LWGEOM_zmflag'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_NDims(geometry)
- RETURNS smallint
- AS '$libdir/postgis-2.0', 'LWGEOM_ndims'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS smallint
+ AS '$libdir/postgis-2.0', 'LWGEOM_ndims'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsEWKT(geometry)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asEWKT'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asEWKT'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsEWKB(geometry)
- RETURNS BYTEA
- AS '$libdir/postgis-2.0','WKBFromLWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS BYTEA
+ AS '$libdir/postgis-2.0','WKBFromLWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsHEXEWKB(geometry)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsHEXEWKB(geometry, text)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsEWKB(geometry,text)
- RETURNS bytea
- AS '$libdir/postgis-2.0','WKBFromLWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','WKBFromLWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsLatLonText(geometry, text)
- RETURNS text
- AS '$libdir/postgis-2.0','LWGEOM_to_latlon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','LWGEOM_to_latlon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsLatLonText(geometry)
- RETURNS text
- AS $$ SELECT ST_AsLatLonText($1, '') $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text
+ AS $$ SELECT ST_AsLatLonText($1, '') $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION GeomFromEWKB(bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOMFromWKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOMFromWKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromEWKB(bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOMFromWKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOMFromWKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION GeomFromEWKT(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromEWKT(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_cache_bbox()
- RETURNS trigger
- AS '$libdir/postgis-2.0', 'cache_bbox'
- LANGUAGE 'c';
+ RETURNS trigger
+ AS '$libdir/postgis-2.0', 'cache_bbox'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION ST_MakePoint(float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakePoint(float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakePoint(float8, float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakePointM(float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint3dm'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint3dm'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_3DMakeBox(geom1 geometry, geom2 geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_construct'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_construct'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakeLine (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makeline_garray'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makeline_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LineFromMultiPoint(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_line_from_mpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_from_mpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakeLine(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makeline'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makeline'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AddPoint(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AddPoint(geom1 geometry, geom2 geometry, integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_RemovePoint(geometry, integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_removepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_removepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SetPoint(geometry, integer, geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_setpoint_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_setpoint_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakeEnvelope(float8, float8, float8, float8, integer DEFAULT 0)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_MakeEnvelope'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_MakeEnvelope'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakePolygon(geometry, geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MakePolygon(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_BuildArea(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_BuildArea'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_BuildArea'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Polygonize (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'polygonize_garray'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'polygonize_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_LineMerge(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'linemerge'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'linemerge'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Dump(geometry)
- RETURNS SETOF geometry_dump
- AS '$libdir/postgis-2.0', 'LWGEOM_dump'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS SETOF geometry_dump
+ AS '$libdir/postgis-2.0', 'LWGEOM_dump'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_DumpRings(geometry)
- RETURNS SETOF geometry_dump
- AS '$libdir/postgis-2.0', 'LWGEOM_dump_rings'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS SETOF geometry_dump
+ AS '$libdir/postgis-2.0', 'LWGEOM_dump_rings'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_DumpPoints(the_geom geometry, cur_path integer[]) RETURNS SETOF geometry_dump AS $$
DECLARE
tmp geometry_dump;
@@ -857,28 +857,28 @@ DECLARE
i integer;
j integer;
g geometry;
-
+
BEGIN
-
+
-- RAISE DEBUG '%,%', cur_path, ST_GeometryType(the_geom);
-- Special case collections : iterate and return the DumpPoints of the geometries
IF (ST_IsCollection(the_geom)) THEN
-
+
i = 1;
FOR tmp2 IN SELECT (ST_Dump(the_geom)).* LOOP
FOR tmp IN SELECT * FROM _ST_DumpPoints(tmp2.geom, cur_path || tmp2.path) LOOP
- RETURN NEXT tmp;
+ RETURN NEXT tmp;
END LOOP;
i = i + 1;
-
+
END LOOP;
RETURN;
END IF;
-
+
-- Special case (POLYGON) : return the points of the rings of a polygon
IF (ST_GeometryType(the_geom) = 'ST_Polygon') THEN
@@ -886,14 +886,14 @@ BEGIN
FOR tmp IN SELECT * FROM _ST_DumpPoints(ST_ExteriorRing(the_geom), cur_path || ARRAY[1]) LOOP
RETURN NEXT tmp;
END LOOP;
-
+
j := ST_NumInteriorRings(the_geom);
FOR i IN 1..j LOOP
FOR tmp IN SELECT * FROM _ST_DumpPoints(ST_InteriorRingN(the_geom, i), cur_path || ARRAY[i+1]) LOOP
RETURN NEXT tmp;
END LOOP;
END LOOP;
-
+
RETURN;
END IF;
@@ -903,11 +903,11 @@ BEGIN
FOR tmp IN SELECT * FROM _ST_DumpPoints(ST_ExteriorRing(the_geom), cur_path || ARRAY[1]) LOOP
RETURN NEXT tmp;
END LOOP;
-
+
RETURN;
END IF;
-
+
-- Special case (POINT) : return the point
IF (ST_GeometryType(the_geom) = 'ST_Point') THEN
@@ -934,154 +934,154 @@ BEGIN
tmp.geom := ST_PointN(the_geom, i);
RETURN NEXT tmp;
END LOOP;
-
+
END
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION ST_DumpPoints(geometry) RETURNS SETOF geometry_dump AS $$
SELECT * FROM _ST_DumpPoints($1, NULL);
-$$ LANGUAGE SQL STRICT;
+$$ LANGUAGE SQL STRICT;
CREATE OR REPLACE FUNCTION populate_geometry_columns(use_typmod boolean DEFAULT true)
- RETURNS text AS
+ RETURNS text AS
$$
DECLARE
- inserted integer;
- oldcount integer;
- probed integer;
- stale integer;
- gcs RECORD;
- gc RECORD;
- gsrid integer;
- gndims integer;
- gtype text;
- query text;
- gc_is_valid boolean;
+ inserted integer;
+ oldcount integer;
+ probed integer;
+ stale integer;
+ gcs RECORD;
+ gc RECORD;
+ gsrid integer;
+ gndims integer;
+ gtype text;
+ query text;
+ gc_is_valid boolean;
BEGIN
- SELECT count(*) INTO oldcount FROM geometry_columns;
- inserted := 0;
-
- -- Count the number of geometry columns in all tables and views
- SELECT count(DISTINCT c.oid) INTO probed
- FROM pg_class c,
- pg_attribute a,
- pg_type t,
- pg_namespace n
- WHERE (c.relkind = 'r' OR c.relkind = 'v')
- AND t.typname = 'geometry'
- AND a.attisdropped = false
- AND a.atttypid = t.oid
- AND a.attrelid = c.oid
- AND c.relnamespace = n.oid
- AND n.nspname NOT ILIKE 'pg_temp%' AND c.relname != 'raster_columns' ;
-
- -- Iterate through all non-dropped geometry columns
- RAISE DEBUG 'Processing Tables.....';
-
- FOR gcs IN
- SELECT DISTINCT ON (c.oid) c.oid, n.nspname, c.relname
- FROM pg_class c,
- pg_attribute a,
- pg_type t,
- pg_namespace n
- WHERE c.relkind = 'r'
- AND t.typname = 'geometry'
- AND a.attisdropped = false
- AND a.atttypid = t.oid
- AND a.attrelid = c.oid
- AND c.relnamespace = n.oid
- AND n.nspname NOT ILIKE 'pg_temp%' AND c.relname != 'raster_columns'
- LOOP
-
- inserted := inserted + populate_geometry_columns(gcs.oid, use_typmod);
- END LOOP;
-
- IF oldcount > inserted THEN
- stale = oldcount-inserted;
- ELSE
- stale = 0;
- END IF;
-
- RETURN 'probed:' ||probed|| ' inserted:'||inserted;
+ SELECT count(*) INTO oldcount FROM geometry_columns;
+ inserted := 0;
+
+ -- Count the number of geometry columns in all tables and views
+ SELECT count(DISTINCT c.oid) INTO probed
+ FROM pg_class c,
+ pg_attribute a,
+ pg_type t,
+ pg_namespace n
+ WHERE (c.relkind = 'r' OR c.relkind = 'v')
+ AND t.typname = 'geometry'
+ AND a.attisdropped = false
+ AND a.atttypid = t.oid
+ AND a.attrelid = c.oid
+ AND c.relnamespace = n.oid
+ AND n.nspname NOT ILIKE 'pg_temp%' AND c.relname != 'raster_columns' ;
+
+ -- Iterate through all non-dropped geometry columns
+ RAISE DEBUG 'Processing Tables.....';
+
+ FOR gcs IN
+ SELECT DISTINCT ON (c.oid) c.oid, n.nspname, c.relname
+ FROM pg_class c,
+ pg_attribute a,
+ pg_type t,
+ pg_namespace n
+ WHERE c.relkind = 'r'
+ AND t.typname = 'geometry'
+ AND a.attisdropped = false
+ AND a.atttypid = t.oid
+ AND a.attrelid = c.oid
+ AND c.relnamespace = n.oid
+ AND n.nspname NOT ILIKE 'pg_temp%' AND c.relname != 'raster_columns'
+ LOOP
+
+ inserted := inserted + populate_geometry_columns(gcs.oid, use_typmod);
+ END LOOP;
+
+ IF oldcount > inserted THEN
+ stale = oldcount-inserted;
+ ELSE
+ stale = 0;
+ END IF;
+
+ RETURN 'probed:' ||probed|| ' inserted:'||inserted;
END
$$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION populate_geometry_columns(tbl_oid oid, use_typmod boolean DEFAULT true)
- RETURNS integer AS
+ RETURNS integer AS
$$
DECLARE
- gcs RECORD;
- gc RECORD;
- gc_old RECORD;
- gsrid integer;
- gndims integer;
- gtype text;
- query text;
- gc_is_valid boolean;
- inserted integer;
- constraint_successful boolean := false;
+ gcs RECORD;
+ gc RECORD;
+ gc_old RECORD;
+ gsrid integer;
+ gndims integer;
+ gtype text;
+ query text;
+ gc_is_valid boolean;
+ inserted integer;
+ constraint_successful boolean := false;
BEGIN
- inserted := 0;
-
- -- Iterate through all geometry columns in this table
- FOR gcs IN
- SELECT n.nspname, c.relname, a.attname
- FROM pg_class c,
- pg_attribute a,
- pg_type t,
- pg_namespace n
- WHERE c.relkind = 'r'
- AND t.typname = 'geometry'
- AND a.attisdropped = false
- AND a.atttypid = t.oid
- AND a.attrelid = c.oid
- AND c.relnamespace = n.oid
- AND n.nspname NOT ILIKE 'pg_temp%'
- AND c.oid = tbl_oid
- LOOP
+ inserted := 0;
+
+ -- Iterate through all geometry columns in this table
+ FOR gcs IN
+ SELECT n.nspname, c.relname, a.attname
+ FROM pg_class c,
+ pg_attribute a,
+ pg_type t,
+ pg_namespace n
+ WHERE c.relkind = 'r'
+ AND t.typname = 'geometry'
+ AND a.attisdropped = false
+ AND a.atttypid = t.oid
+ AND a.attrelid = c.oid
+ AND c.relnamespace = n.oid
+ AND n.nspname NOT ILIKE 'pg_temp%'
+ AND c.oid = tbl_oid
+ LOOP
RAISE DEBUG 'Processing table %.%.%', gcs.nspname, gcs.relname, gcs.attname;
-
+
gc_is_valid := true;
-- Find the srid, coord_dimension, and type of current geometry
-- in geometry_columns -- which is now a view
-
- SELECT type, srid, coord_dimension INTO gc_old
- FROM geometry_columns
- WHERE f_table_schema = gcs.nspname AND f_table_name = gcs.relname AND f_geometry_column = gcs.attname;
-
+
+ SELECT type, srid, coord_dimension INTO gc_old
+ FROM geometry_columns
+ WHERE f_table_schema = gcs.nspname AND f_table_name = gcs.relname AND f_geometry_column = gcs.attname;
+
IF upper(gc_old.type) = 'GEOMETRY' THEN
-- This is an unconstrained geometry we need to do something
-- We need to figure out what to set the type by inspecting the data
EXECUTE 'SELECT st_srid(' || quote_ident(gcs.attname) || ') As srid, GeometryType(' || quote_ident(gcs.attname) || ') As type, ST_NDims(' || quote_ident(gcs.attname) || ') As dims ' ||
- ' FROM ONLY ' || quote_ident(gcs.nspname) || '.' || quote_ident(gcs.relname) ||
+ ' FROM ONLY ' || quote_ident(gcs.nspname) || '.' || quote_ident(gcs.relname) ||
' WHERE ' || quote_ident(gcs.attname) || ' IS NOT NULL LIMIT 1;'
INTO gc;
IF gc IS NULL THEN -- there is no data so we can not determine geometry type
- RAISE WARNING 'No data in table %.%, so no information to determine geometry type and srid', gcs.nspname, gcs.relname;
- RETURN 0;
+ RAISE WARNING 'No data in table %.%, so no information to determine geometry type and srid', gcs.nspname, gcs.relname;
+ RETURN 0;
END IF;
gsrid := gc.srid; gtype := gc.type; gndims := gc.dims;
-
+
IF use_typmod THEN
BEGIN
- EXECUTE 'ALTER TABLE ' || quote_ident(gcs.nspname) || '.' || quote_ident(gcs.relname) || ' ALTER COLUMN ' || quote_ident(gcs.attname) ||
- ' TYPE geometry(' || postgis_type_name(gtype, gndims, true) || ', ' || gsrid::text || ') ';
+ EXECUTE 'ALTER TABLE ' || quote_ident(gcs.nspname) || '.' || quote_ident(gcs.relname) || ' ALTER COLUMN ' || quote_ident(gcs.attname) ||
+ ' TYPE geometry(' || postgis_type_name(gtype, gndims, true) || ', ' || gsrid::text || ') ';
inserted := inserted + 1;
EXCEPTION
WHEN invalid_parameter_value THEN
RAISE WARNING 'Could not convert ''%'' in ''%.%'' to use typmod with srid %, type: % ', quote_ident(gcs.attname), quote_ident(gcs.nspname), quote_ident(gcs.relname), gsrid, postgis_type_name(gtype, gndims, true);
gc_is_valid := false;
END;
-
+
ELSE
-- Try to apply srid check to column
- constraint_successful = false;
+ constraint_successful = false;
IF (gsrid > 0 AND postgis_constraint_srid(gcs.nspname, gcs.relname,gcs.attname) IS NULL ) THEN
BEGIN
- EXECUTE 'ALTER TABLE ONLY ' || quote_ident(gcs.nspname) || '.' || quote_ident(gcs.relname) ||
- ' ADD CONSTRAINT ' || quote_ident('enforce_srid_' || gcs.attname) ||
+ EXECUTE 'ALTER TABLE ONLY ' || quote_ident(gcs.nspname) || '.' || quote_ident(gcs.relname) ||
+ ' ADD CONSTRAINT ' || quote_ident('enforce_srid_' || gcs.attname) ||
' CHECK (st_srid(' || quote_ident(gcs.attname) || ') = ' || gsrid || ')';
constraint_successful := true;
EXCEPTION
@@ -1090,7 +1090,7 @@ BEGIN
gc_is_valid := false;
END;
END IF;
-
+
-- Try to apply ndims check to column
IF (gndims IS NOT NULL AND postgis_constraint_dims(gcs.nspname, gcs.relname,gcs.attname) IS NULL ) THEN
BEGIN
@@ -1104,7 +1104,7 @@ BEGIN
gc_is_valid := false;
END;
END IF;
-
+
-- Try to apply geometrytype check to column
IF (gtype IS NOT NULL AND postgis_constraint_type(gcs.nspname, gcs.relname,gcs.attname) IS NULL ) THEN
BEGIN
@@ -1120,133 +1120,133 @@ BEGIN
END IF;
--only count if we were successful in applying at least one constraint
IF constraint_successful THEN
- inserted := inserted + 1;
+ inserted := inserted + 1;
END IF;
- END IF;
- END IF;
+ END IF;
+ END IF;
- END LOOP;
+ END LOOP;
- RETURN inserted;
+ RETURN inserted;
END
$$
LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION AddGeometryColumn(catalog_name varchar,schema_name varchar,table_name varchar,column_name varchar,new_srid_in integer,new_type varchar,new_dim integer, use_typmod boolean DEFAULT true)
- RETURNS text
- AS
+ RETURNS text
+ AS
$$
DECLARE
- rec RECORD;
- sr varchar;
- real_schema name;
- sql text;
- new_srid integer;
+ rec RECORD;
+ sr varchar;
+ real_schema name;
+ sql text;
+ new_srid integer;
BEGIN
- -- Verify geometry type
- IF (postgis_type_name(new_type,new_dim) IS NULL )
- THEN
- RAISE EXCEPTION 'Invalid type name "%(%)" - valid ones are:
- POINT, MULTIPOINT,
- LINESTRING, MULTILINESTRING,
- POLYGON, MULTIPOLYGON,
- CIRCULARSTRING, COMPOUNDCURVE, MULTICURVE,
- CURVEPOLYGON, MULTISURFACE,
- GEOMETRY, GEOMETRYCOLLECTION,
- POINTM, MULTIPOINTM,
- LINESTRINGM, MULTILINESTRINGM,
- POLYGONM, MULTIPOLYGONM,
- CIRCULARSTRINGM, COMPOUNDCURVEM, MULTICURVEM
- CURVEPOLYGONM, MULTISURFACEM, TRIANGLE, TRIANGLEM,
- POLYHEDRALSURFACE, POLYHEDRALSURFACEM, TIN, TINM
- or GEOMETRYCOLLECTIONM', new_type, new_dim;
- RETURN 'fail';
- END IF;
-
-
- -- Verify dimension
- IF ( (new_dim >4) OR (new_dim <2) ) THEN
- RAISE EXCEPTION 'invalid dimension';
- RETURN 'fail';
- END IF;
-
- IF ( (new_type LIKE '%M') AND (new_dim!=3) ) THEN
- RAISE EXCEPTION 'TypeM needs 3 dimensions';
- RETURN 'fail';
- END IF;
-
-
- -- Verify SRID
- IF ( new_srid_in > 0 ) THEN
- IF new_srid_in > 998999 THEN
- RAISE EXCEPTION 'AddGeometryColumn() - SRID must be <= %', 998999;
- END IF;
- new_srid := new_srid_in;
- SELECT SRID INTO sr FROM spatial_ref_sys WHERE SRID = new_srid;
- IF NOT FOUND THEN
- RAISE EXCEPTION 'AddGeometryColumn() - invalid SRID';
- RETURN 'fail';
- END IF;
- ELSE
- new_srid := ST_SRID('POINT EMPTY'::geometry);
- IF ( new_srid_in != new_srid ) THEN
- RAISE NOTICE 'SRID value % converted to the officially unknown SRID value %', new_srid_in, new_srid;
- END IF;
- END IF;
-
+ -- Verify geometry type
+ IF (postgis_type_name(new_type,new_dim) IS NULL )
+ THEN
+ RAISE EXCEPTION 'Invalid type name "%(%)" - valid ones are:
+ POINT, MULTIPOINT,
+ LINESTRING, MULTILINESTRING,
+ POLYGON, MULTIPOLYGON,
+ CIRCULARSTRING, COMPOUNDCURVE, MULTICURVE,
+ CURVEPOLYGON, MULTISURFACE,
+ GEOMETRY, GEOMETRYCOLLECTION,
+ POINTM, MULTIPOINTM,
+ LINESTRINGM, MULTILINESTRINGM,
+ POLYGONM, MULTIPOLYGONM,
+ CIRCULARSTRINGM, COMPOUNDCURVEM, MULTICURVEM
+ CURVEPOLYGONM, MULTISURFACEM, TRIANGLE, TRIANGLEM,
+ POLYHEDRALSURFACE, POLYHEDRALSURFACEM, TIN, TINM
+ or GEOMETRYCOLLECTIONM', new_type, new_dim;
+ RETURN 'fail';
+ END IF;
+
+
+ -- Verify dimension
+ IF ( (new_dim >4) OR (new_dim <2) ) THEN
+ RAISE EXCEPTION 'invalid dimension';
+ RETURN 'fail';
+ END IF;
+
+ IF ( (new_type LIKE '%M') AND (new_dim!=3) ) THEN
+ RAISE EXCEPTION 'TypeM needs 3 dimensions';
+ RETURN 'fail';
+ END IF;
+
+
+ -- Verify SRID
+ IF ( new_srid_in > 0 ) THEN
+ IF new_srid_in > 998999 THEN
+ RAISE EXCEPTION 'AddGeometryColumn() - SRID must be <= %', 998999;
+ END IF;
+ new_srid := new_srid_in;
+ SELECT SRID INTO sr FROM spatial_ref_sys WHERE SRID = new_srid;
+ IF NOT FOUND THEN
+ RAISE EXCEPTION 'AddGeometryColumn() - invalid SRID';
+ RETURN 'fail';
+ END IF;
+ ELSE
+ new_srid := ST_SRID('POINT EMPTY'::geometry);
+ IF ( new_srid_in != new_srid ) THEN
+ RAISE NOTICE 'SRID value % converted to the officially unknown SRID value %', new_srid_in, new_srid;
+ END IF;
+ END IF;
- -- Verify schema
- IF ( schema_name IS NOT NULL AND schema_name != '' ) THEN
- sql := 'SELECT nspname FROM pg_namespace ' ||
- 'WHERE text(nspname) = ' || quote_literal(schema_name) ||
- 'LIMIT 1';
- RAISE DEBUG '%', sql;
- EXECUTE sql INTO real_schema;
- IF ( real_schema IS NULL ) THEN
- RAISE EXCEPTION 'Schema % is not a valid schemaname', quote_literal(schema_name);
- RETURN 'fail';
- END IF;
- END IF;
+ -- Verify schema
+ IF ( schema_name IS NOT NULL AND schema_name != '' ) THEN
+ sql := 'SELECT nspname FROM pg_namespace ' ||
+ 'WHERE text(nspname) = ' || quote_literal(schema_name) ||
+ 'LIMIT 1';
+ RAISE DEBUG '%', sql;
+ EXECUTE sql INTO real_schema;
- IF ( real_schema IS NULL ) THEN
- RAISE DEBUG 'Detecting schema';
- sql := 'SELECT n.nspname AS schemaname ' ||
- 'FROM pg_catalog.pg_class c ' ||
- 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace ' ||
- 'WHERE c.relkind = ' || quote_literal('r') ||
- ' AND n.nspname NOT IN (' || quote_literal('pg_catalog') || ', ' || quote_literal('pg_toast') || ')' ||
- ' AND pg_catalog.pg_table_is_visible(c.oid)' ||
- ' AND c.relname = ' || quote_literal(table_name);
- RAISE DEBUG '%', sql;
- EXECUTE sql INTO real_schema;
-
- IF ( real_schema IS NULL ) THEN
- RAISE EXCEPTION 'Table % does not occur in the search_path', quote_literal(table_name);
- RETURN 'fail';
- END IF;
- END IF;
+ IF ( real_schema IS NULL ) THEN
+ RAISE EXCEPTION 'Schema % is not a valid schemaname', quote_literal(schema_name);
+ RETURN 'fail';
+ END IF;
+ END IF;
+
+ IF ( real_schema IS NULL ) THEN
+ RAISE DEBUG 'Detecting schema';
+ sql := 'SELECT n.nspname AS schemaname ' ||
+ 'FROM pg_catalog.pg_class c ' ||
+ 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace ' ||
+ 'WHERE c.relkind = ' || quote_literal('r') ||
+ ' AND n.nspname NOT IN (' || quote_literal('pg_catalog') || ', ' || quote_literal('pg_toast') || ')' ||
+ ' AND pg_catalog.pg_table_is_visible(c.oid)' ||
+ ' AND c.relname = ' || quote_literal(table_name);
+ RAISE DEBUG '%', sql;
+ EXECUTE sql INTO real_schema;
+
+ IF ( real_schema IS NULL ) THEN
+ RAISE EXCEPTION 'Table % does not occur in the search_path', quote_literal(table_name);
+ RETURN 'fail';
+ END IF;
+ END IF;
- -- Add geometry column to table
- IF use_typmod THEN
- sql := 'ALTER TABLE ' ||
+ -- Add geometry column to table
+ IF use_typmod THEN
+ sql := 'ALTER TABLE ' ||
quote_ident(real_schema) || '.' || quote_ident(table_name)
|| ' ADD COLUMN ' || quote_ident(column_name) ||
' geometry(' || postgis_type_name(new_type, new_dim) || ', ' || new_srid::text || ')';
RAISE DEBUG '%', sql;
- ELSE
+ ELSE
sql := 'ALTER TABLE ' ||
quote_ident(real_schema) || '.' || quote_ident(table_name)
|| ' ADD COLUMN ' || quote_ident(column_name) ||
' geometry ';
RAISE DEBUG '%', sql;
END IF;
- EXECUTE sql;
+ EXECUTE sql;
- IF NOT use_typmod THEN
+ IF NOT use_typmod THEN
-- Add table CHECKs
sql := 'ALTER TABLE ' ||
quote_ident(real_schema) || '.' || quote_ident(table_name)
@@ -1256,7 +1256,7 @@ BEGIN
') = ' || new_srid::text || ')' ;
RAISE DEBUG '%', sql;
EXECUTE sql;
-
+
sql := 'ALTER TABLE ' ||
quote_ident(real_schema) || '.' || quote_ident(table_name)
|| ' ADD CONSTRAINT '
@@ -1265,7 +1265,7 @@ BEGIN
') = ' || new_dim::text || ')' ;
RAISE DEBUG '%', sql;
EXECUTE sql;
-
+
IF ( NOT (new_type = 'GEOMETRY')) THEN
sql := 'ALTER TABLE ' ||
quote_ident(real_schema) || '.' || quote_ident(table_name) || ' ADD CONSTRAINT ' ||
@@ -1279,131 +1279,131 @@ BEGIN
END IF;
END IF;
- RETURN
- real_schema || '.' ||
- table_name || '.' || column_name ||
- ' SRID:' || new_srid::text ||
- ' TYPE:' || new_type ||
- ' DIMS:' || new_dim::text || ' ';
+ RETURN
+ real_schema || '.' ||
+ table_name || '.' || column_name ||
+ ' SRID:' || new_srid::text ||
+ ' TYPE:' || new_type ||
+ ' DIMS:' || new_dim::text || ' ';
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION AddGeometryColumn(schema_name varchar,table_name varchar,column_name varchar,new_srid integer,new_type varchar,new_dim integer, use_typmod boolean DEFAULT true) RETURNS text AS $$
DECLARE
- ret text;
+ ret text;
BEGIN
- SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7) into ret;
- RETURN ret;
+ SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6,$7) into ret;
+ RETURN ret;
END;
$$
LANGUAGE 'plpgsql' STABLE STRICT;
CREATE OR REPLACE FUNCTION AddGeometryColumn(table_name varchar,column_name varchar,new_srid integer,new_type varchar,new_dim integer, use_typmod boolean DEFAULT true) RETURNS text AS $$
DECLARE
- ret text;
+ ret text;
BEGIN
- SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5, $6) into ret;
- RETURN ret;
+ SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5, $6) into ret;
+ RETURN ret;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION DropGeometryColumn(catalog_name varchar, schema_name varchar,table_name varchar,column_name varchar)
- RETURNS text
- AS
+ RETURNS text
+ AS
$$
DECLARE
- myrec RECORD;
- okay boolean;
- real_schema name;
+ myrec RECORD;
+ okay boolean;
+ real_schema name;
BEGIN
- -- Find, check or fix schema_name
- IF ( schema_name != '' ) THEN
- okay = false;
-
- FOR myrec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
- okay := true;
- END LOOP;
-
- IF ( okay <> true ) THEN
- RAISE NOTICE 'Invalid schema name - using current_schema()';
- SELECT current_schema() into real_schema;
- ELSE
- real_schema = schema_name;
- END IF;
- ELSE
- SELECT current_schema() into real_schema;
- END IF;
-
- -- Find out if the column is in the geometry_columns table
- okay = false;
- FOR myrec IN SELECT * from geometry_columns where f_table_schema = text(real_schema) and f_table_name = table_name and f_geometry_column = column_name LOOP
- okay := true;
- END LOOP;
- IF (okay <> true) THEN
- RAISE EXCEPTION 'column not found in geometry_columns table';
- RETURN false;
- END IF;
+ -- Find, check or fix schema_name
+ IF ( schema_name != '' ) THEN
+ okay = false;
- -- Remove table column
- EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) || '.' ||
- quote_ident(table_name) || ' DROP COLUMN ' ||
- quote_ident(column_name);
+ FOR myrec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
+ okay := true;
+ END LOOP;
- RETURN real_schema || '.' || table_name || '.' || column_name ||' effectively removed.';
+ IF ( okay <> true ) THEN
+ RAISE NOTICE 'Invalid schema name - using current_schema()';
+ SELECT current_schema() into real_schema;
+ ELSE
+ real_schema = schema_name;
+ END IF;
+ ELSE
+ SELECT current_schema() into real_schema;
+ END IF;
+
+ -- Find out if the column is in the geometry_columns table
+ okay = false;
+ FOR myrec IN SELECT * from geometry_columns where f_table_schema = text(real_schema) and f_table_name = table_name and f_geometry_column = column_name LOOP
+ okay := true;
+ END LOOP;
+ IF (okay <> true) THEN
+ RAISE EXCEPTION 'column not found in geometry_columns table';
+ RETURN false;
+ END IF;
+
+ -- Remove table column
+ EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) || '.' ||
+ quote_ident(table_name) || ' DROP COLUMN ' ||
+ quote_ident(column_name);
+
+ RETURN real_schema || '.' || table_name || '.' || column_name ||' effectively removed.';
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION DropGeometryColumn(schema_name varchar, table_name varchar,column_name varchar)
- RETURNS text
- AS
+ RETURNS text
+ AS
$$
DECLARE
- ret text;
+ ret text;
BEGIN
- SELECT DropGeometryColumn('',$1,$2,$3) into ret;
- RETURN ret;
+ SELECT DropGeometryColumn('',$1,$2,$3) into ret;
+ RETURN ret;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION DropGeometryColumn(table_name varchar, column_name varchar)
- RETURNS text
- AS
+ RETURNS text
+ AS
$$
DECLARE
- ret text;
+ ret text;
BEGIN
- SELECT DropGeometryColumn('','',$1,$2) into ret;
- RETURN ret;
+ SELECT DropGeometryColumn('','',$1,$2) into ret;
+ RETURN ret;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION DropGeometryTable(catalog_name varchar, schema_name varchar, table_name varchar)
- RETURNS text
- AS
+ RETURNS text
+ AS
$$
DECLARE
- real_schema name;
+ real_schema name;
BEGIN
- IF ( schema_name = '' ) THEN
- SELECT current_schema() into real_schema;
- ELSE
- real_schema = schema_name;
- END IF;
+ IF ( schema_name = '' ) THEN
+ SELECT current_schema() into real_schema;
+ ELSE
+ real_schema = schema_name;
+ END IF;
- -- TODO: Should we warn if table doesn't exist probably instead just saying dropped
- -- Remove table
- EXECUTE 'DROP TABLE IF EXISTS '
- || quote_ident(real_schema) || '.' ||
- quote_ident(table_name) || ' RESTRICT';
+ -- TODO: Should we warn if table doesn't exist probably instead just saying dropped
+ -- Remove table
+ EXECUTE 'DROP TABLE IF EXISTS '
+ || quote_ident(real_schema) || '.' ||
+ quote_ident(table_name) || ' RESTRICT';
- RETURN
- real_schema || '.' ||
- table_name ||' dropped.';
+ RETURN
+ real_schema || '.' ||
+ table_name ||' dropped.';
END;
$$
@@ -1415,365 +1415,365 @@ CREATE OR REPLACE FUNCTION DropGeometryTable(table_name varchar) RETURNS text AS
$$ SELECT DropGeometryTable('','',$1) $$
LANGUAGE 'sql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION UpdateGeometrySRID(catalogn_name varchar,schema_name varchar,table_name varchar,column_name varchar,new_srid_in integer)
- RETURNS text
- AS
+ RETURNS text
+ AS
$$
DECLARE
- myrec RECORD;
- okay boolean;
- cname varchar;
- real_schema name;
- unknown_srid integer;
- new_srid integer := new_srid_in;
+ myrec RECORD;
+ okay boolean;
+ cname varchar;
+ real_schema name;
+ unknown_srid integer;
+ new_srid integer := new_srid_in;
BEGIN
- -- Find, check or fix schema_name
- IF ( schema_name != '' ) THEN
- okay = false;
-
- FOR myrec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
- okay := true;
- END LOOP;
-
- IF ( okay <> true ) THEN
- RAISE EXCEPTION 'Invalid schema name';
- ELSE
- real_schema = schema_name;
- END IF;
- ELSE
- SELECT INTO real_schema current_schema()::text;
- END IF;
+ -- Find, check or fix schema_name
+ IF ( schema_name != '' ) THEN
+ okay = false;
- -- Ensure that column_name is in geometry_columns
- okay = false;
- FOR myrec IN SELECT type, coord_dimension FROM geometry_columns WHERE f_table_schema = text(real_schema) and f_table_name = table_name and f_geometry_column = column_name LOOP
- okay := true;
- END LOOP;
- IF (NOT okay) THEN
- RAISE EXCEPTION 'column not found in geometry_columns table';
- RETURN false;
- END IF;
+ FOR myrec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
+ okay := true;
+ END LOOP;
- -- Ensure that new_srid is valid
- IF ( new_srid > 0 ) THEN
- IF ( SELECT count(*) = 0 from spatial_ref_sys where srid = new_srid ) THEN
- RAISE EXCEPTION 'invalid SRID: % not found in spatial_ref_sys', new_srid;
- RETURN false;
- END IF;
- ELSE
- unknown_srid := ST_SRID('POINT EMPTY'::geometry);
- IF ( new_srid != unknown_srid ) THEN
- new_srid := unknown_srid;
- RAISE NOTICE 'SRID value % converted to the officially unknown SRID value %', new_srid_in, new_srid;
- END IF;
- END IF;
+ IF ( okay <> true ) THEN
+ RAISE EXCEPTION 'Invalid schema name';
+ ELSE
+ real_schema = schema_name;
+ END IF;
+ ELSE
+ SELECT INTO real_schema current_schema()::text;
+ END IF;
+
+ -- Ensure that column_name is in geometry_columns
+ okay = false;
+ FOR myrec IN SELECT type, coord_dimension FROM geometry_columns WHERE f_table_schema = text(real_schema) and f_table_name = table_name and f_geometry_column = column_name LOOP
+ okay := true;
+ END LOOP;
+ IF (NOT okay) THEN
+ RAISE EXCEPTION 'column not found in geometry_columns table';
+ RETURN false;
+ END IF;
+
+ -- Ensure that new_srid is valid
+ IF ( new_srid > 0 ) THEN
+ IF ( SELECT count(*) = 0 from spatial_ref_sys where srid = new_srid ) THEN
+ RAISE EXCEPTION 'invalid SRID: % not found in spatial_ref_sys', new_srid;
+ RETURN false;
+ END IF;
+ ELSE
+ unknown_srid := ST_SRID('POINT EMPTY'::geometry);
+ IF ( new_srid != unknown_srid ) THEN
+ new_srid := unknown_srid;
+ RAISE NOTICE 'SRID value % converted to the officially unknown SRID value %', new_srid_in, new_srid;
+ END IF;
+ END IF;
- IF postgis_constraint_srid(schema_name, table_name, column_name) IS NOT NULL THEN
- -- srid was enforced with constraints before, keep it that way.
+ IF postgis_constraint_srid(schema_name, table_name, column_name) IS NOT NULL THEN
+ -- srid was enforced with constraints before, keep it that way.
-- Make up constraint name
- cname = 'enforce_srid_' || column_name;
-
+ cname = 'enforce_srid_' || column_name;
+
-- Drop enforce_srid constraint
EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) ||
'.' || quote_ident(table_name) ||
' DROP constraint ' || quote_ident(cname);
-
+
-- Update geometries SRID
EXECUTE 'UPDATE ' || quote_ident(real_schema) ||
'.' || quote_ident(table_name) ||
' SET ' || quote_ident(column_name) ||
' = ST_SetSRID(' || quote_ident(column_name) ||
', ' || new_srid::text || ')';
-
+
-- Reset enforce_srid constraint
EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) ||
'.' || quote_ident(table_name) ||
' ADD constraint ' || quote_ident(cname) ||
' CHECK (st_srid(' || quote_ident(column_name) ||
') = ' || new_srid::text || ')';
- ELSE
+ ELSE
-- We will use typmod to enforce if no srid constraints
- -- We are using postgis_type_name to lookup the new name
- -- (in case Paul changes his mind and flips geometry_columns to return old upper case name)
- EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) || '.' || quote_ident(table_name) ||
+ -- We are using postgis_type_name to lookup the new name
+ -- (in case Paul changes his mind and flips geometry_columns to return old upper case name)
+ EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) || '.' || quote_ident(table_name) ||
' ALTER COLUMN ' || quote_ident(column_name) || ' TYPE geometry(' || postgis_type_name(myrec.type, myrec.coord_dimension, true) || ', ' || new_srid::text || ') USING ST_SetSRID(' || quote_ident(column_name) || ',' || new_srid::text || ');' ;
END IF;
- RETURN real_schema || '.' || table_name || '.' || column_name ||' SRID changed to ' || new_srid::text;
+ RETURN real_schema || '.' || table_name || '.' || column_name ||' SRID changed to ' || new_srid::text;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION UpdateGeometrySRID(varchar,varchar,varchar,integer)
- RETURNS text
- AS $$
+ RETURNS text
+ AS $$
DECLARE
- ret text;
+ ret text;
BEGIN
- SELECT UpdateGeometrySRID('',$1,$2,$3,$4) into ret;
- RETURN ret;
+ SELECT UpdateGeometrySRID('',$1,$2,$3,$4) into ret;
+ RETURN ret;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION UpdateGeometrySRID(varchar,varchar,integer)
- RETURNS text
- AS $$
+ RETURNS text
+ AS $$
DECLARE
- ret text;
+ ret text;
BEGIN
- SELECT UpdateGeometrySRID('','',$1,$2,$3) into ret;
- RETURN ret;
+ SELECT UpdateGeometrySRID('','',$1,$2,$3) into ret;
+ RETURN ret;
END;
$$
LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION find_srid(varchar,varchar,varchar) RETURNS int4 AS
$$
DECLARE
- schem text;
- tabl text;
- sr int4;
+ schem text;
+ tabl text;
+ sr int4;
BEGIN
- IF $1 IS NULL THEN
- RAISE EXCEPTION 'find_srid() - schema is NULL!';
- END IF;
- IF $2 IS NULL THEN
- RAISE EXCEPTION 'find_srid() - table name is NULL!';
- END IF;
- IF $3 IS NULL THEN
- RAISE EXCEPTION 'find_srid() - column name is NULL!';
- END IF;
- schem = $1;
- tabl = $2;
+ IF $1 IS NULL THEN
+ RAISE EXCEPTION 'find_srid() - schema is NULL!';
+ END IF;
+ IF $2 IS NULL THEN
+ RAISE EXCEPTION 'find_srid() - table name is NULL!';
+ END IF;
+ IF $3 IS NULL THEN
+ RAISE EXCEPTION 'find_srid() - column name is NULL!';
+ END IF;
+ schem = $1;
+ tabl = $2;
-- if the table contains a . and the schema is empty
-- split the table into a schema and a table
-- otherwise drop through to default behavior
- IF ( schem = '' and tabl LIKE '%.%' ) THEN
- schem = substr(tabl,1,strpos(tabl,'.')-1);
- tabl = substr(tabl,length(schem)+2);
- ELSE
- schem = schem || '%';
- END IF;
-
- select SRID into sr from geometry_columns where f_table_schema like schem and f_table_name = tabl and f_geometry_column = $3;
- IF NOT FOUND THEN
- RAISE EXCEPTION 'find_srid() - couldnt find the corresponding SRID - is the geometry registered in the GEOMETRY_COLUMNS table? Is there an uppercase/lowercase missmatch?';
- END IF;
- return sr;
+ IF ( schem = '' and tabl LIKE '%.%' ) THEN
+ schem = substr(tabl,1,strpos(tabl,'.')-1);
+ tabl = substr(tabl,length(schem)+2);
+ ELSE
+ schem = schem || '%';
+ END IF;
+
+ select SRID into sr from geometry_columns where f_table_schema like schem and f_table_name = tabl and f_geometry_column = $3;
+ IF NOT FOUND THEN
+ RAISE EXCEPTION 'find_srid() - couldnt find the corresponding SRID - is the geometry registered in the GEOMETRY_COLUMNS table? Is there an uppercase/lowercase missmatch?';
+ END IF;
+ return sr;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION get_proj4_from_srid(integer) RETURNS text AS
$$
BEGIN
- RETURN proj4text::text FROM spatial_ref_sys WHERE srid= $1;
+ RETURN proj4text::text FROM spatial_ref_sys WHERE srid= $1;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_transform_geometry(geometry,text,text,int)
- RETURNS geometry
- AS '$libdir/postgis-2.0','transform_geom'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','transform_geom'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Transform(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0','transform'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','transform'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_version() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_proj_version() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_scripts_installed() RETURNS text
- AS $$ SELECT '2.0.2'::text || ' r' || 10789::text AS version $$
- LANGUAGE 'sql' IMMUTABLE;
+ AS $$ SELECT '2.0.2'::text || ' r' || 10789::text AS version $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_lib_version() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE; -- a new lib will require a new session
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE; -- a new lib will require a new session
CREATE OR REPLACE FUNCTION postgis_scripts_released() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_geos_version() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_svn_version() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_libxml_version() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_scripts_build_date() RETURNS text
- AS 'SELECT ''2012-12-05 22:40:44''::text AS version'
- LANGUAGE 'sql' IMMUTABLE;
+ AS 'SELECT ''2012-12-05 22:46:23''::text AS version'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_lib_build_date() RETURNS text
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION postgis_full_version() RETURNS text
AS $$
DECLARE
- libver text;
- svnver text;
- projver text;
- geosver text;
- gdalver text;
- libxmlver text;
- dbproc text;
- relproc text;
- fullver text;
- rast_lib_ver text;
- rast_scr_ver text;
- topo_scr_ver text;
- json_lib_ver text;
+ libver text;
+ svnver text;
+ projver text;
+ geosver text;
+ gdalver text;
+ libxmlver text;
+ dbproc text;
+ relproc text;
+ fullver text;
+ rast_lib_ver text;
+ rast_scr_ver text;
+ topo_scr_ver text;
+ json_lib_ver text;
BEGIN
- SELECT postgis_lib_version() INTO libver;
- SELECT postgis_proj_version() INTO projver;
- SELECT postgis_geos_version() INTO geosver;
- SELECT postgis_libjson_version() INTO json_lib_ver;
- BEGIN
- SELECT postgis_gdal_version() INTO gdalver;
- EXCEPTION
- WHEN undefined_function THEN
- gdalver := NULL;
- RAISE NOTICE 'Function postgis_gdal_version() not found. Is raster support enabled and rtpostgis.sql installed?';
- END;
- SELECT postgis_libxml_version() INTO libxmlver;
- SELECT postgis_scripts_installed() INTO dbproc;
- SELECT postgis_scripts_released() INTO relproc;
- select postgis_svn_version() INTO svnver;
- BEGIN
- SELECT postgis_topology_scripts_installed() INTO topo_scr_ver;
- EXCEPTION
- WHEN undefined_function THEN
- topo_scr_ver := NULL;
- RAISE NOTICE 'Function postgis_topology_scripts_installed() not found. Is topology support enabled and topology.sql installed?';
- END;
-
- BEGIN
- SELECT postgis_raster_scripts_installed() INTO rast_scr_ver;
- EXCEPTION
- WHEN undefined_function THEN
- rast_scr_ver := NULL;
- RAISE NOTICE 'Function postgis_raster_scripts_installed() not found. Is raster support enabled and rtpostgis.sql installed?';
- END;
-
- BEGIN
- SELECT postgis_raster_lib_version() INTO rast_lib_ver;
- EXCEPTION
- WHEN undefined_function THEN
- rast_lib_ver := NULL;
- RAISE NOTICE 'Function postgis_raster_lib_version() not found. Is raster support enabled and rtpostgis.sql installed?';
- END;
-
- fullver = 'POSTGIS="' || libver;
-
- IF svnver IS NOT NULL THEN
- fullver = fullver || ' r' || svnver;
- END IF;
-
- fullver = fullver || '"';
-
- IF geosver IS NOT NULL THEN
- fullver = fullver || ' GEOS="' || geosver || '"';
- END IF;
-
- IF projver IS NOT NULL THEN
- fullver = fullver || ' PROJ="' || projver || '"';
- END IF;
-
- IF gdalver IS NOT NULL THEN
- fullver = fullver || ' GDAL="' || gdalver || '"';
- END IF;
-
- IF libxmlver IS NOT NULL THEN
- fullver = fullver || ' LIBXML="' || libxmlver || '"';
- END IF;
-
- IF json_lib_ver IS NOT NULL THEN
- fullver = fullver || ' LIBJSON="' || json_lib_ver || '"';
- END IF;
-
- -- fullver = fullver || ' DBPROC="' || dbproc || '"';
- -- fullver = fullver || ' RELPROC="' || relproc || '"';
-
- IF dbproc != relproc THEN
- fullver = fullver || ' (core procs from "' || dbproc || '" need upgrade)';
- END IF;
-
- IF topo_scr_ver IS NOT NULL THEN
- fullver = fullver || ' TOPOLOGY';
- IF topo_scr_ver != relproc THEN
- fullver = fullver || ' (topology procs from "' || topo_scr_ver || '" need upgrade)';
- END IF;
- END IF;
+ SELECT postgis_lib_version() INTO libver;
+ SELECT postgis_proj_version() INTO projver;
+ SELECT postgis_geos_version() INTO geosver;
+ SELECT postgis_libjson_version() INTO json_lib_ver;
+ BEGIN
+ SELECT postgis_gdal_version() INTO gdalver;
+ EXCEPTION
+ WHEN undefined_function THEN
+ gdalver := NULL;
+ RAISE NOTICE 'Function postgis_gdal_version() not found. Is raster support enabled and rtpostgis.sql installed?';
+ END;
+ SELECT postgis_libxml_version() INTO libxmlver;
+ SELECT postgis_scripts_installed() INTO dbproc;
+ SELECT postgis_scripts_released() INTO relproc;
+ select postgis_svn_version() INTO svnver;
+ BEGIN
+ SELECT postgis_topology_scripts_installed() INTO topo_scr_ver;
+ EXCEPTION
+ WHEN undefined_function THEN
+ topo_scr_ver := NULL;
+ RAISE NOTICE 'Function postgis_topology_scripts_installed() not found. Is topology support enabled and topology.sql installed?';
+ END;
+
+ BEGIN
+ SELECT postgis_raster_scripts_installed() INTO rast_scr_ver;
+ EXCEPTION
+ WHEN undefined_function THEN
+ rast_scr_ver := NULL;
+ RAISE NOTICE 'Function postgis_raster_scripts_installed() not found. Is raster support enabled and rtpostgis.sql installed?';
+ END;
+
+ BEGIN
+ SELECT postgis_raster_lib_version() INTO rast_lib_ver;
+ EXCEPTION
+ WHEN undefined_function THEN
+ rast_lib_ver := NULL;
+ RAISE NOTICE 'Function postgis_raster_lib_version() not found. Is raster support enabled and rtpostgis.sql installed?';
+ END;
+
+ fullver = 'POSTGIS="' || libver;
+
+ IF svnver IS NOT NULL THEN
+ fullver = fullver || ' r' || svnver;
+ END IF;
+
+ fullver = fullver || '"';
+
+ IF geosver IS NOT NULL THEN
+ fullver = fullver || ' GEOS="' || geosver || '"';
+ END IF;
+
+ IF projver IS NOT NULL THEN
+ fullver = fullver || ' PROJ="' || projver || '"';
+ END IF;
+
+ IF gdalver IS NOT NULL THEN
+ fullver = fullver || ' GDAL="' || gdalver || '"';
+ END IF;
+
+ IF libxmlver IS NOT NULL THEN
+ fullver = fullver || ' LIBXML="' || libxmlver || '"';
+ END IF;
+
+ IF json_lib_ver IS NOT NULL THEN
+ fullver = fullver || ' LIBJSON="' || json_lib_ver || '"';
+ END IF;
+
+ -- fullver = fullver || ' DBPROC="' || dbproc || '"';
+ -- fullver = fullver || ' RELPROC="' || relproc || '"';
+
+ IF dbproc != relproc THEN
+ fullver = fullver || ' (core procs from "' || dbproc || '" need upgrade)';
+ END IF;
+
+ IF topo_scr_ver IS NOT NULL THEN
+ fullver = fullver || ' TOPOLOGY';
+ IF topo_scr_ver != relproc THEN
+ fullver = fullver || ' (topology procs from "' || topo_scr_ver || '" need upgrade)';
+ END IF;
+ END IF;
- IF rast_lib_ver IS NOT NULL THEN
- fullver = fullver || ' RASTER';
- IF rast_lib_ver != relproc THEN
- fullver = fullver || ' (raster lib from "' || rast_lib_ver || '" need upgrade)';
- END IF;
- END IF;
+ IF rast_lib_ver IS NOT NULL THEN
+ fullver = fullver || ' RASTER';
+ IF rast_lib_ver != relproc THEN
+ fullver = fullver || ' (raster lib from "' || rast_lib_ver || '" need upgrade)';
+ END IF;
+ END IF;
- IF rast_scr_ver IS NOT NULL AND rast_scr_ver != relproc THEN
- fullver = fullver || ' (raster procs from "' || rast_scr_ver || '" need upgrade)';
- END IF;
+ IF rast_scr_ver IS NOT NULL AND rast_scr_ver != relproc THEN
+ fullver = fullver || ' (raster procs from "' || rast_scr_ver || '" need upgrade)';
+ END IF;
- RETURN fullver;
+ RETURN fullver;
END
$$
LANGUAGE 'plpgsql' IMMUTABLE;
CREATE OR REPLACE FUNCTION box2d(geometry)
- RETURNS box2d
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box3d(geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX3D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX3D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box(geometry)
- RETURNS box
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box2d(box3d)
- RETURNS box2d
- AS '$libdir/postgis-2.0','BOX3D_to_BOX2D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','BOX3D_to_BOX2D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box3d(box2d)
- RETURNS box3d
- AS '$libdir/postgis-2.0','BOX2D_to_BOX3D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0','BOX2D_to_BOX3D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box(box3d)
- RETURNS box
- AS '$libdir/postgis-2.0','BOX3D_to_BOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box
+ AS '$libdir/postgis-2.0','BOX3D_to_BOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION text(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0','LWGEOM_to_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','LWGEOM_to_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION box3dtobox(box3d)
- RETURNS box
- AS 'SELECT box($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS box
+ AS 'SELECT box($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry(box2d)
- RETURNS geometry
- AS '$libdir/postgis-2.0','BOX2D_to_LWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','BOX2D_to_LWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry(box3d)
- RETURNS geometry
- AS '$libdir/postgis-2.0','BOX3D_to_LWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','BOX3D_to_LWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geometry(bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_bytea'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_bytea'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION bytea(geometry)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_to_bytea'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_to_bytea'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP CAST IF EXISTS (geometry AS box2d);
CREATE CAST (geometry AS box2d) WITH FUNCTION box2d(geometry) AS IMPLICIT;
DROP CAST IF EXISTS (geometry AS box3d);
@@ -1799,169 +1799,169 @@ CREATE CAST (bytea AS geometry) WITH FUNCTION geometry(bytea) AS IMPLICIT;
DROP CAST IF EXISTS (geometry AS bytea);
CREATE CAST (geometry AS bytea) WITH FUNCTION bytea(geometry) AS IMPLICIT;
CREATE OR REPLACE FUNCTION ST_Simplify(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_simplify2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_simplify2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SnapToGrid(geometry, float8, float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_snaptogrid'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_snaptogrid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SnapToGrid(geometry, float8, float8)
- RETURNS geometry
- AS 'SELECT ST_SnapToGrid($1, 0, 0, $2, $3)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_SnapToGrid($1, 0, 0, $2, $3)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SnapToGrid(geometry, float8)
- RETURNS geometry
- AS 'SELECT ST_SnapToGrid($1, 0, 0, $2, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_SnapToGrid($1, 0, 0, $2, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SnapToGrid(geom1 geometry, geom2 geometry, float8, float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_snaptogrid_pointoff'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_snaptogrid_pointoff'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Segmentize(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_segmentize2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_segmentize2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_line_interpolate_point(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_line_interpolate_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_interpolate_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_line_substring(geometry, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_line_substring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_substring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_line_locate_point(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_line_locate_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_locate_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_locate_between_measures(geometry, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_locate_between_m'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_locate_between_m'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_locate_along_measure(geometry, float8)
- RETURNS geometry
- AS $$ SELECT ST_locate_between_measures($1, $2, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
-CREATE OR REPLACE FUNCTION ST_AddMeasure(geometry, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_AddMeasure'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS $$ SELECT ST_locate_between_measures($1, $2, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+CREATE OR REPLACE FUNCTION ST_AddMeasure(geometry, float8, float8)
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_AddMeasure'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Intersection(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','intersection'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','intersection'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Buffer(geometry,float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0','buffer'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','buffer'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_Buffer(geometry,float8,cstring)
- RETURNS geometry
- AS '$libdir/postgis-2.0','buffer'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','buffer'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Buffer(geometry,float8,integer)
- RETURNS geometry
- AS $$ SELECT _ST_Buffer($1, $2,
- CAST('quad_segs='||CAST($3 AS text) as cstring))
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS $$ SELECT _ST_Buffer($1, $2,
+ CAST('quad_segs='||CAST($3 AS text) as cstring))
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Buffer(geometry,float8,text)
- RETURNS geometry
- AS $$ SELECT _ST_Buffer($1, $2,
- CAST( regexp_replace($3, '^[0123456789]+$',
- 'quad_segs='||$3) AS cstring)
- )
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS $$ SELECT _ST_Buffer($1, $2,
+ CAST( regexp_replace($3, '^[0123456789]+$',
+ 'quad_segs='||$3) AS cstring)
+ )
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_OffsetCurve(line geometry, distance float8, params text DEFAULT '')
RETURNS geometry
AS '$libdir/postgis-2.0','ST_OffsetCurve'
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION ST_ConvexHull(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','convexhull'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','convexhull'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_LineCrossingDirection(geom1 geometry, geom2 geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0', 'ST_LineCrossingDirection'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS integer
+ AS '$libdir/postgis-2.0', 'ST_LineCrossingDirection'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_LineCrossingDirection(geom1 geometry, geom2 geometry)
- RETURNS integer AS
- $$ SELECT CASE WHEN NOT $1 && $2 THEN 0 ELSE _ST_LineCrossingDirection($1,$2) END $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS integer AS
+ $$ SELECT CASE WHEN NOT $1 && $2 THEN 0 ELSE _ST_LineCrossingDirection($1,$2) END $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_SimplifyPreserveTopology(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0','topologypreservesimplify'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','topologypreservesimplify'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_IsValidReason(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0', 'isvalidreason'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'isvalidreason'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_IsValidDetail(geometry)
- RETURNS valid_detail
- AS '$libdir/postgis-2.0', 'isvaliddetail'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS valid_detail
+ AS '$libdir/postgis-2.0', 'isvaliddetail'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_IsValidDetail(geometry, int4)
- RETURNS valid_detail
- AS '$libdir/postgis-2.0', 'isvaliddetail'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS valid_detail
+ AS '$libdir/postgis-2.0', 'isvaliddetail'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_IsValidReason(geometry, int4)
- RETURNS text
- AS $$
+ RETURNS text
+ AS $$
SELECT CASE WHEN valid THEN 'Valid Geometry' ELSE reason END FROM (
- SELECT (ST_isValidDetail($1, $2)).*
+ SELECT (ST_isValidDetail($1, $2)).*
) foo
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT
- COST 100;
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_IsValid(geometry, int4)
- RETURNS boolean
- AS 'SELECT (ST_isValidDetail($1, $2)).valid'
- LANGUAGE 'sql' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS 'SELECT (ST_isValidDetail($1, $2)).valid'
+ LANGUAGE 'sql' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_HausdorffDistance(geom1 geometry, geom2 geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'hausdorffdistance'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'hausdorffdistance'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_HausdorffDistance(geom1 geometry, geom2 geometry, float8)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'hausdorffdistancedensify'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'hausdorffdistancedensify'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Difference(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','difference'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','difference'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Boundary(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','boundary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','boundary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SymDifference(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','symdifference'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','symdifference'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_symmetricdifference(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','symdifference'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','symdifference'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Union(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','geomunion'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','geomunion'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_UnaryUnion(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','ST_UnaryUnion'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','ST_UnaryUnion'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_RemoveRepeatedPoints(geometry)
RETURNS geometry
AS '$libdir/postgis-2.0', 'ST_RemoveRepeatedPoints'
@@ -2003,257 +2003,257 @@ CREATE OR REPLACE FUNCTION ST_Node(g geometry)
LANGUAGE 'c' IMMUTABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION ST_Combine_BBox(box3d,geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_combine'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_combine'
+ LANGUAGE 'c' IMMUTABLE;
DROP AGGREGATE IF EXISTS ST_Extent(geometry);
CREATE AGGREGATE ST_Extent(
- sfunc = ST_combine_bbox,
- finalfunc = box2d,
- basetype = geometry,
- stype = box3d
- );
+ sfunc = ST_combine_bbox,
+ finalfunc = box2d,
+ basetype = geometry,
+ stype = box3d
+ );
DROP AGGREGATE IF EXISTS ST_3DExtent(geometry);
CREATE AGGREGATE ST_3DExtent(
- sfunc = ST_combine_bbox,
- basetype = geometry,
- stype = box3d
- );
+ sfunc = ST_combine_bbox,
+ basetype = geometry,
+ stype = box3d
+ );
CREATE OR REPLACE FUNCTION ST_Collect(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_collect'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_collect'
+ LANGUAGE 'c' IMMUTABLE;
DROP AGGREGATE IF EXISTS ST_MemCollect(geometry);
CREATE AGGREGATE ST_MemCollect(
- sfunc = ST_collect,
- basetype = geometry,
- stype = geometry
- );
+ sfunc = ST_collect,
+ basetype = geometry,
+ stype = geometry
+ );
CREATE OR REPLACE FUNCTION ST_Collect(geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_collect_garray'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_collect_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP AGGREGATE IF EXISTS ST_MemUnion(geometry);
CREATE AGGREGATE ST_MemUnion (
- basetype = geometry,
- sfunc = ST_Union,
- stype = geometry
- );
+ basetype = geometry,
+ sfunc = ST_Union,
+ stype = geometry
+ );
CREATE OR REPLACE FUNCTION pgis_abs_in(cstring)
- RETURNS pgis_abs
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS pgis_abs
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pgis_abs_out(pgis_abs)
- RETURNS cstring
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION pgis_geometry_accum_transfn(pgis_abs, geometry)
- RETURNS pgis_abs
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c';
+ RETURNS pgis_abs
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION pgis_geometry_accum_finalfn(pgis_abs)
- RETURNS geometry[]
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c';
+ RETURNS geometry[]
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION pgis_geometry_union_finalfn(pgis_abs)
- RETURNS geometry
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c';
+ RETURNS geometry
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION pgis_geometry_collect_finalfn(pgis_abs)
- RETURNS geometry
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c';
+ RETURNS geometry
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION pgis_geometry_polygonize_finalfn(pgis_abs)
- RETURNS geometry
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c';
+ RETURNS geometry
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION pgis_geometry_makeline_finalfn(pgis_abs)
- RETURNS geometry
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c';
+ RETURNS geometry
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c';
DROP AGGREGATE IF EXISTS ST_Accum(geometry);
CREATE AGGREGATE ST_Accum (
- sfunc = pgis_geometry_accum_transfn,
- basetype = geometry,
- stype = pgis_abs,
- finalfunc = pgis_geometry_accum_finalfn
- );
+ sfunc = pgis_geometry_accum_transfn,
+ basetype = geometry,
+ stype = pgis_abs,
+ finalfunc = pgis_geometry_accum_finalfn
+ );
CREATE OR REPLACE FUNCTION ST_Union (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0','pgis_union_geometry_array'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','pgis_union_geometry_array'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP AGGREGATE IF EXISTS ST_Union(geometry);
CREATE AGGREGATE ST_Union (
- basetype = geometry,
- sfunc = pgis_geometry_accum_transfn,
- stype = pgis_abs,
- finalfunc = pgis_geometry_union_finalfn
- );
+ basetype = geometry,
+ sfunc = pgis_geometry_accum_transfn,
+ stype = pgis_abs,
+ finalfunc = pgis_geometry_union_finalfn
+ );
DROP AGGREGATE IF EXISTS ST_Collect(geometry);
CREATE AGGREGATE ST_Collect (
- BASETYPE = geometry,
- SFUNC = pgis_geometry_accum_transfn,
- STYPE = pgis_abs,
- FINALFUNC = pgis_geometry_collect_finalfn
- );
+ BASETYPE = geometry,
+ SFUNC = pgis_geometry_accum_transfn,
+ STYPE = pgis_abs,
+ FINALFUNC = pgis_geometry_collect_finalfn
+ );
DROP AGGREGATE IF EXISTS ST_Polygonize(geometry);
CREATE AGGREGATE ST_Polygonize (
- BASETYPE = geometry,
- SFUNC = pgis_geometry_accum_transfn,
- STYPE = pgis_abs,
- FINALFUNC = pgis_geometry_polygonize_finalfn
- );
+ BASETYPE = geometry,
+ SFUNC = pgis_geometry_accum_transfn,
+ STYPE = pgis_abs,
+ FINALFUNC = pgis_geometry_polygonize_finalfn
+ );
DROP AGGREGATE IF EXISTS ST_MakeLine(geometry);
CREATE AGGREGATE ST_MakeLine (
- BASETYPE = geometry,
- SFUNC = pgis_geometry_accum_transfn,
- STYPE = pgis_abs,
- FINALFUNC = pgis_geometry_makeline_finalfn
- );
+ BASETYPE = geometry,
+ SFUNC = pgis_geometry_accum_transfn,
+ STYPE = pgis_abs,
+ FINALFUNC = pgis_geometry_makeline_finalfn
+ );
CREATE OR REPLACE FUNCTION ST_Relate(geom1 geometry, geom2 geometry)
- RETURNS text
- AS '$libdir/postgis-2.0','relate_full'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','relate_full'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Relate(geom1 geometry, geom2 geometry, int4)
- RETURNS text
- AS '$libdir/postgis-2.0','relate_full'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','relate_full'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Relate(geom1 geometry, geom2 geometry,text)
- RETURNS boolean
- AS '$libdir/postgis-2.0','relate_pattern'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','relate_pattern'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Disjoint(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','disjoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','disjoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_Touches(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','touches'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','touches'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Touches(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Touches($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Touches($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_DWithin(geom1 geometry, geom2 geometry,float8)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_dwithin'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_dwithin'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_DWithin(geom1 geometry, geom2 geometry, float8)
- RETURNS boolean
- AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_Intersects(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','intersects'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','intersects'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Intersects(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Intersects($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Intersects($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_Crosses(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','crosses'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','crosses'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Crosses(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Crosses($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Crosses($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_Contains(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','contains'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','contains'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Contains(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Contains($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Contains($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_CoveredBy(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'coveredby'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'coveredby'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_CoveredBy(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_CoveredBy($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_CoveredBy($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_Covers(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'covers'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'covers'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Covers(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Covers($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Covers($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_ContainsProperly(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','containsproperly'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','containsproperly'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_ContainsProperly(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_ContainsProperly($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_ContainsProperly($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_Overlaps(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','overlaps'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','overlaps'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_Within(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT _ST_Contains($2,$1)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT _ST_Contains($2,$1)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_Within(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Contains($2,$1)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Contains($2,$1)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_Overlaps(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Overlaps($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Overlaps($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_IsValid(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'isvalid'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'isvalid'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Centroid(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'centroid'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'centroid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_IsRing(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'isring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'isring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PointOnSurface(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'pointonsurface'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'pointonsurface'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_IsSimple(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'issimple'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'issimple'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_IsCollection(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'ST_IsCollection'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'ST_IsCollection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_Equals(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','ST_Equals'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','ST_Equals'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Equals(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 ~= $2 AND _ST_Equals($1,$2)'
- LANGUAGE 'sql' IMMUTABLE;
-CREATE OR REPLACE FUNCTION Equals(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0','ST_Equals'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS 'SELECT $1 ~= $2 AND _ST_Equals($1,$2)'
+ LANGUAGE 'sql' IMMUTABLE;
+CREATE OR REPLACE FUNCTION Equals(geom1 geometry, geom2 geometry)
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','ST_Equals'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_GeomFromGML(text, int4)
RETURNS geometry
AS '$libdir/postgis-2.0','geom_from_gml'
@@ -2275,578 +2275,578 @@ CREATE OR REPLACE FUNCTION ST_GMLToSQL(text, int4)
AS '$libdir/postgis-2.0','geom_from_gml'
LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromKML(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','geom_from_kml'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','geom_from_kml'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromGeoJson(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','geom_from_geojson'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','geom_from_geojson'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_libjson_version()
- RETURNS text
- AS '$libdir/postgis-2.0','postgis_libjson_version'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','postgis_libjson_version'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsSVG(geom geometry,rel int4 DEFAULT 0,maxdecimaldigits int4 DEFAULT 15)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asSVG'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asSVG'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_AsGML(int4, geometry, int4, int4, text)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asGML'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asGML'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_AsGML(geom geometry, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
- RETURNS TEXT
- AS $$ SELECT _ST_AsGML(2, $1, $2, $3, null); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS $$ SELECT _ST_AsGML(2, $1, $2, $3, null); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGML(version int4, geom geometry, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0, nprefix text DEFAULT null)
- RETURNS TEXT
- AS $$ SELECT _ST_AsGML($1, $2, $3, $4,$5); $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS TEXT
+ AS $$ SELECT _ST_AsGML($1, $2, $3, $4,$5); $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_AsKML(int4,geometry, int4, text)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asKML'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asKML'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_AsKML(geom geometry, maxdecimaldigits int4 DEFAULT 15)
- RETURNS TEXT
- AS $$ SELECT _ST_AsKML(2, ST_Transform($1,4326), $2, null); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS $$ SELECT _ST_AsKML(2, ST_Transform($1,4326), $2, null); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsKML(version int4, geom geometry, maxdecimaldigits int4 DEFAULT 15, nprefix text DEFAULT null)
- RETURNS TEXT
- AS $$ SELECT _ST_AsKML($1, ST_Transform($2,4326), $3, $4); $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS TEXT
+ AS $$ SELECT _ST_AsKML($1, ST_Transform($2,4326), $3, $4); $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_AsGeoJson(int4, geometry, int4, int4)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asGeoJson'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asGeoJson'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGeoJson(geom geometry, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
- RETURNS TEXT
- AS $$ SELECT _ST_AsGeoJson(1, $1, $2, $3); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS $$ SELECT _ST_AsGeoJson(1, $1, $2, $3); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGeoJson(gj_version int4, geom geometry, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
- RETURNS TEXT
- AS $$ SELECT _ST_AsGeoJson($1, $2, $3, $4); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS $$ SELECT _ST_AsGeoJson($1, $2, $3, $4); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeoHash(geom geometry, maxchars int4 DEFAULT 0)
- RETURNS TEXT
- AS '$libdir/postgis-2.0', 'ST_GeoHash'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0', 'ST_GeoHash'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_NumPoints(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_numpoints_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_numpoints_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_NumGeometries(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_numgeometries_collection'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_numgeometries_collection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeometryN(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_geometryn_collection'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_geometryn_collection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Dimension(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_dimension'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_dimension'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ExteriorRing(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_exteriorring_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_exteriorring_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_NumInteriorRings(geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_NumInteriorRing(geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_InteriorRingN(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_interiorringn_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_interiorringn_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION GeometryType(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0', 'LWGEOM_getTYPE'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'LWGEOM_getTYPE'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeometryType(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0', 'geometry_geometrytype'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'geometry_geometrytype'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PointN(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_pointn_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_pointn_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_NumPatches(geometry)
- RETURNS int4
- AS '
- SELECT CASE WHEN ST_GeometryType($1) = ''ST_PolyhedralSurface''
- THEN ST_NumGeometries($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '
+ SELECT CASE WHEN ST_GeometryType($1) = ''ST_PolyhedralSurface''
+ THEN ST_NumGeometries($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PatchN(geometry, integer)
- RETURNS geometry
- AS '
- SELECT CASE WHEN ST_GeometryType($1) = ''ST_PolyhedralSurface''
- THEN ST_GeometryN($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN ST_GeometryType($1) = ''ST_PolyhedralSurface''
+ THEN ST_GeometryN($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_StartPoint(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_startpoint_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_startpoint_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_EndPoint(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_endpoint_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_endpoint_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_IsClosed(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_isclosed'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_isclosed'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_IsEmpty(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_isempty'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_isempty'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SRID(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0','LWGEOM_get_srid'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0','LWGEOM_get_srid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_SetSRID(geometry,int4)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_set_srid'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_set_srid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsBinary(geometry,text)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_asBinary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_asBinary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsBinary(geometry)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_asBinary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_asBinary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsText(geometry)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asText'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asText'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeometryFromText(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeometryFromText(text, int4)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromText(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromText(text, int4)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_WKTToSQL(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PointFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''POINT''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''POINT''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PointFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''POINT''
- THEN ST_GeomFromText($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''POINT''
+ THEN ST_GeomFromText($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LineFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''LINESTRING''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''LINESTRING''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LineFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''LINESTRING''
- THEN ST_GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''LINESTRING''
+ THEN ST_GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolyFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''POLYGON''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''POLYGON''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolyFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''POLYGON''
- THEN ST_GeomFromText($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''POLYGON''
+ THEN ST_GeomFromText($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolygonFromText(text, int4)
- RETURNS geometry
- AS 'SELECT ST_PolyFromText($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_PolyFromText($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolygonFromText(text)
- RETURNS geometry
- AS 'SELECT ST_PolyFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_PolyFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MLineFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(ST_GeomFromText($1, $2)) = ''MULTILINESTRING''
- THEN ST_GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(ST_GeomFromText($1, $2)) = ''MULTILINESTRING''
+ THEN ST_GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MLineFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''MULTILINESTRING''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''MULTILINESTRING''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiLineStringFromText(text)
- RETURNS geometry
- AS 'SELECT ST_MLineFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_MLineFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiLineStringFromText(text, int4)
- RETURNS geometry
- AS 'SELECT ST_MLineFromText($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_MLineFromText($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPointFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''MULTIPOINT''
- THEN ST_GeomFromText($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''MULTIPOINT''
+ THEN ST_GeomFromText($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPointFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''MULTIPOINT''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''MULTIPOINT''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPointFromText(text)
- RETURNS geometry
- AS 'SELECT ST_MPointFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_MPointFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPointFromText(text)
- RETURNS geometry
- AS 'SELECT ST_MPointFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_MPointFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPolyFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''MULTIPOLYGON''
- THEN ST_GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1, $2)) = ''MULTIPOLYGON''
+ THEN ST_GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPolyFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''MULTIPOLYGON''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromText($1)) = ''MULTIPOLYGON''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPolygonFromText(text, int4)
- RETURNS geometry
- AS 'SELECT ST_MPolyFromText($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_MPolyFromText($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPolygonFromText(text)
- RETURNS geometry
- AS 'SELECT ST_MPolyFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_MPolyFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomCollFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(ST_GeomFromText($1, $2)) = ''GEOMETRYCOLLECTION''
- THEN ST_GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(ST_GeomFromText($1, $2)) = ''GEOMETRYCOLLECTION''
+ THEN ST_GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomCollFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(ST_GeomFromText($1)) = ''GEOMETRYCOLLECTION''
- THEN ST_GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(ST_GeomFromText($1)) = ''GEOMETRYCOLLECTION''
+ THEN ST_GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromWKB(bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_WKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_WKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomFromWKB(bytea, int)
- RETURNS geometry
- AS 'SELECT ST_SetSRID(ST_GeomFromWKB($1), $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT ST_SetSRID(ST_GeomFromWKB($1), $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PointFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''POINT''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''POINT''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PointFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''POINT''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''POINT''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LineFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''LINESTRING''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''LINESTRING''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LineFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''LINESTRING''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''LINESTRING''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LinestringFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''LINESTRING''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''LINESTRING''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LinestringFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''LINESTRING''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''LINESTRING''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolyFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''POLYGON''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''POLYGON''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolyFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''POLYGON''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''POLYGON''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolygonFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1,$2)) = ''POLYGON''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1,$2)) = ''POLYGON''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_PolygonFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''POLYGON''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''POLYGON''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPointFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTIPOINT''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTIPOINT''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPointFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOINT''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOINT''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPointFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1,$2)) = ''MULTIPOINT''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1,$2)) = ''MULTIPOINT''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPointFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOINT''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOINT''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiLineFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTILINESTRING''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTILINESTRING''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MLineFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTILINESTRING''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTILINESTRING''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MLineFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTILINESTRING''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTILINESTRING''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPolyFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MPolyFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOLYGON''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOLYGON''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPolyFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MultiPolyFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOLYGON''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1)) = ''MULTIPOLYGON''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomCollFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''GEOMETRYCOLLECTION''
- THEN ST_GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''GEOMETRYCOLLECTION''
+ THEN ST_GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeomCollFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(ST_GeomFromWKB($1)) = ''GEOMETRYCOLLECTION''
- THEN ST_GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(ST_GeomFromWKB($1)) = ''GEOMETRYCOLLECTION''
+ THEN ST_GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_MaxDistance(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_maxdistance2d_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_maxdistance2d_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MaxDistance(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS 'SELECT _ST_MaxDistance(ST_ConvexHull($1), ST_ConvexHull($2))'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS 'SELECT _ST_MaxDistance(ST_ConvexHull($1), ST_ConvexHull($2))'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ClosestPoint(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_closestpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_closestpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ShortestLine(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_shortestline2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_shortestline2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_LongestLine(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_longestline2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_longestline2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LongestLine(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS 'SELECT _ST_LongestLine(ST_ConvexHull($1), ST_ConvexHull($2))'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT _ST_LongestLine(ST_ConvexHull($1), ST_ConvexHull($2))'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_DFullyWithin(geom1 geometry, geom2 geometry,float8)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_dfullywithin'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_dfullywithin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_DFullyWithin(geom1 geometry, geom2 geometry, float8)
- RETURNS boolean
- AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_DFullyWithin(ST_ConvexHull($1), ST_ConvexHull($2), $3)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_DFullyWithin(ST_ConvexHull($1), ST_ConvexHull($2), $3)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_FlipCoordinates(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_FlipCoordinates'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_FlipCoordinates'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_BdPolyFromText(text, integer)
RETURNS geometry
AS $$
DECLARE
- geomtext alias for $1;
- srid alias for $2;
- mline geometry;
- geom geometry;
+ geomtext alias for $1;
+ srid alias for $2;
+ mline geometry;
+ geom geometry;
BEGIN
- mline := ST_MultiLineStringFromText(geomtext, srid);
+ mline := ST_MultiLineStringFromText(geomtext, srid);
- IF mline IS NULL
- THEN
- RAISE EXCEPTION 'Input is not a MultiLinestring';
- END IF;
+ IF mline IS NULL
+ THEN
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
+ END IF;
- geom := ST_BuildArea(mline);
+ geom := ST_BuildArea(mline);
- IF GeometryType(geom) != 'POLYGON'
- THEN
- RAISE EXCEPTION 'Input returns more then a single polygon, try using BdMPolyFromText instead';
- END IF;
+ IF GeometryType(geom) != 'POLYGON'
+ THEN
+ RAISE EXCEPTION 'Input returns more then a single polygon, try using BdMPolyFromText instead';
+ END IF;
- RETURN geom;
+ RETURN geom;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
@@ -2854,375 +2854,375 @@ CREATE OR REPLACE FUNCTION ST_BdMPolyFromText(text, integer)
RETURNS geometry
AS $$
DECLARE
- geomtext alias for $1;
- srid alias for $2;
- mline geometry;
- geom geometry;
+ geomtext alias for $1;
+ srid alias for $2;
+ mline geometry;
+ geom geometry;
BEGIN
- mline := ST_MultiLineStringFromText(geomtext, srid);
+ mline := ST_MultiLineStringFromText(geomtext, srid);
- IF mline IS NULL
- THEN
- RAISE EXCEPTION 'Input is not a MultiLinestring';
- END IF;
+ IF mline IS NULL
+ THEN
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
+ END IF;
- geom := ST_Multi(ST_BuildArea(mline));
+ geom := ST_Multi(ST_BuildArea(mline));
- RETURN geom;
+ RETURN geom;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION UnlockRows(text)
- RETURNS int
- AS $$
+ RETURNS int
+ AS $$
DECLARE
- ret int;
+ ret int;
BEGIN
- IF NOT LongTransactionsEnabled() THEN
- RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
- END IF;
+ IF NOT LongTransactionsEnabled() THEN
+ RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
+ END IF;
- EXECUTE 'DELETE FROM authorization_table where authid = ' ||
- quote_literal($1);
+ EXECUTE 'DELETE FROM authorization_table where authid = ' ||
+ quote_literal($1);
- GET DIAGNOSTICS ret = ROW_COUNT;
+ GET DIAGNOSTICS ret = ROW_COUNT;
- RETURN ret;
+ RETURN ret;
END;
$$
-LANGUAGE 'plpgsql' VOLATILE STRICT;
+LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION LockRow(text, text, text, text, timestamp)
- RETURNS int
- AS $$
+ RETURNS int
+ AS $$
DECLARE
- myschema alias for $1;
- mytable alias for $2;
- myrid alias for $3;
- authid alias for $4;
- expires alias for $5;
- ret int;
- mytoid oid;
- myrec RECORD;
-
+ myschema alias for $1;
+ mytable alias for $2;
+ myrid alias for $3;
+ authid alias for $4;
+ expires alias for $5;
+ ret int;
+ mytoid oid;
+ myrec RECORD;
+
BEGIN
- IF NOT LongTransactionsEnabled() THEN
- RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
- END IF;
+ 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
- AND c.relnamespace = n.oid
- AND n.nspname = myschema;
+ SELECT c.oid INTO mytoid FROM pg_class c, pg_namespace n
+ WHERE c.relname = mytable
+ AND c.relnamespace = n.oid
+ AND n.nspname = myschema;
- -- RAISE NOTICE 'toid: %', mytoid;
+ -- RAISE NOTICE 'toid: %', mytoid;
- FOR myrec IN SELECT * FROM authorization_table WHERE
- toid = mytoid AND rid = myrid
- LOOP
- IF myrec.authid != authid THEN
- RETURN 0;
- ELSE
- RETURN 1;
- END IF;
- END LOOP;
+ FOR myrec IN SELECT * FROM authorization_table WHERE
+ toid = mytoid AND rid = myrid
+ LOOP
+ IF myrec.authid != authid THEN
+ RETURN 0;
+ ELSE
+ RETURN 1;
+ END IF;
+ END LOOP;
- EXECUTE 'INSERT INTO authorization_table VALUES ('||
- quote_literal(mytoid::text)||','||quote_literal(myrid)||
- ','||quote_literal(expires::text)||
- ','||quote_literal(authid) ||')';
+ EXECUTE 'INSERT INTO authorization_table VALUES ('||
+ quote_literal(mytoid::text)||','||quote_literal(myrid)||
+ ','||quote_literal(expires::text)||
+ ','||quote_literal(authid) ||')';
- GET DIAGNOSTICS ret = ROW_COUNT;
+ GET DIAGNOSTICS ret = ROW_COUNT;
- RETURN ret;
+ RETURN ret;
END;
$$
-LANGUAGE 'plpgsql' VOLATILE STRICT;
+LANGUAGE 'plpgsql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION LockRow(text, text, text, text)
- RETURNS int
- AS
+ RETURNS int
+ AS
$$ SELECT LockRow($1, $2, $3, $4, now()::timestamp+'1:00'); $$
- LANGUAGE 'sql' VOLATILE STRICT;
+ LANGUAGE 'sql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION LockRow(text, text, text)
- RETURNS int
- AS
+ RETURNS int
+ AS
$$ SELECT LockRow(current_schema(), $1, $2, $3, now()::timestamp+'1:00'); $$
- LANGUAGE 'sql' VOLATILE STRICT;
+ LANGUAGE 'sql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION LockRow(text, text, text, timestamp)
- RETURNS int
- AS
+ RETURNS int
+ AS
$$ SELECT LockRow(current_schema(), $1, $2, $3, $4); $$
- LANGUAGE 'sql' VOLATILE STRICT;
+ LANGUAGE 'sql' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION AddAuth(text)
- RETURNS BOOLEAN
- AS $$
+ RETURNS BOOLEAN
+ AS $$
DECLARE
- lockid alias for $1;
- okay boolean;
- myrec record;
+ lockid alias for $1;
+ okay boolean;
+ myrec record;
BEGIN
- -- check to see if table exists
- -- if not, CREATE TEMP TABLE mylock (transid xid, lockcode text)
- okay := 'f';
- FOR myrec IN SELECT * FROM pg_class WHERE relname = 'temp_lock_have_table' LOOP
- okay := 't';
- 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 IF;
-
- -- INSERT INTO mylock VALUES ( $1)
--- EXECUTE 'INSERT INTO temp_lock_have_table VALUES ( '||
--- quote_literal(getTransactionID()) || ',' ||
--- quote_literal(lockid) ||')';
-
- INSERT INTO temp_lock_have_table VALUES (getTransactionID(), lockid);
-
- RETURN true::boolean;
+ -- check to see if table exists
+ -- if not, CREATE TEMP TABLE mylock (transid xid, lockcode text)
+ okay := 'f';
+ FOR myrec IN SELECT * FROM pg_class WHERE relname = 'temp_lock_have_table' LOOP
+ okay := 't';
+ 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 IF;
+
+ -- INSERT INTO mylock VALUES ( $1)
+-- EXECUTE 'INSERT INTO temp_lock_have_table VALUES ( '||
+-- quote_literal(getTransactionID()) || ',' ||
+-- quote_literal(lockid) ||')';
+
+ INSERT INTO temp_lock_have_table VALUES (getTransactionID(), lockid);
+
+ RETURN true::boolean;
END;
$$
LANGUAGE PLPGSQL;
CREATE OR REPLACE FUNCTION CheckAuth(text, text, text)
- RETURNS INT
- AS $$
+ RETURNS INT
+ AS $$
DECLARE
- schema text;
+ schema text;
BEGIN
- IF NOT LongTransactionsEnabled() THEN
- RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
- END IF;
+ IF NOT LongTransactionsEnabled() THEN
+ RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
+ END IF;
- if ( $1 != '' ) THEN
- schema = $1;
- ELSE
- SELECT current_schema() into schema;
- END IF;
+ if ( $1 != '' ) THEN
+ schema = $1;
+ ELSE
+ SELECT current_schema() into schema;
+ END IF;
- -- TODO: check for an already existing trigger ?
+ -- TODO: check for an already existing trigger ?
- 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) || ')';
+ 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) || ')';
- RETURN 0;
+ RETURN 0;
END;
$$
LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION CheckAuth(text, text)
- RETURNS INT
- AS
- $$ SELECT CheckAuth('', $1, $2) $$
- LANGUAGE 'sql';
+ RETURNS INT
+ AS
+ $$ SELECT CheckAuth('', $1, $2) $$
+ LANGUAGE 'sql';
CREATE OR REPLACE FUNCTION CheckAuthTrigger()
- RETURNS trigger AS
- '$libdir/postgis-2.0', 'check_authorization'
- LANGUAGE C;
+ RETURNS trigger AS
+ '$libdir/postgis-2.0', 'check_authorization'
+ LANGUAGE C;
CREATE OR REPLACE FUNCTION GetTransactionID()
- RETURNS xid AS
- '$libdir/postgis-2.0', 'getTransactionID'
- LANGUAGE C;
+ RETURNS xid AS
+ '$libdir/postgis-2.0', 'getTransactionID'
+ LANGUAGE C;
CREATE OR REPLACE FUNCTION EnableLongTransactions()
- RETURNS TEXT
- AS $$
+ RETURNS TEXT
+ AS $$
DECLARE
- "query" text;
- exists bool;
- rec RECORD;
+ "query" text;
+ exists bool;
+ rec RECORD;
BEGIN
- exists = 'f';
- FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table'
- LOOP
- exists = 't';
- END LOOP;
-
- IF NOT exists
- THEN
- "query" = 'CREATE TABLE authorization_table (
- toid oid, -- table oid
- rid text, -- row id
- expires timestamp,
- authid text
- )';
- EXECUTE "query";
- END IF;
-
- exists = 'f';
- FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables'
- LOOP
- exists = 't';
- END LOOP;
-
- IF NOT exists THEN
- "query" = 'CREATE VIEW authorized_tables AS ' ||
- 'SELECT ' ||
- 'n.nspname as schema, ' ||
- 'c.relname as table, trim(' ||
- quote_literal(chr(92) || '000') ||
- ' from t.tgargs) as id_column ' ||
- 'FROM pg_trigger t, pg_class c, pg_proc p ' ||
- ', pg_namespace n ' ||
- 'WHERE p.proname = ' || quote_literal('checkauthtrigger') ||
- ' AND c.relnamespace = n.oid' ||
- ' AND t.tgfoid = p.oid and t.tgrelid = c.oid';
- EXECUTE "query";
- END IF;
-
- RETURN 'Long transactions support enabled';
+ exists = 'f';
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table'
+ LOOP
+ exists = 't';
+ END LOOP;
+
+ IF NOT exists
+ THEN
+ "query" = 'CREATE TABLE authorization_table (
+ toid oid, -- table oid
+ rid text, -- row id
+ expires timestamp,
+ authid text
+ )';
+ EXECUTE "query";
+ END IF;
+
+ exists = 'f';
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables'
+ LOOP
+ exists = 't';
+ END LOOP;
+
+ IF NOT exists THEN
+ "query" = 'CREATE VIEW authorized_tables AS ' ||
+ 'SELECT ' ||
+ 'n.nspname as schema, ' ||
+ 'c.relname as table, trim(' ||
+ quote_literal(chr(92) || '000') ||
+ ' from t.tgargs) as id_column ' ||
+ 'FROM pg_trigger t, pg_class c, pg_proc p ' ||
+ ', pg_namespace n ' ||
+ 'WHERE p.proname = ' || quote_literal('checkauthtrigger') ||
+ ' AND c.relnamespace = n.oid' ||
+ ' AND t.tgfoid = p.oid and t.tgrelid = c.oid';
+ EXECUTE "query";
+ END IF;
+
+ RETURN 'Long transactions support enabled';
END;
$$
LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION LongTransactionsEnabled()
- RETURNS bool
-AS $$
+ RETURNS bool
+AS $$
DECLARE
- rec RECORD;
+ rec RECORD;
BEGIN
- FOR rec IN SELECT oid FROM pg_class WHERE relname = 'authorized_tables'
- LOOP
- return 't';
- END LOOP;
- return 'f';
+ FOR rec IN SELECT oid FROM pg_class WHERE relname = 'authorized_tables'
+ LOOP
+ return 't';
+ END LOOP;
+ return 'f';
END;
$$
LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION DisableLongTransactions()
- RETURNS TEXT
- AS $$
+ RETURNS TEXT
+ AS $$
DECLARE
- rec RECORD;
+ rec RECORD;
BEGIN
- --
- -- Drop all triggers applied by CheckAuth()
- --
- FOR rec IN
- SELECT c.relname, t.tgname, t.tgargs FROM pg_trigger t, pg_class c, pg_proc p
- WHERE p.proname = 'checkauthtrigger' and t.tgfoid = p.oid and t.tgrelid = c.oid
- LOOP
- EXECUTE 'DROP TRIGGER ' || quote_ident(rec.tgname) ||
- ' ON ' || quote_ident(rec.relname);
- END LOOP;
-
- --
- -- Drop the authorization_table table
- --
- FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table' LOOP
- DROP TABLE authorization_table;
- END LOOP;
-
- --
- -- Drop the authorized_tables view
- --
- FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables' LOOP
- DROP VIEW authorized_tables;
- END LOOP;
-
- RETURN 'Long transactions support disabled';
+ --
+ -- Drop all triggers applied by CheckAuth()
+ --
+ FOR rec IN
+ SELECT c.relname, t.tgname, t.tgargs FROM pg_trigger t, pg_class c, pg_proc p
+ WHERE p.proname = 'checkauthtrigger' and t.tgfoid = p.oid and t.tgrelid = c.oid
+ LOOP
+ EXECUTE 'DROP TRIGGER ' || quote_ident(rec.tgname) ||
+ ' ON ' || quote_ident(rec.relname);
+ END LOOP;
+
+ --
+ -- Drop the authorization_table table
+ --
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table' LOOP
+ DROP TABLE authorization_table;
+ END LOOP;
+
+ --
+ -- Drop the authorized_tables view
+ --
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables' LOOP
+ DROP VIEW authorized_tables;
+ END LOOP;
+
+ RETURN 'Long transactions support disabled';
END;
$$
LANGUAGE 'plpgsql';
CREATE OR REPLACE FUNCTION geography_typmod_in(cstring[])
- RETURNS integer
- AS '$libdir/postgis-2.0','geography_typmod_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','geography_typmod_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_typmod_out(integer)
- RETURNS cstring
- AS '$libdir/postgis-2.0','postgis_typmod_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','postgis_typmod_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_in(cstring, oid, integer)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_out(geography)
- RETURNS cstring
- AS '$libdir/postgis-2.0','geography_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0','geography_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_recv(internal, oid, integer)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_recv'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_recv'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_send(geography)
- RETURNS bytea
- AS '$libdir/postgis-2.0','geography_send'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','geography_send'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_analyze(internal)
- RETURNS bool
- AS '$libdir/postgis-2.0','geography_analyze'
- LANGUAGE 'c' VOLATILE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0','geography_analyze'
+ LANGUAGE 'c' VOLATILE STRICT;
CREATE OR REPLACE FUNCTION geography(geography, integer, boolean)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_enforce_typmod'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_enforce_typmod'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP CAST IF EXISTS (geography AS geography);
CREATE CAST (geography AS geography) WITH FUNCTION geography(geography, integer, boolean) AS IMPLICIT;
CREATE OR REPLACE FUNCTION geography(bytea)
- RETURNS geography
- AS '$libdir/postgis-2.0','LWGEOM_from_bytea'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','LWGEOM_from_bytea'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION bytea(geography)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_to_bytea'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_to_bytea'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP CAST IF EXISTS (bytea AS geography);
CREATE CAST (bytea AS geography) WITH FUNCTION geography(bytea) AS IMPLICIT;
DROP CAST IF EXISTS (geography AS bytea);
CREATE CAST (geography AS bytea) WITH FUNCTION bytea(geography) AS IMPLICIT;
CREATE OR REPLACE FUNCTION ST_AsText(geography)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asText'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asText'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsText(text)
- RETURNS text AS
- $$ SELECT ST_AsText($1::geometry); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text AS
+ $$ SELECT ST_AsText($1::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeographyFromText(text)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeogFromText(text)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_GeogFromWKB(bytea)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_from_binary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_from_binary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_typmod_dims(integer)
- RETURNS integer
- AS '$libdir/postgis-2.0','postgis_typmod_dims'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','postgis_typmod_dims'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_typmod_srid(integer)
- RETURNS integer
- AS '$libdir/postgis-2.0','postgis_typmod_srid'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','postgis_typmod_srid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_typmod_type(integer)
- RETURNS text
- AS '$libdir/postgis-2.0','postgis_typmod_type'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','postgis_typmod_type'
+ LANGUAGE 'c' IMMUTABLE STRICT;
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,
- 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,
- pg_namespace n
- WHERE t.typname = 'geography'
+ SELECT
+ 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,
+ pg_namespace n
+ WHERE t.typname = 'geography'
AND a.attisdropped = false
AND a.atttypid = t.oid
AND a.attrelid = c.oid
@@ -3230,445 +3230,445 @@ CREATE OR REPLACE VIEW geography_columns AS
AND NOT pg_is_other_temp_schema(c.relnamespace)
AND has_table_privilege( c.oid, 'SELECT'::text );
CREATE OR REPLACE FUNCTION geography(geometry)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_from_geometry'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_from_geometry'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP CAST IF EXISTS (geometry AS geography);
CREATE CAST (geometry AS geography) WITH FUNCTION geography(geometry) AS IMPLICIT;
CREATE OR REPLACE FUNCTION geometry(geography)
- RETURNS geometry
- AS '$libdir/postgis-2.0','geometry_from_geography'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','geometry_from_geography'
+ LANGUAGE 'c' IMMUTABLE STRICT;
DROP CAST IF EXISTS (geography AS geometry);
CREATE CAST (geography AS geometry) WITH FUNCTION geometry(geography) ;
-CREATE OR REPLACE FUNCTION geography_gist_consistent(internal,geography,int4)
- RETURNS bool
- AS '$libdir/postgis-2.0' ,'gserialized_gist_consistent'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_gist_compress(internal)
- RETURNS internal
- AS '$libdir/postgis-2.0','gserialized_gist_compress'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_gist_penalty(internal,internal,internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_penalty'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_gist_picksplit(internal, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_picksplit'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_gist_union(bytea, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_union'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_gist_same(box2d, box2d, internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_same'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_gist_decompress(internal)
- RETURNS internal
- AS '$libdir/postgis-2.0' ,'gserialized_gist_decompress'
- LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_consistent(internal,geography,int4)
+ RETURNS bool
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_consistent'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_compress(internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0','gserialized_gist_compress'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_penalty(internal,internal,internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_penalty'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_picksplit(internal, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_picksplit'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_union(bytea, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_union'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_same(box2d, box2d, internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_same'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_gist_decompress(internal)
+ RETURNS internal
+ AS '$libdir/postgis-2.0' ,'gserialized_gist_decompress'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION geography_gist_selectivity (internal, oid, internal, int4)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'geography_gist_selectivity'
- LANGUAGE 'c';
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'geography_gist_selectivity'
+ LANGUAGE 'c';
CREATE OR REPLACE FUNCTION geography_gist_join_selectivity(internal, oid, internal, smallint)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'geography_gist_selectivity'
- LANGUAGE 'c';
-CREATE OR REPLACE FUNCTION geography_overlaps(geography, geography)
- RETURNS boolean
- AS '$libdir/postgis-2.0' ,'gserialized_overlaps'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'geography_gist_selectivity'
+ LANGUAGE 'c';
+CREATE OR REPLACE FUNCTION geography_overlaps(geography, geography)
+ RETURNS boolean
+ AS '$libdir/postgis-2.0' ,'gserialized_overlaps'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_lt(geography, geography)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'geography_lt'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'geography_lt'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_le(geography, geography)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'geography_le'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'geography_le'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_gt(geography, geography)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'geography_gt'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'geography_gt'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_ge(geography, geography)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'geography_ge'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'geography_ge'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_eq(geography, geography)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'geography_eq'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'geography_eq'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION geography_cmp(geography, geography)
- RETURNS integer
- AS '$libdir/postgis-2.0', 'geography_cmp'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0', 'geography_cmp'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsSVG(geog geography,rel int4 DEFAULT 0,maxdecimaldigits int4 DEFAULT 15)
- RETURNS text
- AS '$libdir/postgis-2.0','geography_as_svg'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','geography_as_svg'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsSVG(text)
- RETURNS text AS
- $$ SELECT ST_AsSVG($1::geometry,0,15); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text AS
+ $$ SELECT ST_AsSVG($1::geometry,0,15); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_AsGML(int4, geography, int4, int4, text)
- RETURNS text
- AS '$libdir/postgis-2.0','geography_as_gml'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS text
+ AS '$libdir/postgis-2.0','geography_as_gml'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_AsGML(text)
- RETURNS text AS
- $$ SELECT _ST_AsGML(2,$1::geometry,15,0, NULL); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text AS
+ $$ SELECT _ST_AsGML(2,$1::geometry,15,0, NULL); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGML(geog geography, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
- RETURNS text
- AS 'SELECT _ST_AsGML(2, $1, $2, $3, null)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text
+ AS 'SELECT _ST_AsGML(2, $1, $2, $3, null)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGML(version int4, geog geography, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0, nprefix text DEFAULT NULL)
- RETURNS text
- AS $$ SELECT _ST_AsGML($1, $2, $3, $4, $5);$$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS text
+ AS $$ SELECT _ST_AsGML($1, $2, $3, $4, $5);$$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_AsKML(int4, geography, int4, text)
- RETURNS text
- AS '$libdir/postgis-2.0','geography_as_kml'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS text
+ AS '$libdir/postgis-2.0','geography_as_kml'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_AsKML(geog geography, maxdecimaldigits int4 DEFAULT 15)
- RETURNS text
- AS 'SELECT _ST_AsKML(2, $1, $2, null)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text
+ AS 'SELECT _ST_AsKML(2, $1, $2, null)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsKML(text)
- RETURNS text AS
- $$ SELECT _ST_AsKML(2, $1::geometry, 15, null); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text AS
+ $$ SELECT _ST_AsKML(2, $1::geometry, 15, null); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsKML(version int4, geog geography, maxdecimaldigits int4 DEFAULT 15, nprefix text DEFAULT null)
- RETURNS text
- AS 'SELECT _ST_AsKML($1, $2, $3, $4)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS text
+ AS 'SELECT _ST_AsKML($1, $2, $3, $4)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION _ST_AsGeoJson(int4, geography, int4, int4)
- RETURNS text
- AS '$libdir/postgis-2.0','geography_as_geojson'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','geography_as_geojson'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGeoJson(text)
- RETURNS text AS
- $$ SELECT _ST_AsGeoJson(1, $1::geometry,15,0); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text AS
+ $$ SELECT _ST_AsGeoJson(1, $1::geometry,15,0); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGeoJson(geog geography, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
- RETURNS text
- AS $$ SELECT _ST_AsGeoJson(1, $1, $2, $3); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text
+ AS $$ SELECT _ST_AsGeoJson(1, $1, $2, $3); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsGeoJson(gj_version int4, geog geography, maxdecimaldigits int4 DEFAULT 15, options int4 DEFAULT 0)
- RETURNS text
- AS $$ SELECT _ST_AsGeoJson($1, $2, $3, $4); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text
+ AS $$ SELECT _ST_AsGeoJson($1, $2, $3, $4); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_Distance(geography, geography, float8, boolean)
- RETURNS float8
- AS '$libdir/postgis-2.0','geography_distance'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','geography_distance'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_DWithin(geography, geography, float8, boolean)
- RETURNS boolean
- AS '$libdir/postgis-2.0','geography_dwithin'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','geography_dwithin'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Distance(geography, geography, boolean)
- RETURNS float8
- AS 'SELECT _ST_Distance($1, $2, 0.0, $3)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS 'SELECT _ST_Distance($1, $2, 0.0, $3)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Distance(geography, geography)
- RETURNS float8
- AS 'SELECT _ST_Distance($1, $2, 0.0, true)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS 'SELECT _ST_Distance($1, $2, 0.0, true)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Distance(text, text)
- RETURNS float8 AS
- $$ SELECT ST_Distance($1::geometry, $2::geometry); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8 AS
+ $$ SELECT ST_Distance($1::geometry, $2::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_Expand(geography, float8)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_DWithin(geography, geography, float8, boolean)
- RETURNS boolean
- AS 'SELECT $1 && _ST_Expand($2,$3) AND $2 && _ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3, $4)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && _ST_Expand($2,$3) AND $2 && _ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3, $4)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_DWithin(geography, geography, float8)
- RETURNS boolean
- AS 'SELECT $1 && _ST_Expand($2,$3) AND $2 && _ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3, true)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && _ST_Expand($2,$3) AND $2 && _ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3, true)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_DWithin(text, text, float8)
- RETURNS boolean AS
- $$ SELECT ST_DWithin($1::geometry, $2::geometry, $3); $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean AS
+ $$ SELECT ST_DWithin($1::geometry, $2::geometry, $3); $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_Area(geog geography, use_spheroid boolean DEFAULT true)
- RETURNS float8
- AS '$libdir/postgis-2.0','geography_area'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','geography_area'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Area(text)
- RETURNS float8 AS
- $$ SELECT ST_Area($1::geometry); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8 AS
+ $$ SELECT ST_Area($1::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Length(geog geography, use_spheroid boolean DEFAULT true)
- RETURNS float8
- AS '$libdir/postgis-2.0','geography_length'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','geography_length'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Length(text)
- RETURNS float8 AS
- $$ SELECT ST_Length($1::geometry); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8 AS
+ $$ SELECT ST_Length($1::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Project(geog geography, distance float8, azimuth float8)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_project'
- LANGUAGE 'c' IMMUTABLE
- COST 100;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_project'
+ LANGUAGE 'c' IMMUTABLE
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Azimuth(geog1 geography, geog2 geography)
- RETURNS float8
- AS '$libdir/postgis-2.0','geography_azimuth'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','geography_azimuth'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Perimeter(geog geography, use_spheroid boolean DEFAULT true)
- RETURNS float8
- AS '$libdir/postgis-2.0','geography_perimeter'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','geography_perimeter'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_PointOutside(geography)
- RETURNS geography
- AS '$libdir/postgis-2.0','geography_point_outside'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geography
+ AS '$libdir/postgis-2.0','geography_point_outside'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_Covers(geography, geography)
- RETURNS boolean
- AS '$libdir/postgis-2.0','geography_covers'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','geography_covers'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_Covers(geography, geography)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Covers($1, $2)'
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Covers($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_Covers(text, text)
- RETURNS boolean AS
- $$ SELECT ST_Covers($1::geometry, $2::geometry); $$
- LANGUAGE 'sql' IMMUTABLE ;
+ RETURNS boolean AS
+ $$ SELECT ST_Covers($1::geometry, $2::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE ;
CREATE OR REPLACE FUNCTION ST_CoveredBy(geography, geography)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Covers($2, $1)'
- LANGUAGE 'sql' IMMUTABLE ;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Covers($2, $1)'
+ LANGUAGE 'sql' IMMUTABLE ;
CREATE OR REPLACE FUNCTION ST_CoveredBy(text, text)
- RETURNS boolean AS
- $$ SELECT ST_CoveredBy($1::geometry, $2::geometry); $$
- LANGUAGE 'sql' IMMUTABLE ;
+ RETURNS boolean AS
+ $$ SELECT ST_CoveredBy($1::geometry, $2::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE ;
CREATE OR REPLACE FUNCTION ST_Intersects(geography, geography)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_Distance($1, $2, 0.0, false) < 0.00001'
- LANGUAGE 'sql' IMMUTABLE ;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_Distance($1, $2, 0.0, false) < 0.00001'
+ LANGUAGE 'sql' IMMUTABLE ;
CREATE OR REPLACE FUNCTION ST_Intersects(text, text)
- RETURNS boolean AS
- $$ SELECT ST_Intersects($1::geometry, $2::geometry); $$
- LANGUAGE 'sql' IMMUTABLE ;
+ RETURNS boolean AS
+ $$ SELECT ST_Intersects($1::geometry, $2::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE ;
CREATE OR REPLACE FUNCTION _ST_BestSRID(geography, geography)
- RETURNS integer
- AS '$libdir/postgis-2.0','geography_bestsrid'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS integer
+ AS '$libdir/postgis-2.0','geography_bestsrid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_BestSRID(geography)
- RETURNS integer
- AS 'SELECT _ST_BestSRID($1,$1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS integer
+ AS 'SELECT _ST_BestSRID($1,$1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Buffer(geography, float8)
- RETURNS geography
- AS 'SELECT geography(ST_Transform(ST_Buffer(ST_Transform(geometry($1), _ST_BestSRID($1)), $2), 4326))'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geography
+ AS 'SELECT geography(ST_Transform(ST_Buffer(ST_Transform(geometry($1), _ST_BestSRID($1)), $2), 4326))'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Buffer(text, float8)
- RETURNS geometry AS
- $$ SELECT ST_Buffer($1::geometry, $2); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry AS
+ $$ SELECT ST_Buffer($1::geometry, $2); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Intersection(geography, geography)
- RETURNS geography
- AS 'SELECT geography(ST_Transform(ST_Intersection(ST_Transform(geometry($1), _ST_BestSRID($1, $2)), ST_Transform(geometry($2), _ST_BestSRID($1, $2))), 4326))'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geography
+ AS 'SELECT geography(ST_Transform(ST_Intersection(ST_Transform(geometry($1), _ST_BestSRID($1, $2)), ST_Transform(geometry($2), _ST_BestSRID($1, $2))), 4326))'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Intersection(text, text)
- RETURNS geometry AS
- $$ SELECT ST_Intersection($1::geometry, $2::geometry); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry AS
+ $$ SELECT ST_Intersection($1::geometry, $2::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsBinary(geography)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_asBinary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_asBinary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsBinary(geography,text)
- RETURNS bytea AS
- $$ SELECT ST_AsBinary($1::geometry, $2); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bytea AS
+ $$ SELECT ST_AsBinary($1::geometry, $2); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsEWKT(geography)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asEWKT'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asEWKT'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_AsEWKT(text)
- RETURNS text AS
- $$ SELECT ST_AsEWKT($1::geometry); $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS text AS
+ $$ SELECT ST_AsEWKT($1::geometry); $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION GeometryType(geography)
- RETURNS text
- AS '$libdir/postgis-2.0', 'LWGEOM_getTYPE'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'LWGEOM_getTYPE'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Summary(geography)
- RETURNS text
- AS '$libdir/postgis-2.0', 'LWGEOM_summary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'LWGEOM_summary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_distance_sphere(geom1 geometry, geom2 geometry)
- RETURNS FLOAT8
- AS $$
- select st_distance(geography($1),geography($2),false)
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT
- COST 300;
+ RETURNS FLOAT8
+ AS $$
+ select st_distance(geography($1),geography($2),false)
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT
+ COST 300;
CREATE OR REPLACE FUNCTION ST_distance_sphere(geom1 geometry, geom2 geometry)
- RETURNS FLOAT8
- AS $$
- select st_distance(geography($1),geography($2),false)
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT
- COST 300;
-CREATE OR REPLACE FUNCTION postgis_type_name(geomname varchar, coord_dimension integer, use_new_name boolean DEFAULT true)
- RETURNS varchar
+ RETURNS FLOAT8
+ AS $$
+ select st_distance(geography($1),geography($2),false)
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT
+ COST 300;
+CREATE OR REPLACE FUNCTION postgis_type_name(geomname varchar, coord_dimension integer, use_new_name boolean DEFAULT true)
+ RETURNS varchar
AS
$$
SELECT CASE WHEN $3 THEN new_name ELSE old_name END As geomname
- FROM
- ( VALUES
- ('GEOMETRY', 'Geometry', 2) ,
- ('GEOMETRY', 'GeometryZ', 3) ,
- ('GEOMETRY', 'GeometryZM', 4) ,
- ('GEOMETRYCOLLECTION', 'GeometryCollection', 2) ,
- ('GEOMETRYCOLLECTION', 'GeometryCollectionZ', 3) ,
- ('GEOMETRYCOLLECTIONM', 'GeometryCollectionM', 3) ,
- ('GEOMETRYCOLLECTION', 'GeometryCollectionZM', 4) ,
-
- ('POINT', 'Point',2) ,
- ('POINTM','PointM',3) ,
- ('POINT', 'PointZ',3) ,
- ('POINT', 'PointZM',4) ,
-
- ('MULTIPOINT','MultiPoint',2) ,
- ('MULTIPOINT','MultiPointZ',3) ,
- ('MULTIPOINTM','MultiPointM',3) ,
- ('MULTIPOINT','MultiPointZM',4) ,
-
- ('POLYGON', 'Polygon',2) ,
- ('POLYGON', 'PolygonZ',3) ,
- ('POLYGONM', 'PolygonM',3) ,
- ('POLYGON', 'PolygonZM',4) ,
-
- ('MULTIPOLYGON', 'MultiPolygon',2) ,
- ('MULTIPOLYGON', 'MultiPolygonZ',3) ,
- ('MULTIPOLYGONM', 'MultiPolygonM',3) ,
- ('MULTIPOLYGON', 'MultiPolygonZM',4) ,
-
- ('MULTILINESTRING', 'MultiLineString',2) ,
- ('MULTILINESTRING', 'MultiLineStringZ',3) ,
- ('MULTILINESTRINGM', 'MultiLineStringM',3) ,
- ('MULTILINESTRING', 'MultiLineStringZM',4) ,
-
- ('LINESTRING', 'LineString',2) ,
- ('LINESTRING', 'LineStringZ',3) ,
- ('LINESTRINGM', 'LineStringM',3) ,
- ('LINESTRING', 'LineStringZM',4) ,
-
- ('CIRCULARSTRING', 'CircularString',2) ,
- ('CIRCULARSTRING', 'CircularStringZ',3) ,
- ('CIRCULARSTRINGM', 'CircularStringM',3) ,
- ('CIRCULARSTRING', 'CircularStringZM',4) ,
-
- ('COMPOUNDCURVE', 'CompoundCurve',2) ,
- ('COMPOUNDCURVE', 'CompoundCurveZ',3) ,
- ('COMPOUNDCURVEM', 'CompoundCurveM',3) ,
- ('COMPOUNDCURVE', 'CompoundCurveZM',4) ,
-
- ('CURVEPOLYGON', 'CurvePolygon',2) ,
- ('CURVEPOLYGON', 'CurvePolygonZ',3) ,
- ('CURVEPOLYGONM', 'CurvePolygonM',3) ,
- ('CURVEPOLYGON', 'CurvePolygonZM',4) ,
-
- ('MULTICURVE', 'MultiCurve',2 ) ,
- ('MULTICURVE', 'MultiCurveZ',3 ) ,
- ('MULTICURVEM', 'MultiCurveM',3 ) ,
- ('MULTICURVE', 'MultiCurveZM',4 ) ,
-
- ('MULTISURFACE', 'MultiSurface', 2) ,
- ('MULTISURFACE', 'MultiSurfaceZ', 3) ,
- ('MULTISURFACEM', 'MultiSurfaceM', 3) ,
- ('MULTISURFACE', 'MultiSurfaceZM', 4) ,
-
- ('POLYHEDRALSURFACE', 'PolyhedralSurface',2) ,
- ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZ',3) ,
- ('POLYHEDRALSURFACEM', 'PolyhedralSurfaceM',3) ,
- ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZM',4) ,
-
- ('TRIANGLE', 'Triangle',2) ,
- ('TRIANGLE', 'TriangleZ',3) ,
- ('TRIANGLEM', 'TriangleM',3) ,
- ('TRIANGLE', 'TriangleZM',4) ,
-
- ('TIN', 'Tin', 2),
- ('TIN', 'TinZ', 3),
- ('TIN', 'TinM', 3),
- ('TIN', 'TinZM', 4) )
- As g(old_name, new_name, coord_dimension)
- WHERE (upper(old_name) = upper($1) OR upper(new_name) = upper($1))
- AND coord_dimension = $2;
+ FROM
+ ( VALUES
+ ('GEOMETRY', 'Geometry', 2) ,
+ ('GEOMETRY', 'GeometryZ', 3) ,
+ ('GEOMETRY', 'GeometryZM', 4) ,
+ ('GEOMETRYCOLLECTION', 'GeometryCollection', 2) ,
+ ('GEOMETRYCOLLECTION', 'GeometryCollectionZ', 3) ,
+ ('GEOMETRYCOLLECTIONM', 'GeometryCollectionM', 3) ,
+ ('GEOMETRYCOLLECTION', 'GeometryCollectionZM', 4) ,
+
+ ('POINT', 'Point',2) ,
+ ('POINTM','PointM',3) ,
+ ('POINT', 'PointZ',3) ,
+ ('POINT', 'PointZM',4) ,
+
+ ('MULTIPOINT','MultiPoint',2) ,
+ ('MULTIPOINT','MultiPointZ',3) ,
+ ('MULTIPOINTM','MultiPointM',3) ,
+ ('MULTIPOINT','MultiPointZM',4) ,
+
+ ('POLYGON', 'Polygon',2) ,
+ ('POLYGON', 'PolygonZ',3) ,
+ ('POLYGONM', 'PolygonM',3) ,
+ ('POLYGON', 'PolygonZM',4) ,
+
+ ('MULTIPOLYGON', 'MultiPolygon',2) ,
+ ('MULTIPOLYGON', 'MultiPolygonZ',3) ,
+ ('MULTIPOLYGONM', 'MultiPolygonM',3) ,
+ ('MULTIPOLYGON', 'MultiPolygonZM',4) ,
+
+ ('MULTILINESTRING', 'MultiLineString',2) ,
+ ('MULTILINESTRING', 'MultiLineStringZ',3) ,
+ ('MULTILINESTRINGM', 'MultiLineStringM',3) ,
+ ('MULTILINESTRING', 'MultiLineStringZM',4) ,
+
+ ('LINESTRING', 'LineString',2) ,
+ ('LINESTRING', 'LineStringZ',3) ,
+ ('LINESTRINGM', 'LineStringM',3) ,
+ ('LINESTRING', 'LineStringZM',4) ,
+
+ ('CIRCULARSTRING', 'CircularString',2) ,
+ ('CIRCULARSTRING', 'CircularStringZ',3) ,
+ ('CIRCULARSTRINGM', 'CircularStringM',3) ,
+ ('CIRCULARSTRING', 'CircularStringZM',4) ,
+
+ ('COMPOUNDCURVE', 'CompoundCurve',2) ,
+ ('COMPOUNDCURVE', 'CompoundCurveZ',3) ,
+ ('COMPOUNDCURVEM', 'CompoundCurveM',3) ,
+ ('COMPOUNDCURVE', 'CompoundCurveZM',4) ,
+
+ ('CURVEPOLYGON', 'CurvePolygon',2) ,
+ ('CURVEPOLYGON', 'CurvePolygonZ',3) ,
+ ('CURVEPOLYGONM', 'CurvePolygonM',3) ,
+ ('CURVEPOLYGON', 'CurvePolygonZM',4) ,
+
+ ('MULTICURVE', 'MultiCurve',2 ) ,
+ ('MULTICURVE', 'MultiCurveZ',3 ) ,
+ ('MULTICURVEM', 'MultiCurveM',3 ) ,
+ ('MULTICURVE', 'MultiCurveZM',4 ) ,
+
+ ('MULTISURFACE', 'MultiSurface', 2) ,
+ ('MULTISURFACE', 'MultiSurfaceZ', 3) ,
+ ('MULTISURFACEM', 'MultiSurfaceM', 3) ,
+ ('MULTISURFACE', 'MultiSurfaceZM', 4) ,
+
+ ('POLYHEDRALSURFACE', 'PolyhedralSurface',2) ,
+ ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZ',3) ,
+ ('POLYHEDRALSURFACEM', 'PolyhedralSurfaceM',3) ,
+ ('POLYHEDRALSURFACE', 'PolyhedralSurfaceZM',4) ,
+
+ ('TRIANGLE', 'Triangle',2) ,
+ ('TRIANGLE', 'TriangleZ',3) ,
+ ('TRIANGLEM', 'TriangleM',3) ,
+ ('TRIANGLE', 'TriangleZM',4) ,
+
+ ('TIN', 'Tin', 2),
+ ('TIN', 'TinZ', 3),
+ ('TIN', 'TinM', 3),
+ ('TIN', 'TinZM', 4) )
+ As g(old_name, new_name, coord_dimension)
+ WHERE (upper(old_name) = upper($1) OR upper(new_name) = upper($1))
+ AND coord_dimension = $2;
$$
LANGUAGE 'sql' IMMUTABLE STRICT COST 200;
CREATE OR REPLACE FUNCTION postgis_constraint_srid(geomschema text, geomtable text, geomcolumn text) RETURNS integer AS
$$
SELECT replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%srid(% = %';
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%srid(% = %';
$$
LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_constraint_dims(geomschema text, geomtable text, geomcolumn text) RETURNS integer AS
$$
-SELECT replace(split_part(s.consrc, ' = ', 2), ')', '')::integer
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%ndims(% = %';
+SELECT replace(split_part(s.consrc, ' = ', 2), ')', '')::integer
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%ndims(% = %';
$$
LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION postgis_constraint_type(geomschema text, geomtable text, geomcolumn text) RETURNS varchar AS
$$
-SELECT replace(split_part(s.consrc, '''', 2), ')', '')::varchar
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%geometrytype(% = %';
+SELECT replace(split_part(s.consrc, '''', 2), ')', '')::varchar
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%geometrytype(% = %';
$$
LANGUAGE 'sql' STABLE STRICT;
-CREATE OR REPLACE VIEW geometry_columns AS
- SELECT current_database()::varchar(256) AS f_table_catalog,
- n.nspname::varchar(256) AS f_table_schema,
- c.relname::varchar(256) AS f_table_name,
- a.attname::varchar(256) AS f_geometry_column,
+CREATE OR REPLACE VIEW geometry_columns AS
+ SELECT current_database()::varchar(256) AS f_table_catalog,
+ n.nspname::varchar(256) AS f_table_schema,
+ c.relname::varchar(256) AS f_table_name,
+ a.attname::varchar(256) AS f_geometry_column,
COALESCE(NULLIF(postgis_typmod_dims(a.atttypmod),2),
postgis_constraint_dims(n.nspname, c.relname, a.attname),
- 2) AS coord_dimension,
+ 2) AS coord_dimension,
COALESCE(NULLIF(postgis_typmod_srid(a.atttypmod),0),
postgis_constraint_srid(n.nspname, c.relname, a.attname),
- 0) AS srid,
+ 0) AS srid,
-- force to be uppercase with no ZM so is backwards compatible
-- with old geometry_columns
replace(
@@ -3681,11 +3681,11 @@ CREATE OR REPLACE VIEW geometry_columns AS
), 'Z', ''
)::varchar(30) AS type
FROM pg_class c, pg_attribute a, pg_type t, pg_namespace n
- WHERE t.typname = 'geometry'::name
- AND a.attisdropped = false
- AND a.atttypid = t.oid
- AND a.attrelid = c.oid
- AND c.relnamespace = n.oid
+ WHERE t.typname = 'geometry'::name
+ AND a.attisdropped = false
+ AND a.atttypid = t.oid
+ AND a.attrelid = c.oid
+ AND c.relnamespace = n.oid
AND (c.relkind = 'r'::"char" OR c.relkind = 'v'::"char")
AND NOT pg_is_other_temp_schema(c.relnamespace)
AND NOT ( n.nspname = 'public' AND c.relname = 'raster_columns' )
@@ -3700,374 +3700,374 @@ CREATE OR REPLACE RULE geometry_columns_delete AS
ON DELETE TO geometry_columns
DO INSTEAD NOTHING;
CREATE OR REPLACE FUNCTION ST_3DDistance(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_mindistance3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_mindistance3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DMaxDistance(geom1 geometry, geom2 geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_maxdistance3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_maxdistance3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DClosestPoint(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_closestpoint3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_closestpoint3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DShortestLine(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_shortestline3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_shortestline3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DLongestLine(geom1 geometry, geom2 geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_longestline3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_longestline3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_3DDWithin(geom1 geometry, geom2 geometry,float8)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_dwithin3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_dwithin3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DDWithin(geom1 geometry, geom2 geometry,float8)
- RETURNS boolean
- AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_3DDWithin($1, $2, $3)'
- LANGUAGE 'sql' IMMUTABLE
- COST 100;
+ RETURNS boolean
+ AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_3DDWithin($1, $2, $3)'
+ LANGUAGE 'sql' IMMUTABLE
+ COST 100;
CREATE OR REPLACE FUNCTION _ST_3DDFullyWithin(geom1 geometry, geom2 geometry,float8)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_dfullywithin3d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_dfullywithin3d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DDFullyWithin(geom1 geometry, geom2 geometry,float8)
- RETURNS boolean
- AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_3DDFullyWithin($1, $2, $3)'
- LANGUAGE 'sql' IMMUTABLE
- COST 100;
+ RETURNS boolean
+ AS 'SELECT $1 && ST_Expand($2,$3) AND $2 && ST_Expand($1,$3) AND _ST_3DDFullyWithin($1, $2, $3)'
+ LANGUAGE 'sql' IMMUTABLE
+ COST 100;
CREATE OR REPLACE FUNCTION ST_3DIntersects(geom1 geometry, geom2 geometry)
- RETURNS boolean
- AS 'SELECT $1 && $2 AND _ST_3DDWithin($1, $2, 0.0)'
- LANGUAGE 'sql' IMMUTABLE
- COST 100;
+ RETURNS boolean
+ AS 'SELECT $1 && $2 AND _ST_3DDWithin($1, $2, 0.0)'
+ LANGUAGE 'sql' IMMUTABLE
+ COST 100;
CREATE OR REPLACE FUNCTION ST_CoordDim(Geometry geometry)
- RETURNS smallint
- AS '$libdir/postgis-2.0', 'LWGEOM_ndims'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS smallint
+ AS '$libdir/postgis-2.0', 'LWGEOM_ndims'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_CurveToLine(geometry, integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_curve_segmentize'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_curve_segmentize'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_CurveToLine(geometry)
- RETURNS geometry AS 'SELECT ST_CurveToLine($1, 32)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry AS 'SELECT ST_CurveToLine($1, 32)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_HasArc(Geometry geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_has_arc'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_has_arc'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LineToCurve(Geometry geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_line_desegmentize'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_desegmentize'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_OrderingEquals(GeometryA geometry, GeometryB geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_same'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_same'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION ST_OrderingEquals(GeometryA geometry, GeometryB geometry)
- RETURNS boolean
- AS $$
- SELECT $1 ~= $2 AND _ST_OrderingEquals($1, $2)
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS $$
+ SELECT $1 ~= $2 AND _ST_OrderingEquals($1, $2)
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Point(float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_Polygon(geometry, int)
- RETURNS geometry
- AS $$
- SELECT ST_SetSRID(ST_MakePolygon($1), $2)
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS $$
+ SELECT ST_SetSRID(ST_MakePolygon($1), $2)
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_WKBToSQL(WKB bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_WKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_WKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LocateBetween(Geometry geometry, FromMeasure float8, ToMeasure float8, LeftRightOffset float8 default 0.0)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_LocateBetween'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_LocateBetween'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LocateAlong(Geometry geometry, Measure float8, LeftRightOffset float8 default 0.0)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_LocateAlong'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_LocateAlong'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_LocateBetweenElevations(Geometry geometry, FromElevation float8, ToElevation float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_LocateBetweenElevations'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_LocateBetweenElevations'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_InterpolatePoint(Line geometry, Point geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'ST_InterpolatePoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'ST_InterpolatePoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_MinimumBoundingCircle(inputgeom geometry, segs_per_quarter integer DEFAULT 48)
- RETURNS geometry AS
+ RETURNS geometry AS
$BODY$
- DECLARE
- hull GEOMETRY;
- ring GEOMETRY;
- center GEOMETRY;
- radius DOUBLE PRECISION;
- dist DOUBLE PRECISION;
- d DOUBLE PRECISION;
- idx1 integer;
- idx2 integer;
- l1 GEOMETRY;
- l2 GEOMETRY;
- p1 GEOMETRY;
- p2 GEOMETRY;
- a1 DOUBLE PRECISION;
- a2 DOUBLE PRECISION;
-
-
- BEGIN
+ DECLARE
+ hull GEOMETRY;
+ ring GEOMETRY;
+ center GEOMETRY;
+ radius DOUBLE PRECISION;
+ dist DOUBLE PRECISION;
+ d DOUBLE PRECISION;
+ idx1 integer;
+ idx2 integer;
+ l1 GEOMETRY;
+ l2 GEOMETRY;
+ p1 GEOMETRY;
+ p2 GEOMETRY;
+ a1 DOUBLE PRECISION;
+ a2 DOUBLE PRECISION;
+
+
+ BEGIN
+
+ -- First compute the ConvexHull of the geometry
+ hull = ST_ConvexHull(inputgeom);
+ --A point really has no MBC
+ IF ST_GeometryType(hull) = 'ST_Point' THEN
+ RETURN hull;
+ END IF;
+ -- convert the hull perimeter to a linestring so we can manipulate individual points
+ --If its already a linestring force it to a closed linestring
+ ring = CASE WHEN ST_GeometryType(hull) = 'ST_LineString' THEN ST_AddPoint(hull, ST_StartPoint(hull)) ELSE ST_ExteriorRing(hull) END;
+
+ dist = 0;
+ -- Brute Force - check every pair
+ FOR i in 1 .. (ST_NumPoints(ring)-2)
+ LOOP
+ FOR j in i .. (ST_NumPoints(ring)-1)
+ LOOP
+ d = ST_Distance(ST_PointN(ring,i),ST_PointN(ring,j));
+ -- Check the distance and update if larger
+ IF (d > dist) THEN
+ dist = d;
+ idx1 = i;
+ idx2 = j;
+ END IF;
+ END LOOP;
+ END LOOP;
- -- First compute the ConvexHull of the geometry
- hull = ST_ConvexHull(inputgeom);
- --A point really has no MBC
- IF ST_GeometryType(hull) = 'ST_Point' THEN
- RETURN hull;
- END IF;
- -- convert the hull perimeter to a linestring so we can manipulate individual points
- --If its already a linestring force it to a closed linestring
- ring = CASE WHEN ST_GeometryType(hull) = 'ST_LineString' THEN ST_AddPoint(hull, ST_StartPoint(hull)) ELSE ST_ExteriorRing(hull) END;
-
- dist = 0;
- -- Brute Force - check every pair
- FOR i in 1 .. (ST_NumPoints(ring)-2)
- LOOP
- FOR j in i .. (ST_NumPoints(ring)-1)
- LOOP
- d = ST_Distance(ST_PointN(ring,i),ST_PointN(ring,j));
- -- Check the distance and update if larger
- IF (d > dist) THEN
- dist = d;
- idx1 = i;
- idx2 = j;
- END IF;
- END LOOP;
- END LOOP;
-
- -- We now have the diameter of the convex hull. The following line returns it if desired.
- -- RETURN ST_MakeLine(ST_PointN(ring,idx1),ST_PointN(ring,idx2));
-
- -- Now for the Minimum Bounding Circle. Since we know the two points furthest from each
- -- other, the MBC must go through those two points. Start with those points as a diameter of a circle.
-
- -- The radius is half the distance between them and the center is midway between them
- radius = ST_Distance(ST_PointN(ring,idx1),ST_PointN(ring,idx2)) / 2.0;
- center = ST_Line_interpolate_point(ST_MakeLine(ST_PointN(ring,idx1),ST_PointN(ring,idx2)),0.5);
-
- -- Loop through each vertex and check if the distance from the center to the point
- -- is greater than the current radius.
- FOR k in 1 .. (ST_NumPoints(ring)-1)
- LOOP
- IF(k <> idx1 and k <> idx2) THEN
- dist = ST_Distance(center,ST_PointN(ring,k));
- IF (dist > radius) THEN
- -- We have to expand the circle. The new circle must pass trhough
- -- three points - the two original diameters and this point.
-
- -- Draw a line from the first diameter to this point
- l1 = ST_Makeline(ST_PointN(ring,idx1),ST_PointN(ring,k));
- -- Compute the midpoint
- p1 = ST_line_interpolate_point(l1,0.5);
- -- Rotate the line 90 degrees around the midpoint (perpendicular bisector)
- l1 = ST_Rotate(l1,pi()/2,p1);
- -- Compute the azimuth of the bisector
- a1 = ST_Azimuth(ST_PointN(l1,1),ST_PointN(l1,2));
- -- Extend the line in each direction the new computed distance to insure they will intersect
- l1 = ST_AddPoint(l1,ST_Makepoint(ST_X(ST_PointN(l1,2))+sin(a1)*dist,ST_Y(ST_PointN(l1,2))+cos(a1)*dist),-1);
- l1 = ST_AddPoint(l1,ST_Makepoint(ST_X(ST_PointN(l1,1))-sin(a1)*dist,ST_Y(ST_PointN(l1,1))-cos(a1)*dist),0);
-
- -- Repeat for the line from the point to the other diameter point
- l2 = ST_Makeline(ST_PointN(ring,idx2),ST_PointN(ring,k));
- p2 = ST_Line_interpolate_point(l2,0.5);
- l2 = ST_Rotate(l2,pi()/2,p2);
- a2 = ST_Azimuth(ST_PointN(l2,1),ST_PointN(l2,2));
- l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,2))+sin(a2)*dist,ST_Y(ST_PointN(l2,2))+cos(a2)*dist),-1);
- l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,1))-sin(a2)*dist,ST_Y(ST_PointN(l2,1))-cos(a2)*dist),0);
-
- -- The new center is the intersection of the two bisectors
- center = ST_Intersection(l1,l2);
- -- The new radius is the distance to any of the three points
- radius = ST_Distance(center,ST_PointN(ring,idx1));
- END IF;
- END IF;
- END LOOP;
- --DONE!! Return the MBC via the buffer command
- RETURN ST_Buffer(center,radius,segs_per_quarter);
+ -- We now have the diameter of the convex hull. The following line returns it if desired.
+ -- RETURN ST_MakeLine(ST_PointN(ring,idx1),ST_PointN(ring,idx2));
+
+ -- Now for the Minimum Bounding Circle. Since we know the two points furthest from each
+ -- other, the MBC must go through those two points. Start with those points as a diameter of a circle.
+
+ -- The radius is half the distance between them and the center is midway between them
+ radius = ST_Distance(ST_PointN(ring,idx1),ST_PointN(ring,idx2)) / 2.0;
+ center = ST_Line_interpolate_point(ST_MakeLine(ST_PointN(ring,idx1),ST_PointN(ring,idx2)),0.5);
+
+ -- Loop through each vertex and check if the distance from the center to the point
+ -- is greater than the current radius.
+ FOR k in 1 .. (ST_NumPoints(ring)-1)
+ LOOP
+ IF(k <> idx1 and k <> idx2) THEN
+ dist = ST_Distance(center,ST_PointN(ring,k));
+ IF (dist > radius) THEN
+ -- We have to expand the circle. The new circle must pass trhough
+ -- three points - the two original diameters and this point.
+
+ -- Draw a line from the first diameter to this point
+ l1 = ST_Makeline(ST_PointN(ring,idx1),ST_PointN(ring,k));
+ -- Compute the midpoint
+ p1 = ST_line_interpolate_point(l1,0.5);
+ -- Rotate the line 90 degrees around the midpoint (perpendicular bisector)
+ l1 = ST_Rotate(l1,pi()/2,p1);
+ -- Compute the azimuth of the bisector
+ a1 = ST_Azimuth(ST_PointN(l1,1),ST_PointN(l1,2));
+ -- Extend the line in each direction the new computed distance to insure they will intersect
+ l1 = ST_AddPoint(l1,ST_Makepoint(ST_X(ST_PointN(l1,2))+sin(a1)*dist,ST_Y(ST_PointN(l1,2))+cos(a1)*dist),-1);
+ l1 = ST_AddPoint(l1,ST_Makepoint(ST_X(ST_PointN(l1,1))-sin(a1)*dist,ST_Y(ST_PointN(l1,1))-cos(a1)*dist),0);
+
+ -- Repeat for the line from the point to the other diameter point
+ l2 = ST_Makeline(ST_PointN(ring,idx2),ST_PointN(ring,k));
+ p2 = ST_Line_interpolate_point(l2,0.5);
+ l2 = ST_Rotate(l2,pi()/2,p2);
+ a2 = ST_Azimuth(ST_PointN(l2,1),ST_PointN(l2,2));
+ l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,2))+sin(a2)*dist,ST_Y(ST_PointN(l2,2))+cos(a2)*dist),-1);
+ l2 = ST_AddPoint(l2,ST_Makepoint(ST_X(ST_PointN(l2,1))-sin(a2)*dist,ST_Y(ST_PointN(l2,1))-cos(a2)*dist),0);
+
+ -- The new center is the intersection of the two bisectors
+ center = ST_Intersection(l1,l2);
+ -- The new radius is the distance to any of the three points
+ radius = ST_Distance(center,ST_PointN(ring,idx1));
+ END IF;
+ END IF;
+ END LOOP;
+ --DONE!! Return the MBC via the buffer command
+ RETURN ST_Buffer(center,radius,segs_per_quarter);
- END;
+ END;
$BODY$
- LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _st_concavehull(param_inputgeom geometry)
RETURNS geometry AS
$$
- DECLARE
- vexhull GEOMETRY;
- var_resultgeom geometry;
- var_inputgeom geometry;
- vexring GEOMETRY;
- cavering GEOMETRY;
- cavept geometry[];
- seglength double precision;
- var_tempgeom geometry;
- scale_factor integer := 1;
- i integer;
-
- BEGIN
+ DECLARE
+ vexhull GEOMETRY;
+ var_resultgeom geometry;
+ var_inputgeom geometry;
+ vexring GEOMETRY;
+ cavering GEOMETRY;
+ cavept geometry[];
+ seglength double precision;
+ var_tempgeom geometry;
+ scale_factor integer := 1;
+ i integer;
+
+ BEGIN
+
+ -- First compute the ConvexHull of the geometry
+ vexhull := ST_ConvexHull(param_inputgeom);
+ var_inputgeom := param_inputgeom;
+ --A point really has no concave hull
+ IF ST_GeometryType(vexhull) = 'ST_Point' OR ST_GeometryType(vexHull) = 'ST_LineString' THEN
+ RETURN vexhull;
+ END IF;
- -- First compute the ConvexHull of the geometry
- vexhull := ST_ConvexHull(param_inputgeom);
- var_inputgeom := param_inputgeom;
- --A point really has no concave hull
- IF ST_GeometryType(vexhull) = 'ST_Point' OR ST_GeometryType(vexHull) = 'ST_LineString' THEN
- RETURN vexhull;
- END IF;
-
- -- convert the hull perimeter to a linestring so we can manipulate individual points
- vexring := CASE WHEN ST_GeometryType(vexhull) = 'ST_LineString' THEN vexhull ELSE ST_ExteriorRing(vexhull) END;
- IF abs(ST_X(ST_PointN(vexring,1))) < 1 THEN --scale the geometry to prevent stupid precision errors - not sure it works so make low for now
- scale_factor := 100;
- vexring := ST_Scale(vexring, scale_factor,scale_factor);
- var_inputgeom := ST_Scale(var_inputgeom, scale_factor, scale_factor);
- --RAISE NOTICE 'Scaling';
- END IF;
- seglength := ST_Length(vexring)/least(ST_NPoints(vexring)*2,1000) ;
-
- vexring := ST_Segmentize(vexring, seglength);
- -- find the point on the original geom that is closest to each point of the convex hull and make a new linestring out of it.
- cavering := ST_Collect(
- ARRAY(
-
- SELECT
- ST_ClosestPoint(var_inputgeom, pt ) As the_geom
- FROM (
- SELECT ST_PointN(vexring, n ) As pt, n
- FROM
- generate_series(1, ST_NPoints(vexring) ) As n
- ) As pt
-
- )
- )
- ;
-
-
- var_resultgeom := ST_MakeLine(geom)
- FROM ST_Dump(cavering) As foo;
-
- IF ST_IsSimple(var_resultgeom) THEN
- var_resultgeom := ST_MakePolygon(var_resultgeom);
- --RAISE NOTICE 'is Simple: %', var_resultgeom;
- ELSE
- --RAISE NOTICE 'is not Simple: %', var_resultgeom;
- var_resultgeom := ST_ConvexHull(var_resultgeom);
- END IF;
-
- IF scale_factor > 1 THEN -- scale the result back
- var_resultgeom := ST_Scale(var_resultgeom, 1/scale_factor, 1/scale_factor);
- END IF;
- RETURN var_resultgeom;
-
- END;
+ -- convert the hull perimeter to a linestring so we can manipulate individual points
+ vexring := CASE WHEN ST_GeometryType(vexhull) = 'ST_LineString' THEN vexhull ELSE ST_ExteriorRing(vexhull) END;
+ IF abs(ST_X(ST_PointN(vexring,1))) < 1 THEN --scale the geometry to prevent stupid precision errors - not sure it works so make low for now
+ scale_factor := 100;
+ vexring := ST_Scale(vexring, scale_factor,scale_factor);
+ var_inputgeom := ST_Scale(var_inputgeom, scale_factor, scale_factor);
+ --RAISE NOTICE 'Scaling';
+ END IF;
+ seglength := ST_Length(vexring)/least(ST_NPoints(vexring)*2,1000) ;
+
+ vexring := ST_Segmentize(vexring, seglength);
+ -- find the point on the original geom that is closest to each point of the convex hull and make a new linestring out of it.
+ cavering := ST_Collect(
+ ARRAY(
+
+ SELECT
+ ST_ClosestPoint(var_inputgeom, pt ) As the_geom
+ FROM (
+ SELECT ST_PointN(vexring, n ) As pt, n
+ FROM
+ generate_series(1, ST_NPoints(vexring) ) As n
+ ) As pt
+
+ )
+ )
+ ;
+
+
+ var_resultgeom := ST_MakeLine(geom)
+ FROM ST_Dump(cavering) As foo;
+
+ IF ST_IsSimple(var_resultgeom) THEN
+ var_resultgeom := ST_MakePolygon(var_resultgeom);
+ --RAISE NOTICE 'is Simple: %', var_resultgeom;
+ ELSE
+ --RAISE NOTICE 'is not Simple: %', var_resultgeom;
+ var_resultgeom := ST_ConvexHull(var_resultgeom);
+ END IF;
+
+ IF scale_factor > 1 THEN -- scale the result back
+ var_resultgeom := ST_Scale(var_resultgeom, 1/scale_factor, 1/scale_factor);
+ END IF;
+ RETURN var_resultgeom;
+
+ END;
$$
LANGUAGE plpgsql IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION ST_ConcaveHull(param_geom geometry, param_pctconvex float, param_allow_holes boolean DEFAULT false) RETURNS geometry AS
$$
- DECLARE
- var_convhull geometry := ST_ConvexHull(param_geom);
- var_param_geom geometry := param_geom;
- var_initarea float := ST_Area(var_convhull);
- var_newarea float := var_initarea;
- var_div integer := 6;
- var_tempgeom geometry;
- var_tempgeom2 geometry;
- var_cent geometry;
- var_geoms geometry[4];
- var_enline geometry;
- var_resultgeom geometry;
- var_atempgeoms geometry[];
- var_buf float := 1;
- BEGIN
- -- We start with convex hull as our base
- var_resultgeom := var_convhull;
-
- IF param_pctconvex = 1 THEN
- return var_resultgeom;
- ELSIF ST_GeometryType(var_param_geom) = 'ST_Polygon' THEN -- it is as concave as it is going to get
- IF param_allow_holes THEN -- leave the holes
- RETURN var_param_geom;
- ELSE -- remove the holes
- var_resultgeom := ST_MakePolygon(ST_ExteriorRing(var_param_geom));
- RETURN var_resultgeom;
- END IF;
- END IF;
- IF ST_Dimension(var_resultgeom) > 1 AND param_pctconvex BETWEEN 0 and 0.98 THEN
- -- get linestring that forms envelope of geometry
- var_enline := ST_Boundary(ST_Envelope(var_param_geom));
- var_buf := ST_Length(var_enline)/1000.0;
- IF ST_GeometryType(var_param_geom) = 'ST_MultiPoint' AND ST_NumGeometries(var_param_geom) BETWEEN 4 and 200 THEN
- -- we make polygons out of points since they are easier to cave in.
- -- Note we limit to between 4 and 200 points because this process is slow and gets quadratically slow
- var_buf := sqrt(ST_Area(var_convhull)*0.8/(ST_NumGeometries(var_param_geom)*ST_NumGeometries(var_param_geom)));
- var_atempgeoms := ARRAY(SELECT geom FROM ST_DumpPoints(var_param_geom));
- -- 5 and 10 and just fudge factors
- var_tempgeom := ST_Union(ARRAY(SELECT geom
- FROM (
- -- fuse near neighbors together
- SELECT DISTINCT ON (i) i, ST_Distance(var_atempgeoms[i],var_atempgeoms[j]), ST_Buffer(ST_MakeLine(var_atempgeoms[i], var_atempgeoms[j]) , var_buf*5, 'quad_segs=3') As geom
- FROM generate_series(1,array_upper(var_atempgeoms, 1)) As i
- INNER JOIN generate_series(1,array_upper(var_atempgeoms, 1)) As j
- ON (
- NOT ST_Intersects(var_atempgeoms[i],var_atempgeoms[j])
- AND ST_DWithin(var_atempgeoms[i],var_atempgeoms[j], var_buf*10)
- )
- UNION ALL
- -- catch the ones with no near neighbors
- SELECT i, 0, ST_Buffer(var_atempgeoms[i] , var_buf*10, 'quad_segs=3') As geom
- FROM generate_series(1,array_upper(var_atempgeoms, 1)) As i
- LEFT JOIN generate_series(ceiling(array_upper(var_atempgeoms,1)/2)::integer,array_upper(var_atempgeoms, 1)) As j
- ON (
- NOT ST_Intersects(var_atempgeoms[i],var_atempgeoms[j])
- AND ST_DWithin(var_atempgeoms[i],var_atempgeoms[j], var_buf*10)
- )
- WHERE j IS NULL
- ORDER BY 1, 2
- ) As foo ) );
- IF ST_IsValid(var_tempgeom) AND ST_GeometryType(var_tempgeom) = 'ST_Polygon' THEN
- var_tempgeom := ST_Intersection(var_tempgeom, var_convhull);
- IF param_allow_holes THEN
- var_param_geom := var_tempgeom;
- ELSE
- var_param_geom := ST_MakePolygon(ST_ExteriorRing(var_tempgeom));
- END IF;
- return var_param_geom;
- ELSIF ST_IsValid(var_tempgeom) THEN
- var_param_geom := ST_Intersection(var_tempgeom, var_convhull);
- END IF;
- END IF;
-
- IF ST_GeometryType(var_param_geom) = 'ST_Polygon' THEN
- IF NOT param_allow_holes THEN
- var_param_geom := ST_MakePolygon(ST_ExteriorRing(var_param_geom));
- END IF;
- return var_param_geom;
- END IF;
+ DECLARE
+ var_convhull geometry := ST_ConvexHull(param_geom);
+ var_param_geom geometry := param_geom;
+ var_initarea float := ST_Area(var_convhull);
+ var_newarea float := var_initarea;
+ var_div integer := 6;
+ var_tempgeom geometry;
+ var_tempgeom2 geometry;
+ var_cent geometry;
+ var_geoms geometry[4];
+ var_enline geometry;
+ var_resultgeom geometry;
+ var_atempgeoms geometry[];
+ var_buf float := 1;
+ BEGIN
+ -- We start with convex hull as our base
+ var_resultgeom := var_convhull;
+
+ IF param_pctconvex = 1 THEN
+ return var_resultgeom;
+ ELSIF ST_GeometryType(var_param_geom) = 'ST_Polygon' THEN -- it is as concave as it is going to get
+ IF param_allow_holes THEN -- leave the holes
+ RETURN var_param_geom;
+ ELSE -- remove the holes
+ var_resultgeom := ST_MakePolygon(ST_ExteriorRing(var_param_geom));
+ RETURN var_resultgeom;
+ END IF;
+ END IF;
+ IF ST_Dimension(var_resultgeom) > 1 AND param_pctconvex BETWEEN 0 and 0.98 THEN
+ -- get linestring that forms envelope of geometry
+ var_enline := ST_Boundary(ST_Envelope(var_param_geom));
+ var_buf := ST_Length(var_enline)/1000.0;
+ IF ST_GeometryType(var_param_geom) = 'ST_MultiPoint' AND ST_NumGeometries(var_param_geom) BETWEEN 4 and 200 THEN
+ -- we make polygons out of points since they are easier to cave in.
+ -- Note we limit to between 4 and 200 points because this process is slow and gets quadratically slow
+ var_buf := sqrt(ST_Area(var_convhull)*0.8/(ST_NumGeometries(var_param_geom)*ST_NumGeometries(var_param_geom)));
+ var_atempgeoms := ARRAY(SELECT geom FROM ST_DumpPoints(var_param_geom));
+ -- 5 and 10 and just fudge factors
+ var_tempgeom := ST_Union(ARRAY(SELECT geom
+ FROM (
+ -- fuse near neighbors together
+ SELECT DISTINCT ON (i) i, ST_Distance(var_atempgeoms[i],var_atempgeoms[j]), ST_Buffer(ST_MakeLine(var_atempgeoms[i], var_atempgeoms[j]) , var_buf*5, 'quad_segs=3') As geom
+ FROM generate_series(1,array_upper(var_atempgeoms, 1)) As i
+ INNER JOIN generate_series(1,array_upper(var_atempgeoms, 1)) As j
+ ON (
+ NOT ST_Intersects(var_atempgeoms[i],var_atempgeoms[j])
+ AND ST_DWithin(var_atempgeoms[i],var_atempgeoms[j], var_buf*10)
+ )
+ UNION ALL
+ -- catch the ones with no near neighbors
+ SELECT i, 0, ST_Buffer(var_atempgeoms[i] , var_buf*10, 'quad_segs=3') As geom
+ FROM generate_series(1,array_upper(var_atempgeoms, 1)) As i
+ LEFT JOIN generate_series(ceiling(array_upper(var_atempgeoms,1)/2)::integer,array_upper(var_atempgeoms, 1)) As j
+ ON (
+ NOT ST_Intersects(var_atempgeoms[i],var_atempgeoms[j])
+ AND ST_DWithin(var_atempgeoms[i],var_atempgeoms[j], var_buf*10)
+ )
+ WHERE j IS NULL
+ ORDER BY 1, 2
+ ) As foo ) );
+ IF ST_IsValid(var_tempgeom) AND ST_GeometryType(var_tempgeom) = 'ST_Polygon' THEN
+ var_tempgeom := ST_Intersection(var_tempgeom, var_convhull);
+ IF param_allow_holes THEN
+ var_param_geom := var_tempgeom;
+ ELSE
+ var_param_geom := ST_MakePolygon(ST_ExteriorRing(var_tempgeom));
+ END IF;
+ return var_param_geom;
+ ELSIF ST_IsValid(var_tempgeom) THEN
+ var_param_geom := ST_Intersection(var_tempgeom, var_convhull);
+ END IF;
+ END IF;
+
+ IF ST_GeometryType(var_param_geom) = 'ST_Polygon' THEN
+ IF NOT param_allow_holes THEN
+ var_param_geom := ST_MakePolygon(ST_ExteriorRing(var_param_geom));
+ END IF;
+ return var_param_geom;
+ END IF;
var_cent := ST_Centroid(var_param_geom);
IF (ST_XMax(var_enline) - ST_XMin(var_enline) ) > var_buf AND (ST_YMax(var_enline) - ST_YMin(var_enline) ) > var_buf THEN
IF ST_Dwithin(ST_Centroid(var_convhull) , ST_Centroid(ST_Envelope(var_param_geom)), var_buf/2) THEN
-- If the geometric dimension is > 1 and the object is symettric (cutting at centroid will not work -- offset a bit)
- var_cent := ST_Translate(var_cent, (ST_XMax(var_enline) - ST_XMin(var_enline))/1000, (ST_YMAX(var_enline) - ST_YMin(var_enline))/1000);
+ var_cent := ST_Translate(var_cent, (ST_XMax(var_enline) - ST_XMin(var_enline))/1000, (ST_YMAX(var_enline) - ST_YMin(var_enline))/1000);
ELSE
-- uses closest point on geometry to centroid. I can't explain why we are doing this
var_cent := ST_ClosestPoint(var_param_geom,var_cent);
@@ -4079,16 +4079,16 @@ $$
FOR i in 1 .. 4 LOOP
var_geoms[i] := ST_MakePolygon(ST_MakeLine(ARRAY[ST_PointN(var_enline,i), ST_PointN(var_enline,i+1), var_cent, ST_PointN(var_enline,i)]));
var_geoms[i] := ST_Intersection(var_param_geom, ST_Buffer(var_geoms[i],var_buf));
- IF ST_IsValid(var_geoms[i]) THEN
-
+ IF ST_IsValid(var_geoms[i]) THEN
+
ELSE
var_geoms[i] := ST_BuildArea(ST_MakeLine(ARRAY[ST_PointN(var_enline,i), ST_PointN(var_enline,i+1), var_cent, ST_PointN(var_enline,i)]));
- END IF;
+ END IF;
END LOOP;
- var_tempgeom := ST_Union(ARRAY[ST_ConvexHull(var_geoms[1]), ST_ConvexHull(var_geoms[2]) , ST_ConvexHull(var_geoms[3]), ST_ConvexHull(var_geoms[4])]);
+ var_tempgeom := ST_Union(ARRAY[ST_ConvexHull(var_geoms[1]), ST_ConvexHull(var_geoms[2]) , ST_ConvexHull(var_geoms[3]), ST_ConvexHull(var_geoms[4])]);
--RAISE NOTICE 'Curr vex % ', ST_AsText(var_tempgeom);
- IF ST_Area(var_tempgeom) <= var_newarea AND ST_IsValid(var_tempgeom) THEN --AND ST_GeometryType(var_tempgeom) ILIKE '%Polygon'
-
+ IF ST_Area(var_tempgeom) <= var_newarea AND ST_IsValid(var_tempgeom) THEN --AND ST_GeometryType(var_tempgeom) ILIKE '%Polygon'
+
var_tempgeom := ST_Buffer(ST_ConcaveHull(var_geoms[1],least(param_pctconvex + param_pctconvex/var_div),true),var_buf, 'quad_segs=2');
FOR i IN 1 .. 4 LOOP
var_geoms[i] := ST_Buffer(ST_ConcaveHull(var_geoms[i],least(param_pctconvex + param_pctconvex/var_div),true), var_buf, 'quad_segs=2');
@@ -4097,7 +4097,7 @@ $$
ELSE
RAISE NOTICE 'Not valid % %', i, ST_AsText(var_tempgeom);
var_tempgeom := ST_Union(var_tempgeom, ST_ConvexHull(var_geoms[i]));
- END IF;
+ END IF;
END LOOP;
--RAISE NOTICE 'Curr concave % ', ST_AsText(var_tempgeom);
@@ -4109,7 +4109,7 @@ $$
var_resultgeom := var_tempgeom;
END IF;
- IF ST_NumGeometries(var_resultgeom) > 1 THEN
+ IF ST_NumGeometries(var_resultgeom) > 1 THEN
var_tempgeom := _ST_ConcaveHull(var_resultgeom);
IF ST_IsValid(var_tempgeom) AND ST_GeometryType(var_tempgeom) ILIKE 'ST_Polygon' THEN
var_resultgeom := var_tempgeom;
@@ -4117,7 +4117,7 @@ $$
var_resultgeom := ST_Buffer(var_tempgeom,var_buf, 'quad_segs=2');
END IF;
END IF;
- IF param_allow_holes = false THEN
+ IF param_allow_holes = false THEN
-- only keep exterior ring since we do not want holes
var_resultgeom := ST_MakePolygon(ST_ExteriorRing(var_resultgeom));
END IF;
@@ -4130,17 +4130,17 @@ $$
var_resultgeom := _ST_ConcaveHull(var_param_geom);
END IF;
RETURN var_resultgeom;
- END;
+ END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _ST_AsX3D(int4, geometry, int4, int4, text)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asX3D'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asX3D'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION ST_AsX3D(geom geometry, maxdecimaldigits integer DEFAULT 15, options integer DEFAULT 0)
- RETURNS TEXT
- AS $$SELECT _ST_AsX3D(3,$1,$2,$3,'');$$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS TEXT
+ AS $$SELECT _ST_AsX3D(3,$1,$2,$3,'');$$
+ LANGUAGE 'sql' IMMUTABLE;
DROP AGGREGATE IF EXISTS memgeomunion(geometry);
DROP AGGREGATE IF EXISTS geomunion(geometry);
DROP AGGREGATE IF EXISTS polygonize(geometry); -- Deprecated in 1.2.3, Dropped in 2.0.0
@@ -4251,8 +4251,6 @@ DROP FUNCTION IF EXISTS SnapToGrid(geometry, float8, float8);
DROP FUNCTION IF EXISTS ST_AsBinary(text); -- deprecated in 2.0
DROP FUNCTION IF EXISTS postgis_uses_stats(); -- deprecated in 2.0
-
-
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- $Id: rtpostgis_drop.sql.in.c 7884 2011-09-22 15:07:25Z robe $
@@ -4262,7 +4260,7 @@ DROP FUNCTION IF EXISTS postgis_uses_stats(); -- deprecated in 2.0
--
-- Copyright (C) 2011 Regina Obe <lr@pcorp.us>
-- Copyright (C) 2011 Regents of the University of California
--- <bkpark@ucdavis.edu>
+-- <bkpark@ucdavis.edu>
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
@@ -4274,7 +4272,7 @@ DROP FUNCTION IF EXISTS postgis_uses_stats(); -- deprecated in 2.0
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- This file will be used to drop obselete functions and other objects.
-- It will be used for both upgrade and uninstall
--- Drop obsolete functions
+-- Drop obsolete functions
-- (which fully obsolete, changed to take default args, or outp params changed) --
-- drop aggregates
@@ -4312,7 +4310,7 @@ 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);
DROP FUNCTION IF EXISTS ST_Intersects(geometry,raster);
-DROP FUNCTION IF EXISTS ST_Intersects(raster, integer, boolean , geometry);
+DROP FUNCTION IF EXISTS ST_Intersects(raster, integer, boolean , geometry);
DROP FUNCTION IF EXISTS ST_Intersects(geometry , raster, integer , boolean);
DROP FUNCTION IF EXISTS ST_Intersection(raster,raster, integer, integer);
DROP FUNCTION IF EXISTS ST_Intersection(geometry,raster);
@@ -4328,21 +4326,21 @@ DROP FUNCTION IF EXISTS ST_MapAlgebra(raster, pixeltype text, expression text, n
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[]);
+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[]);
+DROP FUNCTION IF EXISTS ST_MapAlgebraFct(raster, raster, regprocedure, VARIADIC text[]);
--added extra parameter so these are obsolete --
DROP FUNCTION IF EXISTS ST_AsRaster(geometry , integer , integer , double precision , double precision , text , double precision , double precision , double precision , double precision );
@@ -4352,7 +4350,7 @@ DROP FUNCTION IF EXISTS ST_AsRaster(geometry , integer , integer , double precis
DROP FUNCTION IF EXISTS ST_AsRaster(geometry , integer , integer , double precision , double precision , text[] , double precision[] , double precision[] , double precision , double precision );
DROP FUNCTION IF EXISTS ST_AsRaster(geometry , double precision , double precision , text , double precision , double precision , double precision , double precision , double precision , double precision );
DROP FUNCTION IF EXISTS ST_AsRaster(geometry , raster , text , double precision , double precision );
-DROP FUNCTION IF EXISTS _ST_AsRaster(geometry,double precision , double precision, integer , integer,text[] , double precision[] ,double precision[] , double precision, double precision, double precision,double precision, double precision, double precision,touched boolean);
+DROP FUNCTION IF EXISTS _ST_AsRaster(geometry,double precision , double precision, integer , integer,text[] , double precision[] ,double precision[] , double precision, double precision, double precision,double precision, double precision, double precision,touched boolean);
-- arg names changed
DROP FUNCTION IF EXISTS _ST_Resample(raster, text, double precision, integer, double precision, double precision, double precision, double precision, double precision, double precision);
@@ -4430,11 +4428,11 @@ DROP FUNCTION IF EXISTS st_bandpixeltype(raster, integer);
-- signature changed and some functions dropped --
--- Note: I am only including the surviving variants
--- since some people may be using the dead ones which are in scripts
+-- Note: I am only including the surviving variants
+-- since some people may be using the dead ones which are in scripts
-- and we do not have a replace for those
DROP AGGREGATE IF EXISTS ST_Union(raster);
-DROP AGGREGATE IF EXISTS ST_Union(raster, integer, text);
+DROP AGGREGATE IF EXISTS ST_Union(raster, integer, text);
-- function no longer exists
DROP FUNCTION IF EXISTS st_value(raster, integer, integer, integer);
@@ -4459,7 +4457,7 @@ DROP FUNCTION IF EXISTS dumpaswktpolygons(raster, 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);
-- no longer needed functions changed to use out parameters
@@ -4469,36 +4467,36 @@ DROP TYPE IF EXISTS geomvalxy;
-- raster_columns and raster_overviews tables are deprecated
DROP FUNCTION IF EXISTS _rename_raster_tables();
CREATE OR REPLACE FUNCTION _rename_raster_tables()
- RETURNS void AS $$
- DECLARE
- cnt int;
- BEGIN
- SELECT count(*) INTO cnt
- FROM pg_class c
- JOIN pg_namespace n
- ON c.relnamespace = n.oid
- WHERE c.relname = 'raster_columns'
- AND c.relkind = 'r'::char
- AND NOT pg_is_other_temp_schema(c.relnamespace);
-
- IF cnt > 0 THEN
- EXECUTE 'ALTER TABLE raster_columns RENAME TO deprecated_raster_columns';
- END IF;
-
- SELECT count(*) INTO cnt
- FROM pg_class c
- JOIN pg_namespace n
- ON c.relnamespace = n.oid
- WHERE c.relname = 'raster_overviews'
- AND c.relkind = 'r'::char
- AND NOT pg_is_other_temp_schema(c.relnamespace);
-
- IF cnt > 0 THEN
- EXECUTE 'ALTER TABLE raster_overviews RENAME TO deprecated_raster_overviews';
- END IF;
+ RETURNS void AS $$
+ DECLARE
+ cnt int;
+ BEGIN
+ SELECT count(*) INTO cnt
+ FROM pg_class c
+ JOIN pg_namespace n
+ ON c.relnamespace = n.oid
+ WHERE c.relname = 'raster_columns'
+ AND c.relkind = 'r'::char
+ AND NOT pg_is_other_temp_schema(c.relnamespace);
+
+ IF cnt > 0 THEN
+ EXECUTE 'ALTER TABLE raster_columns RENAME TO deprecated_raster_columns';
+ END IF;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE;
+ SELECT count(*) INTO cnt
+ FROM pg_class c
+ JOIN pg_namespace n
+ ON c.relnamespace = n.oid
+ WHERE c.relname = 'raster_overviews'
+ AND c.relkind = 'r'::char
+ AND NOT pg_is_other_temp_schema(c.relnamespace);
+
+ IF cnt > 0 THEN
+ EXECUTE 'ALTER TABLE raster_overviews RENAME TO deprecated_raster_overviews';
+ END IF;
+
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE;
SELECT _rename_raster_tables();
ALTER EXTENSION postgis DROP FUNCTION _rename_raster_tables();DROP FUNCTION _rename_raster_tables();
@@ -4524,25 +4522,25 @@ DROP FUNCTION IF EXISTS DropRasterConstraints(name, name, boolean, boolean, bool
-- function parameters renamed
CREATE OR REPLACE FUNCTION _drop_st_samealignment()
- RETURNS void AS $$
- DECLARE
- cnt int;
- BEGIN
- SELECT count(*) INTO cnt
- FROM pg_proc
- WHERE lower(proname) = 'st_samealignment'
- AND pronargs = 2
- AND (
- proargnames = '{rasta,rastb}'::text[] OR
- proargnames = '{rastA,rastB}'::text[]
- );
-
- IF cnt > 0 THEN
- RAISE NOTICE 'Dropping ST_SameAlignment(raster, raster) due to parameter name changes. Unfortunately, this is a DROP ... CASCADE as the alignment raster constraint uses ST_SameAlignment(raster, raster). You will need to reapply AddRasterConstraint(''SCHEMA'', ''TABLE'', ''COLUMN'', ''alignment'') to any raster column that requires this constraint.';
- DROP FUNCTION IF EXISTS st_samealignment(raster, raster) CASCADE;
- END IF;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE;
+ RETURNS void AS $$
+ DECLARE
+ cnt int;
+ BEGIN
+ SELECT count(*) INTO cnt
+ FROM pg_proc
+ WHERE lower(proname) = 'st_samealignment'
+ AND pronargs = 2
+ AND (
+ proargnames = '{rasta,rastb}'::text[] OR
+ proargnames = '{rastA,rastB}'::text[]
+ );
+
+ IF cnt > 0 THEN
+ RAISE NOTICE 'Dropping ST_SameAlignment(raster, raster) due to parameter name changes. Unfortunately, this is a DROP ... CASCADE as the alignment raster constraint uses ST_SameAlignment(raster, raster). You will need to reapply AddRasterConstraint(''SCHEMA'', ''TABLE'', ''COLUMN'', ''alignment'') to any raster column that requires this constraint.';
+ DROP FUNCTION IF EXISTS st_samealignment(raster, raster) CASCADE;
+ END IF;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE;
SELECT _drop_st_samealignment();
ALTER EXTENSION postgis DROP FUNCTION _drop_st_samealignment();DROP FUNCTION _drop_st_samealignment();
DROP FUNCTION IF EXISTS _st_intersects(raster, integer, raster, integer);
@@ -4580,8 +4578,6 @@ DROP FUNCTION IF EXISTS st_intersection(raster, integer, raster, integer, text,
DROP FUNCTION IF EXISTS st_intersection(raster, integer, raster, integer, regprocedure);
DROP FUNCTION IF EXISTS st_intersection(raster, raster, text, regprocedure);
DROP FUNCTION IF EXISTS st_intersection(raster, raster, regprocedure);
-
-
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- $Id: rtpostgis_upgrade.sql.in.c 8448 2011-12-16 22:07:26Z dustymugs $
@@ -4591,7 +4587,7 @@ DROP FUNCTION IF EXISTS st_intersection(raster, raster, regprocedure);
--
-- Copyright (c) 2011 Regina Obe <lr@pcorp.us>
-- Copyright (C) 2011 Regents of the University of California
--- <bkpark@ucdavis.edu>
+-- <bkpark@ucdavis.edu>
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
@@ -4605,7 +4601,7 @@ DROP FUNCTION IF EXISTS st_intersection(raster, raster, regprocedure);
-- 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
@@ -4613,14 +4609,6 @@ DROP FUNCTION IF EXISTS st_intersection(raster, raster, regprocedure);
-
-
-
-
-
-
-
-
-- drop st_bytea
SELECT postgis_extension_drop_if_exists('postgis', 'DROP CAST IF EXISTS (raster AS bytea);');DROP CAST IF EXISTS (raster AS bytea);
DROP FUNCTION IF EXISTS st_bytea(raster);
@@ -4637,31 +4625,29 @@ SELECT postgis_extension_drop_if_exists('postgis', 'DROP CAST IF EXISTS (raster
DROP FUNCTION IF EXISTS box2d(raster);
-- create box3d cast if it does not exist
+
-- If we are running 9.0+ we can use DO plpgsql to check
-- and only create if not exists so no need to force a drop
-- that way if people are using it, we will not mess them up
DO language 'plpgsql' $$DECLARE r record;
BEGIN
- IF NOT EXISTS(SELECT cs.typname AS source
- FROM pg_cast AS ca
- INNER JOIN pg_type AS cs ON ca.castsource = cs.oid
- INNER JOIN pg_type AS ct ON ca.casttarget = ct.oid
- WHERE cs.typname = 'raster' AND ct.typname = 'box3d') THEN
- CREATE OR REPLACE FUNCTION box3d(raster)
- RETURNS box3d
- AS 'SELECT box3d(st_convexhull($1))'
- LANGUAGE 'sql' IMMUTABLE STRICT;
- CREATE CAST (raster AS box3d)
- WITH FUNCTION box3d(raster) AS ASSIGNMENT;
+ IF NOT EXISTS(SELECT cs.typname AS source
+ FROM pg_cast AS ca
+ INNER JOIN pg_type AS cs ON ca.castsource = cs.oid
+ INNER JOIN pg_type AS ct ON ca.casttarget = ct.oid
+ WHERE cs.typname = 'raster' AND ct.typname = 'box3d') THEN
+ CREATE OR REPLACE FUNCTION box3d(raster)
+ RETURNS box3d
+ AS 'SELECT box3d(st_convexhull($1))'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+ CREATE CAST (raster AS box3d)
+ WITH FUNCTION box3d(raster) AS ASSIGNMENT;
END IF;
-END$$;
-
+END$$;
-- make geometry cast ASSIGNMENT
SELECT postgis_extension_drop_if_exists('postgis', 'DROP CAST IF EXISTS (raster AS geometry);');DROP CAST IF EXISTS (raster AS geometry);
CREATE CAST (raster AS geometry)
- WITH FUNCTION st_convexhull(raster) AS ASSIGNMENT;
-
-
+ WITH FUNCTION st_convexhull(raster) AS ASSIGNMENT;
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
--
@@ -4674,7 +4660,7 @@ CREATE CAST (raster AS geometry)
-- Copyright (c) 2009-2010 Mateusz Loskot <mateusz@loskot.net>
-- Copyright (c) 2010 David Zwarg <dzwarg@azavea.com>
-- Copyright (C) 2011 Regents of the University of California
--- <bkpark@ucdavis.edu>
+-- <bkpark@ucdavis.edu>
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
@@ -4689,13 +4675,6 @@ CREATE CAST (raster AS geometry)
-
-
-
-
-
-
-
SET client_min_messages TO warning;
@@ -4838,20 +4817,20 @@ CREATE OR REPLACE FUNCTION st_rotation(raster)
LANGUAGE 'sql' VOLATILE;
CREATE OR REPLACE FUNCTION st_metadata(
- rast raster,
- OUT upperleftx double precision,
- OUT upperlefty double precision,
- OUT width int,
- OUT height int,
- OUT scalex double precision,
- OUT scaley double precision,
- OUT skewx double precision,
- OUT skewy double precision,
- OUT srid int,
- OUT numbands int
+ rast raster,
+ OUT upperleftx double precision,
+ OUT upperlefty double precision,
+ OUT width int,
+ OUT height int,
+ OUT scalex double precision,
+ OUT scaley double precision,
+ OUT skewx double precision,
+ OUT skewy double precision,
+ OUT srid int,
+ OUT numbands int
)
- AS '$libdir/rtpostgis-2.0', 'RASTER_metadata'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ AS '$libdir/rtpostgis-2.0', 'RASTER_metadata'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- Constructors ST_MakeEmptyRaster and ST_AddBand
@@ -4869,20 +4848,20 @@ CREATE OR REPLACE FUNCTION st_makeemptyraster(width int, height int, upperleftx
CREATE OR REPLACE FUNCTION st_makeemptyraster(rast raster)
RETURNS raster
AS $$
- DECLARE
- w int;
- h int;
- ul_x double precision;
- ul_y double precision;
- scale_x double precision;
- scale_y double precision;
- skew_x double precision;
- skew_y double precision;
- sr_id int;
- BEGIN
- SELECT width, height, upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid INTO w, h, ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id FROM ST_Metadata(rast);
- RETURN st_makeemptyraster(w, h, ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id);
- END;
+ DECLARE
+ w int;
+ h int;
+ ul_x double precision;
+ ul_y double precision;
+ scale_x double precision;
+ scale_y double precision;
+ skew_x double precision;
+ skew_y double precision;
+ sr_id int;
+ BEGIN
+ SELECT width, height, upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid INTO w, h, ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id FROM ST_Metadata(rast);
+ RETURN st_makeemptyraster(w, h, ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id);
+ END;
$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-- This function can not be STRICT, because nodataval can be NULL indicating that no nodata value should be set
@@ -4902,46 +4881,46 @@ CREATE OR REPLACE FUNCTION st_addband(torast raster, fromrast raster, fromband i
RETURNS RASTER
AS '$libdir/rtpostgis-2.0', 'RASTER_copyband'
LANGUAGE 'c' IMMUTABLE;
-
+
-- Variant that adds multiple raster bands in one array call --
-- If null is passed in for the torast, then array of rasts is accumulated.
CREATE OR REPLACE FUNCTION ST_AddBand(torast raster, fromrasts raster[], fromband integer DEFAULT 1)
RETURNS raster
AS $$
- DECLARE var_result raster := torast;
- var_num integer := array_upper(fromrasts,1);
- var_i integer := 1;
- BEGIN
- IF torast IS NULL AND var_num > 0 THEN
- var_result := ST_Band(fromrasts[1],fromband);
- var_i := 2;
- END IF;
- WHILE var_i <= var_num LOOP
- var_result := ST_AddBand(var_result, fromrasts[var_i], 1);
- var_i := var_i + 1;
- END LOOP;
-
- RETURN var_result;
- END;
+ DECLARE var_result raster := torast;
+ var_num integer := array_upper(fromrasts,1);
+ var_i integer := 1;
+ BEGIN
+ IF torast IS NULL AND var_num > 0 THEN
+ var_result := ST_Band(fromrasts[1],fromband);
+ var_i := 2;
+ END IF;
+ WHILE var_i <= var_num LOOP
+ var_result := ST_AddBand(var_result, fromrasts[var_i], 1);
+ var_i := var_i + 1;
+ END LOOP;
+
+ RETURN var_result;
+ END;
$$ LANGUAGE 'plpgsql';
-----------------------------------------------------------------------
-- Constructor ST_Band
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_band(rast raster, nbands int[] DEFAULT ARRAY[1])
- RETURNS RASTER
- AS '$libdir/rtpostgis-2.0', 'RASTER_band'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS RASTER
+ AS '$libdir/rtpostgis-2.0', 'RASTER_band'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_band(rast raster, nband int)
- RETURNS RASTER
- AS $$ SELECT st_band($1, ARRAY[$2]) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS RASTER
+ AS $$ SELECT st_band($1, ARRAY[$2]) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_band(rast raster, nbands text, delimiter char DEFAULT ',')
- RETURNS RASTER
- AS $$ SELECT st_band($1, regexp_split_to_array(regexp_replace($2, '[[:space:]]', '', 'g'), $3)::int[]) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS RASTER
+ AS $$ SELECT st_band($1, regexp_split_to_array(regexp_replace($2, '[[:space:]]', '', 'g'), $3)::int[]) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- ST_SummaryStats and ST_ApproxSummaryStats
@@ -4949,218 +4928,218 @@ CREATE OR REPLACE FUNCTION st_band(rast raster, nbands text, delimiter char DEFA
CREATE OR REPLACE FUNCTION _st_summarystats(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1)
- RETURNS summarystats
- AS '$libdir/rtpostgis-2.0','RASTER_summaryStats'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS summarystats
+ AS '$libdir/rtpostgis-2.0','RASTER_summaryStats'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_summarystats(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, $3, 1) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, $3, 1) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_summarystats(rast raster, exclude_nodata_value boolean)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, 1, $2, 1) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, 1, $2, 1) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rast raster, nband int, sample_percent double precision)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, TRUE, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, TRUE, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rast raster, exclude_nodata_value boolean, sample_percent double precision DEFAULT 0.1)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, 1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, 1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rast raster, sample_percent double precision)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, 1, TRUE, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, 1, TRUE, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _st_summarystats(rastertable text, rastercolumn text, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1)
- RETURNS summarystats
- AS '$libdir/rtpostgis-2.0','RASTER_summaryStatsCoverage'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS summarystats
+ AS '$libdir/rtpostgis-2.0','RASTER_summaryStatsCoverage'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_summarystats(rastertable text, rastercolumn text, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, $3, $4, 1) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, $3, $4, 1) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_summarystats(rastertable text, rastercolumn text, exclude_nodata_value boolean)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, 1, $3, 1) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, 1, $3, 1) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rastertable text, rastercolumn text, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, $3, $4, $5) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, $3, $4, $5) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rastertable text, rastercolumn text, nband integer, sample_percent double precision)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, $3, TRUE, $4) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, $3, TRUE, $4) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rastertable text, rastercolumn text, exclude_nodata_value boolean)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, 1, $3, 0.1) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, 1, $3, 0.1) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxsummarystats(rastertable text, rastercolumn text, sample_percent double precision)
- RETURNS summarystats
- AS $$ SELECT _st_summarystats($1, $2, 1, TRUE, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS summarystats
+ AS $$ SELECT _st_summarystats($1, $2, 1, TRUE, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Count and ST_ApproxCount
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _st_count(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1)
- RETURNS bigint
- AS $$
- DECLARE
- rtn bigint;
- BEGIN
- IF exclude_nodata_value IS FALSE THEN
- SELECT width * height INTO rtn FROM ST_Metadata(rast);
- ELSE
- SELECT count INTO rtn FROM _st_summarystats($1, $2, $3, $4);
- END IF;
+ RETURNS bigint
+ AS $$
+ DECLARE
+ rtn bigint;
+ BEGIN
+ IF exclude_nodata_value IS FALSE THEN
+ SELECT width * height INTO rtn FROM ST_Metadata(rast);
+ ELSE
+ SELECT count INTO rtn FROM _st_summarystats($1, $2, $3, $4);
+ END IF;
- RETURN rtn;
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURN rtn;
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_count(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, $3, 1) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, $3, 1) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_count(rast raster, exclude_nodata_value boolean)
- RETURNS bigint
- AS $$ SELECT _st_count($1, 1, $2, 1) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, 1, $2, 1) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rast raster, nband int, sample_percent double precision)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, TRUE, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, TRUE, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rast raster, exclude_nodata_value boolean, sample_percent double precision DEFAULT 0.1)
- RETURNS bigint
- AS $$ SELECT _st_count($1, 1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, 1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rast raster, sample_percent double precision)
- RETURNS bigint
- AS $$ SELECT _st_count($1, 1, TRUE, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, 1, TRUE, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _st_count(rastertable text, rastercolumn text, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1)
- RETURNS bigint
- AS $$
- DECLARE
- curs refcursor;
-
- ctable text;
- ccolumn text;
- rast raster;
- stats summarystats;
-
- rtn bigint;
- tmp bigint;
- BEGIN
- -- nband
- IF nband < 1 THEN
- RAISE WARNING 'Invalid band index (must use 1-based). Returning NULL';
- RETURN NULL;
- END IF;
-
- -- sample percent
- IF sample_percent < 0 OR sample_percent > 1 THEN
- RAISE WARNING 'Invalid sample percentage (must be between 0 and 1). Returning NULL';
- RETURN NULL;
- END IF;
-
- -- exclude_nodata_value IS TRUE
- IF exclude_nodata_value IS TRUE THEN
- SELECT count INTO rtn FROM _st_summarystats($1, $2, $3, $4, $5);
- RETURN rtn;
- END IF;
-
- -- clean rastertable and rastercolumn
- ctable := quote_ident(rastertable);
- ccolumn := quote_ident(rastercolumn);
-
- BEGIN
- OPEN curs FOR EXECUTE 'SELECT '
- || ccolumn
- || ' FROM '
- || ctable
- || ' WHERE '
- || ccolumn
- || ' IS NOT NULL';
- EXCEPTION
- WHEN OTHERS THEN
- RAISE WARNING 'Invalid table or column name. Returning NULL';
- RETURN NULL;
- END;
-
- rtn := 0;
- LOOP
- FETCH curs INTO rast;
- EXIT WHEN NOT FOUND;
-
- SELECT (width * height) INTO tmp FROM ST_Metadata(rast);
- rtn := rtn + tmp;
- END LOOP;
-
- CLOSE curs;
-
- RETURN rtn;
- END;
- $$ LANGUAGE 'plpgsql' STABLE STRICT;
+ RETURNS bigint
+ AS $$
+ DECLARE
+ curs refcursor;
+
+ ctable text;
+ ccolumn text;
+ rast raster;
+ stats summarystats;
+
+ rtn bigint;
+ tmp bigint;
+ BEGIN
+ -- nband
+ IF nband < 1 THEN
+ RAISE WARNING 'Invalid band index (must use 1-based). Returning NULL';
+ RETURN NULL;
+ END IF;
+
+ -- sample percent
+ IF sample_percent < 0 OR sample_percent > 1 THEN
+ RAISE WARNING 'Invalid sample percentage (must be between 0 and 1). Returning NULL';
+ RETURN NULL;
+ END IF;
+
+ -- exclude_nodata_value IS TRUE
+ IF exclude_nodata_value IS TRUE THEN
+ SELECT count INTO rtn FROM _st_summarystats($1, $2, $3, $4, $5);
+ RETURN rtn;
+ END IF;
+
+ -- clean rastertable and rastercolumn
+ ctable := quote_ident(rastertable);
+ ccolumn := quote_ident(rastercolumn);
+
+ BEGIN
+ OPEN curs FOR EXECUTE 'SELECT '
+ || ccolumn
+ || ' FROM '
+ || ctable
+ || ' WHERE '
+ || ccolumn
+ || ' IS NOT NULL';
+ EXCEPTION
+ WHEN OTHERS THEN
+ RAISE WARNING 'Invalid table or column name. Returning NULL';
+ RETURN NULL;
+ END;
+
+ rtn := 0;
+ LOOP
+ FETCH curs INTO rast;
+ EXIT WHEN NOT FOUND;
+
+ SELECT (width * height) INTO tmp FROM ST_Metadata(rast);
+ rtn := rtn + tmp;
+ END LOOP;
+
+ CLOSE curs;
+
+ RETURN rtn;
+ END;
+ $$ LANGUAGE 'plpgsql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_count(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, $3, $4, 1) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, $3, $4, 1) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_count(rastertable text, rastercolumn text, exclude_nodata_value boolean)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, 1, $3, 1) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, 1, $3, 1) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, $3, $4, $5) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, $3, $4, $5) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rastertable text, rastercolumn text, nband int, sample_percent double precision)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, $3, TRUE, $4) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, $3, TRUE, $4) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rastertable text, rastercolumn text, exclude_nodata_value boolean, sample_percent double precision DEFAULT 0.1)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, 1, $3, $4) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, 1, $3, $4) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxcount(rastertable text, rastercolumn text, sample_percent double precision)
- RETURNS bigint
- AS $$ SELECT _st_count($1, $2, 1, TRUE, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS bigint
+ AS $$ SELECT _st_count($1, $2, 1, TRUE, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Histogram and ST_ApproxHistogram
@@ -5169,149 +5148,149 @@ CREATE OR REPLACE FUNCTION st_approxcount(rastertable text, rastercolumn text, s
-- Cannot be strict as "width", "min" and "max" can be NULL
CREATE OR REPLACE FUNCTION _st_histogram(
- rast raster, nband int DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- sample_percent double precision DEFAULT 1,
- bins int DEFAULT 0, width double precision[] DEFAULT NULL,
- right boolean DEFAULT FALSE,
- min double precision DEFAULT NULL, max double precision DEFAULT NULL
+ rast raster, nband int DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ sample_percent double precision DEFAULT 1,
+ bins int DEFAULT 0, width double precision[] DEFAULT NULL,
+ right boolean DEFAULT FALSE,
+ min double precision DEFAULT NULL, max double precision DEFAULT NULL
)
- RETURNS SETOF histogram
- AS '$libdir/rtpostgis-2.0','RASTER_histogram'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS SETOF histogram
+ AS '$libdir/rtpostgis-2.0','RASTER_histogram'
+ LANGUAGE 'c' IMMUTABLE;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, 1, $4, $5, $6) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, 1, $4, $5, $6) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int, exclude_nodata_value boolean, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, 1, $4, NULL, $5) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, 1, $4, NULL, $5) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, 1, $3, $4, $5) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, 1, $3, $4, $5) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_histogram(rast raster, nband int, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, 1, $3, NULL, $4) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, 1, $3, NULL, $4) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_approxhistogram(
- rast raster, nband int DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- sample_percent double precision DEFAULT 0.1,
- bins int DEFAULT 0, width double precision[] DEFAULT NULL,
- right boolean DEFAULT FALSE
+ rast raster, nband int DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ sample_percent double precision DEFAULT 0.1,
+ bins int DEFAULT 0, width double precision[] DEFAULT NULL,
+ right boolean DEFAULT FALSE
)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, $4, $5, $6, $7) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, $4, $5, $6, $7) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, $4, $5, NULL, $6) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, $3, $4, $5, NULL, $6) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, sample_percent double precision)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, 0, NULL, FALSE) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, 0, NULL, FALSE) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, sample_percent double precision)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, 1, TRUE, $2, 0, NULL, FALSE) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, 1, TRUE, $2, 0, NULL, FALSE) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, $4, $5, $6) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, $4, $5, $6) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxhistogram(rast raster, nband int, sample_percent double precision, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, $4, NULL, $5) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT min, max, count, percent FROM _st_histogram($1, $2, TRUE, $3, $4, NULL, $5) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION _st_histogram(
- rastertable text, rastercolumn text,
- nband int DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- sample_percent double precision DEFAULT 1,
- bins int DEFAULT 0, width double precision[] DEFAULT NULL,
- right boolean DEFAULT FALSE
+ rastertable text, rastercolumn text,
+ nband int DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ sample_percent double precision DEFAULT 1,
+ bins int DEFAULT 0, width double precision[] DEFAULT NULL,
+ right boolean DEFAULT FALSE
)
- RETURNS SETOF histogram
- AS '$libdir/rtpostgis-2.0','RASTER_histogramCoverage'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS SETOF histogram
+ AS '$libdir/rtpostgis-2.0','RASTER_histogramCoverage'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, bins int DEFAULT 0, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, $4, 1, $5, $6, $7) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, $4, 1, $5, $6, $7) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, $4, 1, $5, NULL, $6) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, $4, 1, $5, NULL, $6) $$
+ LANGUAGE 'sql' STABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, TRUE, 1, $4, $5, $6) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, TRUE, 1, $4, $5, $6) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_histogram(rastertable text, rastercolumn text, nband int, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, TRUE, 1, $4, NULL, $5) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, TRUE, 1, $4, NULL, $5) $$
+ LANGUAGE 'sql' STABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_approxhistogram(
- rastertable text, rastercolumn text,
- nband int DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- sample_percent double precision DEFAULT 0.1,
- bins int DEFAULT 0, width double precision[] DEFAULT NULL,
- right boolean DEFAULT FALSE
+ rastertable text, rastercolumn text,
+ nband int DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ sample_percent double precision DEFAULT 0.1,
+ bins int DEFAULT 0, width double precision[] DEFAULT NULL,
+ right boolean DEFAULT FALSE
)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, $4, $5, $6, $7, $8) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, $4, $5, $6, $7, $8) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, $4, $5, $6, NULL, $7) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, $4, $5, $6, NULL, $7) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, 0, NULL, FALSE) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, 0, NULL, FALSE) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, sample_percent double precision)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, 1, TRUE, $3, 0, NULL, FALSE) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, 1, TRUE, $3, 0, NULL, FALSE) $$
+ LANGUAGE 'sql' STABLE STRICT;
-- Cannot be strict as "width" can be NULL
CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, width double precision[] DEFAULT NULL, right boolean DEFAULT FALSE)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, $5, $6, $7) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, $5, $6, $7) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn text, nband int, sample_percent double precision, bins int, right boolean)
- RETURNS SETOF histogram
- AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, $5, NULL, $6) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF histogram
+ AS $$ SELECT _st_histogram($1, $2, $3, TRUE, $4, $5, NULL, $6) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Quantile and ST_ApproxQuantile
@@ -5320,187 +5299,187 @@ CREATE OR REPLACE FUNCTION st_approxhistogram(rastertable text, rastercolumn tex
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION _st_quantile(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS '$libdir/rtpostgis-2.0','RASTER_quantile'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS SETOF quantile
+ AS '$libdir/rtpostgis-2.0','RASTER_quantile'
+ LANGUAGE 'c' IMMUTABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_quantile(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, $3, 1, $4) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, $3, 1, $4) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_quantile(rast raster, nband int, quantiles double precision[])
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, TRUE, 1, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, TRUE, 1, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_quantile(rast raster, quantiles double precision[])
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, 1, TRUE, 1, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, 1, TRUE, 1, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_quantile(rast raster, nband int, exclude_nodata_value boolean, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, $3, 1, ARRAY[$4]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, $3, 1, ARRAY[$4]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_quantile(rast raster, nband int, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, TRUE, 1, ARRAY[$3]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, TRUE, 1, ARRAY[$3]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "quantile" can be NULL
CREATE OR REPLACE FUNCTION st_quantile(rast raster, exclude_nodata_value boolean, quantile double precision DEFAULT NULL)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, 1, $2, 1, ARRAY[$3]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, 1, $2, 1, ARRAY[$3]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_quantile(rast raster, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, 1, TRUE, 1, ARRAY[$2]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, 1, TRUE, 1, ARRAY[$2]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, $3, $4, $5) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, $3, $4, $5) $$
+ LANGUAGE 'sql' IMMUTABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, nband int, sample_percent double precision, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, TRUE, $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, TRUE, $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, sample_percent double precision, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, 1, TRUE, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, 1, TRUE, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, quantiles double precision[])
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, 1, TRUE, 0.1, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, 1, TRUE, 0.1, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, nband int, exclude_nodata_value boolean, sample_percent double precision, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, $3, $4, ARRAY[$5]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, $3, $4, ARRAY[$5]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, nband int, sample_percent double precision, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, TRUE, $3, ARRAY[$4]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, TRUE, $3, ARRAY[$4]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, sample_percent double precision, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, 1, TRUE, $2, ARRAY[$3]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, 1, TRUE, $2, ARRAY[$3]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Cannot be strict as "quantile" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, exclude_nodata_value boolean, quantile double precision DEFAULT NULL)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, 1, $2, 0.1, ARRAY[$3]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, 1, $2, 0.1, ARRAY[$3]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_approxquantile(rast raster, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, 1, TRUE, 0.1, ARRAY[$2]::double precision[])).value $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, 1, TRUE, 0.1, ARRAY[$2]::double precision[])).value $$
+ LANGUAGE 'sql' IMMUTABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION _st_quantile(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 1, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS '$libdir/rtpostgis-2.0','RASTER_quantileCoverage'
- LANGUAGE 'c' STABLE;
+ RETURNS SETOF quantile
+ AS '$libdir/rtpostgis-2.0','RASTER_quantileCoverage'
+ LANGUAGE 'c' STABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, $3, $4, 1, $5) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, $3, $4, 1, $5) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, nband int, quantiles double precision[])
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, $3, TRUE, 1, $4) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, $3, TRUE, 1, $4) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, quantiles double precision[])
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, 1, TRUE, 1, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, 1, TRUE, 1, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, $3, $4, 1, ARRAY[$5]::double precision[])).value $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, $3, $4, 1, ARRAY[$5]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, nband int, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, $3, TRUE, 1, ARRAY[$4]::double precision[])).value $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, $3, TRUE, 1, ARRAY[$4]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE STRICT;
-- Cannot be strict as "quantile" can be NULL
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, exclude_nodata_value boolean, quantile double precision DEFAULT NULL)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, 1, $3, 1, ARRAY[$4]::double precision[])).value $$
- LANGUAGE 'sql' STABLE;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, 1, $3, 1, ARRAY[$4]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_quantile(rastertable text, rastercolumn text, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, 1, TRUE, 1, ARRAY[$3]::double precision[])).value $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, 1, TRUE, 1, ARRAY[$3]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE STRICT;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, nband int DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, sample_percent double precision DEFAULT 0.1, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, $3, $4, $5, $6) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, $3, $4, $5, $6) $$
+ LANGUAGE 'sql' STABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, nband int, sample_percent double precision, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, $3, TRUE, $4, $5) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, $3, TRUE, $4, $5) $$
+ LANGUAGE 'sql' STABLE;
-- Cannot be strict as "quantiles" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, sample_percent double precision, quantiles double precision[] DEFAULT NULL)
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, 1, TRUE, $3, $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, 1, TRUE, $3, $4) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, quantiles double precision[])
- RETURNS SETOF quantile
- AS $$ SELECT _st_quantile($1, $2, 1, TRUE, 0.1, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS SETOF quantile
+ AS $$ SELECT _st_quantile($1, $2, 1, TRUE, 0.1, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, nband int, exclude_nodata_value boolean, sample_percent double precision, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, $3, $4, $5, ARRAY[$6]::double precision[])).value $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, $3, $4, $5, ARRAY[$6]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, nband int, sample_percent double precision, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, $3, TRUE, $4, ARRAY[$5]::double precision[])).value $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, $3, TRUE, $4, ARRAY[$5]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, sample_percent double precision, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, 1, TRUE, $3, ARRAY[$4]::double precision[])).value $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, 1, TRUE, $3, ARRAY[$4]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE STRICT;
-- Cannot be strict as "quantile" can be NULL
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, exclude_nodata_value boolean, quantile double precision DEFAULT NULL)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, 1, $3, 0.1, ARRAY[$4]::double precision[])).value $$
- LANGUAGE 'sql' STABLE;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, 1, $3, 0.1, ARRAY[$4]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text, quantile double precision)
- RETURNS double precision
- AS $$ SELECT (_st_quantile($1, $2, 1, TRUE, 0.1, ARRAY[$3]::double precision[])).value $$
- LANGUAGE 'sql' STABLE;
+ RETURNS double precision
+ AS $$ SELECT (_st_quantile($1, $2, 1, TRUE, 0.1, ARRAY[$3]::double precision[])).value $$
+ LANGUAGE 'sql' STABLE;
-----------------------------------------------------------------------
-- ST_ValueCount and ST_ValuePercent
@@ -5511,160 +5490,160 @@ CREATE OR REPLACE FUNCTION st_approxquantile(rastertable text, rastercolumn text
-- Allowing "searchvalues" to be NULL instructs the function to count all values
CREATE OR REPLACE FUNCTION _st_valuecount(rast raster, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, searchvalues double precision[] DEFAULT NULL, roundto double precision DEFAULT 0)
- RETURNS SETOF valuecount
- AS '$libdir/rtpostgis-2.0', 'RASTER_valueCount'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS SETOF valuecount
+ AS '$libdir/rtpostgis-2.0', 'RASTER_valueCount'
+ LANGUAGE 'c' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuecount(
- rast raster, nband integer DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- searchvalues double precision[] DEFAULT NULL,
- roundto double precision DEFAULT 0,
- OUT value double precision, OUT count integer
+ rast raster, nband integer DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ searchvalues double precision[] DEFAULT NULL,
+ roundto double precision DEFAULT 0,
+ OUT value double precision, OUT count integer
)
- RETURNS SETOF record
- AS $$ SELECT value, count FROM _st_valuecount($1, $2, $3, $4, $5) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, count FROM _st_valuecount($1, $2, $3, $4, $5) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuecount(rast raster, nband integer, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT count integer)
- RETURNS SETOF record
- AS $$ SELECT value, count FROM _st_valuecount($1, $2, TRUE, $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, count FROM _st_valuecount($1, $2, TRUE, $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuecount(rast raster, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT count integer)
- RETURNS SETOF record
- AS $$ SELECT value, count FROM _st_valuecount($1, 1, TRUE, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, count FROM _st_valuecount($1, 1, TRUE, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuecount(rast raster, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS integer
- AS $$ SELECT (_st_valuecount($1, $2, $3, ARRAY[$4]::double precision[], $5)).count $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS integer
+ AS $$ SELECT (_st_valuecount($1, $2, $3, ARRAY[$4]::double precision[], $5)).count $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuecount(rast raster, nband integer, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS integer
- AS $$ SELECT (_st_valuecount($1, $2, TRUE, ARRAY[$3]::double precision[], $4)).count $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS integer
+ AS $$ SELECT (_st_valuecount($1, $2, TRUE, ARRAY[$3]::double precision[], $4)).count $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuecount(rast raster, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS integer
- AS $$ SELECT (_st_valuecount($1, 1, TRUE, ARRAY[$2]::double precision[], $3)).count $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS integer
+ AS $$ SELECT (_st_valuecount($1, 1, TRUE, ARRAY[$2]::double precision[], $3)).count $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuepercent(
- rast raster, nband integer DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- searchvalues double precision[] DEFAULT NULL,
- roundto double precision DEFAULT 0,
- OUT value double precision, OUT percent double precision
+ rast raster, nband integer DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ searchvalues double precision[] DEFAULT NULL,
+ roundto double precision DEFAULT 0,
+ OUT value double precision, OUT percent double precision
)
- RETURNS SETOF record
- AS $$ SELECT value, percent FROM _st_valuecount($1, $2, $3, $4, $5) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, percent FROM _st_valuecount($1, $2, $3, $4, $5) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuepercent(rast raster, nband integer, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT percent double precision)
- RETURNS SETOF record
- AS $$ SELECT value, percent FROM _st_valuecount($1, $2, TRUE, $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, percent FROM _st_valuecount($1, $2, TRUE, $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuepercent(rast raster, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT percent double precision)
- RETURNS SETOF record
- AS $$ SELECT value, percent FROM _st_valuecount($1, 1, TRUE, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, percent FROM _st_valuecount($1, 1, TRUE, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_valuepercent(rast raster, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS double precision
- AS $$ SELECT (_st_valuecount($1, $2, $3, ARRAY[$4]::double precision[], $5)).percent $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_valuecount($1, $2, $3, ARRAY[$4]::double precision[], $5)).percent $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuepercent(rast raster, nband integer, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS double precision
- AS $$ SELECT (_st_valuecount($1, $2, TRUE, ARRAY[$3]::double precision[], $4)).percent $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_valuecount($1, $2, TRUE, ARRAY[$3]::double precision[], $4)).percent $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuepercent(rast raster, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS double precision
- AS $$ SELECT (_st_valuecount($1, 1, TRUE, ARRAY[$2]::double precision[], $3)).percent $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_valuecount($1, 1, TRUE, ARRAY[$2]::double precision[], $3)).percent $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _st_valuecount(rastertable text, rastercolumn text, nband integer DEFAULT 1, exclude_nodata_value boolean DEFAULT TRUE, searchvalues double precision[] DEFAULT NULL, roundto double precision DEFAULT 0)
- RETURNS SETOF valuecount
- AS '$libdir/rtpostgis-2.0', 'RASTER_valueCountCoverage'
- LANGUAGE 'c' STABLE;
+ RETURNS SETOF valuecount
+ AS '$libdir/rtpostgis-2.0', 'RASTER_valueCountCoverage'
+ LANGUAGE 'c' STABLE;
CREATE OR REPLACE FUNCTION st_valuecount(
- rastertable text, rastercolumn text,
- nband integer DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- searchvalues double precision[] DEFAULT NULL,
- roundto double precision DEFAULT 0,
- OUT value double precision, OUT count integer
+ rastertable text, rastercolumn text,
+ nband integer DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ searchvalues double precision[] DEFAULT NULL,
+ roundto double precision DEFAULT 0,
+ OUT value double precision, OUT count integer
)
- RETURNS SETOF record
- AS $$ SELECT value, count FROM _st_valuecount($1, $2, $3, $4, $5, $6) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, count FROM _st_valuecount($1, $2, $3, $4, $5, $6) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_valuecount(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT count integer)
- RETURNS SETOF record
- AS $$ SELECT value, count FROM _st_valuecount($1, $2, $3, TRUE, $4, $5) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, count FROM _st_valuecount($1, $2, $3, TRUE, $4, $5) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_valuecount(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT count integer)
- RETURNS SETOF record
- AS $$ SELECT value, count FROM _st_valuecount($1, $2, 1, TRUE, $3, $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, count FROM _st_valuecount($1, $2, 1, TRUE, $3, $4) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_valuecount(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS integer
- AS $$ SELECT (_st_valuecount($1, $2, $3, $4, ARRAY[$5]::double precision[], $6)).count $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS integer
+ AS $$ SELECT (_st_valuecount($1, $2, $3, $4, ARRAY[$5]::double precision[], $6)).count $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuecount(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS integer
- AS $$ SELECT (_st_valuecount($1, $2, $3, TRUE, ARRAY[$4]::double precision[], $5)).count $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS integer
+ AS $$ SELECT (_st_valuecount($1, $2, $3, TRUE, ARRAY[$4]::double precision[], $5)).count $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuecount(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS integer
- AS $$ SELECT (_st_valuecount($1, $2, 1, TRUE, ARRAY[$3]::double precision[], $4)).count $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS integer
+ AS $$ SELECT (_st_valuecount($1, $2, 1, TRUE, ARRAY[$3]::double precision[], $4)).count $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuepercent(
- rastertable text, rastercolumn text,
- nband integer DEFAULT 1,
- exclude_nodata_value boolean DEFAULT TRUE,
- searchvalues double precision[] DEFAULT NULL,
- roundto double precision DEFAULT 0,
- OUT value double precision, OUT percent double precision
+ rastertable text, rastercolumn text,
+ nband integer DEFAULT 1,
+ exclude_nodata_value boolean DEFAULT TRUE,
+ searchvalues double precision[] DEFAULT NULL,
+ roundto double precision DEFAULT 0,
+ OUT value double precision, OUT percent double precision
)
- RETURNS SETOF record
- AS $$ SELECT value, percent FROM _st_valuecount($1, $2, $3, $4, $5, $6) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, percent FROM _st_valuecount($1, $2, $3, $4, $5, $6) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_valuepercent(rastertable text, rastercolumn text, nband integer, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT percent double precision)
- RETURNS SETOF record
- AS $$ SELECT value, percent FROM _st_valuecount($1, $2, $3, TRUE, $4, $5) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, percent FROM _st_valuecount($1, $2, $3, TRUE, $4, $5) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_valuepercent(rastertable text, rastercolumn text, searchvalues double precision[], roundto double precision DEFAULT 0, OUT value double precision, OUT percent double precision)
- RETURNS SETOF record
- AS $$ SELECT value, percent FROM _st_valuecount($1, $2, 1, TRUE, $3, $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF record
+ AS $$ SELECT value, percent FROM _st_valuecount($1, $2, 1, TRUE, $3, $4) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_valuepercent(rastertable text, rastercolumn text, nband integer, exclude_nodata_value boolean, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS double precision
- AS $$ SELECT (_st_valuecount($1, $2, $3, $4, ARRAY[$5]::double precision[], $6)).percent $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_valuecount($1, $2, $3, $4, ARRAY[$5]::double precision[], $6)).percent $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuepercent(rastertable text, rastercolumn text, nband integer, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS double precision
- AS $$ SELECT (_st_valuecount($1, $2, $3, TRUE, ARRAY[$4]::double precision[], $5)).percent $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_valuecount($1, $2, $3, TRUE, ARRAY[$4]::double precision[], $5)).percent $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_valuepercent(rastertable text, rastercolumn text, searchvalue double precision, roundto double precision DEFAULT 0)
- RETURNS double precision
- AS $$ SELECT (_st_valuecount($1, $2, 1, TRUE, ARRAY[$3]::double precision[], $4)).percent $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision
+ AS $$ SELECT (_st_valuecount($1, $2, 1, TRUE, ARRAY[$3]::double precision[], $4)).percent $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Reclass
@@ -5672,39 +5651,39 @@ CREATE OR REPLACE FUNCTION st_valuepercent(rastertable text, rastercolumn text,
CREATE OR REPLACE FUNCTION _st_reclass(rast raster, VARIADIC reclassargset reclassarg[])
- RETURNS raster
- AS '$libdir/rtpostgis-2.0', 'RASTER_reclass'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS raster
+ AS '$libdir/rtpostgis-2.0', 'RASTER_reclass'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_reclass(rast raster, VARIADIC reclassargset reclassarg[])
- RETURNS raster
- AS $$
- DECLARE
- i int;
- expr text;
- BEGIN
- -- for each reclassarg, validate elements as all except nodataval cannot be NULL
- FOR i IN SELECT * FROM generate_subscripts($2, 1) LOOP
- IF $2[i].nband IS NULL OR $2[i].reclassexpr IS NULL OR $2[i].pixeltype IS NULL THEN
- RAISE WARNING 'Values are required for the nband, reclassexpr and pixeltype attributes.';
- RETURN rast;
- END IF;
- END LOOP;
-
- RETURN _st_reclass($1, VARIADIC $2);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURNS raster
+ AS $$
+ DECLARE
+ i int;
+ expr text;
+ BEGIN
+ -- for each reclassarg, validate elements as all except nodataval cannot be NULL
+ FOR i IN SELECT * FROM generate_subscripts($2, 1) LOOP
+ IF $2[i].nband IS NULL OR $2[i].reclassexpr IS NULL OR $2[i].pixeltype IS NULL THEN
+ RAISE WARNING 'Values are required for the nband, reclassexpr and pixeltype attributes.';
+ RETURN rast;
+ END IF;
+ END LOOP;
+
+ RETURN _st_reclass($1, VARIADIC $2);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-- Cannot be strict as "nodataval" can be NULL
CREATE OR REPLACE FUNCTION st_reclass(rast raster, nband int, reclassexpr text, pixeltype text, nodataval double precision DEFAULT NULL)
- RETURNS raster
- AS $$ SELECT st_reclass($1, ROW($2, $3, $4, $5)) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS raster
+ AS $$ SELECT st_reclass($1, ROW($2, $3, $4, $5)) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_reclass(rast raster, reclassexpr text, pixeltype text)
- RETURNS raster
- AS $$ SELECT st_reclass($1, ROW(1, $2, $3, NULL)) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT st_reclass($1, ROW(1, $2, $3, NULL)) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- ST_AsGDALRaster and supporting functions
@@ -5712,630 +5691,630 @@ CREATE OR REPLACE FUNCTION st_reclass(rast raster, reclassexpr text, pixeltype t
-- returns set of available and usable GDAL drivers
CREATE OR REPLACE FUNCTION st_gdaldrivers(OUT idx int, OUT short_name text, OUT long_name text, OUT create_options text)
RETURNS SETOF record
- AS '$libdir/rtpostgis-2.0', 'RASTER_getGDALDrivers'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ AS '$libdir/rtpostgis-2.0', 'RASTER_getGDALDrivers'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Cannot be strict as "options" and "srid" can be NULL
CREATE OR REPLACE FUNCTION st_asgdalraster(rast raster, format text, options text[] DEFAULT NULL, srid integer DEFAULT NULL)
- RETURNS bytea
- AS '$libdir/rtpostgis-2.0', 'RASTER_asGDALRaster'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS bytea
+ AS '$libdir/rtpostgis-2.0', 'RASTER_asGDALRaster'
+ LANGUAGE 'c' IMMUTABLE;
-----------------------------------------------------------------------
-- ST_AsTIFF
-----------------------------------------------------------------------
-- Cannot be strict as "options" and "srid" can be NULL
CREATE OR REPLACE FUNCTION st_astiff(rast raster, options text[] DEFAULT NULL, srid integer DEFAULT NULL)
- RETURNS bytea
- AS $$
- DECLARE
- i int;
- num_bands int;
- nodata double precision;
- last_nodata double precision;
- BEGIN
- num_bands := st_numbands($1);
-
- -- TIFF only allows one NODATA value for ALL bands
- FOR i IN 1..num_bands LOOP
- nodata := st_bandnodatavalue($1, i);
- IF last_nodata IS NULL THEN
- last_nodata := nodata;
- ELSEIF nodata != last_nodata THEN
- RAISE NOTICE 'The TIFF format only permits one NODATA value for all bands. The value used will be the last band with a NODATA value.';
- END IF;
- END LOOP;
-
- RETURN st_asgdalraster($1, 'GTiff', $2, $3);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE;
+ RETURNS bytea
+ AS $$
+ DECLARE
+ i int;
+ num_bands int;
+ nodata double precision;
+ last_nodata double precision;
+ BEGIN
+ num_bands := st_numbands($1);
+
+ -- TIFF only allows one NODATA value for ALL bands
+ FOR i IN 1..num_bands LOOP
+ nodata := st_bandnodatavalue($1, i);
+ IF last_nodata IS NULL THEN
+ last_nodata := nodata;
+ ELSEIF nodata != last_nodata THEN
+ RAISE NOTICE 'The TIFF format only permits one NODATA value for all bands. The value used will be the last band with a NODATA value.';
+ END IF;
+ END LOOP;
+
+ RETURN st_asgdalraster($1, 'GTiff', $2, $3);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE;
-- Cannot be strict as "options" and "srid" can be NULL
CREATE OR REPLACE FUNCTION st_astiff(rast raster, nbands int[], options text[] DEFAULT NULL, srid integer DEFAULT NULL)
- RETURNS bytea
- AS $$ SELECT st_astiff(st_band($1, $2), $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS bytea
+ AS $$ SELECT st_astiff(st_band($1, $2), $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE;
-- Cannot be strict as "srid" can be NULL
CREATE OR REPLACE FUNCTION st_astiff(rast raster, compression text, srid integer DEFAULT NULL)
- RETURNS bytea
- AS $$
- DECLARE
- compression2 text;
- c_type text;
- c_level int;
- i int;
- num_bands int;
- options text[];
- BEGIN
- compression2 := trim(both from upper(compression));
-
- IF length(compression2) > 0 THEN
- -- JPEG
- IF position('JPEG' in compression2) != 0 THEN
- c_type := 'JPEG';
- c_level := substring(compression2 from '[0-9]+$');
-
- IF c_level IS NOT NULL THEN
- IF c_level > 100 THEN
- c_level := 100;
- ELSEIF c_level < 1 THEN
- c_level := 1;
- END IF;
-
- options := array_append(options, 'JPEG_QUALITY=' || c_level);
- END IF;
-
- -- per band pixel type check
- num_bands := st_numbands($1);
- FOR i IN 1..num_bands LOOP
- IF st_bandpixeltype($1, i) != '8BUI' THEN
- RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. JPEG compression can only be used with the 8BUI pixel type.', i;
- END IF;
- END LOOP;
-
- -- DEFLATE
- ELSEIF position('DEFLATE' in compression2) != 0 THEN
- c_type := 'DEFLATE';
- c_level := substring(compression2 from '[0-9]+$');
-
- IF c_level IS NOT NULL THEN
- IF c_level > 9 THEN
- c_level := 9;
- ELSEIF c_level < 1 THEN
- c_level := 1;
- END IF;
-
- options := array_append(options, 'ZLEVEL=' || c_level);
- END IF;
-
- ELSE
- c_type := compression2;
-
- -- CCITT
- IF position('CCITT' in compression2) THEN
- -- per band pixel type check
- num_bands := st_numbands($1);
- FOR i IN 1..num_bands LOOP
- IF st_bandpixeltype($1, i) != '1BB' THEN
- RAISE EXCEPTION 'The pixel type of band % in the raster is not 1BB. CCITT compression can only be used with the 1BB pixel type.', i;
- END IF;
- END LOOP;
- END IF;
-
- END IF;
-
- -- compression type check
- IF ARRAY[c_type] <@ ARRAY['JPEG', 'LZW', 'PACKBITS', 'DEFLATE', 'CCITTRLE', 'CCITTFAX3', 'CCITTFAX4', 'NONE'] THEN
- options := array_append(options, 'COMPRESS=' || c_type);
- ELSE
- RAISE NOTICE 'Unknown compression type: %. The outputted TIFF will not be COMPRESSED.', c_type;
- END IF;
- END IF;
-
- RETURN st_astiff($1, options, $3);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE;
+ RETURNS bytea
+ AS $$
+ DECLARE
+ compression2 text;
+ c_type text;
+ c_level int;
+ i int;
+ num_bands int;
+ options text[];
+ BEGIN
+ compression2 := trim(both from upper(compression));
+
+ IF length(compression2) > 0 THEN
+ -- JPEG
+ IF position('JPEG' in compression2) != 0 THEN
+ c_type := 'JPEG';
+ c_level := substring(compression2 from '[0-9]+$');
+
+ IF c_level IS NOT NULL THEN
+ IF c_level > 100 THEN
+ c_level := 100;
+ ELSEIF c_level < 1 THEN
+ c_level := 1;
+ END IF;
+
+ options := array_append(options, 'JPEG_QUALITY=' || c_level);
+ END IF;
+
+ -- per band pixel type check
+ num_bands := st_numbands($1);
+ FOR i IN 1..num_bands LOOP
+ IF st_bandpixeltype($1, i) != '8BUI' THEN
+ RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. JPEG compression can only be used with the 8BUI pixel type.', i;
+ END IF;
+ END LOOP;
+
+ -- DEFLATE
+ ELSEIF position('DEFLATE' in compression2) != 0 THEN
+ c_type := 'DEFLATE';
+ c_level := substring(compression2 from '[0-9]+$');
+
+ IF c_level IS NOT NULL THEN
+ IF c_level > 9 THEN
+ c_level := 9;
+ ELSEIF c_level < 1 THEN
+ c_level := 1;
+ END IF;
+
+ options := array_append(options, 'ZLEVEL=' || c_level);
+ END IF;
+
+ ELSE
+ c_type := compression2;
+
+ -- CCITT
+ IF position('CCITT' in compression2) THEN
+ -- per band pixel type check
+ num_bands := st_numbands($1);
+ FOR i IN 1..num_bands LOOP
+ IF st_bandpixeltype($1, i) != '1BB' THEN
+ RAISE EXCEPTION 'The pixel type of band % in the raster is not 1BB. CCITT compression can only be used with the 1BB pixel type.', i;
+ END IF;
+ END LOOP;
+ END IF;
+
+ END IF;
+
+ -- compression type check
+ IF ARRAY[c_type] <@ ARRAY['JPEG', 'LZW', 'PACKBITS', 'DEFLATE', 'CCITTRLE', 'CCITTFAX3', 'CCITTFAX4', 'NONE'] THEN
+ options := array_append(options, 'COMPRESS=' || c_type);
+ ELSE
+ RAISE NOTICE 'Unknown compression type: %. The outputted TIFF will not be COMPRESSED.', c_type;
+ END IF;
+ END IF;
+
+ RETURN st_astiff($1, options, $3);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE;
-- Cannot be strict as "srid" can be NULL
CREATE OR REPLACE FUNCTION st_astiff(rast raster, nbands int[], compression text, srid integer DEFAULT NULL)
- RETURNS bytea
- AS $$ SELECT st_astiff(st_band($1, $2), $3, $4) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS bytea
+ AS $$ SELECT st_astiff(st_band($1, $2), $3, $4) $$
+ LANGUAGE 'sql' IMMUTABLE;
-----------------------------------------------------------------------
-- ST_AsJPEG
-----------------------------------------------------------------------
-- Cannot be strict as "options" can be NULL
CREATE OR REPLACE FUNCTION st_asjpeg(rast raster, options text[] DEFAULT NULL)
- RETURNS bytea
- AS $$
- DECLARE
- rast2 raster;
- num_bands int;
- i int;
- BEGIN
- num_bands := st_numbands($1);
-
- -- JPEG allows 1 or 3 bands
- IF num_bands <> 1 AND num_bands <> 3 THEN
- RAISE NOTICE 'The JPEG format only permits one or three bands. The first band will be used.';
- rast2 := st_band(rast, ARRAY[1]);
- num_bands := st_numbands(rast);
- ELSE
- rast2 := rast;
- END IF;
-
- -- JPEG only supports 8BUI pixeltype
- FOR i IN 1..num_bands LOOP
- IF st_bandpixeltype(rast, i) != '8BUI' THEN
- RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.', i;
- END IF;
- END LOOP;
-
- RETURN st_asgdalraster(rast2, 'JPEG', $2, NULL);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE;
+ RETURNS bytea
+ AS $$
+ DECLARE
+ rast2 raster;
+ num_bands int;
+ i int;
+ BEGIN
+ num_bands := st_numbands($1);
+
+ -- JPEG allows 1 or 3 bands
+ IF num_bands <> 1 AND num_bands <> 3 THEN
+ RAISE NOTICE 'The JPEG format only permits one or three bands. The first band will be used.';
+ rast2 := st_band(rast, ARRAY[1]);
+ num_bands := st_numbands(rast);
+ ELSE
+ rast2 := rast;
+ END IF;
+
+ -- JPEG only supports 8BUI pixeltype
+ FOR i IN 1..num_bands LOOP
+ IF st_bandpixeltype(rast, i) != '8BUI' THEN
+ RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI. The JPEG format can only be used with the 8BUI pixel type.', i;
+ END IF;
+ END LOOP;
+
+ RETURN st_asgdalraster(rast2, 'JPEG', $2, NULL);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE;
-- Cannot be strict as "options" can be NULL
CREATE OR REPLACE FUNCTION st_asjpeg(rast raster, nbands int[], options text[] DEFAULT NULL)
- RETURNS bytea
- AS $$ SELECT st_asjpeg(st_band($1, $2), $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS bytea
+ AS $$ SELECT st_asjpeg(st_band($1, $2), $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_asjpeg(rast raster, nbands int[], quality int)
- RETURNS bytea
- AS $$
- DECLARE
- quality2 int;
- options text[];
- BEGIN
- IF quality IS NOT NULL THEN
- IF quality > 100 THEN
- quality2 := 100;
- ELSEIF quality < 10 THEN
- quality2 := 10;
- ELSE
- quality2 := quality;
- END IF;
-
- options := array_append(options, 'QUALITY=' || quality2);
- END IF;
-
- RETURN st_asjpeg(st_band($1, $2), options);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS $$
+ DECLARE
+ quality2 int;
+ options text[];
+ BEGIN
+ IF quality IS NOT NULL THEN
+ IF quality > 100 THEN
+ quality2 := 100;
+ ELSEIF quality < 10 THEN
+ quality2 := 10;
+ ELSE
+ quality2 := quality;
+ END IF;
+
+ options := array_append(options, 'QUALITY=' || quality2);
+ END IF;
+
+ RETURN st_asjpeg(st_band($1, $2), options);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-- Cannot be strict as "options" can be NULL
CREATE OR REPLACE FUNCTION st_asjpeg(rast raster, nband int, options text[] DEFAULT NULL)
- RETURNS bytea
- AS $$ SELECT st_asjpeg(st_band($1, $2), $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS bytea
+ AS $$ SELECT st_asjpeg(st_band($1, $2), $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_asjpeg(rast raster, nband int, quality int)
- RETURNS bytea
- AS $$ SELECT st_asjpeg($1, ARRAY[$2], $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS $$ SELECT st_asjpeg($1, ARRAY[$2], $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- ST_AsPNG
-----------------------------------------------------------------------
-- Cannot be strict as "options" can be NULL
CREATE OR REPLACE FUNCTION st_aspng(rast raster, options text[] DEFAULT NULL)
- RETURNS bytea
- AS $$
- DECLARE
- rast2 raster;
- num_bands int;
- i int;
- pt text;
- BEGIN
- num_bands := st_numbands($1);
-
- -- PNG allows 1, 3 or 4 bands
- IF num_bands <> 1 AND num_bands <> 3 AND num_bands <> 4 THEN
- RAISE NOTICE 'The PNG format only permits one, three or four bands. The first band will be used.';
- rast2 := st_band($1, ARRAY[1]);
- num_bands := st_numbands(rast2);
- ELSE
- rast2 := rast;
- END IF;
-
- -- PNG only supports 8BUI and 16BUI pixeltype
- FOR i IN 1..num_bands LOOP
- pt = st_bandpixeltype(rast, i);
- IF pt != '8BUI' AND pt != '16BUI' THEN
- RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types.', i;
- END IF;
- END LOOP;
-
- RETURN st_asgdalraster(rast2, 'PNG', $2, NULL);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE;
+ RETURNS bytea
+ AS $$
+ DECLARE
+ rast2 raster;
+ num_bands int;
+ i int;
+ pt text;
+ BEGIN
+ num_bands := st_numbands($1);
+
+ -- PNG allows 1, 3 or 4 bands
+ IF num_bands <> 1 AND num_bands <> 3 AND num_bands <> 4 THEN
+ RAISE NOTICE 'The PNG format only permits one, three or four bands. The first band will be used.';
+ rast2 := st_band($1, ARRAY[1]);
+ num_bands := st_numbands(rast2);
+ ELSE
+ rast2 := rast;
+ END IF;
+
+ -- PNG only supports 8BUI and 16BUI pixeltype
+ FOR i IN 1..num_bands LOOP
+ pt = st_bandpixeltype(rast, i);
+ IF pt != '8BUI' AND pt != '16BUI' THEN
+ RAISE EXCEPTION 'The pixel type of band % in the raster is not 8BUI or 16BUI. The PNG format can only be used with 8BUI and 16BUI pixel types.', i;
+ END IF;
+ END LOOP;
+
+ RETURN st_asgdalraster(rast2, 'PNG', $2, NULL);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE;
-- Cannot be strict as "options" can be NULL
CREATE OR REPLACE FUNCTION st_aspng(rast raster, nbands int[], options text[] DEFAULT NULL)
- RETURNS bytea
- AS $$ SELECT st_aspng(st_band($1, $2), $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS bytea
+ AS $$ SELECT st_aspng(st_band($1, $2), $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_aspng(rast raster, nbands int[], compression int)
- RETURNS bytea
- AS $$
- DECLARE
- compression2 int;
- options text[];
- BEGIN
- IF compression IS NOT NULL THEN
- IF compression > 9 THEN
- compression2 := 9;
- ELSEIF compression < 1 THEN
- compression2 := 1;
- ELSE
- compression2 := compression;
- END IF;
-
- options := array_append(options, 'ZLEVEL=' || compression2);
- END IF;
-
- RETURN st_aspng(st_band($1, $2), options);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS $$
+ DECLARE
+ compression2 int;
+ options text[];
+ BEGIN
+ IF compression IS NOT NULL THEN
+ IF compression > 9 THEN
+ compression2 := 9;
+ ELSEIF compression < 1 THEN
+ compression2 := 1;
+ ELSE
+ compression2 := compression;
+ END IF;
+
+ options := array_append(options, 'ZLEVEL=' || compression2);
+ END IF;
+
+ RETURN st_aspng(st_band($1, $2), options);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_aspng(rast raster, nband int, options text[] DEFAULT NULL)
- RETURNS bytea
- AS $$ SELECT st_aspng(st_band($1, $2), $3) $$
- LANGUAGE 'sql' IMMUTABLE;
+ RETURNS bytea
+ AS $$ SELECT st_aspng(st_band($1, $2), $3) $$
+ LANGUAGE 'sql' IMMUTABLE;
CREATE OR REPLACE FUNCTION st_aspng(rast raster, nband int, compression int)
- RETURNS bytea
- AS $$ SELECT st_aspng($1, ARRAY[$2], $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS $$ SELECT st_aspng($1, ARRAY[$2], $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- ST_AsRaster
-----------------------------------------------------------------------
-- None of the ST_AsRaster can be strict as some parameters can be NULL
CREATE OR REPLACE FUNCTION _st_asraster(
- geom geometry,
- scalex double precision DEFAULT 0, scaley double precision DEFAULT 0,
- width integer DEFAULT 0, height integer DEFAULT 0,
- pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
- value double precision[] DEFAULT ARRAY[1]::double precision[],
- nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
- upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
- gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ scalex double precision DEFAULT 0, scaley double precision DEFAULT 0,
+ width integer DEFAULT 0, height integer DEFAULT 0,
+ pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
+ value double precision[] DEFAULT ARRAY[1]::double precision[],
+ nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
+ upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
+ gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS '$libdir/rtpostgis-2.0', 'RASTER_asRaster'
- LANGUAGE 'c' STABLE;
+ RETURNS raster
+ AS '$libdir/rtpostgis-2.0', 'RASTER_asRaster'
+ LANGUAGE 'c' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- scalex double precision, scaley double precision,
- gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
- pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
- value double precision[] DEFAULT ARRAY[1]::double precision[],
- nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ scalex double precision, scaley double precision,
+ gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
+ pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
+ value double precision[] DEFAULT ARRAY[1]::double precision[],
+ nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, $6, $7, $8, NULL, NULL, $4, $5, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, $6, $7, $8, NULL, NULL, $4, $5, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- scalex double precision, scaley double precision,
- pixeltype text[],
- value double precision[] DEFAULT ARRAY[1]::double precision[],
- nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
- upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ scalex double precision, scaley double precision,
+ pixeltype text[],
+ value double precision[] DEFAULT ARRAY[1]::double precision[],
+ nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
+ upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, $4, $5, $6, $7, $8, NULL, NULL, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, $4, $5, $6, $7, $8, NULL, NULL, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- width integer, height integer,
- gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
- pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
- value double precision[] DEFAULT ARRAY[1]::double precision[],
- nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ width integer, height integer,
+ gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
+ pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
+ value double precision[] DEFAULT ARRAY[1]::double precision[],
+ nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, $6, $7, $8, NULL, NULL, $4, $5, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, $6, $7, $8, NULL, NULL, $4, $5, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- width integer, height integer,
- pixeltype text[],
- value double precision[] DEFAULT ARRAY[1]::double precision[],
- nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
- upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ width integer, height integer,
+ pixeltype text[],
+ value double precision[] DEFAULT ARRAY[1]::double precision[],
+ nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
+ upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, $4, $5, $6, $7, $8, NULL, NULL, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, $4, $5, $6, $7, $8, NULL, NULL, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- scalex double precision, scaley double precision,
- gridx double precision, gridy double precision,
- pixeltype text,
- value double precision DEFAULT 1,
- nodataval double precision DEFAULT 0,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ scalex double precision, scaley double precision,
+ gridx double precision, gridy double precision,
+ pixeltype text,
+ value double precision DEFAULT 1,
+ nodataval double precision DEFAULT 0,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, ARRAY[$6]::text[], ARRAY[$7]::double precision[], ARRAY[$8]::double precision[], NULL, NULL, $4, $5, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, ARRAY[$6]::text[], ARRAY[$7]::double precision[], ARRAY[$8]::double precision[], NULL, NULL, $4, $5, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- scalex double precision, scaley double precision,
- pixeltype text,
- value double precision DEFAULT 1,
- nodataval double precision DEFAULT 0,
- upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ scalex double precision, scaley double precision,
+ pixeltype text,
+ value double precision DEFAULT 1,
+ nodataval double precision DEFAULT 0,
+ upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, ARRAY[$4]::text[], ARRAY[$5]::double precision[], ARRAY[$6]::double precision[], $7, $8, NULL, NULL, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, $2, $3, NULL, NULL, ARRAY[$4]::text[], ARRAY[$5]::double precision[], ARRAY[$6]::double precision[], $7, $8, NULL, NULL, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- width integer, height integer,
- gridx double precision, gridy double precision,
- pixeltype text,
- value double precision DEFAULT 1,
- nodataval double precision DEFAULT 0,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ width integer, height integer,
+ gridx double precision, gridy double precision,
+ pixeltype text,
+ value double precision DEFAULT 1,
+ nodataval double precision DEFAULT 0,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, ARRAY[$6]::text[], ARRAY[$7]::double precision[], ARRAY[$8]::double precision[], NULL, NULL, $4, $5, $9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, ARRAY[$6]::text[], ARRAY[$7]::double precision[], ARRAY[$8]::double precision[], NULL, NULL, $4, $5, $9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- width integer, height integer,
- pixeltype text,
- value double precision DEFAULT 1,
- nodataval double precision DEFAULT 0,
- upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ width integer, height integer,
+ pixeltype text,
+ value double precision DEFAULT 1,
+ nodataval double precision DEFAULT 0,
+ upperleftx double precision DEFAULT NULL, upperlefty double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, ARRAY[$4]::text[], ARRAY[$5]::double precision[], ARRAY[$6]::double precision[], $7, $8, NULL, NULL,$9, $10, $11) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_asraster($1, NULL, NULL, $2, $3, ARRAY[$4]::text[], ARRAY[$5]::double precision[], ARRAY[$6]::double precision[], $7, $8, NULL, NULL,$9, $10, $11) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- ref raster,
- pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
- value double precision[] DEFAULT ARRAY[1]::double precision[],
- nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
- touched boolean DEFAULT FALSE
+ geom geometry,
+ ref raster,
+ pixeltype text[] DEFAULT ARRAY['8BUI']::text[],
+ value double precision[] DEFAULT ARRAY[1]::double precision[],
+ nodataval double precision[] DEFAULT ARRAY[0]::double precision[],
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$
- DECLARE
- g geometry;
- g_srid integer;
-
- ul_x double precision;
- ul_y double precision;
- scale_x double precision;
- scale_y double precision;
- skew_x double precision;
- skew_y double precision;
- sr_id integer;
- BEGIN
- SELECT upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid INTO ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id FROM ST_Metadata(ref);
- --RAISE NOTICE '%, %, %, %, %, %, %', ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id;
-
- -- geometry and raster has different SRID
- g_srid := ST_SRID(geom);
- IF g_srid != sr_id THEN
- RAISE NOTICE 'The geometry''s SRID (%) is not the same as the raster''s SRID (%). The geometry will be transformed to the raster''s projection', g_srid, sr_id;
- g := ST_Transform(geom, sr_id);
- ELSE
- g := geom;
- END IF;
-
- RETURN _st_asraster(g, scale_x, scale_y, NULL, NULL, $3, $4, $5, NULL, NULL, ul_x, ul_y, skew_x, skew_y, $6);
- END;
- $$ LANGUAGE 'plpgsql' STABLE;
+ RETURNS raster
+ AS $$
+ DECLARE
+ g geometry;
+ g_srid integer;
+
+ ul_x double precision;
+ ul_y double precision;
+ scale_x double precision;
+ scale_y double precision;
+ skew_x double precision;
+ skew_y double precision;
+ sr_id integer;
+ BEGIN
+ SELECT upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid INTO ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id FROM ST_Metadata(ref);
+ --RAISE NOTICE '%, %, %, %, %, %, %', ul_x, ul_y, scale_x, scale_y, skew_x, skew_y, sr_id;
+
+ -- geometry and raster has different SRID
+ g_srid := ST_SRID(geom);
+ IF g_srid != sr_id THEN
+ RAISE NOTICE 'The geometry''s SRID (%) is not the same as the raster''s SRID (%). The geometry will be transformed to the raster''s projection', g_srid, sr_id;
+ g := ST_Transform(geom, sr_id);
+ ELSE
+ g := geom;
+ END IF;
+
+ RETURN _st_asraster(g, scale_x, scale_y, NULL, NULL, $3, $4, $5, NULL, NULL, ul_x, ul_y, skew_x, skew_y, $6);
+ END;
+ $$ LANGUAGE 'plpgsql' STABLE;
CREATE OR REPLACE FUNCTION st_asraster(
- geom geometry,
- ref raster,
- pixeltype text,
- value double precision DEFAULT 1,
- nodataval double precision DEFAULT 0,
- touched boolean DEFAULT FALSE
+ geom geometry,
+ ref raster,
+ pixeltype text,
+ value double precision DEFAULT 1,
+ nodataval double precision DEFAULT 0,
+ touched boolean DEFAULT FALSE
)
- RETURNS raster
- AS $$ SELECT st_asraster($1, $2, ARRAY[$3]::text[], ARRAY[$4]::double precision[], ARRAY[$5]::double precision[], $6) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT st_asraster($1, $2, ARRAY[$3]::text[], ARRAY[$4]::double precision[], ARRAY[$5]::double precision[], $6) $$
+ LANGUAGE 'sql' STABLE;
-----------------------------------------------------------------------
-- ST_Resample
-----------------------------------------------------------------------
-- cannot be strict as almost all parameters can be NULL
CREATE OR REPLACE FUNCTION _st_resample(
- rast raster,
- algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125,
- srid integer DEFAULT NULL,
- scalex double precision DEFAULT 0, scaley double precision DEFAULT 0,
- gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- width integer DEFAULT NULL, height integer DEFAULT NULL
+ rast raster,
+ algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125,
+ srid integer DEFAULT NULL,
+ scalex double precision DEFAULT 0, scaley double precision DEFAULT 0,
+ gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ width integer DEFAULT NULL, height integer DEFAULT NULL
)
- RETURNS raster
- AS '$libdir/rtpostgis-2.0', 'RASTER_resample'
- LANGUAGE 'c' STABLE;
+ RETURNS raster
+ AS '$libdir/rtpostgis-2.0', 'RASTER_resample'
+ LANGUAGE 'c' STABLE;
CREATE OR REPLACE FUNCTION st_resample(
- rast raster,
- srid integer DEFAULT NULL,
- scalex double precision DEFAULT 0, scaley double precision DEFAULT 0,
- gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
+ rast raster,
+ srid integer DEFAULT NULL,
+ scalex double precision DEFAULT 0, scaley double precision DEFAULT 0,
+ gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $9, $10, $2, $3, $4, $5, $6, $7, $8) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $9, $10, $2, $3, $4, $5, $6, $7, $8) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_resample(
- rast raster,
- width integer, height integer,
- srid integer DEFAULT NULL,
- gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
- skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
- algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
+ rast raster,
+ width integer, height integer,
+ srid integer DEFAULT NULL,
+ gridx double precision DEFAULT NULL, gridy double precision DEFAULT NULL,
+ skewx double precision DEFAULT 0, skewy double precision DEFAULT 0,
+ algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $9, $10, $4, NULL, NULL, $5, $6, $7, $8, $2, $3) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $9, $10, $4, NULL, NULL, $5, $6, $7, $8, $2, $3) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_resample(
- rast raster,
- ref raster,
- algorithm text DEFAULT 'NearestNeighbour',
- maxerr double precision DEFAULT 0.125,
- usescale boolean DEFAULT TRUE
+ rast raster,
+ ref raster,
+ algorithm text DEFAULT 'NearestNeighbour',
+ maxerr double precision DEFAULT 0.125,
+ usescale boolean DEFAULT TRUE
)
- RETURNS raster
- AS $$
- DECLARE
- sr_id int;
- dim_x int;
- dim_y int;
- scale_x double precision;
- scale_y double precision;
- grid_x double precision;
- grid_y double precision;
- skew_x double precision;
- skew_y double precision;
- BEGIN
- SELECT srid, width, height, scalex, scaley, upperleftx, upperlefty, skewx, skewy INTO sr_id, dim_x, dim_y, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y FROM st_metadata($2);
-
- IF usescale IS TRUE THEN
- dim_x := NULL;
- dim_y := NULL;
- ELSE
- scale_x := NULL;
- scale_y := NULL;
- END IF;
+ RETURNS raster
+ AS $$
+ DECLARE
+ sr_id int;
+ dim_x int;
+ dim_y int;
+ scale_x double precision;
+ scale_y double precision;
+ grid_x double precision;
+ grid_y double precision;
+ skew_x double precision;
+ skew_y double precision;
+ BEGIN
+ SELECT srid, width, height, scalex, scaley, upperleftx, upperlefty, skewx, skewy INTO sr_id, dim_x, dim_y, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y FROM st_metadata($2);
+
+ IF usescale IS TRUE THEN
+ dim_x := NULL;
+ dim_y := NULL;
+ ELSE
+ scale_x := NULL;
+ scale_y := NULL;
+ END IF;
- RETURN _st_resample($1, $3, $4, sr_id, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y, dim_x, dim_y);
- END;
- $$ LANGUAGE 'plpgsql' STABLE STRICT;
+ RETURN _st_resample($1, $3, $4, sr_id, scale_x, scale_y, grid_x, grid_y, skew_x, skew_y, dim_x, dim_y);
+ END;
+ $$ LANGUAGE 'plpgsql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_resample(
- rast raster,
- ref raster,
- usescale boolean,
- algorithm text DEFAULT 'NearestNeighbour',
- maxerr double precision DEFAULT 0.125
+ rast raster,
+ ref raster,
+ usescale boolean,
+ algorithm text DEFAULT 'NearestNeighbour',
+ maxerr double precision DEFAULT 0.125
)
- RETURNS raster
- AS $$ SELECT st_resample($1, $2, $4, $5, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT st_resample($1, $2, $4, $5, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Transform
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125, scalex double precision DEFAULT 0, scaley double precision DEFAULT 0)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $3, $4, $2, $5, $6) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $3, $4, $2, $5, $6) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, scalex double precision, scaley double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $5, $6, $2, $3, $4) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $5, $6, $2, $3, $4) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_transform(rast raster, srid integer, scalexy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $4, $5, $2, $3, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $4, $5, $2, $3, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Rescale
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_rescale(rast raster, scalex double precision, scaley double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $4, $5, NULL, $2, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $4, $5, NULL, $2, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_rescale(rast raster, scalexy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $3, $4, NULL, $2, $2) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $3, $4, NULL, $2, $2) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_Reskew
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_reskew(rast raster, skewx double precision, skewy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $4, $5, NULL, 0, 0, NULL, NULL, $2, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $4, $5, NULL, 0, 0, NULL, NULL, $2, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_reskew(rast raster, skewxy double precision, algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $3, $4, NULL, 0, 0, NULL, NULL, $2, $2) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $3, $4, NULL, 0, 0, NULL, NULL, $2, $2) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- ST_SnapToGrid
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_snaptogrid(
- rast raster,
- gridx double precision, gridy double precision,
- algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125,
- scalex double precision DEFAULT 0, scaley double precision DEFAULT 0
+ rast raster,
+ gridx double precision, gridy double precision,
+ algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125,
+ scalex double precision DEFAULT 0, scaley double precision DEFAULT 0
)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $4, $5, NULL, $6, $7, $2, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $4, $5, NULL, $6, $7, $2, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_snaptogrid(
- rast raster,
- gridx double precision, gridy double precision,
- scalex double precision, scaley double precision,
- algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
+ rast raster,
+ gridx double precision, gridy double precision,
+ scalex double precision, scaley double precision,
+ algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $6, $7, NULL, $4, $5, $2, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $6, $7, NULL, $4, $5, $2, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION st_snaptogrid(
- rast raster,
- gridx double precision, gridy double precision,
- scalexy double precision,
- algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
+ rast raster,
+ gridx double precision, gridy double precision,
+ scalexy double precision,
+ algorithm text DEFAULT 'NearestNeighbour', maxerr double precision DEFAULT 0.125
)
- RETURNS raster
- AS $$ SELECT _st_resample($1, $5, $6, NULL, $4, $4, $2, $3) $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS raster
+ AS $$ SELECT _st_resample($1, $5, $6, NULL, $4, $4, $2, $3) $$
+ LANGUAGE 'sql' STABLE STRICT;
-----------------------------------------------------------------------
-- One Raster ST_MapAlgebra
@@ -6415,50 +6394,50 @@ CREATE OR REPLACE FUNCTION st_mapalgebrafct(rast raster, onerastuserfunc regproc
-- Two Raster ST_MapAlgebra
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_mapalgebraexpr(
- rast1 raster, band1 integer,
- rast2 raster, band2 integer,
- expression text,
- pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
- nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
- nodatanodataval double precision DEFAULT NULL
+ rast1 raster, band1 integer,
+ rast2 raster, band2 integer,
+ expression text,
+ pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
+ nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
+ nodatanodataval double precision DEFAULT NULL
)
- RETURNS raster
- AS '$libdir/rtpostgis-2.0', 'RASTER_mapAlgebra2'
- LANGUAGE 'c' STABLE;
+ RETURNS raster
+ AS '$libdir/rtpostgis-2.0', 'RASTER_mapAlgebra2'
+ LANGUAGE 'c' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebraexpr(
- rast1 raster,
- rast2 raster,
- expression text,
- pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
- nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
- nodatanodataval double precision DEFAULT NULL
+ rast1 raster,
+ rast2 raster,
+ expression text,
+ pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
+ nodata1expr text DEFAULT NULL, nodata2expr text DEFAULT NULL,
+ nodatanodataval double precision DEFAULT NULL
)
- RETURNS raster
- AS $$ SELECT st_mapalgebraexpr($1, 1, $2, 1, $3, $4, $5, $6, $7, $8) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT st_mapalgebraexpr($1, 1, $2, 1, $3, $4, $5, $6, $7, $8) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebrafct(
- rast1 raster, band1 integer,
- rast2 raster, band2 integer,
- tworastuserfunc regprocedure,
- pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
- VARIADIC userargs text[] DEFAULT NULL
+ rast1 raster, band1 integer,
+ rast2 raster, band2 integer,
+ tworastuserfunc regprocedure,
+ pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
+ VARIADIC userargs text[] DEFAULT NULL
)
- RETURNS raster
- AS '$libdir/rtpostgis-2.0', 'RASTER_mapAlgebra2'
- LANGUAGE 'c' STABLE;
+ RETURNS raster
+ AS '$libdir/rtpostgis-2.0', 'RASTER_mapAlgebra2'
+ LANGUAGE 'c' STABLE;
CREATE OR REPLACE FUNCTION st_mapalgebrafct(
- rast1 raster,
- rast2 raster,
- tworastuserfunc regprocedure,
- pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
- VARIADIC userargs text[] DEFAULT NULL
+ rast1 raster,
+ rast2 raster,
+ tworastuserfunc regprocedure,
+ pixeltype text DEFAULT NULL, extenttype text DEFAULT 'INTERSECTION',
+ VARIADIC userargs text[] DEFAULT NULL
)
- RETURNS raster
- AS $$ SELECT st_mapalgebrafct($1, 1, $2, 1, $3, $4, $5, VARIADIC $6) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster
+ AS $$ SELECT st_mapalgebrafct($1, 1, $2, 1, $3, $4, $5, VARIADIC $6) $$
+ LANGUAGE 'sql' STABLE;
-----------------------------------------------------------------------
-- Neighborhood single raster map algebra
@@ -6713,18 +6692,18 @@ CREATE OR REPLACE FUNCTION _st_hillshade4ma(matrix float[][], nodatamode text, v
IF dz_dx != 0. THEN
aspect := atan2(dz_dy, -dz_dx);
- IF aspect < 0 THEN
- aspect := aspect + (2.0 * pi());
- END IF;
- ELSE
- IF dz_dy > 0.THEN
- aspect := pi() / 2.;
- ELSEIF dz_dy < 0.THEN
- aspect := (2 * pi()) - (pi() / 2.);
- -- set to pi as that is the expected PostgreSQL answer in Linux
- ELSE
+ IF aspect < 0 THEN
+ aspect := aspect + (2.0 * pi());
+ END IF;
+ ELSE
+ IF dz_dy > 0.THEN
+ aspect := pi() / 2.;
+ ELSEIF dz_dy < 0.THEN
+ aspect := (2 * pi()) - (pi() / 2.);
+ -- set to pi as that is the expected PostgreSQL answer in Linux
+ ELSE
aspect := pi();
- END IF;
+ END IF;
END IF;
max_bright := args[5]::float;
@@ -6792,27 +6771,27 @@ CREATE OR REPLACE FUNCTION st_bandpixeltype(rast raster, band integer DEFAULT 1)
LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_bandmetadata(
- rast raster,
- band int[],
- OUT bandnum int,
- OUT pixeltype text,
- OUT nodatavalue double precision,
- OUT isoutdb boolean,
- OUT path text
+ rast raster,
+ band int[],
+ OUT bandnum int,
+ OUT pixeltype text,
+ OUT nodatavalue double precision,
+ OUT isoutdb boolean,
+ OUT path text
)
- AS '$libdir/rtpostgis-2.0','RASTER_bandmetadata'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ AS '$libdir/rtpostgis-2.0','RASTER_bandmetadata'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_bandmetadata(
- rast raster,
- band int DEFAULT 1,
- OUT pixeltype text,
- OUT nodatavalue double precision,
- OUT isoutdb boolean,
- OUT path text
+ rast raster,
+ band int DEFAULT 1,
+ OUT pixeltype text,
+ OUT nodatavalue double precision,
+ OUT isoutdb boolean,
+ OUT path text
)
- AS $$ SELECT pixeltype, nodatavalue, isoutdb, path FROM st_bandmetadata($1, ARRAY[$2]::int[]) LIMIT 1 $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ AS $$ SELECT pixeltype, nodatavalue, isoutdb, path FROM st_bandmetadata($1, ARRAY[$2]::int[]) LIMIT 1 $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- Raster Pixel Accessors
@@ -6840,9 +6819,9 @@ CREATE OR REPLACE FUNCTION st_value(rast raster, band integer, pt geometry, hasn
IF ( gtype != 'ST_Point' ) THEN
RAISE EXCEPTION 'Attempting to get the value of a pixel with a non-point geometry';
END IF;
- IF ST_SRID(rast) != ST_SRID(pt) THEN
- RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
- END IF;
+ IF ST_SRID(rast) != ST_SRID(pt) THEN
+ RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+ END IF;
x := st_x(pt);
y := st_y(pt);
RETURN st_value(rast,
@@ -6867,41 +6846,41 @@ CREATE OR REPLACE FUNCTION st_georeference(rast raster, format text DEFAULT 'GDA
RETURNS text AS
$$
DECLARE
- scale_x numeric;
- scale_y numeric;
- skew_x numeric;
- skew_y numeric;
- ul_x numeric;
- ul_y numeric;
+ scale_x numeric;
+ scale_y numeric;
+ skew_x numeric;
+ skew_y numeric;
+ ul_x numeric;
+ ul_y numeric;
result text;
BEGIN
- SELECT scalex::numeric, scaley::numeric, skewx::numeric, skewy::numeric, upperleftx::numeric, upperlefty::numeric
- INTO scale_x, scale_y, skew_x, skew_y, ul_x, ul_y FROM ST_Metadata(rast);
+ SELECT scalex::numeric, scaley::numeric, skewx::numeric, skewy::numeric, upperleftx::numeric, upperlefty::numeric
+ INTO scale_x, scale_y, skew_x, skew_y, ul_x, ul_y FROM ST_Metadata(rast);
- -- scale x
+ -- scale x
result := trunc(scale_x, 10) || E'\n';
- -- skew y
+ -- skew y
result := result || trunc(skew_y, 10) || E'\n';
- -- skew x
+ -- skew x
result := result || trunc(skew_x, 10) || E'\n';
- -- scale y
+ -- scale y
result := result || trunc(scale_y, 10) || E'\n';
IF format = 'ESRI' THEN
- -- upper left x
+ -- upper left x
result := result || trunc((ul_x + scale_x * 0.5), 10) || E'\n';
- -- upper left y
+ -- upper left y
result = result || trunc((ul_y + scale_y * 0.5), 10) || E'\n';
ELSE -- IF format = 'GDAL' THEN
- -- upper left x
+ -- upper left x
result := result || trunc(ul_x, 10) || E'\n';
- -- upper left y
+ -- upper left y
result := result || trunc(ul_y, 10) || E'\n';
END IF;
@@ -6950,7 +6929,7 @@ CREATE OR REPLACE FUNCTION st_setrotation(rast raster, rotation float8)
LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_setgeotransform(rast raster,
- imag double precision,
+ imag double precision,
jmag double precision,
theta_i double precision,
theta_ij double precision,
@@ -7088,9 +7067,9 @@ CREATE OR REPLACE FUNCTION st_setvalue(rast raster, pt geometry, newvalue float8
CREATE OR REPLACE FUNCTION st_dumpaspolygons(rast raster, band integer DEFAULT 1)
- RETURNS SETOF geomval
- AS '$libdir/rtpostgis-2.0','RASTER_dumpAsPolygons'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS SETOF geomval
+ AS '$libdir/rtpostgis-2.0','RASTER_dumpAsPolygons'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_polygon(rast raster, band integer DEFAULT 1)
RETURNS geometry AS
@@ -7101,7 +7080,7 @@ CREATE OR REPLACE FUNCTION st_polygon(rast raster, band integer DEFAULT 1)
LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_pixelaspolygon(rast raster, x integer, y integer)
- RETURNS geometry
+ RETURNS geometry
AS '$libdir/rtpostgis-2.0','RASTER_getPixelPolygon'
LANGUAGE 'c' IMMUTABLE STRICT;
@@ -7153,13 +7132,13 @@ CREATE OR REPLACE FUNCTION ST_PixelAsPolygons(rast raster, band integer DEFAULT
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _st_world2rastercoord(
- rast raster,
- longitude double precision DEFAULT NULL, latitude double precision DEFAULT NULL,
- OUT columnx integer,
- OUT rowy integer
+ rast raster,
+ longitude double precision DEFAULT NULL, latitude double precision DEFAULT NULL,
+ OUT columnx integer,
+ OUT rowy integer
)
- AS '$libdir/rtpostgis-2.0', 'RASTER_worldToRasterCoord'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/rtpostgis-2.0', 'RASTER_worldToRasterCoord'
+ LANGUAGE 'c' IMMUTABLE;
---------------------------------------------------------------------------------
-- ST_World2RasterCoordX(rast raster, xw float8, yw float8)
@@ -7168,9 +7147,9 @@ CREATE OR REPLACE FUNCTION _st_world2rastercoord(
-- This function works even if the world coordinates are outside the raster extent.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, xw float8, yw float8)
- RETURNS int
- AS $$ SELECT columnx FROM _st_world2rastercoord($1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS int
+ AS $$ SELECT columnx FROM _st_world2rastercoord($1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_World2RasterCoordX(rast raster, xw float8)
@@ -7181,9 +7160,9 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, xw float8, yw floa
-- also provide a Y.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, xw float8)
- RETURNS int
- AS $$ SELECT columnx FROM _st_world2rastercoord($1, $2, NULL) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS int
+ AS $$ SELECT columnx FROM _st_world2rastercoord($1, $2, NULL) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_World2RasterCoordX(rast raster, pt geometry)
@@ -7191,22 +7170,22 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, xw float8)
-- This function works even if the point is outside the raster extent.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, pt geometry)
- RETURNS int AS
- $$
- DECLARE
- xr integer;
- BEGIN
- IF ( st_geometrytype(pt) != 'ST_Point' ) THEN
- RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
- END IF;
- IF ST_SRID(rast) != ST_SRID(pt) THEN
- RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
- END IF;
- SELECT columnx INTO xr FROM _st_world2rastercoord($1, st_x(pt), st_y(pt));
- RETURN xr;
- END;
- $$
- LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURNS int AS
+ $$
+ DECLARE
+ xr integer;
+ BEGIN
+ IF ( st_geometrytype(pt) != 'ST_Point' ) THEN
+ RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
+ END IF;
+ IF ST_SRID(rast) != ST_SRID(pt) THEN
+ RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+ END IF;
+ SELECT columnx INTO xr FROM _st_world2rastercoord($1, st_x(pt), st_y(pt));
+ RETURN xr;
+ END;
+ $$
+ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_World2RasterCoordY(rast raster, xw float8, yw float8)
@@ -7215,9 +7194,9 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordx(rast raster, pt geometry)
-- This function works even if the world coordinates are outside the raster extent.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_world2rastercoordy(rast raster, xw float8, yw float8)
- RETURNS int
- AS $$ SELECT rowy FROM _st_world2rastercoord($1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS int
+ AS $$ SELECT rowy FROM _st_world2rastercoord($1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_World2RasterCoordY(rast raster, yw float8)
@@ -7228,9 +7207,9 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordy(rast raster, xw float8, yw floa
-- also provide an X.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_world2rastercoordy(rast raster, yw float8)
- RETURNS int
- AS $$ SELECT rowy FROM _st_world2rastercoord($1, NULL, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS int
+ AS $$ SELECT rowy FROM _st_world2rastercoord($1, NULL, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_World2RasterCoordY(rast raster, pt geometry)
@@ -7238,35 +7217,35 @@ CREATE OR REPLACE FUNCTION st_world2rastercoordy(rast raster, yw float8)
-- This function works even if the point is outside the raster extent.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_world2rastercoordy(rast raster, pt geometry)
- RETURNS int AS
- $$
- DECLARE
- yr integer;
- BEGIN
- IF ( st_geometrytype(pt) != 'ST_Point' ) THEN
- RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
- END IF;
- IF ST_SRID(rast) != ST_SRID(pt) THEN
- RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
- END IF;
- SELECT rowy INTO yr FROM _st_world2rastercoord($1, st_x(pt), st_y(pt));
- RETURN yr;
- END;
- $$
- LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURNS int AS
+ $$
+ DECLARE
+ yr integer;
+ BEGIN
+ IF ( st_geometrytype(pt) != 'ST_Point' ) THEN
+ RAISE EXCEPTION 'Attempting to compute raster coordinate with a non-point geometry';
+ END IF;
+ IF ST_SRID(rast) != ST_SRID(pt) THEN
+ RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+ END IF;
+ SELECT rowy INTO yr FROM _st_world2rastercoord($1, st_x(pt), st_y(pt));
+ RETURN yr;
+ END;
+ $$
+ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_Raster2WorldCoord
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _st_raster2worldcoord(
- rast raster,
- columnx integer DEFAULT NULL, rowy integer DEFAULT NULL,
- OUT longitude double precision,
- OUT latitude double precision
+ rast raster,
+ columnx integer DEFAULT NULL, rowy integer DEFAULT NULL,
+ OUT longitude double precision,
+ OUT latitude double precision
)
- AS '$libdir/rtpostgis-2.0', 'RASTER_rasterToWorldCoord'
- LANGUAGE 'c' IMMUTABLE;
+ AS '$libdir/rtpostgis-2.0', 'RASTER_rasterToWorldCoord'
+ LANGUAGE 'c' IMMUTABLE;
---------------------------------------------------------------------------------
-- ST_Raster2WorldCoordX(rast raster, xr int, yr int)
@@ -7276,9 +7255,9 @@ CREATE OR REPLACE FUNCTION _st_raster2worldcoord(
-- below the raster width and height.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_raster2worldcoordx(rast raster, xr int, yr int)
- RETURNS float8
- AS $$ SELECT longitude FROM _st_raster2worldcoord($1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS $$ SELECT longitude FROM _st_raster2worldcoord($1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_Raster2WorldCoordX(rast raster, xr int)
@@ -7290,9 +7269,9 @@ CREATE OR REPLACE FUNCTION st_raster2worldcoordx(rast raster, xr int, yr int)
-- also provide a Y.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_raster2worldcoordx(rast raster, xr int)
- RETURNS float8
- AS $$ SELECT longitude FROM _st_raster2worldcoord($1, $2, NULL) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS $$ SELECT longitude FROM _st_raster2worldcoord($1, $2, NULL) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_Raster2WorldCoordY(rast raster, xr int, yr int)
@@ -7302,9 +7281,9 @@ CREATE OR REPLACE FUNCTION st_raster2worldcoordx(rast raster, xr int)
-- below the raster width and height.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_raster2worldcoordy(rast raster, xr int, yr int)
- RETURNS float8
- AS $$ SELECT latitude FROM _st_raster2worldcoord($1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS $$ SELECT latitude FROM _st_raster2worldcoord($1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
---------------------------------------------------------------------------------
-- ST_Raster2WorldCoordY(rast raster, yr int)
@@ -7316,9 +7295,9 @@ CREATE OR REPLACE FUNCTION st_raster2worldcoordy(rast raster, xr int, yr int)
-- also provide an X.
---------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_raster2worldcoordy(rast raster, yr int)
- RETURNS float8
- AS $$ SELECT latitude FROM _st_raster2worldcoord($1, NULL, $2) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS float8
+ AS $$ SELECT latitude FROM _st_raster2worldcoord($1, NULL, $2) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- ST_MinPossibleValue(pixeltype text)
@@ -7328,9 +7307,9 @@ CREATE OR REPLACE FUNCTION st_raster2worldcoordy(rast raster, yr int)
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_minpossiblevalue(pixeltype text)
- RETURNS double precision
- AS '$libdir/rtpostgis-2.0', 'RASTER_minPossibleValue'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS double precision
+ AS '$libdir/rtpostgis-2.0', 'RASTER_minPossibleValue'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-----------------------------------------------------------------------
-- Raster Outputs
@@ -7347,7 +7326,7 @@ CREATE OR REPLACE FUNCTION bytea(raster)
LANGUAGE 'c' IMMUTABLE STRICT;
------------------------------------------------------------------------------
--- Casts
+-- Casts
------------------------------------------------------------------------------
@@ -7357,7 +7336,7 @@ CREATE OR REPLACE FUNCTION bytea(raster)
------------------------------------------------------------------------------
--- GiST index OPERATOR support functions
+-- GiST index OPERATOR support functions
------------------------------------------------------------------------------
-- raster/raster functions
CREATE OR REPLACE FUNCTION raster_overleft(raster, raster)
@@ -7430,7 +7409,7 @@ CREATE OR REPLACE FUNCTION raster_geometry_overlap(raster, geometry)
RETURNS bool
AS 'select $1::geometry && $2'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
-- geometry/raster functions
CREATE OR REPLACE FUNCTION geometry_raster_contain(geometry, raster)
RETURNS bool
@@ -7441,9 +7420,9 @@ CREATE OR REPLACE FUNCTION geometry_raster_overlap(geometry, raster)
RETURNS bool
AS 'select $1 && $2::geometry'
LANGUAGE 'sql' IMMUTABLE STRICT;
-
+
------------------------------------------------------------------------------
--- GiST index OPERATORs
+-- GiST index OPERATORs
------------------------------------------------------------------------------
-- raster/raster operators
@@ -7472,93 +7451,93 @@ CREATE OR REPLACE FUNCTION geometry_raster_overlap(geometry, raster)
-- raster/geometry operators
-
+
-- geometry/raster operators
-
+
-----------------------------------------------------------------------
-- Raster/Raster Spatial Relationship
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_samealignment(rast1 raster, rast2 raster)
- RETURNS boolean
- AS '$libdir/rtpostgis-2.0', 'RASTER_sameAlignment'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/rtpostgis-2.0', 'RASTER_sameAlignment'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_samealignment(
- ulx1 double precision, uly1 double precision, scalex1 double precision, scaley1 double precision, skewx1 double precision, skewy1 double precision,
- ulx2 double precision, uly2 double precision, scalex2 double precision, scaley2 double precision, skewx2 double precision, skewy2 double precision
+ ulx1 double precision, uly1 double precision, scalex1 double precision, scaley1 double precision, skewx1 double precision, skewy1 double precision,
+ ulx2 double precision, uly2 double precision, scalex2 double precision, scaley2 double precision, skewx2 double precision, skewy2 double precision
)
- RETURNS boolean
- AS $$ SELECT st_samealignment(st_makeemptyraster(1, 1, $1, $2, $3, $4, $5, $6), st_makeemptyraster(1, 1, $7, $8, $9, $10, $11, $12)) $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS $$ SELECT st_samealignment(st_makeemptyraster(1, 1, $1, $2, $3, $4, $5, $6), st_makeemptyraster(1, 1, $7, $8, $9, $10, $11, $12)) $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION _st_intersects(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
- RETURNS boolean
- AS '$libdir/rtpostgis-2.0', 'RASTER_intersects'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 1000;
+ RETURNS boolean
+ AS '$libdir/rtpostgis-2.0', 'RASTER_intersects'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 1000;
CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, nband1 integer, rast2 raster, nband2 integer)
- RETURNS boolean
- AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN TRUE ELSE _st_intersects($1, $2, $3, $4) END $$
- LANGUAGE 'sql' IMMUTABLE
- COST 1000;
+ RETURNS boolean
+ AS $$ SELECT $1 && $3 AND CASE WHEN $2 IS NULL OR $4 IS NULL THEN TRUE ELSE _st_intersects($1, $2, $3, $4) END $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
CREATE OR REPLACE FUNCTION st_intersects(rast1 raster, rast2 raster)
- RETURNS boolean
- AS $$ SELECT st_intersects($1, NULL::integer, $2, NULL::integer) $$
- LANGUAGE 'sql' IMMUTABLE
- COST 1000;
+ RETURNS boolean
+ AS $$ SELECT st_intersects($1, NULL::integer, $2, NULL::integer) $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
-----------------------------------------------------------------------
-- Raster/Geometry Spatial Relationship
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL)
- RETURNS boolean
- AS $$
- DECLARE
- gr raster;
- scale double precision;
- BEGIN
- IF ST_SRID(rast) != ST_SRID(geom) THEN
- RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
- END IF;
-
- IF ST_Intersects(geom, ST_ConvexHull(rast)) IS NOT TRUE THEN
- RETURN FALSE;
- ELSEIF nband IS NULL THEN
- RETURN TRUE;
- END IF;
-
- -- scale is set to 1/100th of raster for granularity
- SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast);
- gr := _st_asraster(geom, scale, scale);
- IF gr IS NULL THEN
- RAISE EXCEPTION 'Unable to convert geometry to a raster';
- RETURN FALSE;
- END IF;
-
- RETURN ST_Intersects(rast, nband, gr, 1);
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE
- COST 1000;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ gr raster;
+ scale double precision;
+ BEGIN
+ IF ST_SRID(rast) != ST_SRID(geom) THEN
+ RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+ END IF;
+
+ IF ST_Intersects(geom, ST_ConvexHull(rast)) IS NOT TRUE THEN
+ RETURN FALSE;
+ ELSEIF nband IS NULL THEN
+ RETURN TRUE;
+ END IF;
+
+ -- scale is set to 1/100th of raster for granularity
+ SELECT least(scalex, scaley) / 100. INTO scale FROM ST_Metadata(rast);
+ gr := _st_asraster(geom, scale, scale);
+ IF gr IS NULL THEN
+ RAISE EXCEPTION 'Unable to convert geometry to a raster';
+ RETURN FALSE;
+ END IF;
+
+ RETURN ST_Intersects(rast, nband, gr, 1);
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE
+ COST 1000;
CREATE OR REPLACE FUNCTION st_intersects(rast raster, geom geometry, nband integer DEFAULT NULL)
- RETURNS boolean
- AS $$ SELECT $1::geometry && $2 AND _st_intersects($1, $2, $3) $$
- LANGUAGE 'sql' IMMUTABLE
- COST 1000;
+ RETURNS boolean
+ AS $$ SELECT $1::geometry && $2 AND _st_intersects($1, $2, $3) $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
CREATE OR REPLACE FUNCTION st_intersects(rast raster, nband integer, geom geometry)
- RETURNS boolean
- AS $$ SELECT $1::geometry && $3 AND _st_intersects($1, $3, $2) $$
- LANGUAGE 'sql' IMMUTABLE
- COST 1000;
+ RETURNS boolean
+ AS $$ SELECT $1::geometry && $3 AND _st_intersects($1, $3, $2) $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
-----------------------------------------------------------------------
-- _st_intersects(geom geometry, rast raster, nband integer)
@@ -7568,308 +7547,308 @@ CREATE OR REPLACE FUNCTION st_intersects(rast raster, nband integer, geom geomet
-----------------------------------------------------------------------
-- This function can not be STRICT
CREATE OR REPLACE FUNCTION _st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL)
- RETURNS boolean AS $$
- DECLARE
- hasnodata boolean := TRUE;
- nodata float8 := 0.0;
- convexhull geometry;
- geomintersect geometry;
- x1w double precision := 0.0;
- x2w double precision := 0.0;
- y1w double precision := 0.0;
- y2w double precision := 0.0;
- x1 integer := 0;
- x2 integer := 0;
- x3 integer := 0;
- x4 integer := 0;
- y1 integer := 0;
- y2 integer := 0;
- y3 integer := 0;
- y4 integer := 0;
- x integer := 0;
- y integer := 0;
- xinc integer := 0;
- yinc integer := 0;
- pixelval double precision;
- bintersect boolean := FALSE;
- gtype text;
- scale float8;
- w int;
- h int;
- BEGIN
- IF ST_SRID(rast) != ST_SRID(geom) THEN
- RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
- END IF;
+ RETURNS boolean AS $$
+ DECLARE
+ hasnodata boolean := TRUE;
+ nodata float8 := 0.0;
+ convexhull geometry;
+ geomintersect geometry;
+ x1w double precision := 0.0;
+ x2w double precision := 0.0;
+ y1w double precision := 0.0;
+ y2w double precision := 0.0;
+ x1 integer := 0;
+ x2 integer := 0;
+ x3 integer := 0;
+ x4 integer := 0;
+ y1 integer := 0;
+ y2 integer := 0;
+ y3 integer := 0;
+ y4 integer := 0;
+ x integer := 0;
+ y integer := 0;
+ xinc integer := 0;
+ yinc integer := 0;
+ pixelval double precision;
+ bintersect boolean := FALSE;
+ gtype text;
+ scale float8;
+ w int;
+ h int;
+ BEGIN
+ IF ST_SRID(rast) != ST_SRID(geom) THEN
+ RAISE EXCEPTION 'Raster and geometry do not have the same SRID';
+ END IF;
- convexhull := ST_ConvexHull(rast);
- IF nband IS NOT NULL THEN
- SELECT CASE WHEN bmd.nodatavalue IS NULL THEN FALSE ELSE NULL END INTO hasnodata FROM ST_BandMetaData(rast, nband) AS bmd;
- END IF;
+ convexhull := ST_ConvexHull(rast);
+ IF nband IS NOT NULL THEN
+ SELECT CASE WHEN bmd.nodatavalue IS NULL THEN FALSE ELSE NULL END INTO hasnodata FROM ST_BandMetaData(rast, nband) AS bmd;
+ END IF;
- IF ST_Intersects(geom, convexhull) IS NOT TRUE THEN
- RETURN FALSE;
- ELSEIF nband IS NULL OR hasnodata IS FALSE THEN
- RETURN TRUE;
- END IF;
+ IF ST_Intersects(geom, convexhull) IS NOT TRUE THEN
+ RETURN FALSE;
+ ELSEIF nband IS NULL OR hasnodata IS FALSE THEN
+ RETURN TRUE;
+ END IF;
- -- Get the intersection between with the geometry.
- -- We will search for withvalue pixel only in this area.
- geomintersect := st_intersection(geom, convexhull);
+ -- Get the intersection between with the geometry.
+ -- We will search for withvalue pixel only in this area.
+ geomintersect := st_intersection(geom, convexhull);
--RAISE NOTICE 'geomintersect=%', st_astext(geomintersect);
- -- If the intersection is empty, return false
- IF st_isempty(geomintersect) THEN
- RETURN FALSE;
- END IF;
+ -- If the intersection is empty, return false
+ IF st_isempty(geomintersect) THEN
+ RETURN FALSE;
+ END IF;
- -- We create a minimalistic buffer around the intersection in order to scan every pixels
- -- that would touch the edge or intersect with the geometry
- SELECT sqrt(scalex * scalex + skewy * skewy), width, height INTO scale, w, h FROM ST_Metadata(rast);
- IF scale != 0 THEN
- geomintersect := st_buffer(geomintersect, scale / 1000000);
- END IF;
+ -- We create a minimalistic buffer around the intersection in order to scan every pixels
+ -- that would touch the edge or intersect with the geometry
+ SELECT sqrt(scalex * scalex + skewy * skewy), width, height INTO scale, w, h FROM ST_Metadata(rast);
+ IF scale != 0 THEN
+ geomintersect := st_buffer(geomintersect, scale / 1000000);
+ END IF;
--RAISE NOTICE 'geomintersect2=%', st_astext(geomintersect);
- -- Find the world coordinates of the bounding box of the intersecting area
- x1w := st_xmin(geomintersect);
- y1w := st_ymin(geomintersect);
- x2w := st_xmax(geomintersect);
- y2w := st_ymax(geomintersect);
- nodata := st_bandnodatavalue(rast, nband);
+ -- Find the world coordinates of the bounding box of the intersecting area
+ x1w := st_xmin(geomintersect);
+ y1w := st_ymin(geomintersect);
+ x2w := st_xmax(geomintersect);
+ y2w := st_ymax(geomintersect);
+ nodata := st_bandnodatavalue(rast, nband);
--RAISE NOTICE 'x1w=%, y1w=%, x2w=%, y2w=%', x1w, y1w, x2w, y2w;
- -- Convert world coordinates to raster coordinates
- x1 := st_world2rastercoordx(rast, x1w, y1w);
- y1 := st_world2rastercoordy(rast, x1w, y1w);
- x2 := st_world2rastercoordx(rast, x2w, y1w);
- y2 := st_world2rastercoordy(rast, x2w, y1w);
- x3 := st_world2rastercoordx(rast, x1w, y2w);
- y3 := st_world2rastercoordy(rast, x1w, y2w);
- x4 := st_world2rastercoordx(rast, x2w, y2w);
- y4 := st_world2rastercoordy(rast, x2w, y2w);
+ -- Convert world coordinates to raster coordinates
+ x1 := st_world2rastercoordx(rast, x1w, y1w);
+ y1 := st_world2rastercoordy(rast, x1w, y1w);
+ x2 := st_world2rastercoordx(rast, x2w, y1w);
+ y2 := st_world2rastercoordy(rast, x2w, y1w);
+ x3 := st_world2rastercoordx(rast, x1w, y2w);
+ y3 := st_world2rastercoordy(rast, x1w, y2w);
+ x4 := st_world2rastercoordx(rast, x2w, y2w);
+ y4 := st_world2rastercoordy(rast, x2w, y2w);
--RAISE NOTICE 'x1=%, y1=%, x2=%, y2=%, x3=%, y3=%, x4=%, y4=%', x1, y1, x2, y2, x3, y3, x4, y4;
- -- Order the raster coordinates for the upcoming FOR loop.
- x1 := int4smaller(int4smaller(int4smaller(x1, x2), x3), x4);
- y1 := int4smaller(int4smaller(int4smaller(y1, y2), y3), y4);
- x2 := int4larger(int4larger(int4larger(x1, x2), x3), x4);
- y2 := int4larger(int4larger(int4larger(y1, y2), y3), y4);
+ -- Order the raster coordinates for the upcoming FOR loop.
+ x1 := int4smaller(int4smaller(int4smaller(x1, x2), x3), x4);
+ y1 := int4smaller(int4smaller(int4smaller(y1, y2), y3), y4);
+ x2 := int4larger(int4larger(int4larger(x1, x2), x3), x4);
+ y2 := int4larger(int4larger(int4larger(y1, y2), y3), y4);
- -- Make sure the range is not lower than 1.
- -- This can happen when world coordinate are exactly on the left border
- -- of the raster and that they do not span on more than one pixel.
- x1 := int4smaller(int4larger(x1, 1), w);
- y1 := int4smaller(int4larger(y1, 1), h);
+ -- Make sure the range is not lower than 1.
+ -- This can happen when world coordinate are exactly on the left border
+ -- of the raster and that they do not span on more than one pixel.
+ x1 := int4smaller(int4larger(x1, 1), w);
+ y1 := int4smaller(int4larger(y1, 1), h);
- -- Also make sure the range does not exceed the width and height of the raster.
- -- This can happen when world coordinate are exactly on the lower right border
- -- of the raster.
- x2 := int4smaller(x2, w);
- y2 := int4smaller(y2, h);
+ -- Also make sure the range does not exceed the width and height of the raster.
+ -- This can happen when world coordinate are exactly on the lower right border
+ -- of the raster.
+ x2 := int4smaller(x2, w);
+ y2 := int4smaller(y2, h);
--RAISE NOTICE 'x1=%, y1=%, x2=%, y2=%', x1, y1, x2, y2;
- -- Search exhaustively for withvalue pixel on a moving 3x3 grid
- -- (very often more efficient than searching on a mere 1x1 grid)
- FOR xinc in 0..2 LOOP
- FOR yinc in 0..2 LOOP
- FOR x IN x1+xinc..x2 BY 3 LOOP
- FOR y IN y1+yinc..y2 BY 3 LOOP
- -- Check first if the pixel intersects with the geometry. Often many won't.
- bintersect := NOT st_isempty(st_intersection(st_pixelaspolygon(rast, x, y), geom));
-
- IF bintersect THEN
- -- If the pixel really intersects, check its value. Return TRUE if with value.
- pixelval := st_value(rast, nband, x, y);
- IF pixelval != nodata THEN
- RETURN TRUE;
- END IF;
- END IF;
- END LOOP;
- END LOOP;
- END LOOP;
- END LOOP;
-
- RETURN FALSE;
- END;
- $$ LANGUAGE 'plpgsql' IMMUTABLE
- COST 1000;
+ -- Search exhaustively for withvalue pixel on a moving 3x3 grid
+ -- (very often more efficient than searching on a mere 1x1 grid)
+ FOR xinc in 0..2 LOOP
+ FOR yinc in 0..2 LOOP
+ FOR x IN x1+xinc..x2 BY 3 LOOP
+ FOR y IN y1+yinc..y2 BY 3 LOOP
+ -- Check first if the pixel intersects with the geometry. Often many won't.
+ bintersect := NOT st_isempty(st_intersection(st_pixelaspolygon(rast, x, y), geom));
+
+ IF bintersect THEN
+ -- If the pixel really intersects, check its value. Return TRUE if with value.
+ pixelval := st_value(rast, nband, x, y);
+ IF pixelval != nodata THEN
+ RETURN TRUE;
+ END IF;
+ END IF;
+ END LOOP;
+ END LOOP;
+ END LOOP;
+ END LOOP;
+
+ RETURN FALSE;
+ END;
+ $$ LANGUAGE 'plpgsql' IMMUTABLE
+ COST 1000;
-- This function can not be STRICT
CREATE OR REPLACE FUNCTION st_intersects(geom geometry, rast raster, nband integer DEFAULT NULL)
- RETURNS boolean AS
- $$ SELECT $1 && $2::geometry AND _st_intersects($1, $2, $3); $$
- LANGUAGE 'sql' IMMUTABLE
- COST 1000;
+ RETURNS boolean AS
+ $$ SELECT $1 && $2::geometry AND _st_intersects($1, $2, $3); $$
+ LANGUAGE 'sql' IMMUTABLE
+ COST 1000;
-----------------------------------------------------------------------
-- ST_Intersection (geometry, raster in vector space)
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_intersection(geomin geometry, rast raster, band integer DEFAULT 1)
- RETURNS SETOF geomval AS $$
- DECLARE
- intersects boolean := FALSE;
- BEGIN
- intersects := ST_Intersects(geomin, rast, band);
- IF intersects THEN
- -- Return the intersections of the geometry with the vectorized parts of
- -- the raster and the values associated with those parts, if really their
- -- intersection is not empty.
- RETURN QUERY
- SELECT
- intgeom,
- val
- FROM (
- SELECT
- ST_Intersection((gv).geom, geomin) AS intgeom,
- (gv).val
- FROM ST_DumpAsPolygons(rast, band) gv
- WHERE ST_Intersects((gv).geom, geomin)
- ) foo
- WHERE NOT ST_IsEmpty(intgeom);
- ELSE
- -- If the geometry does not intersect with the raster, return an empty
- -- geometry and a null value
- RETURN QUERY
- SELECT
- emptygeom,
- NULL::float8
- FROM ST_GeomCollFromText('GEOMETRYCOLLECTION EMPTY', ST_SRID($1)) emptygeom;
- END IF;
- END;
- $$
- LANGUAGE 'plpgsql' IMMUTABLE STRICT;
+ RETURNS SETOF geomval AS $$
+ DECLARE
+ intersects boolean := FALSE;
+ BEGIN
+ intersects := ST_Intersects(geomin, rast, band);
+ IF intersects THEN
+ -- Return the intersections of the geometry with the vectorized parts of
+ -- the raster and the values associated with those parts, if really their
+ -- intersection is not empty.
+ RETURN QUERY
+ SELECT
+ intgeom,
+ val
+ FROM (
+ SELECT
+ ST_Intersection((gv).geom, geomin) AS intgeom,
+ (gv).val
+ FROM ST_DumpAsPolygons(rast, band) gv
+ WHERE ST_Intersects((gv).geom, geomin)
+ ) foo
+ WHERE NOT ST_IsEmpty(intgeom);
+ ELSE
+ -- If the geometry does not intersect with the raster, return an empty
+ -- geometry and a null value
+ RETURN QUERY
+ SELECT
+ emptygeom,
+ NULL::float8
+ FROM ST_GeomCollFromText('GEOMETRYCOLLECTION EMPTY', ST_SRID($1)) emptygeom;
+ END IF;
+ END;
+ $$
+ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION st_intersection(rast raster, band integer, geomin geometry)
- RETURNS SETOF geomval AS
- $$ SELECT st_intersection($3, $1, $2) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF geomval AS
+ $$ SELECT st_intersection($3, $1, $2) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(rast raster, geomin geometry)
- RETURNS SETOF geomval AS
- $$ SELECT st_intersection($2, $1, 1) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS SETOF geomval AS
+ $$ SELECT st_intersection($2, $1, 1) $$
+ LANGUAGE 'sql' STABLE;
-----------------------------------------------------------------------
-- ST_Intersection (2-raster in raster space)
-----------------------------------------------------------------------
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster, band1 int,
- rast2 raster, band2 int,
- returnband text DEFAULT 'BOTH',
- nodataval double precision[] DEFAULT NULL
+ rast1 raster, band1 int,
+ rast2 raster, band2 int,
+ returnband text DEFAULT 'BOTH',
+ nodataval double precision[] DEFAULT NULL
)
- RETURNS raster
- AS $$
- DECLARE
- rtn raster;
- _returnband text;
- newnodata1 float8;
- newnodata2 float8;
- BEGIN
- newnodata1 := coalesce(nodataval[1], ST_BandNodataValue(rast1, band1), ST_MinPossibleValue(ST_BandPixelType(rast1, band1)));
- newnodata2 := coalesce(nodataval[2], ST_BandNodataValue(rast2, band2), ST_MinPossibleValue(ST_BandPixelType(rast2, band2)));
-
- _returnband := upper(returnband);
-
- rtn := NULL;
- CASE
- WHEN _returnband = 'BAND1' THEN
- rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast1.val]', ST_BandPixelType(rast1, band1), 'INTERSECTION', newnodata1::text, newnodata1::text, newnodata1);
- rtn := ST_SetBandNodataValue(rtn, 1, newnodata1);
- WHEN _returnband = 'BAND2' THEN
- rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast2.val]', ST_BandPixelType(rast2, band2), 'INTERSECTION', newnodata2::text, newnodata2::text, newnodata2);
- rtn := ST_SetBandNodataValue(rtn, 1, newnodata2);
- WHEN _returnband = 'BOTH' THEN
- rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast1.val]', ST_BandPixelType(rast1, band1), 'INTERSECTION', newnodata1::text, newnodata1::text, newnodata1);
- rtn := ST_SetBandNodataValue(rtn, 1, newnodata1);
- rtn := ST_AddBand(rtn, ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast2.val]', ST_BandPixelType(rast2, band2), 'INTERSECTION', newnodata2::text, newnodata2::text, newnodata2));
- rtn := ST_SetBandNodataValue(rtn, 2, newnodata2);
- ELSE
- RAISE EXCEPTION 'Unknown value provided for returnband: %', returnband;
- RETURN NULL;
- END CASE;
-
- RETURN rtn;
- END;
- $$ LANGUAGE 'plpgsql' STABLE;
+ RETURNS raster
+ AS $$
+ DECLARE
+ rtn raster;
+ _returnband text;
+ newnodata1 float8;
+ newnodata2 float8;
+ BEGIN
+ newnodata1 := coalesce(nodataval[1], ST_BandNodataValue(rast1, band1), ST_MinPossibleValue(ST_BandPixelType(rast1, band1)));
+ newnodata2 := coalesce(nodataval[2], ST_BandNodataValue(rast2, band2), ST_MinPossibleValue(ST_BandPixelType(rast2, band2)));
+
+ _returnband := upper(returnband);
+
+ rtn := NULL;
+ CASE
+ WHEN _returnband = 'BAND1' THEN
+ rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast1.val]', ST_BandPixelType(rast1, band1), 'INTERSECTION', newnodata1::text, newnodata1::text, newnodata1);
+ rtn := ST_SetBandNodataValue(rtn, 1, newnodata1);
+ WHEN _returnband = 'BAND2' THEN
+ rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast2.val]', ST_BandPixelType(rast2, band2), 'INTERSECTION', newnodata2::text, newnodata2::text, newnodata2);
+ rtn := ST_SetBandNodataValue(rtn, 1, newnodata2);
+ WHEN _returnband = 'BOTH' THEN
+ rtn := ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast1.val]', ST_BandPixelType(rast1, band1), 'INTERSECTION', newnodata1::text, newnodata1::text, newnodata1);
+ rtn := ST_SetBandNodataValue(rtn, 1, newnodata1);
+ rtn := ST_AddBand(rtn, ST_MapAlgebraExpr(rast1, band1, rast2, band2, '[rast2.val]', ST_BandPixelType(rast2, band2), 'INTERSECTION', newnodata2::text, newnodata2::text, newnodata2));
+ rtn := ST_SetBandNodataValue(rtn, 2, newnodata2);
+ ELSE
+ RAISE EXCEPTION 'Unknown value provided for returnband: %', returnband;
+ RETURN NULL;
+ END CASE;
+
+ RETURN rtn;
+ END;
+ $$ LANGUAGE 'plpgsql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster, band1 int,
- rast2 raster, band2 int,
- returnband text,
- nodataval double precision
+ rast1 raster, band1 int,
+ rast2 raster, band2 int,
+ returnband text,
+ nodataval double precision
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, $2, $3, $4, $5, ARRAY[$6, $6]) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, $2, $3, $4, $5, ARRAY[$6, $6]) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster, band1 int,
- rast2 raster, band2 int,
- nodataval double precision[]
+ rast1 raster, band1 int,
+ rast2 raster, band2 int,
+ nodataval double precision[]
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, $2, $3, $4, 'BOTH', $5) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, $2, $3, $4, 'BOTH', $5) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster, band1 int,
- rast2 raster, band2 int,
- nodataval double precision
+ rast1 raster, band1 int,
+ rast2 raster, band2 int,
+ nodataval double precision
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, $2, $3, $4, 'BOTH', ARRAY[$5, $5]) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, $2, $3, $4, 'BOTH', ARRAY[$5, $5]) $$
+ LANGUAGE 'sql' STABLE;
-- Variants without band number
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster,
- rast2 raster,
- returnband text DEFAULT 'BOTH',
- nodataval double precision[] DEFAULT NULL
+ rast1 raster,
+ rast2 raster,
+ returnband text DEFAULT 'BOTH',
+ nodataval double precision[] DEFAULT NULL
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, 1, $2, 1, $3, $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, 1, $2, 1, $3, $4) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster,
- rast2 raster,
- returnband text,
- nodataval double precision
+ rast1 raster,
+ rast2 raster,
+ returnband text,
+ nodataval double precision
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, 1, $2, 1, $3, ARRAY[$4, $4]) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, 1, $2, 1, $3, ARRAY[$4, $4]) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster,
- rast2 raster,
- nodataval double precision[]
+ rast1 raster,
+ rast2 raster,
+ nodataval double precision[]
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, 1, $2, 1, 'BOTH', $3) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, 1, $2, 1, 'BOTH', $3) $$
+ LANGUAGE 'sql' STABLE;
CREATE OR REPLACE FUNCTION st_intersection(
- rast1 raster,
- rast2 raster,
- nodataval double precision
+ rast1 raster,
+ rast2 raster,
+ nodataval double precision
)
- RETURNS raster AS
- $$ SELECT st_intersection($1, 1, $2, 1, 'BOTH', ARRAY[$3, $3]) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT st_intersection($1, 1, $2, 1, 'BOTH', ARRAY[$3, $3]) $$
+ LANGUAGE 'sql' STABLE;
-----------------------------------------------------------------------
-- st_union aggregate
-----------------------------------------------------------------------
-- Main state function
-CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster, rast2 raster, p_expression text, p_nodata1expr text, p_nodata2expr text, p_nodatanodataval double precision,t_expression text,t_nodata1expr text, t_nodata2expr text,t_nodatanodataval double precision)
+CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster, rast2 raster, p_expression text, p_nodata1expr text, p_nodata2expr text, p_nodatanodataval double precision,t_expression text,t_nodata1expr text, t_nodata2expr text,t_nodatanodataval double precision)
RETURNS raster AS
$$
DECLARE
@@ -7880,7 +7859,7 @@ CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster, rast2 raster
-- ST_MapAlgebraExpr(rast1 raster, band1 integer, rast2 raster, band2 integer, expression text, pixeltype text, extentexpr text, nodata1expr text, nodata2expr text, nodatanodatadaval double precision)
-- We must make sure that when NULL is passed as the first raster to ST_MapAlgebraExpr, ST_MapAlgebraExpr resolve the nodata1expr
-- Note: rast2 is always a single band raster since it is the accumulated raster thus far
- -- There we always set that to band 1 regardless of what band num is requested
+ -- There we always set that to band 1 regardless of what band num is requested
IF upper(p_expression) = 'LAST' THEN
--RAISE NOTICE 'last asked for ';
RETURN ST_MapAlgebraExpr(rast1, 1, rast2, 1, '[rast2.val]'::text, NULL::text, 'UNION'::text, '[rast2.val]'::text, '[rast1.val]'::text, NULL::double precision);
@@ -7895,15 +7874,15 @@ CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster, rast2 raster
ELSIF upper(p_expression) = 'SUM' THEN
RETURN ST_MapAlgebraExpr(rast1, 1, rast2, 1, '[rast1.val] + [rast2.val]'::text, NULL::text, 'UNION'::text, '[rast2.val]'::text, '[rast1.val]'::text, NULL::double precision);
ELSIF upper(p_expression) = 'RANGE' THEN
- -- have no idea what this is
+ -- have no idea what this is
t_raster = ST_MapAlgebraExpr(rast1, 2, rast2, 1, 'LEAST([rast1.val], [rast2.val])'::text, NULL::text, 'UNION'::text, '[rast2.val]'::text, '[rast1.val]'::text, NULL::double precision);
p_raster := _ST_MapAlgebra4UnionState(rast1, rast2, 'MAX'::text, NULL::text, NULL::text, NULL::double precision, NULL::text, NULL::text, NULL::text, NULL::double precision);
RETURN ST_AddBand(p_raster, t_raster, 1, 2);
ELSIF upper(p_expression) = 'MEAN' THEN
-- looks like t_raster is used to keep track of accumulated count
-- and p_raster is there to keep track of accumulated sum and final state function
- -- would then do a final map to divide them. This one is currently broken because
- -- have not reworked it so it can do without a final function
+ -- would then do a final map to divide them. This one is currently broken because
+ -- have not reworked it so it can do without a final function
t_raster = ST_MapAlgebraExpr(rast1, 2, rast2, 1, '[rast1.val] + 1'::text, NULL::text, 'UNION'::text, '1'::text, '[rast1.val]'::text, 0::double precision);
p_raster := _ST_MapAlgebra4UnionState(rast1, rast2, 'SUM'::text, NULL::text, NULL::text, NULL::double precision, NULL::text, NULL::text, NULL::text, NULL::double precision);
RETURN ST_AddBand(p_raster, t_raster, 1, 2);
@@ -7932,29 +7911,29 @@ CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster,rast2 raster,
AS $$
SELECT _ST_MapAlgebra4UnionState($1,ST_Band($2,$3), 'LAST', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
$$ LANGUAGE 'sql';
-
+
-- State function when there is no expressions and assumes band 1
CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster,rast2 raster)
RETURNS raster
AS $$
SELECT _ST_MapAlgebra4UnionState($1,$2, 'LAST', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
$$ LANGUAGE 'sql';
-
+
-- State function when there isan expressions and assumes band 1
CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionState(rast1 raster,rast2 raster, p_expression text)
RETURNS raster
AS $$
SELECT _ST_MapAlgebra4UnionState($1,$2, $3, NULL, NULL, NULL, NULL, NULL, NULL, NULL)
$$ LANGUAGE 'sql';
-
+
-- Final function with only the primary expression
CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionFinal1(rast raster)
RETURNS raster AS
$$
DECLARE
BEGIN
- -- NOTE: I have to sacrifice RANGE. Sorry RANGE. Any 2 banded raster is going to be treated
- -- as a MEAN
+ -- NOTE: I have to sacrifice RANGE. Sorry RANGE. Any 2 banded raster is going to be treated
+ -- as a MEAN
IF ST_NumBands(rast) = 2 THEN
RETURN ST_MapAlgebraExpr(rast, 1, rast, 2, 'CASE WHEN [rast2.val] > 0 THEN [rast1.val] / [rast2.val]::float8 ELSE NULL END'::text, NULL::text, 'UNION'::text, NULL::text, NULL::text, NULL::double precision);
ELSE
@@ -7963,7 +7942,7 @@ CREATE OR REPLACE FUNCTION _ST_MapAlgebra4UnionFinal1(rast raster)
END;
$$
LANGUAGE 'plpgsql';
-
+
-- Variant with primary expression defaulting to 'LAST' and working on first band
CREATE AGGREGATE ST_Union(raster) (
SFUNC = _ST_MapAlgebra4UnionState,
@@ -7997,11 +7976,11 @@ CREATE AGGREGATE ST_Union(raster, integer, text) (
-- ST_Clip(rast raster, band int, geom geometry, nodata float8 DEFAULT null, crop boolean DEFAULT true)
-- Clip the values of a raster to the shape of a polygon.
--
--- rast - raster to be clipped
--- band - limit the result to only one band
--- geom - geometry defining the shape to clip the raster
+-- rast - raster to be clipped
+-- band - limit the result to only one band
+-- geom - geometry defining the shape to clip the raster
-- nodata - define (if there is none defined) or replace the raster nodata value with this value
--- crop - limit the extent of the result to the extent of the geometry
+-- crop - limit the extent of the result to the extent of the geometry
-----------------------------------------------------------------------
-- ST_Clip
-----------------------------------------------------------------------
@@ -8009,1308 +7988,1308 @@ CREATE AGGREGATE ST_Union(raster, integer, text) (
-- Major variant
CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodataval double precision[] DEFAULT NULL, crop boolean DEFAULT TRUE)
- RETURNS raster
- AS $$
- DECLARE
- g geometry;
- newrast raster;
- geomrast raster;
- numband int;
- bandstart int;
- bandend int;
- newextent text;
- newnodataval double precision;
- newpixtype text;
- bandi int;
- hasnodata bool;
- BEGIN
- IF rast IS NULL THEN
- RETURN NULL;
- END IF;
- IF geom IS NULL THEN
- RETURN rast;
- END IF;
- numband := ST_Numbands(rast);
- IF band IS NULL THEN
- bandstart := 1;
- bandend := numband;
- ELSEIF ST_HasNoBand(rast, band) THEN
- RAISE NOTICE 'Raster do not have band %. Returning null', band;
- RETURN NULL;
- ELSE
- bandstart := band;
- bandend := band;
- END IF;
-
- newpixtype := ST_BandPixelType(rast, bandstart);
- newnodataval := coalesce(nodataval[1], ST_BandNodataValue(rast, bandstart), ST_MinPossibleValue(newpixtype));
- newextent := CASE WHEN crop THEN 'INTERSECTION' ELSE 'FIRST' END;
-
- -- Convert the geometry to a raster
- g := ST_Intersection(geom, rast::geometry);
- geomrast := ST_AsRaster(g, rast, ST_BandPixelType(rast, band), 1, newnodataval);
-
- -- Compute the first raster band
- newrast := ST_MapAlgebraExpr(rast, bandstart, geomrast, 1, '[rast1.val]', newpixtype, newextent, newnodataval::text, newnodataval::text, newnodataval);
- -- Set the newnodataval
- newrast := ST_SetBandNodataValue(newrast, bandstart, newnodataval);
-
- FOR bandi IN bandstart+1..bandend LOOP
- -- for each band we must determine the nodata value
- newpixtype := ST_BandPixelType(rast, bandi);
- IF ST_BandNodataValue(rast, bandi) IS NULL THEN
- hasnodata := FALSE;
- ELSE
- hasnodata := TRUE;
- END IF;
- newnodataval := coalesce(nodataval[bandi], nodataval[array_upper(nodataval, 1)], ST_BandNodataValue(rast, bandi), ST_MinPossibleValue(newpixtype));
- newrast := ST_AddBand(newrast, ST_MapAlgebraExpr(rast, bandi, geomrast, 1, '[rast1.val]', newpixtype, newextent, newnodataval::text, newnodataval::text, newnodataval));
-
- IF hasnodata THEN
- newrast := ST_SetBandNodataValue(newrast, bandi, newnodataval);
- END IF;
- END LOOP;
-
- RETURN newrast;
- END;
- $$ LANGUAGE 'plpgsql' STABLE;
+ RETURNS raster
+ AS $$
+ DECLARE
+ g geometry;
+ newrast raster;
+ geomrast raster;
+ numband int;
+ bandstart int;
+ bandend int;
+ newextent text;
+ newnodataval double precision;
+ newpixtype text;
+ bandi int;
+ hasnodata bool;
+ BEGIN
+ IF rast IS NULL THEN
+ RETURN NULL;
+ END IF;
+ IF geom IS NULL THEN
+ RETURN rast;
+ END IF;
+ numband := ST_Numbands(rast);
+ IF band IS NULL THEN
+ bandstart := 1;
+ bandend := numband;
+ ELSEIF ST_HasNoBand(rast, band) THEN
+ RAISE NOTICE 'Raster do not have band %. Returning null', band;
+ RETURN NULL;
+ ELSE
+ bandstart := band;
+ bandend := band;
+ END IF;
+
+ newpixtype := ST_BandPixelType(rast, bandstart);
+ newnodataval := coalesce(nodataval[1], ST_BandNodataValue(rast, bandstart), ST_MinPossibleValue(newpixtype));
+ newextent := CASE WHEN crop THEN 'INTERSECTION' ELSE 'FIRST' END;
+
+ -- Convert the geometry to a raster
+ g := ST_Intersection(geom, rast::geometry);
+ geomrast := ST_AsRaster(g, rast, ST_BandPixelType(rast, band), 1, newnodataval);
+
+ -- Compute the first raster band
+ newrast := ST_MapAlgebraExpr(rast, bandstart, geomrast, 1, '[rast1.val]', newpixtype, newextent, newnodataval::text, newnodataval::text, newnodataval);
+ -- Set the newnodataval
+ newrast := ST_SetBandNodataValue(newrast, bandstart, newnodataval);
+
+ FOR bandi IN bandstart+1..bandend LOOP
+ -- for each band we must determine the nodata value
+ newpixtype := ST_BandPixelType(rast, bandi);
+ IF ST_BandNodataValue(rast, bandi) IS NULL THEN
+ hasnodata := FALSE;
+ ELSE
+ hasnodata := TRUE;
+ END IF;
+ newnodataval := coalesce(nodataval[bandi], nodataval[array_upper(nodataval, 1)], ST_BandNodataValue(rast, bandi), ST_MinPossibleValue(newpixtype));
+ newrast := ST_AddBand(newrast, ST_MapAlgebraExpr(rast, bandi, geomrast, 1, '[rast1.val]', newpixtype, newextent, newnodataval::text, newnodataval::text, newnodataval));
+
+ IF hasnodata THEN
+ newrast := ST_SetBandNodataValue(newrast, bandi, newnodataval);
+ END IF;
+ END LOOP;
+
+ RETURN newrast;
+ END;
+ $$ LANGUAGE 'plpgsql' STABLE;
-- Nodata values as integer series
CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, nodataval double precision, crop boolean DEFAULT TRUE)
- RETURNS raster AS
- $$ SELECT ST_Clip($1, $2, $3, ARRAY[$4], $5) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT ST_Clip($1, $2, $3, ARRAY[$4], $5) $$
+ LANGUAGE 'sql' STABLE;
-- Variant defaulting nodataval to the one of the raster or the min possible value
CREATE OR REPLACE FUNCTION st_clip(rast raster, band int, geom geometry, crop boolean)
- RETURNS raster AS
- $$ SELECT ST_Clip($1, $2, $3, null::float8[], $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT ST_Clip($1, $2, $3, null::float8[], $4) $$
+ LANGUAGE 'sql' STABLE;
-- Variant defaulting to all bands
CREATE OR REPLACE FUNCTION st_clip(rast raster, geom geometry, nodataval double precision[] DEFAULT NULL, crop boolean DEFAULT TRUE)
- RETURNS raster AS
- $$ SELECT ST_Clip($1, NULL, $2, $3, $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT ST_Clip($1, NULL, $2, $3, $4) $$
+ LANGUAGE 'sql' STABLE;
-- Variant defaulting to all bands
CREATE OR REPLACE FUNCTION st_clip(rast raster, geom geometry, nodataval double precision, crop boolean DEFAULT TRUE)
- RETURNS raster AS
- $$ SELECT ST_Clip($1, NULL, $2, ARRAY[$3], $4) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT ST_Clip($1, NULL, $2, ARRAY[$3], $4) $$
+ LANGUAGE 'sql' STABLE;
-- Variant defaulting nodataval to the one of the raster or the min possible value and returning all bands
CREATE OR REPLACE FUNCTION st_clip(rast raster, geom geometry, crop boolean)
- RETURNS raster AS
- $$ SELECT ST_Clip($1, NULL, $2, null::float8[], $3) $$
- LANGUAGE 'sql' STABLE;
+ RETURNS raster AS
+ $$ SELECT ST_Clip($1, NULL, $2, null::float8[], $3) $$
+ LANGUAGE 'sql' STABLE;
------------------------------------------------------------------------------
-- raster constraint functions
-------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _add_raster_constraint(cn name, sql text)
- RETURNS boolean AS $$
- BEGIN
- BEGIN
- EXECUTE sql;
- EXCEPTION
- WHEN duplicate_object THEN
- RAISE NOTICE 'The constraint "%" already exists. To replace the existing constraint, delete the constraint and call ApplyRasterConstraints again', cn;
- WHEN OTHERS THEN
- RAISE NOTICE 'Unable to add constraint "%"', cn;
- RETURN FALSE;
- END;
-
- RETURN TRUE;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ BEGIN
+ BEGIN
+ EXECUTE sql;
+ EXCEPTION
+ WHEN duplicate_object THEN
+ RAISE NOTICE 'The constraint "%" already exists. To replace the existing constraint, delete the constraint and call ApplyRasterConstraints again', cn;
+ WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to add constraint "%"', cn;
+ RETURN FALSE;
+ END;
+
+ RETURN TRUE;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint(rastschema name, rasttable name, cn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- BEGIN
- EXECUTE 'ALTER TABLE '
- || fqtn
- || ' DROP CONSTRAINT '
- || quote_ident(cn);
- RETURN TRUE;
- EXCEPTION
- WHEN undefined_object THEN
- RAISE NOTICE 'The constraint "%" does not exist. Skipping', cn;
- WHEN OTHERS THEN
- RAISE NOTICE 'Unable to drop constraint "%"', cn;
- RETURN FALSE;
- END;
-
- RETURN TRUE;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ BEGIN
+ EXECUTE 'ALTER TABLE '
+ || fqtn
+ || ' DROP CONSTRAINT '
+ || quote_ident(cn);
+ RETURN TRUE;
+ EXCEPTION
+ WHEN undefined_object THEN
+ RAISE NOTICE 'The constraint "%" does not exist. Skipping', cn;
+ WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to drop constraint "%"', cn;
+ RETURN FALSE;
+ END;
+
+ RETURN TRUE;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_srid(rastschema name, rasttable name, rastcolumn name)
- RETURNS integer AS $$
- SELECT
- replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%st_srid(% = %';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS integer AS $$
+ SELECT
+ replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%st_srid(% = %';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_srid(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr int;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_srid_' || $3;
-
- sql := 'SELECT st_srid('
- || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the SRID of a sample raster';
- RETURN FALSE;
- END;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (st_srid('
- || quote_ident($3)
- || ') = ' || attr || ')';
-
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr int;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_srid_' || $3;
+
+ sql := 'SELECT st_srid('
+ || quote_ident($3)
+ || ') FROM ' || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the SRID of a sample raster';
+ RETURN FALSE;
+ END;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (st_srid('
+ || quote_ident($3)
+ || ') = ' || attr || ')';
+
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_srid(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_srid_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_srid_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_scale(rastschema name, rasttable name, rastcolumn name, axis char)
- RETURNS double precision AS $$
- SELECT
- replace(replace(split_part(split_part(s.consrc, ' = ', 2), '::', 1), ')', ''), '(', '')::double precision
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%st_scale' || $4 || '(% = %';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS double precision AS $$
+ SELECT
+ replace(replace(split_part(split_part(s.consrc, ' = ', 2), '::', 1), ')', ''), '(', '')::double precision
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%st_scale' || $4 || '(% = %';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_scale(rastschema name, rasttable name, rastcolumn name, axis char)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr double precision;
- BEGIN
- IF lower($4) != 'x' AND lower($4) != 'y' THEN
- RAISE EXCEPTION 'axis must be either "x" or "y"';
- RETURN FALSE;
- END IF;
-
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_scale' || $4 || '_' || $3;
-
- sql := 'SELECT st_scale' || $4 || '('
- || quote_ident($3)
- || ') FROM '
- || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the %-scale of a sample raster', upper($4);
- RETURN FALSE;
- END;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (st_scale' || $4 || '('
- || quote_ident($3)
- || ')::numeric(16,10) = (' || attr || ')::numeric(16,10))';
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr double precision;
+ BEGIN
+ IF lower($4) != 'x' AND lower($4) != 'y' THEN
+ RAISE EXCEPTION 'axis must be either "x" or "y"';
+ RETURN FALSE;
+ END IF;
+
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_scale' || $4 || '_' || $3;
+
+ sql := 'SELECT st_scale' || $4 || '('
+ || quote_ident($3)
+ || ') FROM '
+ || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the %-scale of a sample raster', upper($4);
+ RETURN FALSE;
+ END;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (st_scale' || $4 || '('
+ || quote_ident($3)
+ || ')::numeric(16,10) = (' || attr || ')::numeric(16,10))';
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_scale(rastschema name, rasttable name, rastcolumn name, axis char)
- RETURNS boolean AS $$
- BEGIN
- IF lower($4) != 'x' AND lower($4) != 'y' THEN
- RAISE EXCEPTION 'axis must be either "x" or "y"';
- RETURN FALSE;
- END IF;
+ RETURNS boolean AS $$
+ BEGIN
+ IF lower($4) != 'x' AND lower($4) != 'y' THEN
+ RAISE EXCEPTION 'axis must be either "x" or "y"';
+ RETURN FALSE;
+ END IF;
- RETURN _drop_raster_constraint($1, $2, 'enforce_scale' || $4 || '_' || $3);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURN _drop_raster_constraint($1, $2, 'enforce_scale' || $4 || '_' || $3);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_blocksize(rastschema name, rasttable name, rastcolumn name, axis text)
- RETURNS integer AS $$
- SELECT
- replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%st_' || $4 || '(% = %';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS integer AS $$
+ SELECT
+ replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%st_' || $4 || '(% = %';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_blocksize(rastschema name, rasttable name, rastcolumn name, axis text)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr int;
- BEGIN
- IF lower($4) != 'width' AND lower($4) != 'height' THEN
- RAISE EXCEPTION 'axis must be either "width" or "height"';
- RETURN FALSE;
- END IF;
-
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_' || $4 || '_' || $3;
-
- sql := 'SELECT st_' || $4 || '('
- || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the % of a sample raster', $4;
- RETURN FALSE;
- END;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (st_' || $4 || '('
- || quote_ident($3)
- || ') = ' || attr || ')';
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr int;
+ BEGIN
+ IF lower($4) != 'width' AND lower($4) != 'height' THEN
+ RAISE EXCEPTION 'axis must be either "width" or "height"';
+ RETURN FALSE;
+ END IF;
+
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_' || $4 || '_' || $3;
+
+ sql := 'SELECT st_' || $4 || '('
+ || quote_ident($3)
+ || ') FROM ' || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the % of a sample raster', $4;
+ RETURN FALSE;
+ END;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (st_' || $4 || '('
+ || quote_ident($3)
+ || ') = ' || attr || ')';
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_blocksize(rastschema name, rasttable name, rastcolumn name, axis text)
- RETURNS boolean AS $$
- BEGIN
- IF lower($4) != 'width' AND lower($4) != 'height' THEN
- RAISE EXCEPTION 'axis must be either "width" or "height"';
- RETURN FALSE;
- END IF;
+ RETURNS boolean AS $$
+ BEGIN
+ IF lower($4) != 'width' AND lower($4) != 'height' THEN
+ RAISE EXCEPTION 'axis must be either "width" or "height"';
+ RETURN FALSE;
+ END IF;
- RETURN _drop_raster_constraint($1, $2, 'enforce_' || $4 || '_' || $3);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURN _drop_raster_constraint($1, $2, 'enforce_' || $4 || '_' || $3);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_extent(rastschema name, rasttable name, rastcolumn name)
- RETURNS geometry AS $$
- SELECT
- trim(both '''' from split_part(trim(split_part(s.consrc, ',', 2)), '::', 1))::geometry
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%st_coveredby(st_convexhull(%';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS geometry AS $$
+ SELECT
+ trim(both '''' from split_part(trim(split_part(s.consrc, ',', 2)), '::', 1))::geometry
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%st_coveredby(st_convexhull(%';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_extent(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr text;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_max_extent_' || $3;
-
- sql := 'SELECT st_ashexewkb(st_convexhull(st_collect(st_convexhull('
- || quote_ident($3)
- || ')))) FROM '
- || fqtn;
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the extent of a sample raster. Attempting memory efficient (slower) approach';
-
- sql := 'SELECT st_ashexewkb(st_convexhull(st_memunion(st_convexhull('
- || quote_ident($3)
- || ')))) FROM '
- || fqtn;
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Still unable to get the extent of a sample raster. Cannot add extent constraint';
- RETURN FALSE;
- END;
- END;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (st_coveredby(st_convexhull('
- || quote_ident($3)
- || '), ''' || attr || '''::geometry))';
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr text;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_max_extent_' || $3;
+
+ sql := 'SELECT st_ashexewkb(st_convexhull(st_collect(st_convexhull('
+ || quote_ident($3)
+ || ')))) FROM '
+ || fqtn;
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the extent of a sample raster. Attempting memory efficient (slower) approach';
+
+ sql := 'SELECT st_ashexewkb(st_convexhull(st_memunion(st_convexhull('
+ || quote_ident($3)
+ || ')))) FROM '
+ || fqtn;
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Still unable to get the extent of a sample raster. Cannot add extent constraint';
+ RETURN FALSE;
+ END;
+ END;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (st_coveredby(st_convexhull('
+ || quote_ident($3)
+ || '), ''' || attr || '''::geometry))';
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_extent(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_max_extent_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_max_extent_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_alignment(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- SELECT
- TRUE
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%st_samealignment(%';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS boolean AS $$
+ SELECT
+ TRUE
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%st_samealignment(%';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_alignment(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr text;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_same_alignment_' || $3;
-
- sql := 'SELECT st_makeemptyraster(1, 1, upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid) FROM st_metadata((SELECT '
- || quote_ident($3)
- || ' FROM ' || fqtn || ' LIMIT 1))';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the alignment of a sample raster';
- RETURN FALSE;
- END;
-
- sql := 'ALTER TABLE ' || fqtn ||
- ' ADD CONSTRAINT ' || quote_ident(cn) ||
- ' CHECK (st_samealignment(' || quote_ident($3) || ', ''' || attr || '''::raster))';
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr text;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_same_alignment_' || $3;
+
+ sql := 'SELECT st_makeemptyraster(1, 1, upperleftx, upperlefty, scalex, scaley, skewx, skewy, srid) FROM st_metadata((SELECT '
+ || quote_ident($3)
+ || ' FROM ' || fqtn || ' LIMIT 1))';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the alignment of a sample raster';
+ RETURN FALSE;
+ END;
+
+ sql := 'ALTER TABLE ' || fqtn ||
+ ' ADD CONSTRAINT ' || quote_ident(cn) ||
+ ' CHECK (st_samealignment(' || quote_ident($3) || ', ''' || attr || '''::raster))';
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_alignment(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_same_alignment_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_same_alignment_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_regular_blocking(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean
- AS $$
- DECLARE
- cn text;
- sql text;
- rtn boolean;
- BEGIN
- cn := 'enforce_regular_blocking_' || $3;
-
- sql := 'SELECT TRUE FROM pg_class c, pg_namespace n, pg_constraint s'
- || ' WHERE n.nspname = ' || quote_literal($1)
- || ' AND c.relname = ' || quote_literal($2)
- || ' AND s.connamespace = n.oid AND s.conrelid = c.oid'
- || ' AND s.conname = ' || quote_literal(cn);
- EXECUTE sql INTO rtn;
- RETURN rtn;
- END;
- $$ LANGUAGE 'plpgsql' STABLE STRICT
+ RETURNS boolean
+ AS $$
+ DECLARE
+ cn text;
+ sql text;
+ rtn boolean;
+ BEGIN
+ cn := 'enforce_regular_blocking_' || $3;
+
+ sql := 'SELECT TRUE FROM pg_class c, pg_namespace n, pg_constraint s'
+ || ' WHERE n.nspname = ' || quote_literal($1)
+ || ' AND c.relname = ' || quote_literal($2)
+ || ' AND s.connamespace = n.oid AND s.conrelid = c.oid'
+ || ' AND s.conname = ' || quote_literal(cn);
+ EXECUTE sql INTO rtn;
+ RETURN rtn;
+ END;
+ $$ LANGUAGE 'plpgsql' STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_regular_blocking(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- BEGIN
-
- RAISE INFO 'The regular_blocking constraint is just a flag indicating that the column "%" is regularly blocked. It is up to the end-user to ensure that the column is truely regularly blocked.', quote_ident($3);
-
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ BEGIN
+
+ RAISE INFO 'The regular_blocking constraint is just a flag indicating that the column "%" is regularly blocked. It is up to the end-user to ensure that the column is truely regularly blocked.', quote_ident($3);
+
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
- cn := 'enforce_regular_blocking_' || $3;
+ cn := 'enforce_regular_blocking_' || $3;
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (TRUE)';
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (TRUE)';
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_regular_blocking(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_regular_blocking_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_regular_blocking_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_num_bands(rastschema name, rasttable name, rastcolumn name)
- RETURNS integer AS $$
- SELECT
- replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%st_numbands(%';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS integer AS $$
+ SELECT
+ replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', '')::integer
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%st_numbands(%';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_raster_constraint_num_bands(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr int;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_num_bands_' || $3;
-
- sql := 'SELECT st_numbands(' || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the number of bands of a sample raster';
- RETURN FALSE;
- END;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (st_numbands(' || quote_ident($3)
- || ') = ' || attr
- || ')';
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr int;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_num_bands_' || $3;
+
+ sql := 'SELECT st_numbands(' || quote_ident($3)
+ || ') FROM ' || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the number of bands of a sample raster';
+ RETURN FALSE;
+ END;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (st_numbands(' || quote_ident($3)
+ || ') = ' || attr
+ || ')';
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_num_bands(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_num_bands_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_num_bands_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_pixel_types(rastschema name, rasttable name, rastcolumn name)
- RETURNS text[] AS $$
- SELECT
- trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::text[]
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%_raster_constraint_pixel_types(%';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS text[] AS $$
+ SELECT
+ trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::text[]
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%_raster_constraint_pixel_types(%';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_pixel_types(rast raster)
- RETURNS text[] AS
- $$ SELECT array_agg(pixeltype)::text[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS text[] AS
+ $$ SELECT array_agg(pixeltype)::text[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION _add_raster_constraint_pixel_types(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr text[];
- max int;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_pixel_types_' || $3;
-
- sql := 'SELECT _raster_constraint_pixel_types(' || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the pixel types of a sample raster';
- RETURN FALSE;
- END;
- max := array_length(attr, 1);
- IF max < 1 OR max IS NULL THEN
- RAISE NOTICE 'Unable to get the pixel types of a sample raster';
- RETURN FALSE;
- END IF;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (_raster_constraint_pixel_types(' || quote_ident($3)
- || ') = ''{';
- FOR x in 1..max LOOP
- sql := sql || '"' || attr[x] || '"';
- IF x < max THEN
- sql := sql || ',';
- END IF;
- END LOOP;
- sql := sql || '}''::text[])';
-
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr text[];
+ max int;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_pixel_types_' || $3;
+
+ sql := 'SELECT _raster_constraint_pixel_types(' || quote_ident($3)
+ || ') FROM ' || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the pixel types of a sample raster';
+ RETURN FALSE;
+ END;
+ max := array_length(attr, 1);
+ IF max < 1 OR max IS NULL THEN
+ RAISE NOTICE 'Unable to get the pixel types of a sample raster';
+ RETURN FALSE;
+ END IF;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (_raster_constraint_pixel_types(' || quote_ident($3)
+ || ') = ''{';
+ FOR x in 1..max LOOP
+ sql := sql || '"' || attr[x] || '"';
+ IF x < max THEN
+ sql := sql || ',';
+ END IF;
+ END LOOP;
+ sql := sql || '}''::text[])';
+
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_pixel_types(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_pixel_types_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_pixel_types_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_nodata_values(rastschema name, rasttable name, rastcolumn name)
- RETURNS double precision[] AS $$
- SELECT
- trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::double precision[]
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%_raster_constraint_nodata_values(%';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS double precision[] AS $$
+ SELECT
+ trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::double precision[]
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%_raster_constraint_nodata_values(%';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_nodata_values(rast raster)
- RETURNS double precision[] AS
- $$ SELECT array_agg(nodatavalue)::double precision[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS double precision[] AS
+ $$ SELECT array_agg(nodatavalue)::double precision[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION _add_raster_constraint_nodata_values(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr double precision[];
- max int;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_nodata_values_' || $3;
-
- sql := 'SELECT _raster_constraint_nodata_values(' || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the nodata values of a sample raster';
- RETURN FALSE;
- END;
- max := array_length(attr, 1);
- IF max < 1 OR max IS NULL THEN
- RAISE NOTICE 'Unable to get the nodata values of a sample raster';
- RETURN FALSE;
- END IF;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (_raster_constraint_nodata_values(' || quote_ident($3)
- || ')::numeric(16,10)[] = ''{';
- FOR x in 1..max LOOP
- IF attr[x] IS NULL THEN
- sql := sql || 'NULL';
- ELSE
- sql := sql || attr[x];
- END IF;
- IF x < max THEN
- sql := sql || ',';
- END IF;
- END LOOP;
- sql := sql || '}''::numeric(16,10)[])';
-
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr double precision[];
+ max int;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_nodata_values_' || $3;
+
+ sql := 'SELECT _raster_constraint_nodata_values(' || quote_ident($3)
+ || ') FROM ' || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the nodata values of a sample raster';
+ RETURN FALSE;
+ END;
+ max := array_length(attr, 1);
+ IF max < 1 OR max IS NULL THEN
+ RAISE NOTICE 'Unable to get the nodata values of a sample raster';
+ RETURN FALSE;
+ END IF;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (_raster_constraint_nodata_values(' || quote_ident($3)
+ || ')::numeric(16,10)[] = ''{';
+ FOR x in 1..max LOOP
+ IF attr[x] IS NULL THEN
+ sql := sql || 'NULL';
+ ELSE
+ sql := sql || attr[x];
+ END IF;
+ IF x < max THEN
+ sql := sql || ',';
+ END IF;
+ END LOOP;
+ sql := sql || '}''::numeric(16,10)[])';
+
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_nodata_values(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_nodata_values_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_nodata_values_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_info_out_db(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean[] AS $$
- SELECT
- trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::boolean[]
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%_raster_constraint_out_db(%';
- $$ LANGUAGE sql STABLE STRICT
+ RETURNS boolean[] AS $$
+ SELECT
+ trim(both '''' from split_part(replace(replace(split_part(s.consrc, ' = ', 2), ')', ''), '(', ''), '::', 1))::boolean[]
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%_raster_constraint_out_db(%';
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _raster_constraint_out_db(rast raster)
- RETURNS boolean[] AS
- $$ SELECT array_agg(isoutdb)::boolean[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
- LANGUAGE 'sql' STABLE STRICT;
+ RETURNS boolean[] AS
+ $$ SELECT array_agg(isoutdb)::boolean[] FROM st_bandmetadata($1, ARRAY[]::int[]); $$
+ LANGUAGE 'sql' STABLE STRICT;
CREATE OR REPLACE FUNCTION _add_raster_constraint_out_db(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- attr boolean[];
- max int;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_out_db_' || $3;
-
- sql := 'SELECT _raster_constraint_out_db(' || quote_ident($3)
- || ') FROM ' || fqtn
- || ' LIMIT 1';
- BEGIN
- EXECUTE sql INTO attr;
- EXCEPTION WHEN OTHERS THEN
- RAISE NOTICE 'Unable to get the out-of-database bands of a sample raster';
- RETURN FALSE;
- END;
- max := array_length(attr, 1);
- IF max < 1 OR max IS NULL THEN
- RAISE NOTICE 'Unable to get the out-of-database bands of a sample raster';
- RETURN FALSE;
- END IF;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (_raster_constraint_out_db(' || quote_ident($3)
- || ') = ''{';
- FOR x in 1..max LOOP
- IF attr[x] IS FALSE THEN
- sql := sql || 'FALSE';
- ELSE
- sql := sql || 'TRUE';
- END IF;
- IF x < max THEN
- sql := sql || ',';
- END IF;
- END LOOP;
- sql := sql || '}''::boolean[])';
-
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ attr boolean[];
+ max int;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_out_db_' || $3;
+
+ sql := 'SELECT _raster_constraint_out_db(' || quote_ident($3)
+ || ') FROM ' || fqtn
+ || ' LIMIT 1';
+ BEGIN
+ EXECUTE sql INTO attr;
+ EXCEPTION WHEN OTHERS THEN
+ RAISE NOTICE 'Unable to get the out-of-database bands of a sample raster';
+ RETURN FALSE;
+ END;
+ max := array_length(attr, 1);
+ IF max < 1 OR max IS NULL THEN
+ RAISE NOTICE 'Unable to get the out-of-database bands of a sample raster';
+ RETURN FALSE;
+ END IF;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (_raster_constraint_out_db(' || quote_ident($3)
+ || ') = ''{';
+ FOR x in 1..max LOOP
+ IF attr[x] IS FALSE THEN
+ sql := sql || 'FALSE';
+ ELSE
+ sql := sql || 'TRUE';
+ END IF;
+ IF x < max THEN
+ sql := sql || ',';
+ END IF;
+ END LOOP;
+ sql := sql || '}''::boolean[])';
+
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_raster_constraint_out_db(rastschema name, rasttable name, rastcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_out_db_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_out_db_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
------------------------------------------------------------------------------
-- AddRasterConstraints
------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION AddRasterConstraints (
- rastschema name,
- rasttable name,
- rastcolumn name,
- VARIADIC constraints text[]
+ rastschema name,
+ rasttable name,
+ rastcolumn name,
+ VARIADIC constraints text[]
)
- RETURNS boolean
- AS $$
- DECLARE
- max int;
- cnt int;
- sql text;
- schema name;
- x int;
- kw text;
- rtn boolean;
- BEGIN
- cnt := 0;
- max := array_length(constraints, 1);
- IF max < 1 THEN
- RAISE NOTICE 'No constraints indicated to be added. Doing nothing';
- RETURN TRUE;
- END IF;
-
- -- validate schema
- schema := NULL;
- IF length($1) > 0 THEN
- sql := 'SELECT nspname FROM pg_namespace '
- || 'WHERE nspname = ' || quote_literal($1)
- || 'LIMIT 1';
- EXECUTE sql INTO schema;
-
- IF schema IS NULL THEN
- RAISE EXCEPTION 'The value provided for schema is invalid';
- RETURN FALSE;
- END IF;
- END IF;
-
- IF schema IS NULL THEN
- sql := 'SELECT n.nspname AS schemaname '
- || 'FROM pg_catalog.pg_class c '
- || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
- || 'WHERE c.relkind = ' || quote_literal('r')
- || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
- || ', ' || quote_literal('pg_toast')
- || ') AND pg_catalog.pg_table_is_visible(c.oid)'
- || ' AND c.relname = ' || quote_literal($2);
- EXECUTE sql INTO schema;
-
- IF schema IS NULL THEN
- RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal($2);
- RETURN FALSE;
- END IF;
- END IF;
-
- <<kwloop>>
- FOR x in 1..max LOOP
- kw := trim(both from lower(constraints[x]));
-
- BEGIN
- CASE
- WHEN kw = 'srid' THEN
- RAISE NOTICE 'Adding SRID constraint';
- rtn := _add_raster_constraint_srid(schema, $2, $3);
- WHEN kw IN ('scale_x', 'scalex') THEN
- RAISE NOTICE 'Adding scale-X constraint';
- rtn := _add_raster_constraint_scale(schema, $2, $3, 'x');
- WHEN kw IN ('scale_y', 'scaley') THEN
- RAISE NOTICE 'Adding scale-Y constraint';
- rtn := _add_raster_constraint_scale(schema, $2, $3, 'y');
- WHEN kw = 'scale' THEN
- RAISE NOTICE 'Adding scale-X constraint';
- rtn := _add_raster_constraint_scale(schema, $2, $3, 'x');
- RAISE NOTICE 'Adding scale-Y constraint';
- rtn := _add_raster_constraint_scale(schema, $2, $3, 'y');
- WHEN kw IN ('blocksize_x', 'blocksizex', 'width') THEN
- RAISE NOTICE 'Adding blocksize-X constraint';
- rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'width');
- WHEN kw IN ('blocksize_y', 'blocksizey', 'height') THEN
- RAISE NOTICE 'Adding blocksize-Y constraint';
- rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'height');
- WHEN kw = 'blocksize' THEN
- RAISE NOTICE 'Adding blocksize-X constraint';
- rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'width');
- RAISE NOTICE 'Adding blocksize-Y constraint';
- rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'height');
- WHEN kw IN ('same_alignment', 'samealignment', 'alignment') THEN
- RAISE NOTICE 'Adding alignment constraint';
- rtn := _add_raster_constraint_alignment(schema, $2, $3);
- WHEN kw IN ('regular_blocking', 'regularblocking') THEN
- RAISE NOTICE 'Adding regular blocking constraint';
- rtn := _add_raster_constraint_regular_blocking(schema, $2, $3);
- WHEN kw IN ('num_bands', 'numbands') THEN
- RAISE NOTICE 'Adding number of bands constraint';
- rtn := _add_raster_constraint_num_bands(schema, $2, $3);
- WHEN kw IN ('pixel_types', 'pixeltypes') THEN
- RAISE NOTICE 'Adding pixel type constraint';
- rtn := _add_raster_constraint_pixel_types(schema, $2, $3);
- WHEN kw IN ('nodata_values', 'nodatavalues', 'nodata') THEN
- RAISE NOTICE 'Adding nodata value constraint';
- rtn := _add_raster_constraint_nodata_values(schema, $2, $3);
- WHEN kw IN ('out_db', 'outdb') THEN
- RAISE NOTICE 'Adding out-of-database constraint';
- rtn := _add_raster_constraint_out_db(schema, $2, $3);
- WHEN kw = 'extent' THEN
- RAISE NOTICE 'Adding maximum extent constraint';
- rtn := _add_raster_constraint_extent(schema, $2, $3);
- ELSE
- RAISE NOTICE 'Unknown constraint: %. Skipping', quote_literal(constraints[x]);
- CONTINUE kwloop;
- END CASE;
- END;
-
- IF rtn IS FALSE THEN
- cnt := cnt + 1;
- RAISE WARNING 'Unable to add constraint: %. Skipping', quote_literal(constraints[x]);
- END IF;
-
- END LOOP kwloop;
-
- IF cnt = max THEN
- RAISE EXCEPTION 'None of the constraints specified could be added. Is the schema name, table name or column name incorrect?';
- RETURN FALSE;
- END IF;
-
- RETURN TRUE;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ max int;
+ cnt int;
+ sql text;
+ schema name;
+ x int;
+ kw text;
+ rtn boolean;
+ BEGIN
+ cnt := 0;
+ max := array_length(constraints, 1);
+ IF max < 1 THEN
+ RAISE NOTICE 'No constraints indicated to be added. Doing nothing';
+ RETURN TRUE;
+ END IF;
+
+ -- validate schema
+ schema := NULL;
+ IF length($1) > 0 THEN
+ sql := 'SELECT nspname FROM pg_namespace '
+ || 'WHERE nspname = ' || quote_literal($1)
+ || 'LIMIT 1';
+ EXECUTE sql INTO schema;
+
+ IF schema IS NULL THEN
+ RAISE EXCEPTION 'The value provided for schema is invalid';
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ IF schema IS NULL THEN
+ sql := 'SELECT n.nspname AS schemaname '
+ || 'FROM pg_catalog.pg_class c '
+ || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
+ || 'WHERE c.relkind = ' || quote_literal('r')
+ || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
+ || ', ' || quote_literal('pg_toast')
+ || ') AND pg_catalog.pg_table_is_visible(c.oid)'
+ || ' AND c.relname = ' || quote_literal($2);
+ EXECUTE sql INTO schema;
+
+ IF schema IS NULL THEN
+ RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal($2);
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ <<kwloop>>
+ FOR x in 1..max LOOP
+ kw := trim(both from lower(constraints[x]));
+
+ BEGIN
+ CASE
+ WHEN kw = 'srid' THEN
+ RAISE NOTICE 'Adding SRID constraint';
+ rtn := _add_raster_constraint_srid(schema, $2, $3);
+ WHEN kw IN ('scale_x', 'scalex') THEN
+ RAISE NOTICE 'Adding scale-X constraint';
+ rtn := _add_raster_constraint_scale(schema, $2, $3, 'x');
+ WHEN kw IN ('scale_y', 'scaley') THEN
+ RAISE NOTICE 'Adding scale-Y constraint';
+ rtn := _add_raster_constraint_scale(schema, $2, $3, 'y');
+ WHEN kw = 'scale' THEN
+ RAISE NOTICE 'Adding scale-X constraint';
+ rtn := _add_raster_constraint_scale(schema, $2, $3, 'x');
+ RAISE NOTICE 'Adding scale-Y constraint';
+ rtn := _add_raster_constraint_scale(schema, $2, $3, 'y');
+ WHEN kw IN ('blocksize_x', 'blocksizex', 'width') THEN
+ RAISE NOTICE 'Adding blocksize-X constraint';
+ rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'width');
+ WHEN kw IN ('blocksize_y', 'blocksizey', 'height') THEN
+ RAISE NOTICE 'Adding blocksize-Y constraint';
+ rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'height');
+ WHEN kw = 'blocksize' THEN
+ RAISE NOTICE 'Adding blocksize-X constraint';
+ rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'width');
+ RAISE NOTICE 'Adding blocksize-Y constraint';
+ rtn := _add_raster_constraint_blocksize(schema, $2, $3, 'height');
+ WHEN kw IN ('same_alignment', 'samealignment', 'alignment') THEN
+ RAISE NOTICE 'Adding alignment constraint';
+ rtn := _add_raster_constraint_alignment(schema, $2, $3);
+ WHEN kw IN ('regular_blocking', 'regularblocking') THEN
+ RAISE NOTICE 'Adding regular blocking constraint';
+ rtn := _add_raster_constraint_regular_blocking(schema, $2, $3);
+ WHEN kw IN ('num_bands', 'numbands') THEN
+ RAISE NOTICE 'Adding number of bands constraint';
+ rtn := _add_raster_constraint_num_bands(schema, $2, $3);
+ WHEN kw IN ('pixel_types', 'pixeltypes') THEN
+ RAISE NOTICE 'Adding pixel type constraint';
+ rtn := _add_raster_constraint_pixel_types(schema, $2, $3);
+ WHEN kw IN ('nodata_values', 'nodatavalues', 'nodata') THEN
+ RAISE NOTICE 'Adding nodata value constraint';
+ rtn := _add_raster_constraint_nodata_values(schema, $2, $3);
+ WHEN kw IN ('out_db', 'outdb') THEN
+ RAISE NOTICE 'Adding out-of-database constraint';
+ rtn := _add_raster_constraint_out_db(schema, $2, $3);
+ WHEN kw = 'extent' THEN
+ RAISE NOTICE 'Adding maximum extent constraint';
+ rtn := _add_raster_constraint_extent(schema, $2, $3);
+ ELSE
+ RAISE NOTICE 'Unknown constraint: %. Skipping', quote_literal(constraints[x]);
+ CONTINUE kwloop;
+ END CASE;
+ END;
+
+ IF rtn IS FALSE THEN
+ cnt := cnt + 1;
+ RAISE WARNING 'Unable to add constraint: %. Skipping', quote_literal(constraints[x]);
+ END IF;
+
+ END LOOP kwloop;
+
+ IF cnt = max THEN
+ RAISE EXCEPTION 'None of the constraints specified could be added. Is the schema name, table name or column name incorrect?';
+ RETURN FALSE;
+ END IF;
+
+ RETURN TRUE;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION AddRasterConstraints (
- rasttable name,
- rastcolumn name,
- VARIADIC constraints text[]
+ rasttable name,
+ rastcolumn name,
+ VARIADIC constraints text[]
)
- RETURNS boolean AS
- $$ SELECT AddRasterConstraints('', $1, $2, VARIADIC $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT AddRasterConstraints('', $1, $2, VARIADIC $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION AddRasterConstraints (
- rastschema name,
- rasttable name,
- rastcolumn name,
- srid boolean DEFAULT TRUE,
- scale_x boolean DEFAULT TRUE,
- scale_y boolean DEFAULT TRUE,
- blocksize_x boolean DEFAULT TRUE,
- blocksize_y boolean DEFAULT TRUE,
- same_alignment boolean DEFAULT TRUE,
- regular_blocking boolean DEFAULT FALSE, -- false as regular_blocking is not a usable constraint
- num_bands boolean DEFAULT TRUE,
- pixel_types boolean DEFAULT TRUE,
- nodata_values boolean DEFAULT TRUE,
- out_db boolean DEFAULT TRUE,
- extent boolean DEFAULT TRUE
+ rastschema name,
+ rasttable name,
+ rastcolumn name,
+ srid boolean DEFAULT TRUE,
+ scale_x boolean DEFAULT TRUE,
+ scale_y boolean DEFAULT TRUE,
+ blocksize_x boolean DEFAULT TRUE,
+ blocksize_y boolean DEFAULT TRUE,
+ same_alignment boolean DEFAULT TRUE,
+ regular_blocking boolean DEFAULT FALSE, -- false as regular_blocking is not a usable constraint
+ num_bands boolean DEFAULT TRUE,
+ pixel_types boolean DEFAULT TRUE,
+ nodata_values boolean DEFAULT TRUE,
+ out_db boolean DEFAULT TRUE,
+ extent boolean DEFAULT TRUE
)
- RETURNS boolean
- AS $$
- DECLARE
- constraints text[];
- BEGIN
- IF srid IS TRUE THEN
- constraints := constraints || 'srid'::text;
- END IF;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ constraints text[];
+ BEGIN
+ IF srid IS TRUE THEN
+ constraints := constraints || 'srid'::text;
+ END IF;
- IF scale_x IS TRUE THEN
- constraints := constraints || 'scale_x'::text;
- END IF;
+ IF scale_x IS TRUE THEN
+ constraints := constraints || 'scale_x'::text;
+ END IF;
- IF scale_y IS TRUE THEN
- constraints := constraints || 'scale_y'::text;
- END IF;
+ IF scale_y IS TRUE THEN
+ constraints := constraints || 'scale_y'::text;
+ END IF;
- IF blocksize_x IS TRUE THEN
- constraints := constraints || 'blocksize_x'::text;
- END IF;
+ IF blocksize_x IS TRUE THEN
+ constraints := constraints || 'blocksize_x'::text;
+ END IF;
- IF blocksize_y IS TRUE THEN
- constraints := constraints || 'blocksize_y'::text;
- END IF;
+ IF blocksize_y IS TRUE THEN
+ constraints := constraints || 'blocksize_y'::text;
+ END IF;
- IF same_alignment IS TRUE THEN
- constraints := constraints || 'same_alignment'::text;
- END IF;
+ IF same_alignment IS TRUE THEN
+ constraints := constraints || 'same_alignment'::text;
+ END IF;
- IF regular_blocking IS TRUE THEN
- constraints := constraints || 'regular_blocking'::text;
- END IF;
+ IF regular_blocking IS TRUE THEN
+ constraints := constraints || 'regular_blocking'::text;
+ END IF;
- IF num_bands IS TRUE THEN
- constraints := constraints || 'num_bands'::text;
- END IF;
+ IF num_bands IS TRUE THEN
+ constraints := constraints || 'num_bands'::text;
+ END IF;
- IF pixel_types IS TRUE THEN
- constraints := constraints || 'pixel_types'::text;
- END IF;
+ IF pixel_types IS TRUE THEN
+ constraints := constraints || 'pixel_types'::text;
+ END IF;
- IF nodata_values IS TRUE THEN
- constraints := constraints || 'nodata_values'::text;
- END IF;
+ IF nodata_values IS TRUE THEN
+ constraints := constraints || 'nodata_values'::text;
+ END IF;
- IF out_db IS TRUE THEN
- constraints := constraints || 'out_db'::text;
- END IF;
+ IF out_db IS TRUE THEN
+ constraints := constraints || 'out_db'::text;
+ END IF;
- IF extent IS TRUE THEN
- constraints := constraints || 'extent'::text;
- END IF;
+ IF extent IS TRUE THEN
+ constraints := constraints || 'extent'::text;
+ END IF;
- RETURN AddRasterConstraints($1, $2, $3, VARIADIC constraints);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURN AddRasterConstraints($1, $2, $3, VARIADIC constraints);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION AddRasterConstraints (
- rasttable name,
- rastcolumn name,
- srid boolean DEFAULT TRUE,
- scale_x boolean DEFAULT TRUE,
- scale_y boolean DEFAULT TRUE,
- blocksize_x boolean DEFAULT TRUE,
- blocksize_y boolean DEFAULT TRUE,
- same_alignment boolean DEFAULT TRUE,
- regular_blocking boolean DEFAULT FALSE, -- false as regular_blocking is not a usable constraint
- num_bands boolean DEFAULT TRUE,
- pixel_types boolean DEFAULT TRUE,
- nodata_values boolean DEFAULT TRUE,
- out_db boolean DEFAULT TRUE,
- extent boolean DEFAULT TRUE
+ rasttable name,
+ rastcolumn name,
+ srid boolean DEFAULT TRUE,
+ scale_x boolean DEFAULT TRUE,
+ scale_y boolean DEFAULT TRUE,
+ blocksize_x boolean DEFAULT TRUE,
+ blocksize_y boolean DEFAULT TRUE,
+ same_alignment boolean DEFAULT TRUE,
+ regular_blocking boolean DEFAULT FALSE, -- false as regular_blocking is not a usable constraint
+ num_bands boolean DEFAULT TRUE,
+ pixel_types boolean DEFAULT TRUE,
+ nodata_values boolean DEFAULT TRUE,
+ out_db boolean DEFAULT TRUE,
+ extent boolean DEFAULT TRUE
)
- RETURNS boolean AS
- $$ SELECT AddRasterConstraints('', $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT AddRasterConstraints('', $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
------------------------------------------------------------------------------
-- DropRasterConstraints
------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION DropRasterConstraints (
- rastschema name,
- rasttable name,
- rastcolumn name,
- VARIADIC constraints text[]
+ rastschema name,
+ rasttable name,
+ rastcolumn name,
+ VARIADIC constraints text[]
)
- RETURNS boolean
- AS $$
- DECLARE
- max int;
- x int;
- schema name;
- sql text;
- kw text;
- rtn boolean;
- cnt int;
- BEGIN
- cnt := 0;
- max := array_length(constraints, 1);
- IF max < 1 THEN
- RAISE NOTICE 'No constraints indicated to be dropped. Doing nothing';
- RETURN TRUE;
- END IF;
-
- -- validate schema
- schema := NULL;
- IF length($1) > 0 THEN
- sql := 'SELECT nspname FROM pg_namespace '
- || 'WHERE nspname = ' || quote_literal($1)
- || 'LIMIT 1';
- EXECUTE sql INTO schema;
-
- IF schema IS NULL THEN
- RAISE EXCEPTION 'The value provided for schema is invalid';
- RETURN FALSE;
- END IF;
- END IF;
-
- IF schema IS NULL THEN
- sql := 'SELECT n.nspname AS schemaname '
- || 'FROM pg_catalog.pg_class c '
- || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
- || 'WHERE c.relkind = ' || quote_literal('r')
- || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
- || ', ' || quote_literal('pg_toast')
- || ') AND pg_catalog.pg_table_is_visible(c.oid)'
- || ' AND c.relname = ' || quote_literal($2);
- EXECUTE sql INTO schema;
-
- IF schema IS NULL THEN
- RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal($2);
- RETURN FALSE;
- END IF;
- END IF;
-
- <<kwloop>>
- FOR x in 1..max LOOP
- kw := trim(both from lower(constraints[x]));
-
- BEGIN
- CASE
- WHEN kw = 'srid' THEN
- RAISE NOTICE 'Dropping SRID constraint';
- rtn := _drop_raster_constraint_srid(schema, $2, $3);
- WHEN kw IN ('scale_x', 'scalex') THEN
- RAISE NOTICE 'Dropping scale-X constraint';
- rtn := _drop_raster_constraint_scale(schema, $2, $3, 'x');
- WHEN kw IN ('scale_y', 'scaley') THEN
- RAISE NOTICE 'Dropping scale-Y constraint';
- rtn := _drop_raster_constraint_scale(schema, $2, $3, 'y');
- WHEN kw = 'scale' THEN
- RAISE NOTICE 'Dropping scale-X constraint';
- rtn := _drop_raster_constraint_scale(schema, $2, $3, 'x');
- RAISE NOTICE 'Dropping scale-Y constraint';
- rtn := _drop_raster_constraint_scale(schema, $2, $3, 'y');
- WHEN kw IN ('blocksize_x', 'blocksizex', 'width') THEN
- RAISE NOTICE 'Dropping blocksize-X constraint';
- rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'width');
- WHEN kw IN ('blocksize_y', 'blocksizey', 'height') THEN
- RAISE NOTICE 'Dropping blocksize-Y constraint';
- rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'height');
- WHEN kw = 'blocksize' THEN
- RAISE NOTICE 'Dropping blocksize-X constraint';
- rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'width');
- RAISE NOTICE 'Dropping blocksize-Y constraint';
- rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'height');
- WHEN kw IN ('same_alignment', 'samealignment', 'alignment') THEN
- RAISE NOTICE 'Dropping alignment constraint';
- rtn := _drop_raster_constraint_alignment(schema, $2, $3);
- WHEN kw IN ('regular_blocking', 'regularblocking') THEN
- RAISE NOTICE 'Dropping regular blocking constraint';
- rtn := _drop_raster_constraint_regular_blocking(schema, $2, $3);
- WHEN kw IN ('num_bands', 'numbands') THEN
- RAISE NOTICE 'Dropping number of bands constraint';
- rtn := _drop_raster_constraint_num_bands(schema, $2, $3);
- WHEN kw IN ('pixel_types', 'pixeltypes') THEN
- RAISE NOTICE 'Dropping pixel type constraint';
- rtn := _drop_raster_constraint_pixel_types(schema, $2, $3);
- WHEN kw IN ('nodata_values', 'nodatavalues', 'nodata') THEN
- RAISE NOTICE 'Dropping nodata value constraint';
- rtn := _drop_raster_constraint_nodata_values(schema, $2, $3);
- WHEN kw IN ('out_db', 'outdb') THEN
- RAISE NOTICE 'Dropping out-of-database constraint';
- rtn := _drop_raster_constraint_out_db(schema, $2, $3);
- WHEN kw = 'extent' THEN
- RAISE NOTICE 'Dropping maximum extent constraint';
- rtn := _drop_raster_constraint_extent(schema, $2, $3);
- ELSE
- RAISE NOTICE 'Unknown constraint: %. Skipping', quote_literal(constraints[x]);
- CONTINUE kwloop;
- END CASE;
- END;
-
- IF rtn IS FALSE THEN
- cnt := cnt + 1;
- RAISE WARNING 'Unable to drop constraint: %. Skipping', quote_literal(constraints[x]);
- END IF;
-
- END LOOP kwloop;
-
- IF cnt = max THEN
- RAISE EXCEPTION 'None of the constraints specified could be dropped. Is the schema name, table name or column name incorrect?';
- RETURN FALSE;
- END IF;
-
- RETURN TRUE;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ max int;
+ x int;
+ schema name;
+ sql text;
+ kw text;
+ rtn boolean;
+ cnt int;
+ BEGIN
+ cnt := 0;
+ max := array_length(constraints, 1);
+ IF max < 1 THEN
+ RAISE NOTICE 'No constraints indicated to be dropped. Doing nothing';
+ RETURN TRUE;
+ END IF;
+
+ -- validate schema
+ schema := NULL;
+ IF length($1) > 0 THEN
+ sql := 'SELECT nspname FROM pg_namespace '
+ || 'WHERE nspname = ' || quote_literal($1)
+ || 'LIMIT 1';
+ EXECUTE sql INTO schema;
+
+ IF schema IS NULL THEN
+ RAISE EXCEPTION 'The value provided for schema is invalid';
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ IF schema IS NULL THEN
+ sql := 'SELECT n.nspname AS schemaname '
+ || 'FROM pg_catalog.pg_class c '
+ || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
+ || 'WHERE c.relkind = ' || quote_literal('r')
+ || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
+ || ', ' || quote_literal('pg_toast')
+ || ') AND pg_catalog.pg_table_is_visible(c.oid)'
+ || ' AND c.relname = ' || quote_literal($2);
+ EXECUTE sql INTO schema;
+
+ IF schema IS NULL THEN
+ RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal($2);
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ <<kwloop>>
+ FOR x in 1..max LOOP
+ kw := trim(both from lower(constraints[x]));
+
+ BEGIN
+ CASE
+ WHEN kw = 'srid' THEN
+ RAISE NOTICE 'Dropping SRID constraint';
+ rtn := _drop_raster_constraint_srid(schema, $2, $3);
+ WHEN kw IN ('scale_x', 'scalex') THEN
+ RAISE NOTICE 'Dropping scale-X constraint';
+ rtn := _drop_raster_constraint_scale(schema, $2, $3, 'x');
+ WHEN kw IN ('scale_y', 'scaley') THEN
+ RAISE NOTICE 'Dropping scale-Y constraint';
+ rtn := _drop_raster_constraint_scale(schema, $2, $3, 'y');
+ WHEN kw = 'scale' THEN
+ RAISE NOTICE 'Dropping scale-X constraint';
+ rtn := _drop_raster_constraint_scale(schema, $2, $3, 'x');
+ RAISE NOTICE 'Dropping scale-Y constraint';
+ rtn := _drop_raster_constraint_scale(schema, $2, $3, 'y');
+ WHEN kw IN ('blocksize_x', 'blocksizex', 'width') THEN
+ RAISE NOTICE 'Dropping blocksize-X constraint';
+ rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'width');
+ WHEN kw IN ('blocksize_y', 'blocksizey', 'height') THEN
+ RAISE NOTICE 'Dropping blocksize-Y constraint';
+ rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'height');
+ WHEN kw = 'blocksize' THEN
+ RAISE NOTICE 'Dropping blocksize-X constraint';
+ rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'width');
+ RAISE NOTICE 'Dropping blocksize-Y constraint';
+ rtn := _drop_raster_constraint_blocksize(schema, $2, $3, 'height');
+ WHEN kw IN ('same_alignment', 'samealignment', 'alignment') THEN
+ RAISE NOTICE 'Dropping alignment constraint';
+ rtn := _drop_raster_constraint_alignment(schema, $2, $3);
+ WHEN kw IN ('regular_blocking', 'regularblocking') THEN
+ RAISE NOTICE 'Dropping regular blocking constraint';
+ rtn := _drop_raster_constraint_regular_blocking(schema, $2, $3);
+ WHEN kw IN ('num_bands', 'numbands') THEN
+ RAISE NOTICE 'Dropping number of bands constraint';
+ rtn := _drop_raster_constraint_num_bands(schema, $2, $3);
+ WHEN kw IN ('pixel_types', 'pixeltypes') THEN
+ RAISE NOTICE 'Dropping pixel type constraint';
+ rtn := _drop_raster_constraint_pixel_types(schema, $2, $3);
+ WHEN kw IN ('nodata_values', 'nodatavalues', 'nodata') THEN
+ RAISE NOTICE 'Dropping nodata value constraint';
+ rtn := _drop_raster_constraint_nodata_values(schema, $2, $3);
+ WHEN kw IN ('out_db', 'outdb') THEN
+ RAISE NOTICE 'Dropping out-of-database constraint';
+ rtn := _drop_raster_constraint_out_db(schema, $2, $3);
+ WHEN kw = 'extent' THEN
+ RAISE NOTICE 'Dropping maximum extent constraint';
+ rtn := _drop_raster_constraint_extent(schema, $2, $3);
+ ELSE
+ RAISE NOTICE 'Unknown constraint: %. Skipping', quote_literal(constraints[x]);
+ CONTINUE kwloop;
+ END CASE;
+ END;
+
+ IF rtn IS FALSE THEN
+ cnt := cnt + 1;
+ RAISE WARNING 'Unable to drop constraint: %. Skipping', quote_literal(constraints[x]);
+ END IF;
+
+ END LOOP kwloop;
+
+ IF cnt = max THEN
+ RAISE EXCEPTION 'None of the constraints specified could be dropped. Is the schema name, table name or column name incorrect?';
+ RETURN FALSE;
+ END IF;
+
+ RETURN TRUE;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION DropRasterConstraints (
- rasttable name,
- rastcolumn name,
- VARIADIC constraints text[]
+ rasttable name,
+ rastcolumn name,
+ VARIADIC constraints text[]
)
- RETURNS boolean AS
- $$ SELECT DropRasterConstraints('', $1, $2, VARIADIC $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT DropRasterConstraints('', $1, $2, VARIADIC $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION DropRasterConstraints (
- rastschema name,
- rasttable name,
- rastcolumn name,
- srid boolean DEFAULT TRUE,
- scale_x boolean DEFAULT TRUE,
- scale_y boolean DEFAULT TRUE,
- blocksize_x boolean DEFAULT TRUE,
- blocksize_y boolean DEFAULT TRUE,
- same_alignment boolean DEFAULT TRUE,
- regular_blocking boolean DEFAULT TRUE,
- num_bands boolean DEFAULT TRUE,
- pixel_types boolean DEFAULT TRUE,
- nodata_values boolean DEFAULT TRUE,
- out_db boolean DEFAULT TRUE,
- extent boolean DEFAULT TRUE
+ rastschema name,
+ rasttable name,
+ rastcolumn name,
+ srid boolean DEFAULT TRUE,
+ scale_x boolean DEFAULT TRUE,
+ scale_y boolean DEFAULT TRUE,
+ blocksize_x boolean DEFAULT TRUE,
+ blocksize_y boolean DEFAULT TRUE,
+ same_alignment boolean DEFAULT TRUE,
+ regular_blocking boolean DEFAULT TRUE,
+ num_bands boolean DEFAULT TRUE,
+ pixel_types boolean DEFAULT TRUE,
+ nodata_values boolean DEFAULT TRUE,
+ out_db boolean DEFAULT TRUE,
+ extent boolean DEFAULT TRUE
)
- RETURNS boolean
- AS $$
- DECLARE
- constraints text[];
- BEGIN
- IF srid IS TRUE THEN
- constraints := constraints || 'srid'::text;
- END IF;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ constraints text[];
+ BEGIN
+ IF srid IS TRUE THEN
+ constraints := constraints || 'srid'::text;
+ END IF;
- IF scale_x IS TRUE THEN
- constraints := constraints || 'scale_x'::text;
- END IF;
+ IF scale_x IS TRUE THEN
+ constraints := constraints || 'scale_x'::text;
+ END IF;
- IF scale_y IS TRUE THEN
- constraints := constraints || 'scale_y'::text;
- END IF;
+ IF scale_y IS TRUE THEN
+ constraints := constraints || 'scale_y'::text;
+ END IF;
- IF blocksize_x IS TRUE THEN
- constraints := constraints || 'blocksize_x'::text;
- END IF;
+ IF blocksize_x IS TRUE THEN
+ constraints := constraints || 'blocksize_x'::text;
+ END IF;
- IF blocksize_y IS TRUE THEN
- constraints := constraints || 'blocksize_y'::text;
- END IF;
+ IF blocksize_y IS TRUE THEN
+ constraints := constraints || 'blocksize_y'::text;
+ END IF;
- IF same_alignment IS TRUE THEN
- constraints := constraints || 'same_alignment'::text;
- END IF;
+ IF same_alignment IS TRUE THEN
+ constraints := constraints || 'same_alignment'::text;
+ END IF;
- IF regular_blocking IS TRUE THEN
- constraints := constraints || 'regular_blocking'::text;
- END IF;
+ IF regular_blocking IS TRUE THEN
+ constraints := constraints || 'regular_blocking'::text;
+ END IF;
- IF num_bands IS TRUE THEN
- constraints := constraints || 'num_bands'::text;
- END IF;
+ IF num_bands IS TRUE THEN
+ constraints := constraints || 'num_bands'::text;
+ END IF;
- IF pixel_types IS TRUE THEN
- constraints := constraints || 'pixel_types'::text;
- END IF;
+ IF pixel_types IS TRUE THEN
+ constraints := constraints || 'pixel_types'::text;
+ END IF;
- IF nodata_values IS TRUE THEN
- constraints := constraints || 'nodata_values'::text;
- END IF;
+ IF nodata_values IS TRUE THEN
+ constraints := constraints || 'nodata_values'::text;
+ END IF;
- IF out_db IS TRUE THEN
- constraints := constraints || 'out_db'::text;
- END IF;
+ IF out_db IS TRUE THEN
+ constraints := constraints || 'out_db'::text;
+ END IF;
- IF extent IS TRUE THEN
- constraints := constraints || 'extent'::text;
- END IF;
+ IF extent IS TRUE THEN
+ constraints := constraints || 'extent'::text;
+ END IF;
- RETURN DropRasterConstraints($1, $2, $3, VARIADIC constraints);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURN DropRasterConstraints($1, $2, $3, VARIADIC constraints);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION DropRasterConstraints (
- rasttable name,
- rastcolumn name,
- srid boolean DEFAULT TRUE,
- scale_x boolean DEFAULT TRUE,
- scale_y boolean DEFAULT TRUE,
- blocksize_x boolean DEFAULT TRUE,
- blocksize_y boolean DEFAULT TRUE,
- same_alignment boolean DEFAULT TRUE,
- regular_blocking boolean DEFAULT TRUE,
- num_bands boolean DEFAULT TRUE,
- pixel_types boolean DEFAULT TRUE,
- nodata_values boolean DEFAULT TRUE,
- out_db boolean DEFAULT TRUE,
- extent boolean DEFAULT TRUE
+ rasttable name,
+ rastcolumn name,
+ srid boolean DEFAULT TRUE,
+ scale_x boolean DEFAULT TRUE,
+ scale_y boolean DEFAULT TRUE,
+ blocksize_x boolean DEFAULT TRUE,
+ blocksize_y boolean DEFAULT TRUE,
+ same_alignment boolean DEFAULT TRUE,
+ regular_blocking boolean DEFAULT TRUE,
+ num_bands boolean DEFAULT TRUE,
+ pixel_types boolean DEFAULT TRUE,
+ nodata_values boolean DEFAULT TRUE,
+ out_db boolean DEFAULT TRUE,
+ extent boolean DEFAULT TRUE
)
- RETURNS boolean AS
- $$ SELECT DropRasterConstraints('', $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT DropRasterConstraints('', $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
------------------------------------------------------------------------------
-- raster_columns
@@ -9320,299 +9299,299 @@ CREATE OR REPLACE FUNCTION DropRasterConstraints (
------------------------------------------------------------------------------
CREATE OR REPLACE VIEW raster_columns AS
- SELECT
- current_database() AS r_table_catalog,
- n.nspname AS r_table_schema,
- c.relname AS r_table_name,
- a.attname AS r_raster_column,
- COALESCE(_raster_constraint_info_srid(n.nspname, c.relname, a.attname), (SELECT ST_SRID('POINT(0 0)'::geometry))) AS srid,
- _raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'x') AS scale_x,
- _raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'y') AS scale_y,
- _raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'width') AS blocksize_x,
- _raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'height') AS blocksize_y,
- COALESCE(_raster_constraint_info_alignment(n.nspname, c.relname, a.attname), FALSE) AS same_alignment,
- COALESCE(_raster_constraint_info_regular_blocking(n.nspname, c.relname, a.attname), FALSE) AS regular_blocking,
- _raster_constraint_info_num_bands(n.nspname, c.relname, a.attname) AS num_bands,
- _raster_constraint_info_pixel_types(n.nspname, c.relname, a.attname) AS pixel_types,
- _raster_constraint_info_nodata_values(n.nspname, c.relname, a.attname) AS nodata_values,
- _raster_constraint_info_out_db(n.nspname, c.relname, a.attname) AS out_db,
- _raster_constraint_info_extent(n.nspname, c.relname, a.attname) AS extent
- FROM
- pg_class c,
- pg_attribute a,
- pg_type t,
- pg_namespace n
- WHERE t.typname = 'raster'::name
- AND a.attisdropped = false
- AND a.atttypid = t.oid
- AND a.attrelid = c.oid
- AND c.relnamespace = n.oid
- AND (c.relkind = 'r'::"char" OR c.relkind = 'v'::"char")
- AND NOT pg_is_other_temp_schema(c.relnamespace);
+ SELECT
+ current_database() AS r_table_catalog,
+ n.nspname AS r_table_schema,
+ c.relname AS r_table_name,
+ a.attname AS r_raster_column,
+ COALESCE(_raster_constraint_info_srid(n.nspname, c.relname, a.attname), (SELECT ST_SRID('POINT(0 0)'::geometry))) AS srid,
+ _raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'x') AS scale_x,
+ _raster_constraint_info_scale(n.nspname, c.relname, a.attname, 'y') AS scale_y,
+ _raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'width') AS blocksize_x,
+ _raster_constraint_info_blocksize(n.nspname, c.relname, a.attname, 'height') AS blocksize_y,
+ COALESCE(_raster_constraint_info_alignment(n.nspname, c.relname, a.attname), FALSE) AS same_alignment,
+ COALESCE(_raster_constraint_info_regular_blocking(n.nspname, c.relname, a.attname), FALSE) AS regular_blocking,
+ _raster_constraint_info_num_bands(n.nspname, c.relname, a.attname) AS num_bands,
+ _raster_constraint_info_pixel_types(n.nspname, c.relname, a.attname) AS pixel_types,
+ _raster_constraint_info_nodata_values(n.nspname, c.relname, a.attname) AS nodata_values,
+ _raster_constraint_info_out_db(n.nspname, c.relname, a.attname) AS out_db,
+ _raster_constraint_info_extent(n.nspname, c.relname, a.attname) AS extent
+ FROM
+ pg_class c,
+ pg_attribute a,
+ pg_type t,
+ pg_namespace n
+ WHERE t.typname = 'raster'::name
+ AND a.attisdropped = false
+ AND a.atttypid = t.oid
+ AND a.attrelid = c.oid
+ AND c.relnamespace = n.oid
+ AND (c.relkind = 'r'::"char" OR c.relkind = 'v'::"char")
+ AND NOT pg_is_other_temp_schema(c.relnamespace);
------------------------------------------------------------------------------
-- overview constraint functions
-------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _overview_constraint(ov raster, factor integer, refschema name, reftable name, refcolumn name)
- RETURNS boolean AS
- $$ SELECT COALESCE((SELECT TRUE FROM raster_columns WHERE r_table_catalog = current_database() AND r_table_schema = $3 AND r_table_name = $4 AND r_raster_column = $5), FALSE) $$
- LANGUAGE 'sql' STABLE
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT COALESCE((SELECT TRUE FROM raster_columns WHERE r_table_catalog = current_database() AND r_table_schema = $3 AND r_table_name = $4 AND r_raster_column = $5), FALSE) $$
+ LANGUAGE 'sql' STABLE
+ COST 100;
CREATE OR REPLACE FUNCTION _overview_constraint_info(
- ovschema name, ovtable name, ovcolumn name,
- OUT refschema name, OUT reftable name, OUT refcolumn name, OUT factor integer
+ ovschema name, ovtable name, ovcolumn name,
+ OUT refschema name, OUT reftable name, OUT refcolumn name, OUT factor integer
)
- AS $$
- SELECT
- split_part(split_part(s.consrc, '''::name', 1), '''', 2)::name,
- split_part(split_part(s.consrc, '''::name', 2), '''', 2)::name,
- split_part(split_part(s.consrc, '''::name', 3), '''', 2)::name,
- trim(both from split_part(s.consrc, ',', 2))::integer
- FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
- WHERE n.nspname = $1
- AND c.relname = $2
- AND a.attname = $3
- AND a.attrelid = c.oid
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND a.attnum = ANY (s.conkey)
- AND s.consrc LIKE '%_overview_constraint(%'
- $$ LANGUAGE sql STABLE STRICT
+ AS $$
+ SELECT
+ split_part(split_part(s.consrc, '''::name', 1), '''', 2)::name,
+ split_part(split_part(s.consrc, '''::name', 2), '''', 2)::name,
+ split_part(split_part(s.consrc, '''::name', 3), '''', 2)::name,
+ trim(both from split_part(s.consrc, ',', 2))::integer
+ FROM pg_class c, pg_namespace n, pg_attribute a, pg_constraint s
+ WHERE n.nspname = $1
+ AND c.relname = $2
+ AND a.attname = $3
+ AND a.attrelid = c.oid
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND a.attnum = ANY (s.conkey)
+ AND s.consrc LIKE '%_overview_constraint(%'
+ $$ LANGUAGE sql STABLE STRICT
COST 100;
CREATE OR REPLACE FUNCTION _add_overview_constraint(
- ovschema name, ovtable name, ovcolumn name,
- refschema name, reftable name, refcolumn name,
- factor integer
+ ovschema name, ovtable name, ovcolumn name,
+ refschema name, reftable name, refcolumn name,
+ factor integer
)
- RETURNS boolean AS $$
- DECLARE
- fqtn text;
- cn name;
- sql text;
- BEGIN
- fqtn := '';
- IF length($1) > 0 THEN
- fqtn := quote_ident($1) || '.';
- END IF;
- fqtn := fqtn || quote_ident($2);
-
- cn := 'enforce_overview_' || $3;
-
- sql := 'ALTER TABLE ' || fqtn
- || ' ADD CONSTRAINT ' || quote_ident(cn)
- || ' CHECK (_overview_constraint(' || quote_ident($3)
- || ',' || $7
- || ',' || quote_literal($4)
- || ',' || quote_literal($5)
- || ',' || quote_literal($6)
- || '))';
-
- RETURN _add_raster_constraint(cn, sql);
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS $$
+ DECLARE
+ fqtn text;
+ cn name;
+ sql text;
+ BEGIN
+ fqtn := '';
+ IF length($1) > 0 THEN
+ fqtn := quote_ident($1) || '.';
+ END IF;
+ fqtn := fqtn || quote_ident($2);
+
+ cn := 'enforce_overview_' || $3;
+
+ sql := 'ALTER TABLE ' || fqtn
+ || ' ADD CONSTRAINT ' || quote_ident(cn)
+ || ' CHECK (_overview_constraint(' || quote_ident($3)
+ || ',' || $7
+ || ',' || quote_literal($4)
+ || ',' || quote_literal($5)
+ || ',' || quote_literal($6)
+ || '))';
+
+ RETURN _add_raster_constraint(cn, sql);
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION _drop_overview_constraint(ovschema name, ovtable name, ovcolumn name)
- RETURNS boolean AS
- $$ SELECT _drop_raster_constraint($1, $2, 'enforce_overview_' || $3) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean AS
+ $$ SELECT _drop_raster_constraint($1, $2, 'enforce_overview_' || $3) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
------------------------------------------------------------------------------
-- RASTER_OVERVIEWS
------------------------------------------------------------------------------
CREATE OR REPLACE VIEW raster_overviews AS
- SELECT
- current_database() AS o_table_catalog,
- n.nspname AS o_table_schema,
- c.relname AS o_table_name,
- a.attname AS o_raster_column,
- current_database() AS r_table_catalog,
- split_part(split_part(s.consrc, '''::name', 1), '''', 2)::name AS r_table_schema,
- split_part(split_part(s.consrc, '''::name', 2), '''', 2)::name AS r_table_name,
- split_part(split_part(s.consrc, '''::name', 3), '''', 2)::name AS r_raster_column,
- trim(both from split_part(s.consrc, ',', 2))::integer AS overview_factor
- FROM
- pg_class c,
- pg_attribute a,
- pg_type t,
- pg_namespace n,
- pg_constraint s
- WHERE t.typname = 'raster'::name
- AND a.attisdropped = false
- AND a.atttypid = t.oid
- AND a.attrelid = c.oid
- AND c.relnamespace = n.oid
- AND (c.relkind = 'r'::"char" OR c.relkind = 'v'::"char")
- AND s.connamespace = n.oid
- AND s.conrelid = c.oid
- AND s.consrc LIKE '%_overview_constraint(%'
- AND NOT pg_is_other_temp_schema(c.relnamespace);
+ SELECT
+ current_database() AS o_table_catalog,
+ n.nspname AS o_table_schema,
+ c.relname AS o_table_name,
+ a.attname AS o_raster_column,
+ current_database() AS r_table_catalog,
+ split_part(split_part(s.consrc, '''::name', 1), '''', 2)::name AS r_table_schema,
+ split_part(split_part(s.consrc, '''::name', 2), '''', 2)::name AS r_table_name,
+ split_part(split_part(s.consrc, '''::name', 3), '''', 2)::name AS r_raster_column,
+ trim(both from split_part(s.consrc, ',', 2))::integer AS overview_factor
+ FROM
+ pg_class c,
+ pg_attribute a,
+ pg_type t,
+ pg_namespace n,
+ pg_constraint s
+ WHERE t.typname = 'raster'::name
+ AND a.attisdropped = false
+ AND a.atttypid = t.oid
+ AND a.attrelid = c.oid
+ AND c.relnamespace = n.oid
+ AND (c.relkind = 'r'::"char" OR c.relkind = 'v'::"char")
+ AND s.connamespace = n.oid
+ AND s.conrelid = c.oid
+ AND s.consrc LIKE '%_overview_constraint(%'
+ AND NOT pg_is_other_temp_schema(c.relnamespace);
------------------------------------------------------------------------------
-- AddOverviewConstraints
------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION AddOverviewConstraints (
- ovschema name, ovtable name, ovcolumn name,
- refschema name, reftable name, refcolumn name,
- ovfactor int
+ ovschema name, ovtable name, ovcolumn name,
+ refschema name, reftable name, refcolumn name,
+ ovfactor int
)
- RETURNS boolean
- AS $$
- DECLARE
- x int;
- s name;
- t name;
- oschema name;
- rschema name;
- sql text;
- rtn boolean;
- BEGIN
- FOR x IN 1..2 LOOP
- s := '';
-
- IF x = 1 THEN
- s := $1;
- t := $2;
- ELSE
- s := $4;
- t := $5;
- END IF;
-
- -- validate user-provided schema
- IF length(s) > 0 THEN
- sql := 'SELECT nspname FROM pg_namespace '
- || 'WHERE nspname = ' || quote_literal(s)
- || 'LIMIT 1';
- EXECUTE sql INTO s;
-
- IF s IS NULL THEN
- RAISE EXCEPTION 'The value % is not a valid schema', quote_literal(s);
- RETURN FALSE;
- END IF;
- END IF;
-
- -- no schema, determine what it could be using the table
- IF length(s) < 1 THEN
- sql := 'SELECT n.nspname AS schemaname '
- || 'FROM pg_catalog.pg_class c '
- || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
- || 'WHERE c.relkind = ' || quote_literal('r')
- || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
- || ', ' || quote_literal('pg_toast')
- || ') AND pg_catalog.pg_table_is_visible(c.oid)'
- || ' AND c.relname = ' || quote_literal(t);
- EXECUTE sql INTO s;
-
- IF s IS NULL THEN
- RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal(t);
- RETURN FALSE;
- END IF;
- END IF;
-
- IF x = 1 THEN
- oschema := s;
- ELSE
- rschema := s;
- END IF;
- END LOOP;
-
- -- reference raster
- rtn := _add_overview_constraint(oschema, $2, $3, rschema, $5, $6, $7);
- IF rtn IS FALSE THEN
- RAISE EXCEPTION 'Unable to add the overview constraint. Is the schema name, table name or column name incorrect?';
- RETURN FALSE;
- END IF;
-
- RETURN TRUE;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ x int;
+ s name;
+ t name;
+ oschema name;
+ rschema name;
+ sql text;
+ rtn boolean;
+ BEGIN
+ FOR x IN 1..2 LOOP
+ s := '';
+
+ IF x = 1 THEN
+ s := $1;
+ t := $2;
+ ELSE
+ s := $4;
+ t := $5;
+ END IF;
+
+ -- validate user-provided schema
+ IF length(s) > 0 THEN
+ sql := 'SELECT nspname FROM pg_namespace '
+ || 'WHERE nspname = ' || quote_literal(s)
+ || 'LIMIT 1';
+ EXECUTE sql INTO s;
+
+ IF s IS NULL THEN
+ RAISE EXCEPTION 'The value % is not a valid schema', quote_literal(s);
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ -- no schema, determine what it could be using the table
+ IF length(s) < 1 THEN
+ sql := 'SELECT n.nspname AS schemaname '
+ || 'FROM pg_catalog.pg_class c '
+ || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
+ || 'WHERE c.relkind = ' || quote_literal('r')
+ || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
+ || ', ' || quote_literal('pg_toast')
+ || ') AND pg_catalog.pg_table_is_visible(c.oid)'
+ || ' AND c.relname = ' || quote_literal(t);
+ EXECUTE sql INTO s;
+
+ IF s IS NULL THEN
+ RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal(t);
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ IF x = 1 THEN
+ oschema := s;
+ ELSE
+ rschema := s;
+ END IF;
+ END LOOP;
+
+ -- reference raster
+ rtn := _add_overview_constraint(oschema, $2, $3, rschema, $5, $6, $7);
+ IF rtn IS FALSE THEN
+ RAISE EXCEPTION 'Unable to add the overview constraint. Is the schema name, table name or column name incorrect?';
+ RETURN FALSE;
+ END IF;
+
+ RETURN TRUE;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION AddOverviewConstraints (
- ovtable name, ovcolumn name,
- reftable name, refcolumn name,
- ovfactor int
+ ovtable name, ovcolumn name,
+ reftable name, refcolumn name,
+ ovfactor int
)
- RETURNS boolean
- AS $$ SELECT AddOverviewConstraints('', $1, $2, '', $3, $4, $5) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean
+ AS $$ SELECT AddOverviewConstraints('', $1, $2, '', $3, $4, $5) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
------------------------------------------------------------------------------
-- DropOverviewConstraints
------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION DropOverviewConstraints (
- ovschema name,
- ovtable name,
- ovcolumn name
+ ovschema name,
+ ovtable name,
+ ovcolumn name
)
- RETURNS boolean
- AS $$
- DECLARE
- schema name;
- sql text;
- rtn boolean;
- BEGIN
- -- validate schema
- schema := NULL;
- IF length($1) > 0 THEN
- sql := 'SELECT nspname FROM pg_namespace '
- || 'WHERE nspname = ' || quote_literal($1)
- || 'LIMIT 1';
- EXECUTE sql INTO schema;
-
- IF schema IS NULL THEN
- RAISE EXCEPTION 'The value provided for schema is invalid';
- RETURN FALSE;
- END IF;
- END IF;
-
- IF schema IS NULL THEN
- sql := 'SELECT n.nspname AS schemaname '
- || 'FROM pg_catalog.pg_class c '
- || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
- || 'WHERE c.relkind = ' || quote_literal('r')
- || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
- || ', ' || quote_literal('pg_toast')
- || ') AND pg_catalog.pg_table_is_visible(c.oid)'
- || ' AND c.relname = ' || quote_literal($2);
- EXECUTE sql INTO schema;
-
- IF schema IS NULL THEN
- RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal($2);
- RETURN FALSE;
- END IF;
- END IF;
-
- rtn := _drop_overview_constraint(schema, $2, $3);
- IF rtn IS FALSE THEN
- RAISE EXCEPTION 'Unable to drop the overview constraint . Is the schema name, table name or column name incorrect?';
- RETURN FALSE;
- END IF;
-
- RETURN TRUE;
- END;
- $$ LANGUAGE 'plpgsql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean
+ AS $$
+ DECLARE
+ schema name;
+ sql text;
+ rtn boolean;
+ BEGIN
+ -- validate schema
+ schema := NULL;
+ IF length($1) > 0 THEN
+ sql := 'SELECT nspname FROM pg_namespace '
+ || 'WHERE nspname = ' || quote_literal($1)
+ || 'LIMIT 1';
+ EXECUTE sql INTO schema;
+
+ IF schema IS NULL THEN
+ RAISE EXCEPTION 'The value provided for schema is invalid';
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ IF schema IS NULL THEN
+ sql := 'SELECT n.nspname AS schemaname '
+ || 'FROM pg_catalog.pg_class c '
+ || 'JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace '
+ || 'WHERE c.relkind = ' || quote_literal('r')
+ || ' AND n.nspname NOT IN (' || quote_literal('pg_catalog')
+ || ', ' || quote_literal('pg_toast')
+ || ') AND pg_catalog.pg_table_is_visible(c.oid)'
+ || ' AND c.relname = ' || quote_literal($2);
+ EXECUTE sql INTO schema;
+
+ IF schema IS NULL THEN
+ RAISE EXCEPTION 'The table % does not occur in the search_path', quote_literal($2);
+ RETURN FALSE;
+ END IF;
+ END IF;
+
+ rtn := _drop_overview_constraint(schema, $2, $3);
+ IF rtn IS FALSE THEN
+ RAISE EXCEPTION 'Unable to drop the overview constraint . Is the schema name, table name or column name incorrect?';
+ RETURN FALSE;
+ END IF;
+
+ RETURN TRUE;
+ END;
+ $$ LANGUAGE 'plpgsql' VOLATILE STRICT
+ COST 100;
CREATE OR REPLACE FUNCTION DropOverviewConstraints (
- ovtable name,
- ovcolumn name
+ ovtable name,
+ ovcolumn name
)
- RETURNS boolean
- AS $$ SELECT DropOverviewConstraints('', $1, $2) $$
- LANGUAGE 'sql' VOLATILE STRICT
- COST 100;
+ RETURNS boolean
+ AS $$ SELECT DropOverviewConstraints('', $1, $2) $$
+ LANGUAGE 'sql' VOLATILE STRICT
+ COST 100;
-------------------------------------------------------------------
--- END
+-- END
-------------------------------------------------------------------
diff --git a/gcc/postgis_share/legacy.sql b/clang/postgis_share/legacy.sql
index 234e916..4417686 100644
--- a/gcc/postgis_share/legacy.sql
+++ b/clang/postgis_share/legacy.sql
@@ -1,9 +1,7 @@
-
-
-- $Id: legacy.sql.in.c 9735 2012-05-16 08:29:14Z robe $
-- 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
-- $Id: legacy_minimal.sql.in.c 10736 2012-11-25 22:17:48Z robe $
-- Bare minimum Legacy functions --
-- This file that contains what we have determined are
@@ -13,285 +11,264 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsBinary(geometry)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_asBinary'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_asBinary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsBinary(geometry,text)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_asBinary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_asBinary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsText(geometry)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asText'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asText'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Estimated_Extent(text,text,text) RETURNS box2d AS
- '$libdir/postgis-2.0', 'geometry_estimated_extent'
- LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
-
+ '$libdir/postgis-2.0', '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
- '$libdir/postgis-2.0', 'geometry_estimated_extent'
- LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;
-
+ '$libdir/postgis-2.0', '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;
-
+ 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;
-
+ 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 '$libdir/postgis-2.0', 'LWGEOM_ndims'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS smallint
+ AS '$libdir/postgis-2.0', 'LWGEOM_ndims'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SetSRID(geometry,int4)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_set_srid'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_set_srid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SRID(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0','LWGEOM_get_srid'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0','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
- $$ SELECT ST_AsBinary($1::geometry);$$
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS bytea
+ AS
+ $$ SELECT ST_AsBinary($1::geometry);$$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.5.0
-- hack to allow unknown to cast to geometry
CREATE OR REPLACE FUNCTION ST_AsText(bytea)
- RETURNS text
- AS
- $$ SELECT ST_AsText($1::geometry);$$
- LANGUAGE 'sql' IMMUTABLE STRICT;
---- start functions that in theory should never have been used or internal like stuff deprecated
+ RETURNS text
+ AS
+ $$ SELECT ST_AsText($1::geometry);$$
+ LANGUAGE 'sql' IMMUTABLE STRICT;--- start functions that in theory should never have been used or internal like stuff deprecated
-- these were superceded by PostGIS_AddBBOX , PostGIS_DropBBOX, PostGIS_HasBBOX in 1.5 --
CREATE OR REPLACE FUNCTION addbbox(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_addBBOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_addBBOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
CREATE OR REPLACE FUNCTION dropbbox(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_dropBBOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_dropBBOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION hasbbox(geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'LWGEOM_hasBBOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS bool
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0','LWGEOM_get_srid'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0','LWGEOM_get_srid'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeometryFromText(text, int4)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeometryFromText(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromWKB(bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_WKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','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;
-
+ 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 '$libdir/postgis-2.0', 'LWGEOM_noop'
- LANGUAGE 'c' VOLATILE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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 $$
- SELECT $1 && $2
- $$
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS $$
+ SELECT $1 && $2
+ $$
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
CREATE OR REPLACE FUNCTION SE_Is3D(geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'LWGEOM_hasz'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'LWGEOM_hasz'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION SE_IsMeasured(geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'LWGEOM_hasm'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'LWGEOM_hasm'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- PostGIS equivalent function: Z(geometry)
CREATE OR REPLACE FUNCTION SE_Z(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_z_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_z_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- PostGIS equivalent function: M(geometry)
CREATE OR REPLACE FUNCTION SE_M(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_m_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_m_point'
+ 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 '$libdir/postgis-2.0', 'LWGEOM_locate_between_m'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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;
+ 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
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box3d(geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX3D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX3D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box(geometry)
- RETURNS box
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box2d(box3d)
- RETURNS box2d
- AS '$libdir/postgis-2.0','BOX3D_to_BOX2D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','BOX3D_to_BOX2D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box3d(box2d)
- RETURNS box3d
- AS '$libdir/postgis-2.0','BOX2D_to_BOX3D'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0','BOX2D_to_BOX3D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box(box3d)
- RETURNS box
- AS '$libdir/postgis-2.0','BOX3D_to_BOX'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box
+ AS '$libdir/postgis-2.0','BOX3D_to_BOX'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_text(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0','LWGEOM_to_text'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','LWGEOM_to_text'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry(box2d)
- RETURNS geometry
- AS '$libdir/postgis-2.0','BOX2D_to_LWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','BOX2D_to_LWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry(box3d)
- RETURNS geometry
- AS '$libdir/postgis-2.0','BOX3D_to_LWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','BOX3D_to_LWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry(text)
- RETURNS geometry
- AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','parse_WKT_lwgeom'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry(bytea)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_from_bytea'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_from_bytea'
+ LANGUAGE 'c' IMMUTABLE STRICT;
--- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_bytea(geometry)
- RETURNS bytea
- AS '$libdir/postgis-2.0','LWGEOM_to_bytea'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','LWGEOM_to_bytea'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box3d_in(cstring)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_in'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_in'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_box3d_out(box3d)
- RETURNS cstring
- AS '$libdir/postgis-2.0', 'BOX3D_out'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS cstring
+ AS '$libdir/postgis-2.0', 'BOX3D_out'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- START MANAGEMENT FUNCTIONS
-- These are legacy management functions with no place in our 2.0 world
@@ -316,14 +293,14 @@ LANGUAGE 'sql' IMMUTABLE;
-----------------------------------------------------------------------
-- This function will:
--
--- o try to fix the schema of records with an integer one
--- (for PG>=73)
+-- o try to fix the schema of records with an integer one
+-- (for PG>=73)
--
--- o link records to system tables through attrelid and varattnum
--- (for PG<75)
+-- o link records to system tables through attrelid and varattnum
+-- (for PG<75)
--
--- o delete all records for which no linking was possible
--- (for PG<75)
+-- o delete all records for which no linking was possible
+-- (for PG<75)
--
--
-----------------------------------------------------------------------
@@ -331,20 +308,19 @@ CREATE OR REPLACE FUNCTION fix_geometry_columns() RETURNS text
AS
$$
DECLARE
- mislinked record;
- result text;
- linked integer;
- deleted integer;
- foundschema integer;
+ mislinked record;
+ result text;
+ linked integer;
+ deleted integer;
+ foundschema integer;
BEGIN
- -- Since 7.3 schema support has been added.
- -- Previous postgis versions used to put the database name in
- -- the schema column. This needs to be fixed, so we try to
- -- set the correct schema for each geometry_colums record
- -- looking at table, column, type and srid.
-
- return 'This function is obsolete now that geometry_columns is a view';
+ -- Since 7.3 schema support has been added.
+ -- Previous postgis versions used to put the database name in
+ -- the schema column. This needs to be fixed, so we try to
+ -- set the correct schema for each geometry_colums record
+ -- looking at table, column, type and srid.
+ return 'This function is obsolete now that geometry_columns is a view';
END;
$$
@@ -368,17 +344,12 @@ LANGUAGE 'plpgsql' VOLATILE;
CREATE OR REPLACE FUNCTION probe_geometry_columns() RETURNS text AS
$$
DECLARE
- inserted integer;
- oldcount integer;
- probed integer;
- stale integer;
+ inserted integer;
+ oldcount integer;
+ probed integer;
+ stale integer;
BEGIN
-
-
-
-
-
- RETURN 'This function is obsolete now that geometry_columns is a view';
+ RETURN 'This function is obsolete now that geometry_columns is a view';
END
$$
@@ -391,43 +362,42 @@ LANGUAGE 'plpgsql' VOLATILE;
-- Deprecation in 1.5.0
-- these remarked out functions cause problems and no one uses them directly
-- They should not be installed
-
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_lt(geometry, geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_lt'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_lt'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_le(geometry, geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_le'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_le'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_gt(geometry, geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_gt'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_gt'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_ge(geometry, geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_ge'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_ge'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_eq(geometry, geometry)
- RETURNS bool
- AS '$libdir/postgis-2.0', 'lwgeom_eq'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'lwgeom_eq'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION st_geometry_cmp(geometry, geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0', 'lwgeom_cmp'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS integer
+ AS '$libdir/postgis-2.0', 'lwgeom_cmp'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
--- end functions that in theory should never have been used
@@ -437,222 +407,222 @@ CREATE OR REPLACE FUNCTION st_geometry_cmp(geometry, geometry)
-- Availability: 1.1.2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Affine(geometry,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8,float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_affine'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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, $2, $3, 0, $4, $5, 0, 0, 0, 1, $6, $7, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_affine($1, $2, $3, 0, $4, $5, 0, 0, 0, 1, $6, $7, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Availability: 1.1.2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION RotateZ(geometry,float8)
- RETURNS geometry
- AS 'SELECT st_affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, 0, 0, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_affine($1, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0, 1, 0, 0, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Availability: 1.1.2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Rotate(geometry,float8)
- RETURNS geometry
- AS 'SELECT st_rotateZ($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_rotateZ($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Availability: 1.1.2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION RotateX(geometry,float8)
- RETURNS geometry
- AS 'SELECT st_affine($1, 1, 0, 0, 0, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_affine($1, 1, 0, 0, 0, cos($2), -sin($2), 0, sin($2), cos($2), 0, 0, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Availability: 1.1.2
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION RotateY(geometry,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;
-
+ 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)
- RETURNS geometry
- AS 'SELECT st_affine($1, $2, 0, 0, 0, $3, 0, 0, 0, $4, 0, 0, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_affine($1, $2, 0, 0, 0, $3, 0, 0, 0, $4, 0, 0, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Availability: 1.1.0
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Scale(geometry,float8,float8)
- RETURNS geometry
- AS 'SELECT st_scale($1, $2, $3, 1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_scale($1, $2, $3, 1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Translate(geometry,float8,float8,float8)
- RETURNS geometry
- AS 'SELECT st_affine($1, 1, 0, 0, 0, 1, 0, 0, 0, 1, $2, $3, $4)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_affine($1, 1, 0, 0, 0, 1, 0, 0, 0, 1, $2, $3, $4)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Translate(geometry,float8,float8)
- RETURNS geometry
- AS 'SELECT st_translate($1, $2, $3, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ 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)
- RETURNS geometry
- AS 'SELECT st_affine($1, $4, 0, 0, 0, $5, 0,
- 0, 0, 1, $2 * $4, $3 * $5, 0)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT st_affine($1, $4, 0, 0, 0, $5, 0,
+ 0, 0, 1, $2 * $4, $3 * $5, 0)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- END Affine functions
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AddPoint(geometry, geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AddPoint(geometry, geometry, integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_addpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Area(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_area_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','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
CREATE OR REPLACE FUNCTION Area2D(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_area_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_area_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsEWKB(geometry)
- RETURNS BYTEA
- AS '$libdir/postgis-2.0','WKBFromLWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS BYTEA
+ AS '$libdir/postgis-2.0','WKBFromLWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsEWKB(geometry,text)
- RETURNS bytea
- AS '$libdir/postgis-2.0','WKBFromLWGEOM'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS bytea
+ AS '$libdir/postgis-2.0','WKBFromLWGEOM'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsEWKT(geometry)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asEWKT'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','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)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS 'SELECT _ST_AsGML(2, $1, 15, 0, 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)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS 'SELECT _ST_AsGML(2, $1, $2, 0, 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;
-
+ 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;
-
+ 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;
-
+ 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 '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsHEXEWKB(geometry, text)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asHEXEWKB'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsSVG(geometry)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asSVG'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asSVG'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsSVG(geometry,int4)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asSVG'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asSVG'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION AsSVG(geometry,int4,int4)
- RETURNS TEXT
- AS '$libdir/postgis-2.0','LWGEOM_asSVG'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS TEXT
+ AS '$libdir/postgis-2.0','LWGEOM_asSVG'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION azimuth(geometry,geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_azimuth'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_azimuth'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION BdPolyFromText(text, integer)
RETURNS geometry
AS $$
DECLARE
- geomtext alias for $1;
- srid alias for $2;
- mline geometry;
- geom geometry;
+ geomtext alias for $1;
+ srid alias for $2;
+ mline geometry;
+ geom geometry;
BEGIN
- mline := ST_MultiLineStringFromText(geomtext, srid);
+ mline := ST_MultiLineStringFromText(geomtext, srid);
- IF mline IS NULL
- THEN
- RAISE EXCEPTION 'Input is not a MultiLinestring';
- END IF;
+ IF mline IS NULL
+ THEN
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
+ END IF;
- geom := ST_BuildArea(mline);
+ geom := ST_BuildArea(mline);
- IF GeometryType(geom) != 'POLYGON'
- THEN
- RAISE EXCEPTION 'Input returns more then a single polygon, try using BdMPolyFromText instead';
- END IF;
+ IF GeometryType(geom) != 'POLYGON'
+ THEN
+ RAISE EXCEPTION 'Input returns more then a single polygon, try using BdMPolyFromText instead';
+ END IF;
- RETURN geom;
+ RETURN geom;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
@@ -662,170 +632,170 @@ CREATE OR REPLACE FUNCTION BdMPolyFromText(text, integer)
RETURNS geometry
AS $$
DECLARE
- geomtext alias for $1;
- srid alias for $2;
- mline geometry;
- geom geometry;
+ geomtext alias for $1;
+ srid alias for $2;
+ mline geometry;
+ geom geometry;
BEGIN
- mline := ST_MultiLineStringFromText(geomtext, srid);
+ mline := ST_MultiLineStringFromText(geomtext, srid);
- IF mline IS NULL
- THEN
- RAISE EXCEPTION 'Input is not a MultiLinestring';
- END IF;
+ IF mline IS NULL
+ THEN
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
+ END IF;
- geom := ST_Multi(ST_BuildArea(mline));
+ geom := ST_Multi(ST_BuildArea(mline));
- RETURN geom;
+ RETURN geom;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION boundary(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','boundary'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','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;
-
+ 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 '$libdir/postgis-2.0','buffer'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','buffer'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION BuildArea(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'ST_BuildArea'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'ST_BuildArea'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
+
-- This is also available w/out GEOS
CREATE OR REPLACE FUNCTION Centroid(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Contains(geometry,geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION convexhull(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','convexhull'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','convexhull'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION crosses(geometry,geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION distance(geometry,geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0', 'LWGEOM_mindistance2d'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_mindistance2d'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION difference(geometry,geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','difference'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','difference'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Dimension(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_dimension'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_dimension'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION disjoint(geometry,geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION distance_sphere(geometry,geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_distance_sphere'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','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 '$libdir/postgis-2.0','LWGEOM_distance_ellipsoid'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','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 '$libdir/postgis-2.0', 'LWGEOM_dump'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS SETOF geometry_dump
+ AS '$libdir/postgis-2.0', 'LWGEOM_dump'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION DumpRings(geometry)
- RETURNS SETOF geometry_dump
- AS '$libdir/postgis-2.0', 'LWGEOM_dump_rings'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS SETOF geometry_dump
+ AS '$libdir/postgis-2.0', 'LWGEOM_dump_rings'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Envelope(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_envelope'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_envelope'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Expand(box2d,float8)
- RETURNS box2d
- AS '$libdir/postgis-2.0', 'BOX2D_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS box2d
+ AS '$libdir/postgis-2.0', 'BOX2D_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Expand(box3d,float8)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Expand(geometry,float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_expand'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_expand'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
CREATE AGGREGATE Extent(
- sfunc = ST_combine_bbox,
- basetype = geometry,
- finalfunc = box2d,
- stype = box3d
- );
-
+ 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
$$
DECLARE
- tablename alias for $1;
- columnname alias for $2;
- myrec RECORD;
+ tablename alias for $1;
+ columnname alias for $2;
+ myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") As extent FROM "' || tablename || '"' LOOP
- return myrec.extent;
- END LOOP;
+ FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") As extent FROM "' || tablename || '"' LOOP
+ return myrec.extent;
+ END LOOP;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
@@ -834,1109 +804,1109 @@ LANGUAGE 'plpgsql' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION Find_Extent(text,text,text) RETURNS box2d AS
$$
DECLARE
- schemaname alias for $1;
- tablename alias for $2;
- columnname alias for $3;
- myrec RECORD;
+ schemaname alias for $1;
+ tablename alias for $2;
+ columnname alias for $3;
+ myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") FROM "' || schemaname || '"."' || tablename || '" As extent ' LOOP
- return myrec.extent;
- END LOOP;
+ FOR myrec IN EXECUTE 'SELECT ST_Extent("' || columnname || '") FROM "' || schemaname || '"."' || tablename || '" As extent ' LOOP
+ return myrec.extent;
+ END LOOP;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;
-
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION EndPoint(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_endpoint_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_endpoint_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ExteriorRing(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_exteriorring_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_exteriorring_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_2d(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_3dm(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_3dm'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_3dm'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_3dz(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_3dz'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_4d(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_4d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_4d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Force_Collection(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_collection'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_collection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ForceRHR(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_clockwise_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_clockwise_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomCollFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(GeomFromText($1, $2)) = ''GEOMETRYCOLLECTION''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(GeomFromText($1, $2)) = ''GEOMETRYCOLLECTION''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomCollFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(GeomFromText($1)) = ''GEOMETRYCOLLECTION''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(GeomFromText($1)) = ''GEOMETRYCOLLECTION''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomCollFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(GeomFromWKB($1, $2)) = ''GEOMETRYCOLLECTION''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
- -- Deprecation in 1.2.3
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(GeomFromWKB($1, $2)) = ''GEOMETRYCOLLECTION''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
+ -- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomCollFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(GeomFromWKB($1)) = ''GEOMETRYCOLLECTION''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(GeomFromWKB($1)) = ''GEOMETRYCOLLECTION''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeometryN(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_geometryn_collection'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_geometryn_collection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomUnion(geometry,geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','geomunion'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
--- Availability: 1.5.0 -- replaced with postgis_getbbox
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','geomunion'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
+-- Availability: 1.5.0 -- replaced with postgis_getbbox
CREATE OR REPLACE FUNCTION getbbox(geometry)
- RETURNS box2d
- AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS box2d
+ AS '$libdir/postgis-2.0','LWGEOM_to_BOX2D'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION intersects(geometry,geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsRing(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsSimple(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'issimple'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'issimple'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION length_spheroid(geometry, spheroid)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','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 '$libdir/postgis-2.0','LWGEOM_length2d_ellipsoid'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','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 '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineMerge(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'linemerge'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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;
-
+ 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 '$libdir/postgis-2.0', 'BOX2D_construct'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS box2d
+ AS '$libdir/postgis-2.0', 'BOX2D_construct'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePolygon(geometry, geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePolygon(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOLYGON''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOLYGON''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION multi(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_force_multi'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_force_multi'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolyFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolyFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOLYGON''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOLYGON''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION InteriorRingN(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_interiorringn_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_interiorringn_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION intersection(geometry,geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','intersection'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','intersection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
- -- Deprecation in 1.2.3
+ -- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsClosed(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_isclosed'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_isclosed'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsEmpty(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'LWGEOM_isempty'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'LWGEOM_isempty'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION IsValid(geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0', 'isvalid'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0', 'isvalid'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
-- this is a fake (for back-compatibility)
-- uses 3d if 3d is available, 2d otherwise
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION length3d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION length2d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length2d_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length2d_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION length(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION line_interpolate_point(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_line_interpolate_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_line_locate_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_line_substring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_substring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''LINESTRING''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''LINESTRING''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''LINESTRING''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''LINESTRING''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromMultiPoint(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_line_from_mpoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_line_from_mpoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''LINESTRING''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''LINESTRING''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''LINESTRING''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''LINESTRING''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineStringFromText(text)
- RETURNS geometry
- AS 'SELECT LineFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT LineFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LineStringFromText(text, int4)
- RETURNS geometry
- AS 'SELECT LineFromText($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ 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
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''LINESTRING''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''LINESTRING''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION LinestringFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''LINESTRING''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''LINESTRING''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION locate_between_measures(geometry, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_locate_between_m'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_locate_between_m'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION M(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_m_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_m_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakeBox3d(geometry, geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_construct'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_construct'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION makeline_garray (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makeline_garray'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makeline_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE AGGREGATE makeline (
- BASETYPE = geometry,
- SFUNC = pgis_geometry_accum_transfn,
- STYPE = pgis_abs,
- FINALFUNC = pgis_geometry_makeline_finalfn
- );
-
+ BASETYPE = geometry,
+ SFUNC = pgis_geometry_accum_transfn,
+ STYPE = pgis_abs,
+ FINALFUNC = pgis_geometry_makeline_finalfn
+ );
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakeLine(geometry, geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makeline'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makeline'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePoint(float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePoint(float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
- -- Deprecation in 1.2.3
+ -- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePoint(float8, float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MakePointM(float8, float8, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_makepoint3dm'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_maxdistance2d_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0', 'LWGEOM_maxdistance2d_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION mem_size(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_mem_size'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_mem_size'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE
- WHEN geometrytype(GeomFromText($1, $2)) = ''MULTILINESTRING''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE
+ WHEN geometrytype(GeomFromText($1, $2)) = ''MULTILINESTRING''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''MULTILINESTRING''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''MULTILINESTRING''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MLineFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTILINESTRING''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTILINESTRING''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPointFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1,$2)) = ''MULTIPOINT''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1,$2)) = ''MULTIPOINT''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPointFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''MULTIPOINT''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''MULTIPOINT''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPointFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1,$2)) = ''MULTIPOINT''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1,$2)) = ''MULTIPOINT''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPointFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOINT''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOINT''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''MULTIPOLYGON''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''MULTIPOLYGON''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''MULTIPOLYGON''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''MULTIPOLYGON''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MPolyFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTIPOLYGON''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiLineFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION MultiLineFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''MULTILINESTRING''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiLineFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTILINESTRING''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTILINESTRING''
+ THEN GeomFromWKB($1)
+ 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;
-
+ 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;
-
+ 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;
-
+ 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;
-
+ 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;
-
+ 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
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1,$2)) = ''MULTIPOINT''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1,$2)) = ''MULTIPOINT''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPointFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOINT''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''MULTIPOINT''
+ THEN GeomFromWKB($1)
+ 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;
-
+ RETURNS geometry
+ AS 'SELECT MPolyFromText($1, $2)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION MultiPolygonFromText(text)
- RETURNS geometry
- AS 'SELECT MPolyFromText($1)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS 'SELECT MPolyFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumInteriorRing(geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS integer
+ AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumInteriorRings(geometry)
- RETURNS integer
- AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS integer
+ AS '$libdir/postgis-2.0','LWGEOM_numinteriorrings_polygon'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION npoints(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_npoints'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_npoints'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION nrings(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_nrings'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_nrings'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumGeometries(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_numgeometries_collection'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_numgeometries_collection'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION NumPoints(geometry)
- RETURNS int4
- AS '$libdir/postgis-2.0', 'LWGEOM_numpoints_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS int4
+ AS '$libdir/postgis-2.0', 'LWGEOM_numpoints_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION overlaps(geometry,geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- this is a fake (for back-compatibility)
-- uses 3d if 3d is available, 2d otherwise
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION perimeter3d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_perimeter_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_perimeter_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION perimeter2d(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_perimeter2d_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_inside_circle_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS bool
+ AS '$libdir/postgis-2.0', 'LWGEOM_inside_circle_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''POINT''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''POINT''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''POINT''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''POINT''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''POINT''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''POINT''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''POINT''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(ST_GeomFromWKB($1, $2)) = ''POINT''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointN(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0','LWGEOM_pointn_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','LWGEOM_pointn_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PointOnSurface(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromText(text)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''POLYGON''
- THEN GeomFromText($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1)) = ''POLYGON''
+ THEN GeomFromText($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromText(text, int4)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''POLYGON''
- THEN GeomFromText($1,$2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromText($1, $2)) = ''POLYGON''
+ THEN GeomFromText($1,$2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''POLYGON''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1, $2)) = ''POLYGON''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolyFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''POLYGON''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''POLYGON''
+ THEN GeomFromWKB($1)
+ 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;
-
+ 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;
-
+ RETURNS geometry
+ AS 'SELECT PolyFromText($1)'
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolygonFromWKB(bytea, int)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1,$2)) = ''POLYGON''
- THEN GeomFromWKB($1, $2)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
- -- Deprecation in 1.2.3
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1,$2)) = ''POLYGON''
+ THEN GeomFromWKB($1, $2)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
+ -- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION PolygonFromWKB(bytea)
- RETURNS geometry
- AS '
- SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''POLYGON''
- THEN GeomFromWKB($1)
- ELSE NULL END
- '
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '
+ SELECT CASE WHEN geometrytype(GeomFromWKB($1)) = ''POLYGON''
+ THEN GeomFromWKB($1)
+ ELSE NULL END
+ '
+ LANGUAGE 'sql' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Polygonize_GArray (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'polygonize_garray'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'polygonize_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION relate(geometry,geometry)
- RETURNS text
- AS '$libdir/postgis-2.0','relate_full'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0','relate_full'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION relate(geometry,geometry,text)
- RETURNS boolean
- AS '$libdir/postgis-2.0','relate_pattern'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0','relate_pattern'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION RemovePoint(geometry, integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_removepoint'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_removepoint'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION reverse(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_reverse'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_reverse'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Segmentize(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_segmentize2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_segmentize2d'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION SetPoint(geometry, integer, geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_setpoint_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_longitude_shift'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_longitude_shift'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Simplify(geometry, float8)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_simplify2d'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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 '$libdir/postgis-2.0', 'LWGEOM_snaptogrid'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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;
-
+ 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 '$libdir/postgis-2.0', 'LWGEOM_snaptogrid_pointoff'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', '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;
-
+ 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 '$libdir/postgis-2.0', 'LWGEOM_makeline_garray'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_makeline_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION StartPoint(geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_startpoint_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_startpoint_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION symdifference(geometry,geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','symdifference'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','symdifference'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION symmetricdifference(geometry,geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0','symdifference'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','symdifference'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION summary(geometry)
- RETURNS text
- AS '$libdir/postgis-2.0', 'LWGEOM_summary'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS text
+ AS '$libdir/postgis-2.0', 'LWGEOM_summary'
+ LANGUAGE 'c' IMMUTABLE STRICT;
CREATE OR REPLACE FUNCTION transform(geometry,integer)
- RETURNS geometry
- AS '$libdir/postgis-2.0','transform'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','transform'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION touches(geometry,geometry)
- RETURNS boolean
- AS '$libdir/postgis-2.0'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS boolean
+ AS '$libdir/postgis-2.0'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION within(geometry,geometry)
- RETURNS boolean
- AS 'SELECT ST_Within($1, $2)'
- LANGUAGE 'sql' IMMUTABLE STRICT;
-
+ 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 '$libdir/postgis-2.0','LWGEOM_x_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_x_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION xmax(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_xmax'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_xmax'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION xmin(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_xmin'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_xmin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Y(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_y_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_y_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ymax(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_ymax'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_ymax'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION ymin(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_ymin'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_ymin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION Z(geometry)
- RETURNS float8
- AS '$libdir/postgis-2.0','LWGEOM_z_point'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS float8
+ AS '$libdir/postgis-2.0','LWGEOM_z_point'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION zmax(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_zmax'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_zmax'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION zmin(box3d)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','BOX3D_zmin'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','BOX3D_zmin'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION zmflag(geometry)
- RETURNS smallint
- AS '$libdir/postgis-2.0', 'LWGEOM_zmflag'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS smallint
+ AS '$libdir/postgis-2.0', 'LWGEOM_zmflag'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- end old ogc names that have been replaced with new SQL-MM names --
--- Start Aggregates and supporting functions --
-- Deprecation in: 1.2.3
CREATE AGGREGATE accum (
- sfunc = pgis_geometry_accum_transfn,
- basetype = geometry,
- stype = pgis_abs,
- finalfunc = pgis_geometry_accum_finalfn
- );
+ sfunc = pgis_geometry_accum_transfn,
+ basetype = geometry,
+ stype = pgis_abs,
+ finalfunc = pgis_geometry_accum_finalfn
+ );
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION collect(geometry, geometry)
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'LWGEOM_collect'
- LANGUAGE 'c' IMMUTABLE;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'LWGEOM_collect'
+ LANGUAGE 'c' IMMUTABLE;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION combine_bbox(box2d,geometry)
- RETURNS box2d
- AS '$libdir/postgis-2.0', 'BOX2D_combine'
- LANGUAGE 'c' IMMUTABLE;
-
+ RETURNS box2d
+ AS '$libdir/postgis-2.0', 'BOX2D_combine'
+ LANGUAGE 'c' IMMUTABLE;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION combine_bbox(box3d,geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_combine'
- LANGUAGE 'c' IMMUTABLE;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_combine'
+ LANGUAGE 'c' IMMUTABLE;
- -- Deprecation in 1.5.0
+ -- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION ST_Polygonize_GArray (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'polygonize_garray'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'polygonize_garray'
+ LANGUAGE 'c' IMMUTABLE STRICT
+ COST 100;
-- Deprecation in 1.4.0
CREATE OR REPLACE FUNCTION ST_unite_garray (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0','pgis_union_geometry_array'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0','pgis_union_geometry_array'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION unite_garray (geometry[])
- RETURNS geometry
- AS '$libdir/postgis-2.0', 'pgis_union_geometry_array'
- LANGUAGE 'c' IMMUTABLE STRICT;
-
+ RETURNS geometry
+ AS '$libdir/postgis-2.0', 'pgis_union_geometry_array'
+ LANGUAGE 'c' IMMUTABLE STRICT;
+
-- Deprecation in 1.2.3
CREATE AGGREGATE Extent3d(
- sfunc = combine_bbox,
- basetype = geometry,
- stype = box3d
- );
-
+ sfunc = combine_bbox,
+ basetype = geometry,
+ stype = box3d
+ );
+
-- Deprecation in 1.2.3
CREATE AGGREGATE memcollect(
- sfunc = ST_collect,
- basetype = geometry,
- stype = geometry
- );
+ sfunc = ST_collect,
+ basetype = geometry,
+ stype = geometry
+ );
-- Deprecation in 1.2.3
CREATE AGGREGATE MemGeomUnion (
- basetype = geometry,
- sfunc = geomunion,
- stype = geometry
- );
+ basetype = geometry,
+ sfunc = geomunion,
+ stype = geometry
+ );
-- End Aggregates and supporting functions --
------------------------------------------------
@@ -1945,33 +1915,33 @@ CREATE AGGREGATE MemGeomUnion (
-- Renamed in 2.0.0 to ST_3DLength
CREATE OR REPLACE FUNCTION ST_Length3D(geometry)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_length_linestring'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Renamed in 2.0.0 to ST_3DLength_spheroid
CREATE OR REPLACE FUNCTION ST_Length_spheroid3D(geometry, spheroid)
- RETURNS FLOAT8
- AS '$libdir/postgis-2.0','LWGEOM_length_ellipsoid_linestring'
- LANGUAGE 'c' IMMUTABLE STRICT
- COST 100;
-
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0','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
- AS '$libdir/postgis-2.0', 'LWGEOM_perimeter_poly'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS FLOAT8
+ AS '$libdir/postgis-2.0', 'LWGEOM_perimeter_poly'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Renamed in 2.0.0 to ST_3DMakeBox
CREATE OR REPLACE FUNCTION ST_MakeBox3D(geometry, geometry)
- RETURNS box3d
- AS '$libdir/postgis-2.0', 'BOX3D_construct'
- LANGUAGE 'c' IMMUTABLE STRICT;
+ RETURNS box3d
+ AS '$libdir/postgis-2.0', 'BOX3D_construct'
+ LANGUAGE 'c' IMMUTABLE STRICT;
-- Renamed in 2.0.0 to ST_3DExtent
CREATE AGGREGATE ST_Extent3D(
- sfunc = ST_combine_bbox,
- basetype = geometry,
- stype = box3d
- );
+ sfunc = ST_combine_bbox,
+ basetype = geometry,
+ stype = box3d
+ );
--END 3D functions--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment