Submit
Path:
~
/
/
usr
/
share
/
pgsql
/
extension
/
File Content:
earthdistance--1.1.sql
/* contrib/earthdistance/earthdistance--1.1.sql */ -- complain if script is sourced in psql, rather than via CREATE EXTENSION \echo Use "CREATE EXTENSION earthdistance" to load this file. \quit -- earth() returns the radius of the earth in meters. This is the only -- place you need to change things for the cube base distance functions -- in order to use different units (or a better value for the Earth's radius). CREATE FUNCTION earth() RETURNS float8 LANGUAGE SQL IMMUTABLE PARALLEL SAFE AS 'SELECT ''6378168''::float8'; -- Astronomers may want to change the earth function so that distances will be -- returned in degrees. To do this comment out the above definition and -- uncomment the one below. Note that doing this will break the regression -- tests. -- -- CREATE FUNCTION earth() RETURNS float8 -- LANGUAGE SQL IMMUTABLE -- AS 'SELECT 180/pi()'; -- Define domain for locations on the surface of the earth using a cube -- datatype with constraints. cube provides 3D indexing. -- The cube is restricted to be a point, no more than 3 dimensions -- (for less than 3 dimensions 0 is assumed for the missing coordinates) -- and that the point must be very near the surface of the sphere -- centered about the origin with the radius of the earth. CREATE DOMAIN earth AS cube CONSTRAINT not_point check(cube_is_point(value)) CONSTRAINT not_3d check(cube_dim(value) <= 3) CONSTRAINT on_surface check(abs(cube_distance(value, '(0)'::cube) / earth() - '1'::float8) < '10e-7'::float8); CREATE FUNCTION sec_to_gc(float8) RETURNS float8 LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT CASE WHEN $1 < 0 THEN 0::float8 WHEN $1/(2*earth()) > 1 THEN pi()*earth() ELSE 2*earth()*asin($1/(2*earth())) END'; CREATE FUNCTION gc_to_sec(float8) RETURNS float8 LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT CASE WHEN $1 < 0 THEN 0::float8 WHEN $1/earth() > pi() THEN 2*earth() ELSE 2*earth()*sin($1/(2*earth())) END'; CREATE FUNCTION ll_to_earth(float8, float8) RETURNS earth LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))::earth'; CREATE FUNCTION latitude(earth) RETURNS float8 LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT CASE WHEN cube_ll_coord($1, 3)/earth() < -1 THEN -90::float8 WHEN cube_ll_coord($1, 3)/earth() > 1 THEN 90::float8 ELSE degrees(asin(cube_ll_coord($1, 3)/earth())) END'; CREATE FUNCTION longitude(earth) RETURNS float8 LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT degrees(atan2(cube_ll_coord($1, 2), cube_ll_coord($1, 1)))'; CREATE FUNCTION earth_distance(earth, earth) RETURNS float8 LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT sec_to_gc(cube_distance($1, $2))'; CREATE FUNCTION earth_box(earth, float8) RETURNS cube LANGUAGE SQL IMMUTABLE STRICT PARALLEL SAFE AS 'SELECT cube_enlarge($1, gc_to_sec($2), 3)'; --------------- geo_distance CREATE FUNCTION geo_distance (point, point) RETURNS float8 LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE AS 'MODULE_PATHNAME'; --------------- geo_distance as operator <@> CREATE OPERATOR <@> ( LEFTARG = point, RIGHTARG = point, PROCEDURE = geo_distance, COMMUTATOR = <@> );
Submit
FILE
FOLDER
Name
Size
Permission
Action
adminpack--1.0--1.1.sql
274 bytes
0644
adminpack--1.0.sql
1535 bytes
0644
adminpack--1.1--2.0.sql
1682 bytes
0644
adminpack--2.0--2.1.sql
595 bytes
0644
adminpack.control
176 bytes
0644
amcheck--1.0--1.1.sql
931 bytes
0644
amcheck--1.0.sql
704 bytes
0644
amcheck--1.1--1.2.sql
705 bytes
0644
amcheck.control
154 bytes
0644
autoinc--1.0.sql
249 bytes
0644
autoinc.control
149 bytes
0644
bloom--1.0.sql
666 bytes
0644
bloom.control
156 bytes
0644
btree_gin--1.0--1.1.sql
1372 bytes
0644
btree_gin--1.0.sql
24818 bytes
0644
btree_gin--1.1--1.2.sql
1445 bytes
0644
btree_gin--1.2--1.3.sql
4571 bytes
0644
btree_gin.control
175 bytes
0644
btree_gist--1.0--1.1.sql
3739 bytes
0644
btree_gist--1.1--1.2.sql
5048 bytes
0644
btree_gist--1.2--1.3.sql
1955 bytes
0644
btree_gist--1.2.sql
41115 bytes
0644
btree_gist--1.3--1.4.sql
1932 bytes
0644
btree_gist--1.4--1.5.sql
1872 bytes
0644
btree_gist.control
178 bytes
0644
citext--1.0--1.1.sql
1028 bytes
0644
citext--1.1--1.2.sql
3424 bytes
0644
citext--1.2--1.3.sql
850 bytes
0644
citext--1.3--1.4.sql
668 bytes
0644
citext--1.4--1.5.sql
2284 bytes
0644
citext--1.4.sql
13466 bytes
0644
citext--1.5--1.6.sql
427 bytes
0644
citext.control
173 bytes
0644
cube--1.0--1.1.sql
1594 bytes
0644
cube--1.1--1.2.sql
3815 bytes
0644
cube--1.2--1.3.sql
365 bytes
0644
cube--1.2.sql
9761 bytes
0644
cube--1.3--1.4.sql
2387 bytes
0644
cube.control
157 bytes
0644
dblink--1.0--1.1.sql
419 bytes
0644
dblink--1.1--1.2.sql
2832 bytes
0644
dblink--1.2.sql
6645 bytes
0644
dblink.control
170 bytes
0644
dict_int--1.0.sql
711 bytes
0644
dict_int.control
173 bytes
0644
dict_xsyn--1.0.sql
694 bytes
0644
dict_xsyn.control
179 bytes
0644
earthdistance--1.0--1.1.sql
671 bytes
0644
earthdistance--1.1.sql
3234 bytes
0644
earthdistance.control
202 bytes
0644
file_fdw--1.0.sql
475 bytes
0644
file_fdw.control
155 bytes
0644
fuzzystrmatch--1.0--1.1.sql
788 bytes
0644
fuzzystrmatch--1.1.sql
1576 bytes
0644
fuzzystrmatch.control
190 bytes
0644
hstore--1.0--1.1.sql
279 bytes
0644
hstore--1.1--1.2.sql
1639 bytes
0644
hstore--1.2--1.3.sql
525 bytes
0644
hstore--1.3--1.4.sql
5310 bytes
0644
hstore--1.4--1.5.sql
409 bytes
0644
hstore--1.4.sql
13765 bytes
0644
hstore--1.5--1.6.sql
455 bytes
0644
hstore--1.6--1.7.sql
1061 bytes
0644
hstore.control
173 bytes
0644
hstore_plperl--1.0.sql
580 bytes
0644
hstore_plperl.control
186 bytes
0644
hstore_plperlu--1.0.sql
627 bytes
0644
hstore_plperlu.control
189 bytes
0644
hstore_plpython3u--1.0.sql
750 bytes
0644
hstore_plpython3u.control
201 bytes
0644
insert_username--1.0.sql
273 bytes
0644
insert_username.control
170 bytes
0644
intagg--1.0--1.1.sql
897 bytes
0644
intagg--1.1.sql
1089 bytes
0644
intagg.control
119 bytes
0644
intarray--1.0--1.1.sql
1794 bytes
0644
intarray--1.1--1.2.sql
5525 bytes
0644
intarray--1.2--1.3.sql
663 bytes
0644
intarray--1.2.sql
12293 bytes
0644
intarray.control
191 bytes
0644
isn--1.0--1.1.sql
12333 bytes
0644
isn--1.1--1.2.sql
5264 bytes
0644
isn--1.1.sql
69885 bytes
0644
isn.control
175 bytes
0644
jsonb_plperl--1.0.sql
658 bytes
0644
jsonb_plperl.control
191 bytes
0644
jsonb_plperlu--1.0.sql
704 bytes
0644
jsonb_plperlu.control
178 bytes
0644
jsonb_plpython3u--1.0.sql
732 bytes
0644
jsonb_plpython3u.control
191 bytes
0644
lo--1.0--1.1.sql
223 bytes
0644
lo--1.1.sql
722 bytes
0644
lo.control
141 bytes
0644
ltree--1.0--1.1.sql
6336 bytes
0644
ltree--1.1--1.2.sql
5217 bytes
0644
ltree--1.1.sql
19375 bytes
0644
ltree.control
170 bytes
0644
ltree_plpython3u--1.0.sql
449 bytes
0644
ltree_plpython3u.control
197 bytes
0644
moddatetime--1.0.sql
261 bytes
0644
moddatetime.control
165 bytes
0644
pageinspect--1.0--1.1.sql
560 bytes
0644
pageinspect--1.1--1.2.sql
562 bytes
0644
pageinspect--1.2--1.3.sql
1946 bytes
0644
pageinspect--1.3--1.4.sql
2566 bytes
0644
pageinspect--1.4--1.5.sql
1347 bytes
0644
pageinspect--1.5--1.6.sql
2252 bytes
0644
pageinspect--1.5.sql
6262 bytes
0644
pageinspect--1.6--1.7.sql
698 bytes
0644
pageinspect--1.7--1.8.sql
1711 bytes
0644
pageinspect.control
173 bytes
0644
pg_buffercache--1.0--1.1.sql
508 bytes
0644
pg_buffercache--1.1--1.2.sql
271 bytes
0644
pg_buffercache--1.2--1.3.sql
328 bytes
0644
pg_buffercache--1.2.sql
794 bytes
0644
pg_buffercache.control
157 bytes
0644
pg_freespacemap--1.0--1.1.sql
335 bytes
0644
pg_freespacemap--1.1--1.2.sql
377 bytes
0644
pg_freespacemap--1.1.sql
899 bytes
0644
pg_freespacemap.control
160 bytes
0644
pg_prewarm--1.0--1.1.sql
281 bytes
0644
pg_prewarm--1.1--1.2.sql
458 bytes
0644
pg_prewarm--1.1.sql
475 bytes
0644
pg_prewarm.control
139 bytes
0644
pg_stat_statements--1.0--1.1.sql
1246 bytes
0644
pg_stat_statements--1.1--1.2.sql
1336 bytes
0644
pg_stat_statements--1.2--1.3.sql
1454 bytes
0644
pg_stat_statements--1.3--1.4.sql
345 bytes
0644
pg_stat_statements--1.4--1.5.sql
305 bytes
0644
pg_stat_statements--1.4.sql
1427 bytes
0644
pg_stat_statements--1.5--1.6.sql
376 bytes
0644
pg_stat_statements--1.6--1.7.sql
806 bytes
0644
pg_stat_statements--1.7--1.8.sql
1744 bytes
0644
pg_stat_statements.control
204 bytes
0644
pg_trgm--1.0--1.1.sql
536 bytes
0644
pg_trgm--1.1--1.2.sql
2192 bytes
0644
pg_trgm--1.2--1.3.sql
3498 bytes
0644
pg_trgm--1.3--1.4.sql
2045 bytes
0644
pg_trgm--1.3.sql
7942 bytes
0644
pg_trgm--1.4--1.5.sql
858 bytes
0644
pg_trgm.control
192 bytes
0644
pg_visibility--1.0--1.1.sql
883 bytes
0644
pg_visibility--1.1--1.2.sql
833 bytes
0644
pg_visibility--1.1.sql
2825 bytes
0644
pg_visibility.control
186 bytes
0644
pgcrypto--1.0--1.1.sql
307 bytes
0644
pgcrypto--1.1--1.2.sql
483 bytes
0644
pgcrypto--1.2--1.3.sql
2346 bytes
0644
pgcrypto--1.3.sql
5708 bytes
0644
pgcrypto.control
152 bytes
0644
pgrowlocks--1.0--1.1.sql
651 bytes
0644
pgrowlocks--1.1--1.2.sql
253 bytes
0644
pgrowlocks--1.2.sql
555 bytes
0644
pgrowlocks.control
152 bytes
0644
pgstattuple--1.0--1.1.sql
400 bytes
0644
pgstattuple--1.1--1.2.sql
1435 bytes
0644
pgstattuple--1.2--1.3.sql
1126 bytes
0644
pgstattuple--1.3--1.4.sql
623 bytes
0644
pgstattuple--1.4--1.5.sql
5506 bytes
0644
pgstattuple--1.4.sql
3764 bytes
0644
pgstattuple.control
147 bytes
0644
plpgsql--1.0.sql
658 bytes
0644
plpgsql.control
193 bytes
0644
postgres_fdw--1.0.sql
507 bytes
0644
postgres_fdw.control
172 bytes
0644
refint--1.0.sql
343 bytes
0644
refint.control
169 bytes
0644
seg--1.0--1.1.sql
3005 bytes
0644
seg--1.1--1.2.sql
360 bytes
0644
seg--1.1.sql
8142 bytes
0644
seg--1.2--1.3.sql
2344 bytes
0644
seg.control
187 bytes
0644
sslinfo--1.0--1.1.sql
375 bytes
0644
sslinfo--1.1--1.2.sql
746 bytes
0644
sslinfo--1.2.sql
1534 bytes
0644
sslinfo.control
146 bytes
0644
tablefunc--1.0.sql
2153 bytes
0644
tablefunc.control
189 bytes
0644
tcn--1.0.sql
274 bytes
0644
tcn.control
149 bytes
0644
tsm_system_rows--1.0.sql
327 bytes
0644
tsm_system_rows.control
201 bytes
0644
tsm_system_time--1.0.sql
327 bytes
0644
tsm_system_time.control
207 bytes
0644
unaccent--1.0--1.1.sql
445 bytes
0644
unaccent--1.1.sql
910 bytes
0644
unaccent.control
172 bytes
0644
uuid-ossp--1.0--1.1.sql
688 bytes
0644
uuid-ossp--1.1.sql
1516 bytes
0644
uuid-ossp.control
178 bytes
0644
xml2--1.0--1.1.sql
944 bytes
0644
xml2--1.1.sql
2049 bytes
0644
xml2.control
182 bytes
0644
N4ST4R_ID | Naxtarrr