source: trunk/postgis/geography.sql.in.c @ 5065

Last change on this file since 5065 was 5065, checked in by pramsey, 7 years ago

Rename ST_GeographyFromBinary to ST_GeogFromWKB. Add ST_GeogFromText to ape the ISO geometry spec more closely. (#360)

  • Property svn:keywords set to Author Date Id Revision
File size: 23.2 KB
Line 
1---------------------------------------------------------------------------
2-- $Id: geography.sql.in.c 5065 2009-12-30 01:25:17Z pramsey $
3--
4-- PostGIS - Spatial Types for PostgreSQL
5-- Copyright 2009 Paul Ramsey <pramsey@cleverelephant.ca>
6--
7-- This is free software; you can redistribute and/or modify it under
8-- the terms of the GNU General Public Licence. See the COPYING file.
9--
10---------------------------------------------------------------------------
11
12-- Availability: 1.5.0
13CREATE OR REPLACE FUNCTION geography_typmod_in(cstring[])
14        RETURNS integer
15        AS 'MODULE_PATHNAME','geography_typmod_in'
16        LANGUAGE 'C' IMMUTABLE STRICT; 
17
18-- Availability: 1.5.0
19CREATE OR REPLACE FUNCTION geography_typmod_out(integer)
20        RETURNS cstring
21        AS 'MODULE_PATHNAME','geography_typmod_out'
22        LANGUAGE 'C' IMMUTABLE STRICT; 
23       
24-- Availability: 1.5.0
25CREATE OR REPLACE FUNCTION geography_in(cstring, oid, integer)
26        RETURNS geography
27        AS 'MODULE_PATHNAME','geography_in'
28        LANGUAGE 'C' IMMUTABLE STRICT; 
29
30-- Availability: 1.5.0
31CREATE OR REPLACE FUNCTION geography_out(geography)
32        RETURNS cstring
33        AS 'MODULE_PATHNAME','geography_out'
34        LANGUAGE 'C' IMMUTABLE STRICT; 
35
36-- Availability: 1.5.0
37CREATE OR REPLACE FUNCTION geography_analyze(internal)
38        RETURNS bool
39        AS 'MODULE_PATHNAME','geography_analyze'
40        LANGUAGE 'C' VOLATILE STRICT; 
41
42-- Availability: 1.5.0
43CREATE TYPE geography (
44        internallength = variable,
45        input = geography_in,
46        output = geography_out,
47        typmod_in = geography_typmod_in,
48        typmod_out = geography_typmod_out,
49        analyze = geography_analyze,
50        storage = main,
51        alignment = double
52);
53
54--
55-- GIDX type is used by the GiST index bindings. 
56-- In/out functions are stubs, as all access should be internal.
57---
58-- Availability: 1.5.0
59CREATE OR REPLACE FUNCTION gidx_in(cstring)
60        RETURNS gidx
61        AS 'MODULE_PATHNAME','gidx_in'
62        LANGUAGE 'C' IMMUTABLE STRICT; 
63
64-- Availability: 1.5.0
65CREATE OR REPLACE FUNCTION gidx_out(gidx)
66        RETURNS cstring
67        AS 'MODULE_PATHNAME','gidx_out'
68        LANGUAGE 'C' IMMUTABLE STRICT; 
69
70-- Availability: 1.5.0
71CREATE TYPE gidx (
72        internallength = variable,
73        input = gidx_in,
74        output = gidx_out,
75        storage = plain,
76        alignment = double
77);
78
79
80-- Availability: 1.5.0
81CREATE OR REPLACE FUNCTION geography(geography, integer, boolean)
82        RETURNS geography
83        AS 'MODULE_PATHNAME','geography_enforce_typmod'
84        LANGUAGE 'C' IMMUTABLE STRICT; 
85
86-- Availability: 1.5.0
87CREATE CAST (geography AS geography) WITH FUNCTION geography(geography, integer, boolean) AS IMPLICIT;
88
89-- Availability: 1.5.0
90CREATE OR REPLACE FUNCTION ST_AsText(geography)
91        RETURNS text
92        AS 'MODULE_PATHNAME','geography_as_text'
93        LANGUAGE 'C' IMMUTABLE STRICT;
94       
95-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
96-- TODO Remove in 2.0
97CREATE OR REPLACE FUNCTION ST_AsText(text)
98        RETURNS text AS
99        $$ SELECT ST_AsText($1::geometry);  $$
100        LANGUAGE 'SQL' IMMUTABLE STRICT;
101
102-- Availability: 1.5.0
103CREATE OR REPLACE FUNCTION ST_GeographyFromText(text)
104        RETURNS geography
105        AS 'MODULE_PATHNAME','geography_from_text'
106        LANGUAGE 'C' IMMUTABLE STRICT;
107
108-- Availability: 1.5.0
109CREATE OR REPLACE FUNCTION ST_GeogFromText(text)
110        RETURNS geography
111        AS 'MODULE_PATHNAME','geography_from_text'
112        LANGUAGE 'C' IMMUTABLE STRICT;
113
114-- Availability: 1.5.0
115CREATE OR REPLACE FUNCTION ST_AsBinary(geography)
116        RETURNS bytea
117        AS 'MODULE_PATHNAME','geography_as_binary'
118        LANGUAGE 'C' IMMUTABLE STRICT;
119       
120-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
121-- TODO Remove in 2.0
122CREATE OR REPLACE FUNCTION ST_AsBinary(text)
123        RETURNS bytea AS
124        $$ SELECT ST_AsBinary($1::geometry);  $$
125        LANGUAGE 'SQL' IMMUTABLE STRICT;
126
127-- Availability: 1.5.0
128CREATE OR REPLACE FUNCTION ST_GeogFromWKB(bytea)
129        RETURNS geography
130        AS 'MODULE_PATHNAME','geography_from_binary'
131        LANGUAGE 'C' IMMUTABLE STRICT;
132
133-- Availability: 1.5.0
134CREATE OR REPLACE FUNCTION geography_typmod_dims(integer)
135        RETURNS integer
136        AS 'MODULE_PATHNAME','geography_typmod_dims'
137        LANGUAGE 'C' IMMUTABLE STRICT;
138
139-- Availability: 1.5.0
140CREATE OR REPLACE FUNCTION geography_typmod_srid(integer)
141        RETURNS integer
142        AS 'MODULE_PATHNAME','geography_typmod_srid'
143        LANGUAGE 'C' IMMUTABLE STRICT;
144
145-- Availability: 1.5.0
146CREATE OR REPLACE FUNCTION geography_typmod_type(integer)
147        RETURNS text
148        AS 'MODULE_PATHNAME','geography_typmod_type'
149        LANGUAGE 'C' IMMUTABLE STRICT;
150
151-- Availability: 1.5.0
152CREATE OR REPLACE VIEW geography_columns AS
153        SELECT
154                current_database() AS f_table_catalog, 
155                n.nspname AS f_table_schema, 
156                c.relname AS f_table_name, 
157                a.attname AS f_geography_column,
158                geography_typmod_dims(a.atttypmod) AS coord_dimension,
159                geography_typmod_srid(a.atttypmod) AS srid,
160                geography_typmod_type(a.atttypmod) AS type
161        FROM
162                pg_class c, 
163                pg_attribute a, 
164                pg_type t, 
165                pg_namespace n
166        WHERE c.relkind IN('r','v')
167        AND t.typname = 'geography'
168        AND a.attisdropped = false
169        AND a.atttypid = t.oid
170        AND a.attrelid = c.oid
171        AND c.relnamespace = n.oid;
172
173-- Availability: 1.5.0
174CREATE OR REPLACE FUNCTION geography(geometry)
175        RETURNS geography
176        AS 'MODULE_PATHNAME','geography_from_geometry'
177        LANGUAGE 'C' IMMUTABLE STRICT;
178
179-- Availability: 1.5.0
180CREATE CAST (geometry AS geography) WITH FUNCTION geography(geometry) AS IMPLICIT;
181
182-- Availability: 1.5.0
183CREATE OR REPLACE FUNCTION geometry(geography)
184        RETURNS geometry
185        AS 'MODULE_PATHNAME','geometry_from_geography'
186        LANGUAGE 'C' IMMUTABLE STRICT;
187
188-- Availability: 1.5.0
189CREATE CAST (geography AS geometry) WITH FUNCTION geometry(geography) ;
190
191-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
192-- GiST Support Functions
193-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
194
195-- Availability: 1.5.0
196CREATE OR REPLACE FUNCTION geography_gist_consistent(internal,geometry,int4) 
197        RETURNS bool
198        AS 'MODULE_PATHNAME' ,'geography_gist_consistent'
199        LANGUAGE 'C';
200
201-- Availability: 1.5.0
202CREATE OR REPLACE FUNCTION geography_gist_compress(internal) 
203        RETURNS internal
204        AS 'MODULE_PATHNAME','geography_gist_compress'
205        LANGUAGE 'C';
206
207-- Availability: 1.5.0
208CREATE OR REPLACE FUNCTION geography_gist_penalty(internal,internal,internal) 
209        RETURNS internal
210        AS 'MODULE_PATHNAME' ,'geography_gist_penalty'
211        LANGUAGE 'C';
212
213-- Availability: 1.5.0
214CREATE OR REPLACE FUNCTION geography_gist_picksplit(internal, internal) 
215        RETURNS internal
216        AS 'MODULE_PATHNAME' ,'geography_gist_picksplit'
217        LANGUAGE 'C';
218
219-- Availability: 1.5.0
220CREATE OR REPLACE FUNCTION geography_gist_union(bytea, internal) 
221        RETURNS internal
222        AS 'MODULE_PATHNAME' ,'geography_gist_union'
223        LANGUAGE 'C';
224
225-- Availability: 1.5.0
226CREATE OR REPLACE FUNCTION geography_gist_same(box2d, box2d, internal) 
227        RETURNS internal
228        AS 'MODULE_PATHNAME' ,'geography_gist_same'
229        LANGUAGE 'C';
230
231-- Availability: 1.5.0
232CREATE OR REPLACE FUNCTION geography_gist_decompress(internal) 
233        RETURNS internal
234        AS 'MODULE_PATHNAME' ,'geography_gist_decompress'
235        LANGUAGE 'C';
236
237-- Availability: 1.5.0
238CREATE OR REPLACE FUNCTION geography_gist_selectivity (internal, oid, internal, int4)
239        RETURNS float8
240        AS 'MODULE_PATHNAME', 'geography_gist_selectivity'
241        LANGUAGE 'C';
242
243-- Availability: 1.5.0
244CREATE OR REPLACE FUNCTION geography_gist_join_selectivity(internal, oid, internal, smallint)
245        RETURNS float8
246        AS 'MODULE_PATHNAME', 'geography_gist_join_selectivity'
247        LANGUAGE 'C';
248
249-- Availability: 1.5.0
250CREATE OR REPLACE FUNCTION geography_overlaps(geography, geography) 
251        RETURNS boolean
252        AS 'MODULE_PATHNAME' ,'geography_overlaps'
253        LANGUAGE 'C' IMMUTABLE STRICT;
254
255-- Availability: 1.5.0
256CREATE OPERATOR && (
257        LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_overlaps,
258        COMMUTATOR = '&&',
259        RESTRICT = geography_gist_selectivity, 
260        JOIN = geography_gist_join_selectivity
261);
262
263
264-- Availability: 1.5.0
265CREATE OPERATOR CLASS gist_geography_ops
266        DEFAULT FOR TYPE geography USING GIST AS
267        STORAGE         gidx,
268        OPERATOR        3        &&     ,
269--      OPERATOR        6        ~=     ,
270--      OPERATOR        7        ~      ,
271--      OPERATOR        8        @      ,
272        FUNCTION        1        geography_gist_consistent (internal, geometry, int4),
273        FUNCTION        2        geography_gist_union (bytea, internal),
274        FUNCTION        3        geography_gist_compress (internal),
275        FUNCTION        4        geography_gist_decompress (internal),
276        FUNCTION        5        geography_gist_penalty (internal, internal, internal),
277        FUNCTION        6        geography_gist_picksplit (internal, internal),
278        FUNCTION        7        geography_gist_same (box2d, box2d, internal);
279
280
281-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
282-- B-Tree Functions
283-- For sorting and grouping
284-- Availability: 1.5.0
285-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
286
287CREATE OR REPLACE FUNCTION geography_lt(geography, geography)
288        RETURNS bool
289        AS 'MODULE_PATHNAME', 'geography_lt'
290        LANGUAGE 'C' IMMUTABLE STRICT;
291
292CREATE OR REPLACE FUNCTION geography_le(geography, geography)
293        RETURNS bool
294        AS 'MODULE_PATHNAME', 'geography_le'
295        LANGUAGE 'C' IMMUTABLE STRICT;
296
297CREATE OR REPLACE FUNCTION geography_gt(geography, geography)
298        RETURNS bool
299        AS 'MODULE_PATHNAME', 'geography_gt'
300        LANGUAGE 'C' IMMUTABLE STRICT;
301
302CREATE OR REPLACE FUNCTION geography_ge(geography, geography)
303        RETURNS bool
304        AS 'MODULE_PATHNAME', 'geography_ge'
305        LANGUAGE 'C' IMMUTABLE STRICT;
306
307CREATE OR REPLACE FUNCTION geography_eq(geography, geography)
308        RETURNS bool
309        AS 'MODULE_PATHNAME', 'geography_eq'
310        LANGUAGE 'C' IMMUTABLE STRICT;
311
312CREATE OR REPLACE FUNCTION geography_cmp(geography, geography)
313        RETURNS integer
314        AS 'MODULE_PATHNAME', 'geography_cmp'
315        LANGUAGE 'C' IMMUTABLE STRICT;
316
317--
318-- Sorting operators for Btree
319--
320
321CREATE OPERATOR < (
322        LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_lt,
323        COMMUTATOR = '>', NEGATOR = '>=',
324        RESTRICT = contsel, JOIN = contjoinsel
325);
326
327CREATE OPERATOR <= (
328        LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_le,
329        COMMUTATOR = '>=', NEGATOR = '>',
330        RESTRICT = contsel, JOIN = contjoinsel
331);
332
333CREATE OPERATOR = (
334        LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_eq,
335        COMMUTATOR = '=', -- we might implement a faster negator here
336        RESTRICT = contsel, JOIN = contjoinsel
337);
338
339CREATE OPERATOR >= (
340        LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_ge,
341        COMMUTATOR = '<=', NEGATOR = '<',
342        RESTRICT = contsel, JOIN = contjoinsel
343);
344CREATE OPERATOR > (
345        LEFTARG = geography, RIGHTARG = geography, PROCEDURE = geography_gt,
346        COMMUTATOR = '<', NEGATOR = '<=',
347        RESTRICT = contsel, JOIN = contjoinsel
348);
349
350CREATE OPERATOR CLASS btree_geography_ops
351        DEFAULT FOR TYPE geography USING btree AS
352        OPERATOR        1       < ,
353        OPERATOR        2       <= ,
354        OPERATOR        3       = ,
355        OPERATOR        4       >= ,
356        OPERATOR        5       > ,
357        FUNCTION        1       geography_cmp (geography, geography);
358
359
360-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
361-- Export Functions
362-- Availability: 1.5.0
363-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
364
365--
366-- SVG OUTPUT
367--
368
369-- ST_AsSVG(geography, precision, rel)
370CREATE OR REPLACE FUNCTION ST_AsSVG(geography,int4,int4)
371        RETURNS text
372        AS 'MODULE_PATHNAME','geography_as_svg'
373        LANGUAGE 'C' IMMUTABLE STRICT;
374
375-- ST_AsSVG(geography, precision) / rel=0
376CREATE OR REPLACE FUNCTION ST_AsSVG(geography,int4)
377        RETURNS text
378        AS 'MODULE_PATHNAME','geography_as_svg'
379        LANGUAGE 'C' IMMUTABLE STRICT;
380
381-- ST_AsSVG(geography) / precision=15, rel=0
382CREATE OR REPLACE FUNCTION ST_AsSVG(geography)
383        RETURNS text
384        AS 'MODULE_PATHNAME','geography_as_svg'
385        LANGUAGE 'C' IMMUTABLE STRICT;
386       
387-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
388-- TODO Remove in 2.0
389CREATE OR REPLACE FUNCTION ST_AsSVG(text)
390        RETURNS text AS
391        $$ SELECT ST_AsSVG($1::geometry);  $$
392        LANGUAGE 'SQL' IMMUTABLE STRICT;
393
394
395--
396-- GML OUTPUT
397--
398
399-- _ST_AsGML(version, geography, precision, option)
400CREATE OR REPLACE FUNCTION _ST_AsGML(int4, geography, int4, int4)
401        RETURNS text
402        AS 'MODULE_PATHNAME','geography_as_gml'
403        LANGUAGE 'C' IMMUTABLE STRICT;
404
405-- ST_AsGML(geography, precision) / version=2 options=0
406CREATE OR REPLACE FUNCTION ST_AsGML(geography, int4)
407        RETURNS text
408        AS 'SELECT _ST_AsGML(2, $1, $2, 0)'
409        LANGUAGE 'SQL' IMMUTABLE STRICT;
410
411-- ST_AsGML(geography) / precision=15 version=2 options=0
412CREATE OR REPLACE FUNCTION ST_AsGML(geography)
413        RETURNS text
414        AS 'SELECT _ST_AsGML(2, $1, 15, 0)'
415        LANGUAGE 'SQL' IMMUTABLE STRICT;
416
417-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
418-- TODO Remove in 2.0
419CREATE OR REPLACE FUNCTION ST_AsGML(text)
420        RETURNS text AS
421        $$ SELECT ST_AsGML($1::geometry);  $$
422        LANGUAGE 'SQL' IMMUTABLE STRICT;
423
424-- ST_AsGML(version, geography) / precision=15 version=2 options=0
425CREATE OR REPLACE FUNCTION ST_AsGML(int4, geography)
426        RETURNS text
427        AS 'SELECT _ST_AsGML($1, $2, 15, 0)'
428        LANGUAGE 'SQL' IMMUTABLE STRICT;
429
430-- ST_AsGML(version, geography, precision) / options = 0
431CREATE OR REPLACE FUNCTION ST_AsGML(int4, geography, int4)
432        RETURNS text
433        AS 'SELECT _ST_AsGML($1, $2, $3, 0)'
434        LANGUAGE 'SQL' IMMUTABLE STRICT;
435
436-- ST_AsGML (geography, precision, option) / version=2
437CREATE OR REPLACE FUNCTION ST_AsGML(geography, int4, int4)
438        RETURNS text
439        AS 'SELECT _ST_AsGML(2, $1, $2, $3)'
440        LANGUAGE 'SQL' IMMUTABLE STRICT;
441
442-- ST_AsGML(version, geography, precision, option)
443CREATE OR REPLACE FUNCTION ST_AsGML(int4, geography, int4, int4)
444        RETURNS text
445        AS 'SELECT _ST_AsGML($1, $2, $3, $4)'
446        LANGUAGE 'SQL' IMMUTABLE STRICT;
447
448
449
450--
451-- KML OUTPUT
452--
453
454-- _ST_AsKML(version, geography, precision)
455CREATE OR REPLACE FUNCTION _ST_AsKML(int4, geography, int4)
456        RETURNS text
457        AS 'MODULE_PATHNAME','geography_as_kml'
458        LANGUAGE 'C' IMMUTABLE STRICT;
459
460-- AsKML(geography,precision) / version=2
461CREATE OR REPLACE FUNCTION ST_AsKML(geography, int4)
462        RETURNS text
463        AS 'SELECT _ST_AsKML(2, $1, $2)'
464        LANGUAGE 'SQL' IMMUTABLE STRICT;
465
466-- AsKML(geography) / precision=15 version=2
467CREATE OR REPLACE FUNCTION ST_AsKML(geography)
468        RETURNS text
469        AS 'SELECT _ST_AsKML(2, $1, 15)'
470        LANGUAGE 'SQL' IMMUTABLE STRICT;
471
472-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
473-- TODO Remove in 2.0
474CREATE OR REPLACE FUNCTION ST_AsKML(text)
475        RETURNS text AS
476        $$ SELECT ST_AsKML($1::geometry);  $$
477        LANGUAGE 'SQL' IMMUTABLE STRICT;
478
479-- ST_AsKML(version, geography) / precision=15 
480CREATE OR REPLACE FUNCTION ST_AsKML(int4, geography)
481        RETURNS text
482        AS 'SELECT _ST_AsKML($1, $2, 15)'
483        LANGUAGE 'SQL' IMMUTABLE STRICT;
484
485-- ST_AsKML(version, geography, precision)
486CREATE OR REPLACE FUNCTION ST_AsKML(int4, geography, int4)
487        RETURNS text
488        AS 'SELECT _ST_AsKML($1, $2, $3)'
489        LANGUAGE 'SQL' IMMUTABLE STRICT;
490
491
492
493--
494-- GeoJson Output
495--
496
497CREATE OR REPLACE FUNCTION _ST_AsGeoJson(int4, geography, int4, int4)
498        RETURNS text
499        AS 'MODULE_PATHNAME','geography_as_geojson'
500        LANGUAGE 'C' IMMUTABLE STRICT;
501
502-- ST_AsGeoJson(geography, precision) / version=1 options=0
503CREATE OR REPLACE FUNCTION ST_AsGeoJson(geography, int4)
504        RETURNS text
505        AS 'SELECT _ST_AsGeoJson(1, $1, $2, 0)'
506        LANGUAGE 'SQL' IMMUTABLE STRICT;
507
508-- ST_AsGeoJson(geography) / precision=15 version=1 options=0
509CREATE OR REPLACE FUNCTION ST_AsGeoJson(geography)
510        RETURNS text
511        AS 'SELECT _ST_AsGeoJson(1, $1, 15, 0)'
512        LANGUAGE 'SQL' IMMUTABLE STRICT;
513
514-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
515-- TODO Remove in 2.0
516CREATE OR REPLACE FUNCTION ST_AsGeoJson(text)
517        RETURNS text AS
518        $$ SELECT ST_AsGeoJson($1::geometry);  $$
519        LANGUAGE 'SQL' IMMUTABLE STRICT;
520
521-- ST_AsGeoJson(version, geography) / precision=15 options=0
522CREATE OR REPLACE FUNCTION ST_AsGeoJson(int4, geography)
523        RETURNS text
524        AS 'SELECT _ST_AsGeoJson($1, $2, 15, 0)'
525        LANGUAGE 'SQL' IMMUTABLE STRICT;
526
527-- ST_AsGeoJson(version, geography, precision) / options=0
528CREATE OR REPLACE FUNCTION ST_AsGeoJson(int4, geography, int4)
529        RETURNS text
530        AS 'SELECT _ST_AsGeoJson($1, $2, $3, 0)'
531        LANGUAGE 'SQL' IMMUTABLE STRICT;
532
533-- ST_AsGeoJson(geography, precision, options) / version=1
534CREATE OR REPLACE FUNCTION ST_AsGeoJson(geography, int4, int4)
535        RETURNS text
536        AS 'SELECT _ST_AsGeoJson(1, $1, $2, $3)'
537        LANGUAGE 'SQL' IMMUTABLE STRICT;
538
539-- ST_AsGeoJson(version, geography, precision,options)
540CREATE OR REPLACE FUNCTION ST_AsGeoJson(int4, geography, int4, int4)
541        RETURNS text
542        AS 'SELECT _ST_AsGeoJson($1, $2, $3, $4)'
543        LANGUAGE 'SQL' IMMUTABLE STRICT;
544
545-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
546-- Measurement Functions
547-- Availability: 1.5.0
548-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
549
550-- Stop calculation and return immediately once distance is less than tolerance
551-- Availability: 1.5.0
552CREATE OR REPLACE FUNCTION _ST_Distance(geography, geography, float8, boolean)
553        RETURNS float8
554        AS 'MODULE_PATHNAME','geography_distance'
555        LANGUAGE 'C' IMMUTABLE STRICT
556        COST 100;
557
558-- Stop calculation and return immediately once distance is less than tolerance
559-- Availability: 1.5.0
560CREATE OR REPLACE FUNCTION _ST_DWithin(geography, geography, float8, boolean)
561        RETURNS boolean
562        AS 'MODULE_PATHNAME','geography_dwithin'
563        LANGUAGE 'C' IMMUTABLE STRICT
564        COST 100;
565
566-- Availability: 1.5.0
567CREATE OR REPLACE FUNCTION ST_Distance(geography, geography, boolean)
568        RETURNS float8
569        AS 'SELECT _ST_Distance($1, $2, 0.0, $3)'
570        LANGUAGE 'SQL' IMMUTABLE STRICT;
571
572-- Currently defaulting to spheroid calculations
573-- Availability: 1.5.0
574CREATE OR REPLACE FUNCTION ST_Distance(geography, geography)
575        RETURNS float8
576        AS 'SELECT _ST_Distance($1, $2, 0.0, true)'
577        LANGUAGE 'SQL' IMMUTABLE STRICT;
578       
579-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
580-- TODO Remove in 2.0
581CREATE OR REPLACE FUNCTION ST_Distance(text, text)
582        RETURNS float8 AS
583        $$ SELECT ST_Distance($1::geometry, $2::geometry);  $$
584        LANGUAGE 'SQL' IMMUTABLE STRICT;
585
586-- Only expands the bounding box, the actual geometry will remain unchanged, use with care.
587-- Availability: 1.5.0
588CREATE OR REPLACE FUNCTION _ST_Expand(geography, float8)
589        RETURNS geography
590        AS 'MODULE_PATHNAME','geography_expand'
591        LANGUAGE 'C' IMMUTABLE STRICT;
592
593-- Availability: 1.5.0
594CREATE OR REPLACE FUNCTION ST_DWithin(geography, geography, float8, boolean)
595        RETURNS boolean
596        AS 'SELECT $1 && _ST_Expand($2,$3) AND $2 && _ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3, $4)'
597        LANGUAGE 'SQL' IMMUTABLE;
598
599-- Currently defaulting to spheroid calculations
600-- Availability: 1.5.0
601CREATE OR REPLACE FUNCTION ST_DWithin(geography, geography, float8)
602        RETURNS boolean
603        AS 'SELECT $1 && _ST_Expand($2,$3) AND $2 && _ST_Expand($1,$3) AND _ST_DWithin($1, $2, $3, true)'
604        LANGUAGE 'SQL' IMMUTABLE;
605
606-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
607-- TODO Remove in 2.0
608CREATE OR REPLACE FUNCTION ST_DWithin(text, text, float8)
609        RETURNS boolean AS
610        $$ SELECT ST_DWithin($1::geometry, $2::geometry, $3);  $$
611        LANGUAGE 'SQL' IMMUTABLE STRICT;
612
613-- Availability: 1.5.0
614CREATE OR REPLACE FUNCTION ST_Area(geography, boolean)
615        RETURNS float8
616        AS 'MODULE_PATHNAME','geography_area'
617        LANGUAGE 'C' IMMUTABLE STRICT
618        COST 100;
619
620-- Currently defaulting to spheroid calculations
621-- Availability: 1.5.0
622CREATE OR REPLACE FUNCTION ST_Area(geography)
623        RETURNS float8
624        AS 'SELECT ST_Area($1, true)'
625        LANGUAGE 'SQL' IMMUTABLE STRICT;
626
627-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
628-- TODO Remove in 2.0
629CREATE OR REPLACE FUNCTION ST_Area(text)
630        RETURNS float8 AS
631        $$ SELECT ST_Area($1::geometry);  $$
632        LANGUAGE 'SQL' IMMUTABLE STRICT;
633
634-- Availability: 1.5.0
635CREATE OR REPLACE FUNCTION ST_Length(geography, boolean)
636        RETURNS float8
637        AS 'MODULE_PATHNAME','geography_length'
638        LANGUAGE 'C' IMMUTABLE STRICT
639        COST 100;
640
641-- Availability: 1.5.0
642CREATE OR REPLACE FUNCTION ST_Length(geography)
643        RETURNS float8
644        AS 'SELECT ST_Length($1, true)'
645        LANGUAGE 'SQL' IMMUTABLE;
646
647-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
648-- TODO Remove in 2.0
649CREATE OR REPLACE FUNCTION ST_Length(text)
650        RETURNS float8 AS
651        $$ SELECT ST_Length($1::geometry);  $$
652        LANGUAGE 'SQL' IMMUTABLE STRICT;
653
654-- Availability: 1.5.0
655CREATE OR REPLACE FUNCTION _ST_PointOutside(geography)
656        RETURNS geography
657        AS 'MODULE_PATHNAME','geography_point_outside'
658        LANGUAGE 'C' IMMUTABLE STRICT;
659
660-- Only implemented for polygon-over-point
661-- Availability: 1.5.0
662CREATE OR REPLACE FUNCTION _ST_Covers(geography, geography)
663        RETURNS boolean
664        AS 'MODULE_PATHNAME','geography_covers'
665        LANGUAGE 'C' IMMUTABLE STRICT
666        COST 100;
667
668-- Only implemented for polygon-over-point
669-- Availability: 1.5.0
670CREATE OR REPLACE FUNCTION ST_Covers(geography, geography)
671        RETURNS boolean
672        AS 'SELECT $1 && $2 AND _ST_Covers($1, $2)'
673        LANGUAGE 'SQL' IMMUTABLE STRICT;
674
675-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
676-- TODO Remove in 2.0
677CREATE OR REPLACE FUNCTION ST_Covers(text, text)
678        RETURNS boolean AS
679        $$ SELECT ST_Covers($1::geometry, $2::geometry);  $$
680        LANGUAGE 'SQL' IMMUTABLE STRICT;
681
682-- Only implemented for polygon-over-point
683-- Availability: 1.5.0
684CREATE OR REPLACE FUNCTION ST_CoveredBy(geography, geography)
685        RETURNS boolean
686        AS 'SELECT $1 && $2 AND _ST_Covers($2, $1)'
687        LANGUAGE 'SQL' IMMUTABLE STRICT;
688
689-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
690-- TODO Remove in 2.0
691CREATE OR REPLACE FUNCTION ST_CoveredBy(text, text)
692        RETURNS boolean AS
693        $$ SELECT ST_CoveredBy($1::geometry, $2::geometry);  $$
694        LANGUAGE 'SQL' IMMUTABLE STRICT;
695
696-- Availability: 1.5.0
697CREATE OR REPLACE FUNCTION ST_Intersects(geography, geography)
698        RETURNS boolean
699        AS 'SELECT $1 && $2 AND _ST_Distance($1, $2, 0.0, false) < 0.00001'
700        LANGUAGE 'SQL' IMMUTABLE STRICT;
701
702-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
703-- TODO Remove in 2.0
704CREATE OR REPLACE FUNCTION ST_Intersects(text, text)
705        RETURNS boolean AS
706        $$ SELECT ST_Intersects($1::geometry, $2::geometry);  $$
707        LANGUAGE 'SQL' IMMUTABLE STRICT;
708
709-- Availability: 1.5.0
710CREATE OR REPLACE FUNCTION _ST_BestSRID(geography, geography)
711        RETURNS integer
712        AS 'MODULE_PATHNAME','geography_bestsrid'
713        LANGUAGE 'C' IMMUTABLE STRICT;
714
715-- Availability: 1.5.0
716CREATE OR REPLACE FUNCTION _ST_BestSRID(geography)
717        RETURNS integer
718        AS 'SELECT _ST_BestSRID($1,$1)'
719        LANGUAGE 'SQL' IMMUTABLE STRICT;
720
721-- Availability: 1.5.0
722CREATE OR REPLACE FUNCTION ST_Buffer(geography, float8)
723        RETURNS geography
724        AS 'SELECT geography(ST_Transform(ST_Buffer(ST_Transform(geometry($1), _ST_BestSRID($1)), $2), 4326))'
725        LANGUAGE 'SQL' IMMUTABLE STRICT;
726
727-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
728-- TODO Remove in 2.0
729CREATE OR REPLACE FUNCTION ST_Buffer(text, float8)
730        RETURNS geometry AS
731        $$ SELECT ST_Buffer($1::geometry, $2);  $$
732        LANGUAGE 'SQL' IMMUTABLE STRICT;
733
734-- Availability: 1.5.0
735CREATE OR REPLACE FUNCTION ST_Intersection(geography, geography)
736        RETURNS geography
737        AS 'SELECT geography(ST_Transform(ST_Intersection(ST_Transform(geometry($1), _ST_BestSRID($1, $2)), ST_Transform(geometry($2), _ST_BestSRID($1, $2))), 4326))'
738        LANGUAGE 'SQL' IMMUTABLE STRICT;
739
740-- Availability: 1.5.0 - this is just a hack to prevent unknown from causing ambiguous name because of geography
741-- TODO Remove in 2.0
742CREATE OR REPLACE FUNCTION ST_Intersection(text, text)
743        RETURNS geometry AS
744        $$ SELECT ST_Intersection($1::geometry, $2::geometry);  $$
745        LANGUAGE 'SQL' IMMUTABLE STRICT;
746
747-- ---------- ---------- ---------- ---------- ---------- ---------- ----------
Note: See TracBrowser for help on using the repository browser.