postgis.sql.in 181 KB
Newer Older
1 2 3 4
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
--
-- PostGIS - Spatial Types for PostgreSQL
5
-- http://postgis.net
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
-- Copyright 2001-2003 Refractions Research Inc.
--
-- This is free software; you can redistribute and/or modify it under
-- the terms of the GNU General Public Licence. See the COPYING file.
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
-- WARNING: Any change in this file must be evaluated for compatibility.
--          Changes cleanly handled by postgis_upgrade.sql are fine,
--	    other changes will require a bump in Major version.
--	    Currently only function replaceble by CREATE OR REPLACE
--	    are cleanly handled.
--
-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#include "sqldefines.h"

SET client_min_messages TO warning;

-- INSTALL VERSION: POSTGIS_LIB_VERSION

BEGIN;

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
-- Check that no other postgis is installed
DO $$
DECLARE
  rec RECORD;
BEGIN
  FOR rec IN
    SELECT n.nspname, p.proname FROM pg_proc p, pg_namespace n
    WHERE p.proname = 'postgis_version'
    AND p.pronamespace = n.oid
  LOOP
    RAISE EXCEPTION 'PostGIS is already installed in schema ''%'', uninstall it first', rec.nspname;
  END LOOP;
END
$$ LANGUAGE 'plpgsql';


45
-- Let the user know about a deprecated signature and its new name, if any
46 47 48
CREATE OR REPLACE FUNCTION _postgis_deprecate(oldname text, newname text, version text)
RETURNS void AS
$$
49 50
DECLARE
  curver_text text;
51
BEGIN
52
  --
53
  -- Raises a NOTICE if it was deprecated in this version,
54 55 56 57 58 59 60 61 62 63 64
  -- a WARNING if in a previous version (only up to minor version checked)
  --
    curver_text := POSTGIS_LIB_VERSION;
    IF split_part(curver_text,'.',1)::int > split_part(version,'.',1)::int OR
       ( split_part(curver_text,'.',1) = split_part(version,'.',1) AND
         split_part(curver_text,'.',2) != split_part(version,'.',2) )
    THEN
      RAISE WARNING '% signature was deprecated in %. Please use %', oldname, version, newname;
    ELSE
      RAISE DEBUG '% signature was deprecated in %. Please use %', oldname, version, newname;
    END IF;
65 66 67
END;
$$ LANGUAGE 'plpgsql' IMMUTABLE STRICT;

68 69 70 71 72 73
-------------------------------------------------------------------
--  SPHEROID TYPE
-------------------------------------------------------------------
CREATE OR REPLACE FUNCTION spheroid_in(cstring)
	RETURNS spheroid
	AS 'MODULE_PATHNAME','ellipsoid_in'
74
	LANGUAGE 'c' IMMUTABLE STRICT;
75 76 77 78

CREATE OR REPLACE FUNCTION spheroid_out(spheroid)
	RETURNS cstring
	AS 'MODULE_PATHNAME','ellipsoid_out'
79
	LANGUAGE 'c' IMMUTABLE STRICT;
80

81
-- Availability: 0.5.0
82 83 84 85 86 87 88 89 90 91 92 93 94
CREATE TYPE spheroid (
	alignment = double,
	internallength = 65,
	input = spheroid_in,
	output = spheroid_out
);

-------------------------------------------------------------------
--  GEOMETRY TYPE (lwgeom)
-------------------------------------------------------------------
CREATE OR REPLACE FUNCTION geometry_in(cstring)
	RETURNS geometry
	AS 'MODULE_PATHNAME','LWGEOM_in'
95
	LANGUAGE 'c' IMMUTABLE STRICT;
96 97 98 99

CREATE OR REPLACE FUNCTION geometry_out(geometry)
	RETURNS cstring
	AS 'MODULE_PATHNAME','LWGEOM_out'
100
	LANGUAGE 'c' IMMUTABLE STRICT;
101 102 103 104 105

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_typmod_in(cstring[])
	RETURNS integer
	AS 'MODULE_PATHNAME','geometry_typmod_in'
106
	LANGUAGE 'c' IMMUTABLE STRICT; 
107 108 109 110 111

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_typmod_out(integer)
	RETURNS cstring
	AS 'MODULE_PATHNAME','postgis_typmod_out'
112
	LANGUAGE 'c' IMMUTABLE STRICT; 
113 114 115

CREATE OR REPLACE FUNCTION geometry_analyze(internal)
	RETURNS bool
116
	AS 'MODULE_PATHNAME', 'gserialized_analyze_nd'
117
	LANGUAGE 'c' VOLATILE STRICT;
118 119 120 121

CREATE OR REPLACE FUNCTION geometry_recv(internal)
	RETURNS geometry
	AS 'MODULE_PATHNAME','LWGEOM_recv'
122
	LANGUAGE 'c' IMMUTABLE STRICT;
123 124 125 126

CREATE OR REPLACE FUNCTION geometry_send(geometry)
	RETURNS bytea
	AS 'MODULE_PATHNAME','LWGEOM_send'
127
	LANGUAGE 'c' IMMUTABLE STRICT;
128

129
-- Availability: 0.1.0
130 131 132 133 134 135 136 137 138
CREATE TYPE geometry (
	internallength = variable,
	input = geometry_in,
	output = geometry_out,
	send = geometry_send,
	receive = geometry_recv,
	typmod_in = geometry_typmod_in,
	typmod_out = geometry_typmod_out,
	delimiter = ':',
139
	alignment = double,
140 141 142 143 144 145 146 147 148 149
	analyze = geometry_analyze,
	storage = main
);


-- Availability: 2.0.0
-- Special cast for enforcing the typmod restrictions
CREATE OR REPLACE FUNCTION geometry(geometry, integer, boolean)
	RETURNS geometry
	AS 'MODULE_PATHNAME','geometry_enforce_typmod'
150
	LANGUAGE 'c' IMMUTABLE STRICT; 
151 152 153 154 155

-- Availability: 2.0.0
CREATE CAST (geometry AS geometry) WITH FUNCTION geometry(geometry, integer, boolean) AS IMPLICIT;


156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION geometry(point)
	RETURNS geometry
	AS 'MODULE_PATHNAME','point_to_geometry'
	LANGUAGE 'c' IMMUTABLE STRICT; 

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION point(geometry)
	RETURNS point
	AS 'MODULE_PATHNAME','geometry_to_point'
	LANGUAGE 'c' IMMUTABLE STRICT; 

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION geometry(path)
	RETURNS geometry
	AS 'MODULE_PATHNAME','path_to_geometry'
	LANGUAGE 'c' IMMUTABLE STRICT; 

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION path(geometry)
	RETURNS path
	AS 'MODULE_PATHNAME','geometry_to_path'
	LANGUAGE 'c' IMMUTABLE STRICT; 

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION geometry(polygon)
	RETURNS geometry
	AS 'MODULE_PATHNAME','polygon_to_geometry'
	LANGUAGE 'c' IMMUTABLE STRICT; 

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION polygon(geometry)
	RETURNS polygon
	AS 'MODULE_PATHNAME','geometry_to_polygon'
	LANGUAGE 'c' IMMUTABLE STRICT; 

CREATE CAST (geometry AS point) WITH FUNCTION point(geometry);
CREATE CAST (point AS geometry) WITH FUNCTION geometry(point);
CREATE CAST (geometry AS path) WITH FUNCTION path(geometry);
CREATE CAST (path AS geometry) WITH FUNCTION geometry(path);
CREATE CAST (geometry AS polygon) WITH FUNCTION polygon(geometry);
CREATE CAST (polygon AS geometry) WITH FUNCTION geometry(polygon);

199 200 201 202 203 204 205 206
-------------------------------------------------------------------
--  BOX3D TYPE
-- Point coordinate data access
-------------------------------------------
-- PostGIS equivalent function: X(geometry)
CREATE OR REPLACE FUNCTION ST_X(geometry)
	RETURNS float8
	AS 'MODULE_PATHNAME','LWGEOM_x_point'
207
	LANGUAGE 'c' IMMUTABLE STRICT;
208 209 210 211 212

-- PostGIS equivalent function: Y(geometry)
CREATE OR REPLACE FUNCTION ST_Y(geometry)
	RETURNS float8
	AS 'MODULE_PATHNAME','LWGEOM_y_point'
213
	LANGUAGE 'c' IMMUTABLE STRICT;
214 215 216 217 218

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Z(geometry)
	RETURNS float8
	AS 'MODULE_PATHNAME','LWGEOM_z_point'
219
	LANGUAGE 'c' IMMUTABLE STRICT;
220 221 222 223 224

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_M(geometry)
	RETURNS float8
	AS 'MODULE_PATHNAME','LWGEOM_m_point'
225
	LANGUAGE 'c' IMMUTABLE STRICT;
226 227 228 229 230 231 232

-------------------------------------------
-------------------------------------------------------------------

CREATE OR REPLACE FUNCTION box3d_in(cstring)
	RETURNS box3d
	AS 'MODULE_PATHNAME', 'BOX3D_in'
233
	LANGUAGE 'c' IMMUTABLE STRICT;
234 235 236 237

CREATE OR REPLACE FUNCTION box3d_out(box3d)
	RETURNS cstring
	AS 'MODULE_PATHNAME', 'BOX3D_out'
238
	LANGUAGE 'c' IMMUTABLE STRICT;
239

240
-- Availability: 0.1.0
241 242
CREATE TYPE box3d (
	alignment = double,
243
	internallength = 52,
244 245 246 247 248 249 250 251 252 253 254
	input = box3d_in,
	output = box3d_out
);

-----------------------------------------------------------------------
-- BOX2D
-----------------------------------------------------------------------

CREATE OR REPLACE FUNCTION box2d_in(cstring)
	RETURNS box2d
	AS 'MODULE_PATHNAME','BOX2D_in'
255
	LANGUAGE 'c' IMMUTABLE STRICT;
256 257 258 259

CREATE OR REPLACE FUNCTION box2d_out(box2d)
	RETURNS cstring
	AS 'MODULE_PATHNAME','BOX2D_out'
260
	LANGUAGE 'c' IMMUTABLE STRICT;
261

262
-- Availability: 0.8.2
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
CREATE TYPE box2d (
	internallength = 65,
	input = box2d_in,
	output = box2d_out,
	storage = plain
);

-------------------------------------------------------------------
--  BOX2DF TYPE (INTERNAL ONLY)
-------------------------------------------------------------------
--
-- Box2Df type is used by the GiST index bindings. 
-- In/out functions are stubs, as all access should be internal.
---
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION box2df_in(cstring)
	RETURNS box2df
	AS 'MODULE_PATHNAME','box2df_in'
281
	LANGUAGE 'c' IMMUTABLE STRICT; 
282 283 284 285 286

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION box2df_out(box2df)
	RETURNS cstring
	AS 'MODULE_PATHNAME','box2df_out'
287
	LANGUAGE 'c' IMMUTABLE STRICT; 
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310

-- Availability: 2.0.0
CREATE TYPE box2df (
	internallength = 16,
	input = box2df_in,
	output = box2df_out,
	storage = plain,
	alignment = double
);


-------------------------------------------------------------------
--  GIDX TYPE (INTERNAL ONLY)
-------------------------------------------------------------------
--
-- GIDX type is used by the N-D and GEOGRAPHY GiST index bindings. 
-- In/out functions are stubs, as all access should be internal.
---

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION gidx_in(cstring)
	RETURNS gidx
	AS 'MODULE_PATHNAME','gidx_in'
311
	LANGUAGE 'c' IMMUTABLE STRICT; 
312 313 314 315 316

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION gidx_out(gidx)
	RETURNS cstring
	AS 'MODULE_PATHNAME','gidx_out'
317
	LANGUAGE 'c' IMMUTABLE STRICT; 
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333

-- Availability: 1.5.0
CREATE TYPE gidx (
	internallength = variable,
	input = gidx_in,
	output = gidx_out,
	storage = plain,
	alignment = double
);

-------------------------------------------------------------------
-- BTREE indexes
-------------------------------------------------------------------
CREATE OR REPLACE FUNCTION geometry_lt(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'lwgeom_lt'
334
	LANGUAGE 'c' IMMUTABLE STRICT;
335 336 337 338

CREATE OR REPLACE FUNCTION geometry_le(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'lwgeom_le'
339
	LANGUAGE 'c' IMMUTABLE STRICT;
340 341 342 343

CREATE OR REPLACE FUNCTION geometry_gt(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'lwgeom_gt'
344
	LANGUAGE 'c' IMMUTABLE STRICT;
345 346 347 348

CREATE OR REPLACE FUNCTION geometry_ge(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'lwgeom_ge'
349
	LANGUAGE 'c' IMMUTABLE STRICT;
350 351 352 353

CREATE OR REPLACE FUNCTION geometry_eq(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'lwgeom_eq'
354
	LANGUAGE 'c' IMMUTABLE STRICT;
355 356 357 358

CREATE OR REPLACE FUNCTION geometry_cmp(geom1 geometry, geom2 geometry)
	RETURNS integer
	AS 'MODULE_PATHNAME', 'lwgeom_cmp'
359
	LANGUAGE 'c' IMMUTABLE STRICT;
360 361 362 363 364

--
-- Sorting operators for Btree
--

365
-- Availability: 0.9.0
366 367 368 369 370 371
CREATE OPERATOR < (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_lt,
	COMMUTATOR = '>', NEGATOR = '>=',
	RESTRICT = contsel, JOIN = contjoinsel
);

372
-- Availability: 0.9.0
373 374 375 376 377 378
CREATE OPERATOR <= (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_le,
	COMMUTATOR = '>=', NEGATOR = '>',
	RESTRICT = contsel, JOIN = contjoinsel
);

379
-- Availability: 0.9.0
380 381 382 383 384 385
CREATE OPERATOR = (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_eq,
	COMMUTATOR = '=', -- we might implement a faster negator here
	RESTRICT = contsel, JOIN = contjoinsel
);

386
-- Availability: 0.9.0
387 388 389 390 391
CREATE OPERATOR >= (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_ge,
	COMMUTATOR = '<=', NEGATOR = '<',
	RESTRICT = contsel, JOIN = contjoinsel
);
392 393

-- Availability: 0.9.0
394 395 396 397 398 399
CREATE OPERATOR > (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_gt,
	COMMUTATOR = '<', NEGATOR = '<=',
	RESTRICT = contsel, JOIN = contjoinsel
);

400
-- Availability: 0.9.0
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
CREATE OPERATOR CLASS btree_geometry_ops
	DEFAULT FOR TYPE geometry USING btree AS
	OPERATOR	1	< ,
	OPERATOR	2	<= ,
	OPERATOR	3	= ,
	OPERATOR	4	>= ,
	OPERATOR	5	> ,
	FUNCTION	1	geometry_cmp (geom1 geometry, geom2 geometry);


-----------------------------------------------------------------------------
-- GiST 2D GEOMETRY-over-GSERIALIZED INDEX
-----------------------------------------------------------------------------

-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- GiST Support Functions
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_distance_2d(internal,geometry,int4) 
	RETURNS float8 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_distance_2d'
423
	LANGUAGE 'c';
424 425 426 427 428

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_consistent_2d(internal,geometry,int4) 
	RETURNS bool 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_consistent_2d'
429
	LANGUAGE 'c';
430 431 432 433 434

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_compress_2d(internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME','gserialized_gist_compress_2d'
435
	LANGUAGE 'c';
436 437 438 439 440

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_penalty_2d(internal,internal,internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_penalty_2d'
441
	LANGUAGE 'c';
442 443 444 445 446

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_picksplit_2d(internal, internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_picksplit_2d'
447
	LANGUAGE 'c';
448 449 450 451 452

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_union_2d(bytea, internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_union_2d'
453
	LANGUAGE 'c';
454 455 456 457 458

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_same_2d(geom1 geometry, geom2 geometry, internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_same_2d'
459
	LANGUAGE 'c';
460 461 462 463 464

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_decompress_2d(internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_decompress_2d'
465
	LANGUAGE 'c';
466

467 468 469 470

-----------------------------------------------------------------------------

-- Availability: 2.1.0
471 472 473
-- Given a table, column and query geometry, returns the estimate of what proportion
-- of the table would be returned by a query using the &&/&&& operators. The mode
-- changes whether the estimate is in x/y only or in all available dimensions.
474 475 476 477 478
CREATE OR REPLACE FUNCTION _postgis_selectivity(tbl regclass, att_name text, geom geometry, mode text default '2')
	RETURNS float8
	AS 'MODULE_PATHNAME', '_postgis_gserialized_sel'
	LANGUAGE 'c' STRICT;

479
-- Availability: 2.1.0
480 481 482 483
-- Given a two tables and columns, returns estimate of the proportion of rows
-- a &&/&&& join will return relative to the number of rows an unconstrained
-- table join would return. Mode flips result between evaluation in x/y only
-- and evaluation in all available dimensions.
484
CREATE OR REPLACE FUNCTION _postgis_join_selectivity(regclass, text, regclass, text, text default '2')
485
	RETURNS float8
486
	AS 'MODULE_PATHNAME', '_postgis_gserialized_joinsel'
487
	LANGUAGE 'c' STRICT;
488

489
-- Availability: 2.1.0
490 491 492
-- Given a table and a column, returns the statistics information stored by 
-- PostgreSQL, in a JSON text form. Mode determines whether the 2D statistics
-- or the ND statistics are returned.
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
CREATE OR REPLACE FUNCTION _postgis_stats(tbl regclass, att_name text, text default '2')
	RETURNS text
	AS 'MODULE_PATHNAME', '_postgis_gserialized_stats'
	LANGUAGE 'c' STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION gserialized_gist_sel_2d (internal, oid, internal, int4)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'gserialized_gist_sel_2d'
	LANGUAGE 'c';

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION gserialized_gist_sel_nd (internal, oid, internal, int4)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'gserialized_gist_sel_nd'
	LANGUAGE 'c';

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION gserialized_gist_joinsel_2d (internal, oid, internal, smallint)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'gserialized_gist_joinsel_2d'
	LANGUAGE 'c';

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION gserialized_gist_joinsel_nd (internal, oid, internal, smallint)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'gserialized_gist_joinsel_nd'
	LANGUAGE 'c';
521 522


523 524 525 526 527 528 529 530 531 532 533 534
-----------------------------------------------------------------------------
-- GEOMETRY Operators
-----------------------------------------------------------------------------

-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- 2D GEOMETRY Operators
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_overlaps(geom1 geometry, geom2 geometry) 
	RETURNS boolean 
	AS 'MODULE_PATHNAME' ,'gserialized_overlaps_2d'
535
	LANGUAGE 'c' IMMUTABLE STRICT;
536

537 538
-- Availability: 0.1.0
-- Changed: 2.0.0 use gserialized selectivity estimators
539 540
CREATE OPERATOR && (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps,
541 542 543
	COMMUTATOR = '&&',
 	RESTRICT = gserialized_gist_sel_2d, 
	JOIN = gserialized_gist_joinsel_2d	
544 545 546 547 548 549
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_same(geom1 geometry, geom2 geometry) 
	RETURNS boolean 
	AS 'MODULE_PATHNAME' ,'gserialized_same_2d'
550
	LANGUAGE 'c' IMMUTABLE STRICT;
551

552
-- Availability: 0.1.0
553 554 555 556 557
CREATE OPERATOR ~= (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_same,
	RESTRICT = contsel, JOIN = contjoinsel
);

558 559 560
-- As of 2.2.0 this no longer returns the centroid/centroid distance, it 
-- returns the actual distance, to support the 'recheck' functionality
-- enabled in the KNN operator
561 562 563
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_distance_centroid(geom1 geometry, geom2 geometry) 
	RETURNS float8 
564 565 566 567 568
#if POSTGIS_PGSQL_VERSION >= 95
  AS 'MODULE_PATHNAME' ,'distance'
#else
  AS 'MODULE_PATHNAME' ,'gserialized_distance_centroid_2d'
#endif
569
	LANGUAGE 'c' IMMUTABLE STRICT;
570 571 572 573

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_distance_box(geom1 geometry, geom2 geometry) 
	RETURNS float8 
574
  AS 'MODULE_PATHNAME' ,'gserialized_distance_box_2d'
575
	LANGUAGE 'c' IMMUTABLE STRICT;
576

577
-- Availability: 2.0.0
578 579 580 581 582
CREATE OPERATOR <-> (
    LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_distance_centroid,
    COMMUTATOR = '<->'
);

583
-- Availability: 2.0.0
584 585 586 587 588 589 590 591 592
CREATE OPERATOR <#> (
    LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_distance_box,
    COMMUTATOR = '<#>'
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_contains(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_contains_2d'
593
	LANGUAGE 'c' IMMUTABLE STRICT;
594 595 596 597 598

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_within(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_within_2d'
599
	LANGUAGE 'c' IMMUTABLE STRICT;
600

601
-- Availability: 0.1.0
602 603 604 605 606 607
CREATE OPERATOR @ (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_within,
	COMMUTATOR = '~',
	RESTRICT = contsel, JOIN = contjoinsel
);

608
-- Availability: 0.1.0
609 610 611 612 613 614 615 616 617 618
CREATE OPERATOR ~ (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_contains,
	COMMUTATOR = '@',
	RESTRICT = contsel, JOIN = contjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_left(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_left_2d'
619
	LANGUAGE 'c' IMMUTABLE STRICT;
620

621
-- Availability: 0.1.0
622 623 624 625 626 627 628 629 630 631
CREATE OPERATOR << (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_left,
	COMMUTATOR = '>>',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_overleft(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_overleft_2d'
632
	LANGUAGE 'c' IMMUTABLE STRICT;
633

634
-- Availability: 0.1.0
635 636 637 638 639 640 641 642 643 644
CREATE OPERATOR &< (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overleft,
	COMMUTATOR = '&>',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_below(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_below_2d'
645
	LANGUAGE 'c' IMMUTABLE STRICT;
646

647
-- Availability: 0.1.0
648 649 650 651 652 653 654 655 656 657
CREATE OPERATOR <<| (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_below,
	COMMUTATOR = '|>>',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_overbelow(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_overbelow_2d'
658
	LANGUAGE 'c' IMMUTABLE STRICT;
659

660
-- Availability: 0.1.0
661 662 663 664 665 666 667 668 669 670
CREATE OPERATOR &<| (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overbelow,
	COMMUTATOR = '|&>',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_overright(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_overright_2d'
671
	LANGUAGE 'c' IMMUTABLE STRICT;
672

673
-- Availability: 0.1.0
674 675 676 677 678 679 680 681 682 683
CREATE OPERATOR &> (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overright,
	COMMUTATOR = '&<',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_right(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_right_2d'
684
	LANGUAGE 'c' IMMUTABLE STRICT;
685

686
-- Availability: 0.1.0
687 688 689 690 691 692 693 694 695 696
CREATE OPERATOR >> (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_right,
	COMMUTATOR = '<<',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_overabove(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_overabove_2d'
697
	LANGUAGE 'c' IMMUTABLE STRICT;
698

699
-- Availability: 0.1.0
700 701 702 703 704 705 706 707 708 709
CREATE OPERATOR |&> (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overabove,
	COMMUTATOR = '&<|',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_above(geom1 geometry, geom2 geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'gserialized_above_2d'
710
	LANGUAGE 'c' IMMUTABLE STRICT;
711

712
-- Availability: 0.1.0
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760
CREATE OPERATOR |>> (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_above,
	COMMUTATOR = '<<|',
	RESTRICT = positionsel, JOIN = positionjoinsel
);

-- Availability: 2.0.0
CREATE OPERATOR CLASS gist_geometry_ops_2d
	DEFAULT FOR TYPE geometry USING GIST AS
	STORAGE box2df,
	OPERATOR        1        <<  ,
	OPERATOR        2        &<	 ,
	OPERATOR        3        &&  ,
	OPERATOR        4        &>	 ,
	OPERATOR        5        >>	 ,
	OPERATOR        6        ~=	 ,
	OPERATOR        7        ~	 ,
	OPERATOR        8        @	 ,
	OPERATOR        9        &<| ,
	OPERATOR        10       <<| ,
	OPERATOR        11       |>> ,
	OPERATOR        12       |&> ,
#if POSTGIS_PGSQL_VERSION >= 91
	OPERATOR        13       <-> FOR ORDER BY pg_catalog.float_ops,
	OPERATOR        14       <#> FOR ORDER BY pg_catalog.float_ops,
	FUNCTION        8        geometry_gist_distance_2d (internal, geometry, int4),
#endif
	FUNCTION        1        geometry_gist_consistent_2d (internal, geometry, int4),
	FUNCTION        2        geometry_gist_union_2d (bytea, internal),
	FUNCTION        3        geometry_gist_compress_2d (internal),
	FUNCTION        4        geometry_gist_decompress_2d (internal),
	FUNCTION        5        geometry_gist_penalty_2d (internal, internal, internal),
	FUNCTION        6        geometry_gist_picksplit_2d (internal, internal),
	FUNCTION        7        geometry_gist_same_2d (geom1 geometry, geom2 geometry, internal);


-----------------------------------------------------------------------------
-- GiST ND GEOMETRY-over-GSERIALIZED
-----------------------------------------------------------------------------

-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- GiST Support Functions
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_consistent_nd(internal,geometry,int4) 
	RETURNS bool 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_consistent'
761
	LANGUAGE 'c';
762 763 764 765 766

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_compress_nd(internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME','gserialized_gist_compress'
767
	LANGUAGE 'c';
768 769 770 771 772

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_penalty_nd(internal,internal,internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_penalty'
773
	LANGUAGE 'c';
774 775 776 777 778

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_picksplit_nd(internal, internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_picksplit'
779
	LANGUAGE 'c';
780 781 782 783 784

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_union_nd(bytea, internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_union'
785
	LANGUAGE 'c';
786 787 788 789 790

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_same_nd(geometry, geometry, internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_same'
791
	LANGUAGE 'c';
792 793 794 795 796

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_gist_decompress_nd(internal) 
	RETURNS internal 
	AS 'MODULE_PATHNAME' ,'gserialized_gist_decompress'
797
	LANGUAGE 'c';
798 799 800 801 802 803 804 805 806 807


-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
-- N-D GEOMETRY Operators
-- ---------- ---------- ---------- ---------- ---------- ---------- ----------

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION geometry_overlaps_nd(geometry, geometry) 
	RETURNS boolean 
	AS 'MODULE_PATHNAME' ,'gserialized_overlaps'
808
	LANGUAGE 'c' IMMUTABLE STRICT;
809 810 811 812

-- Availability: 2.0.0
CREATE OPERATOR &&& (
	LEFTARG = geometry, RIGHTARG = geometry, PROCEDURE = geometry_overlaps_nd,
813 814 815
	COMMUTATOR = '&&&',
	RESTRICT = gserialized_gist_sel_nd,
	JOIN = gserialized_gist_joinsel_nd	
816 817
);

818 819 820
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION geometry_distance_centroid_nd(geometry,geometry)
	RETURNS float8
821
	AS 'MODULE_PATHNAME', 'gserialized_distance_nd'
822 823 824 825 826 827 828 829 830
	LANGUAGE 'c' IMMUTABLE STRICT;

-- Availability: 2.2.0
CREATE OPERATOR <<->> (
    LEFTARG = geometry, RIGHTARG = geometry,
    PROCEDURE = geometry_distance_centroid_nd,
    COMMUTATOR = '<<->>'
);

831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848
--
-- This is for use with |=| operator, which does not directly use
-- ST_DistanceCPA just in case it'll ever need to change behavior
-- (operators definition cannot be altered)
--
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION geometry_distance_cpa(geometry, geometry)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'ST_DistanceCPA'
	LANGUAGE 'c' IMMUTABLE STRICT;

-- Availability: 2.2.0
CREATE OPERATOR |=| (
    LEFTARG = geometry, RIGHTARG = geometry,
    PROCEDURE = geometry_distance_cpa,
    COMMUTATOR = '|=|'
);

849 850 851 852 853 854 855
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION geometry_gist_distance_nd(internal,geometry,int4)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'gserialized_gist_distance'
	LANGUAGE 'c';


856 857 858 859 860 861 862 863
-- Availability: 2.0.0
CREATE OPERATOR CLASS gist_geometry_ops_nd
	FOR TYPE geometry USING GIST AS
	STORAGE 	gidx,
	OPERATOR        3        &&&	,
--	OPERATOR        6        ~=	,
--	OPERATOR        7        ~	,
--	OPERATOR        8        @	,
864 865 866
#if POSTGIS_PGSQL_VERSION >= 91
	-- Availability: 2.2.0
	OPERATOR        13       <<->> FOR ORDER BY pg_catalog.float_ops,
867 868 869 870
#if POSTGIS_PGSQL_VERSION >= 95
	-- Availability: 2.2.0
	OPERATOR        20       |=| FOR ORDER BY pg_catalog.float_ops,
#endif
871 872 873
	-- Availability: 2.2.0
	FUNCTION        8        geometry_gist_distance_nd (internal, geometry, int4),
#endif
874 875 876 877 878 879 880 881 882
	FUNCTION        1        geometry_gist_consistent_nd (internal, geometry, int4),
	FUNCTION        2        geometry_gist_union_nd (bytea, internal),
	FUNCTION        3        geometry_gist_compress_nd (internal),
	FUNCTION        4        geometry_gist_decompress_nd (internal),
	FUNCTION        5        geometry_gist_penalty_nd (internal, internal, internal),
	FUNCTION        6        geometry_gist_picksplit_nd (internal, internal),
	FUNCTION        7        geometry_gist_same_nd (geometry, geometry, internal);


883 884
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_ShiftLongitude(geometry)
885 886
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_longitude_shift'
887
	LANGUAGE 'c' IMMUTABLE STRICT;
888

889 890 891 892 893 894 895 896 897
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_Shift_Longitude(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Shift_Longitude', 'ST_ShiftLongitude', '2.2.0');
    SELECT ST_ShiftLongitude($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

898 899 900 901 902 903 904 905
-----------------------------------------------------------------------------
--  BOX3D FUNCTIONS
-----------------------------------------------------------------------------

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_XMin(box3d)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','BOX3D_xmin'
906
	LANGUAGE 'c' IMMUTABLE STRICT;
907 908 909 910 911

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_YMin(box3d)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','BOX3D_ymin'
912
	LANGUAGE 'c' IMMUTABLE STRICT;
913 914 915 916 917

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_ZMin(box3d)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','BOX3D_zmin'
918
	LANGUAGE 'c' IMMUTABLE STRICT;
919 920 921 922 923

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_XMax(box3d)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','BOX3D_xmax'
924
	LANGUAGE 'c' IMMUTABLE STRICT;
925 926 927 928 929

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_YMax(box3d)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','BOX3D_ymax'
930
	LANGUAGE 'c' IMMUTABLE STRICT;
931 932 933 934 935

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_ZMax(box3d)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','BOX3D_zmax'
936
	LANGUAGE 'c' IMMUTABLE STRICT;
937 938 939 940 941 942 943 944 945

-----------------------------------------------------------------------------
--  BOX2D FUNCTIONS
-----------------------------------------------------------------------------

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_expand(box2d,float8)
	RETURNS box2d
	AS 'MODULE_PATHNAME', 'BOX2D_expand'
946
	LANGUAGE 'c' IMMUTABLE STRICT;
947 948 949 950

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION postgis_getbbox(geometry)
	RETURNS box2d
951
	AS 'MODULE_PATHNAME','LWGEOM_to_BOX2DF'
952
	LANGUAGE 'c' IMMUTABLE STRICT;
953 954 955 956 957

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_MakeBox2d(geom1 geometry, geom2 geometry)
	RETURNS box2d
	AS 'MODULE_PATHNAME', 'BOX2D_construct'
958
	LANGUAGE 'c' IMMUTABLE STRICT;
959 960

-----------------------------------------------------------------------
961
-- ST_ESTIMATED_EXTENT( <schema name>, <table name>, <column name> )
962 963
-----------------------------------------------------------------------

964 965
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_EstimatedExtent(text,text,text) RETURNS box2d AS
966
	'MODULE_PATHNAME', 'gserialized_estimated_extent'
967 968
	LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;

969
-- Availability: 1.2.2
970
-- Deprecation in 2.1.0 
971 972
CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text,text) RETURNS box2d AS
  $$ SELECT _postgis_deprecate('ST_Estimated_Extent', 'ST_EstimatedExtent', '2.1.0');
973 974 975
    -- We use security invoker instead of security definer 
    -- to prevent malicious injection of a different same named function
    SELECT ST_EstimatedExtent($1, $2, $3);
976
  $$
977
	LANGUAGE 'sql' IMMUTABLE STRICT SECURITY INVOKER;
978 979 980 981

-----------------------------------------------------------------------
-- ST_ESTIMATED_EXTENT( <table name>, <column name> )
-----------------------------------------------------------------------
982

983 984
-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_EstimatedExtent(text,text) RETURNS box2d AS
985
	'MODULE_PATHNAME', 'gserialized_estimated_extent'
986 987
	LANGUAGE 'c' IMMUTABLE STRICT SECURITY DEFINER;

988 989 990 991
-- Availability: 1.2.2
-- Deprecation in 2.1.0 
CREATE OR REPLACE FUNCTION ST_estimated_extent(text,text) RETURNS box2d AS
  $$ SELECT _postgis_deprecate('ST_Estimated_Extent', 'ST_EstimatedExtent', '2.1.0');
992 993 994 995
    -- We use security invoker instead of security definer 
    -- to prevent malicious injection of a same named different function
    -- that would be run under elevated permissions
    SELECT ST_EstimatedExtent($1, $2);
996
  $$
997
	LANGUAGE 'sql' IMMUTABLE STRICT SECURITY INVOKER;
998

999 1000 1001
-----------------------------------------------------------------------
-- FIND_EXTENT( <schema name>, <table name>, <column name> )
-----------------------------------------------------------------------
1002 1003 1004

-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_FindExtent(text,text,text) RETURNS box2d AS
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018
$$
DECLARE
	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;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;

1019 1020 1021 1022 1023 1024 1025
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_find_extent(text,text,text) RETURNS box2d AS
  $$ SELECT _postgis_deprecate('ST_Find_Extent', 'ST_FindExtent', '2.2.0');
    SELECT ST_FindExtent($1,$2,$3);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;
1026 1027 1028 1029

-----------------------------------------------------------------------
-- FIND_EXTENT( <table name>, <column name> )
-----------------------------------------------------------------------
1030 1031 1032

-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_FindExtent(text,text) RETURNS box2d AS
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046
$$
DECLARE
	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;
END;
$$
LANGUAGE 'plpgsql' IMMUTABLE STRICT;

1047 1048 1049 1050 1051 1052 1053
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_find_extent(text,text) RETURNS box2d AS
  $$ SELECT _postgis_deprecate('ST_Find_Extent', 'ST_FindExtent', '2.2.0');
    SELECT ST_FindExtent($1,$2);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;
1054 1055 1056 1057 1058 1059 1060 1061

-------------------------------------------
-- other lwgeom functions
-------------------------------------------
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION postgis_addbbox(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME','LWGEOM_addBBOX'
1062
	LANGUAGE 'c' IMMUTABLE STRICT;
1063 1064 1065 1066 1067

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION postgis_dropbbox(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME','LWGEOM_dropBBOX'
1068
	LANGUAGE 'c' IMMUTABLE STRICT;
1069 1070 1071 1072 1073

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION postgis_hasbbox(geometry)
	RETURNS bool
	AS 'MODULE_PATHNAME', 'LWGEOM_hasBBOX'
1074
	LANGUAGE 'c' IMMUTABLE STRICT;
1075 1076 1077 1078 1079


------------------------------------------------------------------------
-- DEBUG
------------------------------------------------------------------------
1080 1081 1082

-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_MemSize(geometry)
1083 1084
	RETURNS int4
	AS 'MODULE_PATHNAME', 'LWGEOM_mem_size'
1085
	LANGUAGE 'c' IMMUTABLE STRICT;
1086

1087 1088 1089 1090 1091 1092 1093 1094 1095
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_mem_size(geometry)
	RETURNS int4 AS
  $$ SELECT _postgis_deprecate('ST_Mem_Size', 'ST_MemSize', '2.2.0');
    SELECT ST_MemSize($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT SECURITY INVOKER;

1096 1097 1098 1099
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_summary(geometry)
	RETURNS text
	AS 'MODULE_PATHNAME', 'LWGEOM_summary'
1100
	LANGUAGE 'c' IMMUTABLE STRICT;
1101 1102 1103 1104 1105

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Npoints(geometry)
	RETURNS int4
	AS 'MODULE_PATHNAME', 'LWGEOM_npoints'
1106
	LANGUAGE 'c' IMMUTABLE STRICT;
1107 1108 1109 1110 1111

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_nrings(geometry)
	RETURNS int4
	AS 'MODULE_PATHNAME', 'LWGEOM_nrings'
1112
	LANGUAGE 'c' IMMUTABLE STRICT;
1113 1114 1115 1116 1117 1118 1119 1120

------------------------------------------------------------------------
-- Measures
------------------------------------------------------------------------
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION ST_3DLength(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_length_linestring'
1121
	LANGUAGE 'c' IMMUTABLE STRICT;
1122 1123 1124 1125 1126

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Length2d(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_length2d_linestring'
1127
	LANGUAGE 'c' IMMUTABLE STRICT;
1128 1129 1130 1131 1132

-- PostGIS equivalent function: length2d(geometry)
CREATE OR REPLACE FUNCTION ST_Length(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_length2d_linestring'
1133
	LANGUAGE 'c' IMMUTABLE STRICT;
1134

1135 1136
-- Availability in 2.2.0
CREATE OR REPLACE FUNCTION ST_LengthSpheroid(geometry, spheroid)
1137 1138
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','LWGEOM_length_ellipsoid_linestring'
1139
	LANGUAGE 'c' IMMUTABLE STRICT
1140 1141
	COST 100;

1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154
-- this is a fake (for back-compatibility)
-- uses 3d if 3d is available, 2d otherwise
-- Availability: 2.0.0
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_3DLength_spheroid(geometry, spheroid)
	RETURNS FLOAT8 AS
  $$ SELECT _postgis_deprecate('ST_3DLength_Spheroid', 'ST_LengthSpheroid', '2.2.0');
    SELECT ST_LengthSpheroid($1,$2);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT
	COST 100;


1155 1156 1157 1158 1159 1160 1161 1162 1163
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_length_spheroid(geometry, spheroid)
	RETURNS FLOAT8 AS
  $$ SELECT _postgis_deprecate('ST_Length_Spheroid', 'ST_LengthSpheroid', '2.2.0');
    SELECT ST_LengthSpheroid($1,$2);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

1164 1165
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_Length2DSpheroid(geometry, spheroid)
1166 1167
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','LWGEOM_length2d_ellipsoid'
1168
	LANGUAGE 'c' IMMUTABLE STRICT
1169 1170
	COST 100;

1171 1172 1173 1174 1175 1176 1177 1178 1179
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_length2d_spheroid(geometry, spheroid)
	RETURNS FLOAT8 AS
  $$ SELECT _postgis_deprecate('ST_Length2D_Spheroid', 'ST_Length2DSpheroid', '2.2.0');
    SELECT ST_Length2DSpheroid($1,$2);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

1180 1181 1182 1183
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION ST_3DPerimeter(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_perimeter_poly'
1184
	LANGUAGE 'c' IMMUTABLE STRICT;
1185 1186 1187 1188 1189

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_perimeter2d(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_perimeter2d_poly'
1190
	LANGUAGE 'c' IMMUTABLE STRICT;
1191 1192 1193 1194 1195

-- PostGIS equivalent function: perimeter2d(geometry)
CREATE OR REPLACE FUNCTION ST_Perimeter(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_perimeter2d_poly'
1196
	LANGUAGE 'c' IMMUTABLE STRICT;
1197 1198 1199 1200 1201 1202

-- Availability: 1.2.2
-- Deprecation in 1.3.4
CREATE OR REPLACE FUNCTION ST_area2d(geometry)
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME', 'LWGEOM_area_polygon'
1203
	LANGUAGE 'c' IMMUTABLE STRICT;
1204 1205 1206 1207

-- PostGIS equivalent function: area(geometry)
CREATE OR REPLACE FUNCTION ST_Area(geometry)
	RETURNS FLOAT8
1208
	AS 'MODULE_PATHNAME','area'
1209
	LANGUAGE 'c' IMMUTABLE STRICT;
1210

1211 1212
-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION ST_DistanceSpheroid(geom1 geometry, geom2 geometry,spheroid)
1213 1214
	RETURNS FLOAT8
	AS 'MODULE_PATHNAME','LWGEOM_distance_ellipsoid'
1215
	LANGUAGE 'c' IMMUTABLE STRICT
1216 1217
	COST 100;

1218 1219 1220 1221 1222 1223 1224 1225 1226
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_distance_spheroid(geom1 geometry, geom2 geometry,spheroid)
	RETURNS FLOAT8 AS
  $$ SELECT _postgis_deprecate('ST_Distance_Spheroid', 'ST_DistanceSpheroid', '2.2.0');
    SELECT ST_DistanceSpheroid($1,$2,$3);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

1227 1228 1229 1230 1231
-- Minimum distance. 2d only.

-- PostGIS equivalent function: distance(geom1 geometry, geom2 geometry)
CREATE OR REPLACE FUNCTION ST_Distance(geom1 geometry, geom2 geometry)
	RETURNS float8
1232
	AS 'MODULE_PATHNAME', 'distance'
1233
	LANGUAGE 'c' IMMUTABLE STRICT
1234 1235
	COST 100;

1236 1237
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_PointInsideCircle(geometry,float8,float8,float8)
1238 1239
	RETURNS bool
	AS 'MODULE_PATHNAME', 'LWGEOM_inside_circle_point'
1240
	LANGUAGE 'c' IMMUTABLE STRICT;
1241

1242 1243 1244 1245 1246 1247 1248 1249 1250
-- Availability: 1.2.2
-- Deprecation in 2.2.0
CREATE OR REPLACE FUNCTION ST_point_inside_circle(geometry,float8,float8,float8)
	RETURNS bool AS
  $$ SELECT _postgis_deprecate('ST_Point_Inside_Circle', 'ST_PointInsideCircle', '2.2.0');
    SELECT ST_PointInsideCircle($1,$2,$3,$4);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

1251 1252 1253 1254
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_azimuth(geom1 geometry, geom2 geometry)
	RETURNS float8
	AS 'MODULE_PATHNAME', 'LWGEOM_azimuth'
1255
	LANGUAGE 'c' IMMUTABLE STRICT;
1256 1257 1258 1259

------------------------------------------------------------------------
-- MISC
------------------------------------------------------------------------
1260 1261 1262

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Force2D(geometry)
1263 1264
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_2d'
1265
	LANGUAGE 'c' IMMUTABLE STRICT;
1266 1267

-- Availability: 1.2.2
1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
-- Deprecation in 2.1.0
CREATE OR REPLACE FUNCTION ST_force_2d(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Force_2d', 'ST_Force2D', '2.1.0');
    SELECT ST_Force2D($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Force3DZ(geometry)
1278 1279
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_3dz'
1280
	LANGUAGE 'c' IMMUTABLE STRICT;
1281 1282

-- Availability: 1.2.2
1283 1284 1285 1286 1287 1288 1289 1290 1291 1292
-- Deprecation in 2.1.0
CREATE OR REPLACE FUNCTION ST_force_3dz(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Force_3dz', 'ST_Force3DZ', '2.1.0');
    SELECT ST_Force3DZ($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Force3D(geometry)
1293 1294
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_3dz'
1295
	LANGUAGE 'c' IMMUTABLE STRICT;
1296 1297

-- Availability: 1.2.2
1298 1299 1300 1301 1302 1303 1304 1305 1306 1307
-- Deprecation in 2.1.0
CREATE OR REPLACE FUNCTION ST_force_3d(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Force_3d', 'ST_Force3D', '2.1.0');
    SELECT ST_Force3D($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Force3DM(geometry)
1308 1309
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_3dm'
1310
	LANGUAGE 'c' IMMUTABLE STRICT;
1311 1312

-- Availability: 1.2.2
1313 1314 1315 1316 1317 1318 1319 1320 1321 1322
-- Deprecation in 2.1.0
CREATE OR REPLACE FUNCTION ST_force_3dm(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Force_3dm', 'ST_Force3DM', '2.1.0');
    SELECT ST_Force3DM($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_Force4D(geometry)
1323 1324
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_4d'
1325
	LANGUAGE 'c' IMMUTABLE STRICT;
1326 1327

-- Availability: 1.2.2
1328 1329 1330 1331 1332 1333 1334 1335 1336 1337
-- Deprecation in 2.1.0
CREATE OR REPLACE FUNCTION ST_force_4d(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Force_4d', 'ST_Force4D', '2.1.0');
    SELECT ST_Force4D($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_ForceCollection(geometry)
1338 1339
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_collection'
1340
	LANGUAGE 'c' IMMUTABLE STRICT;
1341

1342 1343 1344 1345 1346 1347 1348 1349 1350
-- Availability: 1.2.2
-- Deprecation in 2.1.0
CREATE OR REPLACE FUNCTION ST_force_collection(geometry)
	RETURNS geometry AS
  $$ SELECT _postgis_deprecate('ST_Force_Collection', 'ST_ForceCollection', '2.1.0');
    SELECT ST_ForceCollection($1);
  $$
	LANGUAGE 'sql' IMMUTABLE STRICT;

1351 1352 1353 1354
-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION ST_CollectionExtract(geometry, integer)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'ST_CollectionExtract'
1355
	LANGUAGE 'c' IMMUTABLE STRICT;
1356 1357 1358 1359 1360

-- Availability: 2.0.0
CREATE OR REPLACE FUNCTION ST_CollectionHomogenize(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'ST_CollectionHomogenize'
1361
	LANGUAGE 'c' IMMUTABLE STRICT;
1362 1363 1364 1365 1366

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Multi(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_multi'
1367
	LANGUAGE 'c' IMMUTABLE STRICT;
1368

1369 1370 1371 1372 1373 1374
-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_ForceCurve(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_curve'
	LANGUAGE 'c' IMMUTABLE STRICT;

1375
-- Availability: 2.1.0
1376
CREATE OR REPLACE FUNCTION ST_ForceSFS(geometry)
1377 1378
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_sfs'
1379 1380 1381 1382 1383 1384
	LANGUAGE 'c' IMMUTABLE STRICT;

-- Availability: 2.1.0
CREATE OR REPLACE FUNCTION ST_ForceSFS(geometry, version text)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_sfs'
1385 1386
	LANGUAGE 'c' IMMUTABLE STRICT;

1387 1388 1389 1390
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Expand(box3d,float8)
	RETURNS box3d
	AS 'MODULE_PATHNAME', 'BOX3D_expand'
1391
	LANGUAGE 'c' IMMUTABLE STRICT;
1392 1393 1394 1395 1396

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Expand(geometry,float8)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_expand'
1397
	LANGUAGE 'c' IMMUTABLE STRICT;
1398 1399 1400 1401 1402

-- PostGIS equivalent function: envelope(geometry)
CREATE OR REPLACE FUNCTION ST_Envelope(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_envelope'
1403
	LANGUAGE 'c' IMMUTABLE STRICT;
1404 1405 1406 1407 1408 1409

-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_BoundingDiagonal(geom geometry, fits boolean DEFAULT false)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'ST_BoundingDiagonal'
	LANGUAGE 'c' IMMUTABLE STRICT;
1410 1411 1412 1413 1414

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_Reverse(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_reverse'
1415
	LANGUAGE 'c' IMMUTABLE STRICT;
1416 1417 1418 1419 1420

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_ForceRHR(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_force_clockwise_poly'
1421
	LANGUAGE 'c' IMMUTABLE STRICT;
1422 1423 1424 1425 1426

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION postgis_noop(geometry)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_noop'
1427
	LANGUAGE 'c' VOLATILE STRICT;
1428 1429 1430 1431 1432
	
-- Deprecation in 1.5.0
CREATE OR REPLACE FUNCTION ST_zmflag(geometry)
	RETURNS smallint
	AS 'MODULE_PATHNAME', 'LWGEOM_zmflag'
1433
	LANGUAGE 'c' IMMUTABLE STRICT;
1434 1435 1436 1437 1438

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_NDims(geometry)
	RETURNS smallint
	AS 'MODULE_PATHNAME', 'LWGEOM_ndims'
1439
	LANGUAGE 'c' IMMUTABLE STRICT;
1440 1441 1442 1443 1444

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_AsEWKT(geometry)
	RETURNS TEXT
	AS 'MODULE_PATHNAME','LWGEOM_asEWKT'
1445
	LANGUAGE 'c' IMMUTABLE STRICT;
1446
	
1447
-- Availability: 2.2.0
1448
CREATE OR REPLACE FUNCTION ST_AsTWKB(geom geometry, prec int4 default NULL, prec_z int4 default NULL, prec_m int4 default NULL, with_sizes boolean default NULL, with_boxes boolean default NULL)
1449 1450
	RETURNS bytea
	AS 'MODULE_PATHNAME','TWKBFromLWGEOM'
1451
	LANGUAGE 'c' IMMUTABLE;
1452 1453 1454 1455 1456 1457 1458

-- Availability: 2.2.0
CREATE OR REPLACE FUNCTION ST_AsTWKB(geom geometry[], ids bigint[], prec int4 default NULL, prec_z int4 default NULL, prec_m int4 default NULL, with_sizes boolean default NULL, with_boxes boolean default NULL)
	RETURNS bytea
	AS 'MODULE_PATHNAME','TWKBFromLWGEOMArray'
	LANGUAGE 'c' IMMUTABLE;

1459 1460 1461 1462
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_AsEWKB(geometry)
	RETURNS BYTEA
	AS 'MODULE_PATHNAME','WKBFromLWGEOM'
1463
	LANGUAGE 'c' IMMUTABLE STRICT;
1464 1465 1466 1467 1468

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_AsHEXEWKB(geometry)
	RETURNS TEXT
	AS 'MODULE_PATHNAME','LWGEOM_asHEXEWKB'
1469
	LANGUAGE 'c' IMMUTABLE STRICT;
1470 1471 1472 1473 1474

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_AsHEXEWKB(geometry, text)
	RETURNS TEXT
	AS 'MODULE_PATHNAME','LWGEOM_asHEXEWKB'
1475
	LANGUAGE 'c' IMMUTABLE STRICT;
1476 1477 1478 1479 1480

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_AsEWKB(geometry,text)
	RETURNS bytea
	AS 'MODULE_PATHNAME','WKBFromLWGEOM'
1481
	LANGUAGE 'c' IMMUTABLE STRICT;
1482 1483

-- Availability: 2.0.0
1484
CREATE OR REPLACE FUNCTION ST_AsLatLonText(geom geometry, tmpl text DEFAULT '')
1485 1486
	RETURNS text
	AS 'MODULE_PATHNAME','LWGEOM_to_latlon'
1487
	LANGUAGE 'c' IMMUTABLE STRICT;
1488 1489 1490 1491

-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromEWKB(bytea)
	RETURNS geometry
1492
	AS 'MODULE_PATHNAME','LWGEOMFromEWKB'
1493
	LANGUAGE 'c' IMMUTABLE STRICT;
1494 1495 1496 1497

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_GeomFromEWKB(bytea)
	RETURNS geometry
1498
	AS 'MODULE_PATHNAME','LWGEOMFromEWKB'
1499
	LANGUAGE 'c' IMMUTABLE STRICT;
1500

Nicklas Avén's avatar
Nicklas Avén committed
1501 1502 1503 1504 1505 1506
-- Availability: 2.2
CREATE OR REPLACE FUNCTION ST_GeomFromTWKB(bytea)
	RETURNS geometry
	AS 'MODULE_PATHNAME','LWGEOMFromTWKB'
	LANGUAGE 'c' IMMUTABLE STRICT;

1507 1508 1509 1510
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION GeomFromEWKT(text)
	RETURNS geometry
	AS 'MODULE_PATHNAME','parse_WKT_lwgeom'
1511
	LANGUAGE 'c' IMMUTABLE STRICT;
1512 1513 1514 1515 1516

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_GeomFromEWKT(text)
	RETURNS geometry
	AS 'MODULE_PATHNAME','parse_WKT_lwgeom'
1517
	LANGUAGE 'c' IMMUTABLE STRICT;
1518 1519 1520 1521 1522

-- Availability: 1.5.0
CREATE OR REPLACE FUNCTION postgis_cache_bbox()
	RETURNS trigger
	AS 'MODULE_PATHNAME', 'cache_bbox'
1523
	LANGUAGE 'c';
1524 1525 1526 1527 1528 1529 1530 1531 1532

------------------------------------------------------------------------
-- CONSTRUCTORS
------------------------------------------------------------------------

-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_MakePoint(float8, float8)
	RETURNS geometry
	AS 'MODULE_PATHNAME', 'LWGEOM_makepoint'