Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
a5715eec
Commit
a5715eec
authored
Nov 08, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up format of SQL.
parent
4c1383ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
274 additions
and
274 deletions
+274
-274
contrib/earthdistance/expected/earthdistance.out
contrib/earthdistance/expected/earthdistance.out
+137
-137
contrib/earthdistance/sql/earthdistance.sql
contrib/earthdistance/sql/earthdistance.sql
+137
-137
No files found.
contrib/earthdistance/expected/earthdistance.out
View file @
a5715eec
...
...
@@ -11,7 +11,7 @@ psql:../cube/cube.sql:17: NOTICE: Argument type "cube" is only a shell
--
-- The radius of the Earth we are using.
--
select
earth()::numeric(20,5);
SELECT
earth()::numeric(20,5);
earth
---------------
6378168.00000
...
...
@@ -20,55 +20,55 @@ select earth()::numeric(20,5);
--
-- Convert straight line distances to great circle distances.
--
select
(pi()*earth())::numeric(20,5);
SELECT
(pi()*earth())::numeric(20,5);
numeric
----------------
20037605.73216
(1 row)
select
sec_to_gc(0)::numeric(20,5);
SELECT
sec_to_gc(0)::numeric(20,5);
sec_to_gc
-----------
0.00000
(1 row)
select
sec_to_gc(2*earth())::numeric(20,5);
SELECT
sec_to_gc(2*earth())::numeric(20,5);
sec_to_gc
----------------
20037605.73216
(1 row)
select
sec_to_gc(10*earth())::numeric(20,5);
SELECT
sec_to_gc(10*earth())::numeric(20,5);
sec_to_gc
----------------
20037605.73216
(1 row)
select
sec_to_gc(-earth())::numeric(20,5);
SELECT
sec_to_gc(-earth())::numeric(20,5);
sec_to_gc
-----------
0.00000
(1 row)
select
sec_to_gc(1000)::numeric(20,5);
SELECT
sec_to_gc(1000)::numeric(20,5);
sec_to_gc
------------
1000.00000
(1 row)
select
sec_to_gc(10000)::numeric(20,5);
SELECT
sec_to_gc(10000)::numeric(20,5);
sec_to_gc
-------------
10000.00102
(1 row)
select
sec_to_gc(100000)::numeric(20,5);
SELECT
sec_to_gc(100000)::numeric(20,5);
sec_to_gc
--------------
100001.02426
(1 row)
select
sec_to_gc(1000000)::numeric(20,5);
SELECT
sec_to_gc(1000000)::numeric(20,5);
sec_to_gc
---------------
1001027.07131
...
...
@@ -77,55 +77,55 @@ select sec_to_gc(1000000)::numeric(20,5);
--
-- Convert great circle distances to straight line distances.
--
select
gc_to_sec(0)::numeric(20,5);
SELECT
gc_to_sec(0)::numeric(20,5);
gc_to_sec
-----------
0.00000
(1 row)
select
gc_to_sec(sec_to_gc(2*earth()))::numeric(20,5);
SELECT
gc_to_sec(sec_to_gc(2*earth()))::numeric(20,5);
gc_to_sec
----------------
12756336.00000
(1 row)
select
gc_to_sec(10*earth())::numeric(20,5);
SELECT
gc_to_sec(10*earth())::numeric(20,5);
gc_to_sec
----------------
12756336.00000
(1 row)
select
gc_to_sec(pi()*earth())::numeric(20,5);
SELECT
gc_to_sec(pi()*earth())::numeric(20,5);
gc_to_sec
----------------
12756336.00000
(1 row)
select
gc_to_sec(-1000)::numeric(20,5);
SELECT
gc_to_sec(-1000)::numeric(20,5);
gc_to_sec
-----------
0.00000
(1 row)
select
gc_to_sec(1000)::numeric(20,5);
SELECT
gc_to_sec(1000)::numeric(20,5);
gc_to_sec
------------
1000.00000
(1 row)
select
gc_to_sec(10000)::numeric(20,5);
SELECT
gc_to_sec(10000)::numeric(20,5);
gc_to_sec
------------
9999.99898
(1 row)
select
gc_to_sec(100000)::numeric(20,5);
SELECT
gc_to_sec(100000)::numeric(20,5);
gc_to_sec
-------------
99998.97577
(1 row)
select
gc_to_sec(1000000)::numeric(20,5);
SELECT
gc_to_sec(1000000)::numeric(20,5);
gc_to_sec
--------------
998976.08618
...
...
@@ -135,7 +135,7 @@ select gc_to_sec(1000000)::numeric(20,5);
-- Set coordinates using latitude and longitude.
-- Extract each coordinate separately so we can round them.
--
select
cube_ll_coord(ll_to_earth(0,0),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(0,0),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(0,0),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(0,0),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -143,7 +143,7 @@ select cube_ll_coord(ll_to_earth(0,0),1)::numeric(20,5),
6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(360,360),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(360,360),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(360,360),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(360,360),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -151,7 +151,7 @@ select cube_ll_coord(ll_to_earth(360,360),1)::numeric(20,5),
6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(180,180),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(180,180),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(180,180),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(180,180),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -159,7 +159,7 @@ select cube_ll_coord(ll_to_earth(180,180),1)::numeric(20,5),
6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(180,360),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(180,360),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(180,360),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(180,360),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -167,7 +167,7 @@ select cube_ll_coord(ll_to_earth(180,360),1)::numeric(20,5),
-6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(-180,-360),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(-180,-360),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(-180,-360),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(-180,-360),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -175,7 +175,7 @@ select cube_ll_coord(ll_to_earth(-180,-360),1)::numeric(20,5),
-6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(0,180),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(0,180),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(0,180),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(0,180),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -183,7 +183,7 @@ select cube_ll_coord(ll_to_earth(0,180),1)::numeric(20,5),
-6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(0,-180),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(0,-180),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(0,-180),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(0,-180),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -191,7 +191,7 @@ select cube_ll_coord(ll_to_earth(0,-180),1)::numeric(20,5),
-6378168.00000 | 0.00000 | 0.00000
(1 row)
select
cube_ll_coord(ll_to_earth(90,0),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(90,0),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(90,0),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(90,0),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -199,7 +199,7 @@ select cube_ll_coord(ll_to_earth(90,0),1)::numeric(20,5),
0.00000 | 0.00000 | 6378168.00000
(1 row)
select
cube_ll_coord(ll_to_earth(90,180),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(90,180),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(90,180),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(90,180),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -207,7 +207,7 @@ select cube_ll_coord(ll_to_earth(90,180),1)::numeric(20,5),
0.00000 | 0.00000 | 6378168.00000
(1 row)
select
cube_ll_coord(ll_to_earth(-90,0),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(-90,0),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(-90,0),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(-90,0),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -215,7 +215,7 @@ select cube_ll_coord(ll_to_earth(-90,0),1)::numeric(20,5),
0.00000 | 0.00000 | -6378168.00000
(1 row)
select
cube_ll_coord(ll_to_earth(-90,180),1)::numeric(20,5),
SELECT
cube_ll_coord(ll_to_earth(-90,180),1)::numeric(20,5),
cube_ll_coord(ll_to_earth(-90,180),2)::numeric(20,5),
cube_ll_coord(ll_to_earth(-90,180),3)::numeric(20,5);
cube_ll_coord | cube_ll_coord | cube_ll_coord
...
...
@@ -226,121 +226,121 @@ select cube_ll_coord(ll_to_earth(-90,180),1)::numeric(20,5),
--
-- Test getting the latitude of a location.
--
select
latitude(ll_to_earth(0,0))::numeric(20,10);
SELECT
latitude(ll_to_earth(0,0))::numeric(20,10);
latitude
--------------
0.0000000000
(1 row)
select
latitude(ll_to_earth(45,0))::numeric(20,10);
SELECT
latitude(ll_to_earth(45,0))::numeric(20,10);
latitude
---------------
45.0000000000
(1 row)
select
latitude(ll_to_earth(90,0))::numeric(20,10);
SELECT
latitude(ll_to_earth(90,0))::numeric(20,10);
latitude
---------------
90.0000000000
(1 row)
select
latitude(ll_to_earth(-45,0))::numeric(20,10);
SELECT
latitude(ll_to_earth(-45,0))::numeric(20,10);
latitude
----------------
-45.0000000000
(1 row)
select
latitude(ll_to_earth(-90,0))::numeric(20,10);
SELECT
latitude(ll_to_earth(-90,0))::numeric(20,10);
latitude
----------------
-90.0000000000
(1 row)
select
latitude(ll_to_earth(0,90))::numeric(20,10);
SELECT
latitude(ll_to_earth(0,90))::numeric(20,10);
latitude
--------------
0.0000000000
(1 row)
select
latitude(ll_to_earth(45,90))::numeric(20,10);
SELECT
latitude(ll_to_earth(45,90))::numeric(20,10);
latitude
---------------
45.0000000000
(1 row)
select
latitude(ll_to_earth(90,90))::numeric(20,10);
SELECT
latitude(ll_to_earth(90,90))::numeric(20,10);
latitude
---------------
90.0000000000
(1 row)
select
latitude(ll_to_earth(-45,90))::numeric(20,10);
SELECT
latitude(ll_to_earth(-45,90))::numeric(20,10);
latitude
----------------
-45.0000000000
(1 row)
select
latitude(ll_to_earth(-90,90))::numeric(20,10);
SELECT
latitude(ll_to_earth(-90,90))::numeric(20,10);
latitude
----------------
-90.0000000000
(1 row)
select
latitude(ll_to_earth(0,180))::numeric(20,10);
SELECT
latitude(ll_to_earth(0,180))::numeric(20,10);
latitude
--------------
0.0000000000
(1 row)
select
latitude(ll_to_earth(45,180))::numeric(20,10);
SELECT
latitude(ll_to_earth(45,180))::numeric(20,10);
latitude
---------------
45.0000000000
(1 row)
select
latitude(ll_to_earth(90,180))::numeric(20,10);
SELECT
latitude(ll_to_earth(90,180))::numeric(20,10);
latitude
---------------
90.0000000000
(1 row)
select
latitude(ll_to_earth(-45,180))::numeric(20,10);
SELECT
latitude(ll_to_earth(-45,180))::numeric(20,10);
latitude
----------------
-45.0000000000
(1 row)
select
latitude(ll_to_earth(-90,180))::numeric(20,10);
SELECT
latitude(ll_to_earth(-90,180))::numeric(20,10);
latitude
----------------
-90.0000000000
(1 row)
select
latitude(ll_to_earth(0,-90))::numeric(20,10);
SELECT
latitude(ll_to_earth(0,-90))::numeric(20,10);
latitude
--------------
0.0000000000
(1 row)
select
latitude(ll_to_earth(45,-90))::numeric(20,10);
SELECT
latitude(ll_to_earth(45,-90))::numeric(20,10);
latitude
---------------
45.0000000000
(1 row)
select
latitude(ll_to_earth(90,-90))::numeric(20,10);
SELECT
latitude(ll_to_earth(90,-90))::numeric(20,10);
latitude
---------------
90.0000000000
(1 row)
select
latitude(ll_to_earth(-45,-90))::numeric(20,10);
SELECT
latitude(ll_to_earth(-45,-90))::numeric(20,10);
latitude
----------------
-45.0000000000
(1 row)
select
latitude(ll_to_earth(-90,-90))::numeric(20,10);
SELECT
latitude(ll_to_earth(-90,-90))::numeric(20,10);
latitude
----------------
-90.0000000000
...
...
@@ -349,121 +349,121 @@ select latitude(ll_to_earth(-90,-90))::numeric(20,10);
--
-- Test getting the longitude of a location.
--
select
longitude(ll_to_earth(0,0))::numeric(20,10);
SELECT
longitude(ll_to_earth(0,0))::numeric(20,10);
longitude
--------------
0.0000000000
(1 row)
select
longitude(ll_to_earth(45,0))::numeric(20,10);
SELECT
longitude(ll_to_earth(45,0))::numeric(20,10);
longitude
--------------
0.0000000000
(1 row)
select
longitude(ll_to_earth(90,0))::numeric(20,10);
SELECT
longitude(ll_to_earth(90,0))::numeric(20,10);
longitude
--------------
0.0000000000
(1 row)
select
longitude(ll_to_earth(-45,0))::numeric(20,10);
SELECT
longitude(ll_to_earth(-45,0))::numeric(20,10);
longitude
--------------
0.0000000000
(1 row)
select
longitude(ll_to_earth(-90,0))::numeric(20,10);
SELECT
longitude(ll_to_earth(-90,0))::numeric(20,10);
longitude
--------------
0.0000000000
(1 row)
select
longitude(ll_to_earth(0,90))::numeric(20,10);
SELECT
longitude(ll_to_earth(0,90))::numeric(20,10);
longitude
---------------
90.0000000000
(1 row)
select
longitude(ll_to_earth(45,90))::numeric(20,10);
SELECT
longitude(ll_to_earth(45,90))::numeric(20,10);
longitude
---------------
90.0000000000
(1 row)
select
longitude(ll_to_earth(90,90))::numeric(20,10);
SELECT
longitude(ll_to_earth(90,90))::numeric(20,10);
longitude
---------------
90.0000000000
(1 row)
select
longitude(ll_to_earth(-45,90))::numeric(20,10);
SELECT
longitude(ll_to_earth(-45,90))::numeric(20,10);
longitude
---------------
90.0000000000
(1 row)
select
longitude(ll_to_earth(-90,90))::numeric(20,10);
SELECT
longitude(ll_to_earth(-90,90))::numeric(20,10);
longitude
---------------
90.0000000000
(1 row)
select
longitude(ll_to_earth(0,180))::numeric(20,10);
SELECT
longitude(ll_to_earth(0,180))::numeric(20,10);
longitude
----------------
180.0000000000
(1 row)
select
longitude(ll_to_earth(45,180))::numeric(20,10);
SELECT
longitude(ll_to_earth(45,180))::numeric(20,10);
longitude
----------------
180.0000000000
(1 row)
select
longitude(ll_to_earth(90,180))::numeric(20,10);
SELECT
longitude(ll_to_earth(90,180))::numeric(20,10);
longitude
----------------
180.0000000000
(1 row)
select
longitude(ll_to_earth(-45,180))::numeric(20,10);
SELECT
longitude(ll_to_earth(-45,180))::numeric(20,10);
longitude
----------------
180.0000000000
(1 row)
select
longitude(ll_to_earth(-90,180))::numeric(20,10);
SELECT
longitude(ll_to_earth(-90,180))::numeric(20,10);
longitude
----------------
180.0000000000
(1 row)
select
longitude(ll_to_earth(0,-90))::numeric(20,10);
SELECT
longitude(ll_to_earth(0,-90))::numeric(20,10);
longitude
----------------
-90.0000000000
(1 row)
select
longitude(ll_to_earth(45,-90))::numeric(20,10);
SELECT
longitude(ll_to_earth(45,-90))::numeric(20,10);
longitude
----------------
-90.0000000000
(1 row)
select
longitude(ll_to_earth(90,-90))::numeric(20,10);
SELECT
longitude(ll_to_earth(90,-90))::numeric(20,10);
longitude
----------------
-90.0000000000
(1 row)
select
longitude(ll_to_earth(-45,-90))::numeric(20,10);
SELECT
longitude(ll_to_earth(-45,-90))::numeric(20,10);
longitude
----------------
-90.0000000000
(1 row)
select
longitude(ll_to_earth(-90,-90))::numeric(20,10);
SELECT
longitude(ll_to_earth(-90,-90))::numeric(20,10);
longitude
----------------
-90.0000000000
...
...
@@ -480,73 +480,73 @@ select longitude(ll_to_earth(-90,-90))::numeric(20,10);
--
-- Test getting the distance between two points using earth_distance.
--
select
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0))::numeric(20,5);
earth_distance
----------------
0.00000
(1 row)
select
earth_distance(ll_to_earth(0,0),ll_to_earth(0,180))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(0,0),ll_to_earth(0,180))::numeric(20,5);
earth_distance
----------------
20037605.73216
(1 row)
select
earth_distance(ll_to_earth(0,0),ll_to_earth(90,0))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(0,0),ll_to_earth(90,0))::numeric(20,5);
earth_distance
----------------
10018802.86608
(1 row)
select
earth_distance(ll_to_earth(0,0),ll_to_earth(0,90))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(0,0),ll_to_earth(0,90))::numeric(20,5);
earth_distance
----------------
10018802.86608
(1 row)
select
earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))::numeric(20,5);
earth_distance
----------------
111320.03185
(1 row)
select
earth_distance(ll_to_earth(0,0),ll_to_earth(1,0))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(0,0),ll_to_earth(1,0))::numeric(20,5);
earth_distance
----------------
111320.03185
(1 row)
select
earth_distance(ll_to_earth(30,0),ll_to_earth(30,1))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(30,0),ll_to_earth(30,1))::numeric(20,5);
earth_distance
----------------
96405.66962
(1 row)
select
earth_distance(ll_to_earth(30,0),ll_to_earth(31,0))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(30,0),ll_to_earth(31,0))::numeric(20,5);
earth_distance
----------------
111320.03185
(1 row)
select
earth_distance(ll_to_earth(60,0),ll_to_earth(60,1))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(60,0),ll_to_earth(60,1))::numeric(20,5);
earth_distance
----------------
55659.48608
(1 row)
select
earth_distance(ll_to_earth(60,0),ll_to_earth(61,0))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(60,0),ll_to_earth(61,0))::numeric(20,5);
earth_distance
----------------
111320.03185
(1 row)
select
earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))::numeric(20,5);
SELECT
earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))::numeric(20,5);
earth_distance
----------------
1819303.21265
(1 row)
select
(earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))*
SELECT
(earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))*
100./2.54/12./5280.)::numeric(20,5);
numeric
------------
...
...
@@ -556,73 +556,73 @@ select (earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))*
--
-- Test getting the distance between two points using geo_distance.
--
select
geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
SELECT
geo_distance('(0,0)'::point,'(0,0)'::point)::numeric(20,5);
geo_distance
--------------
0.00000
(1 row)
select
geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
SELECT
geo_distance('(0,0)'::point,'(180,0)'::point)::numeric(20,5);
geo_distance
--------------
12436.77274
(1 row)
select
geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
SELECT
geo_distance('(0,0)'::point,'(0,90)'::point)::numeric(20,5);
geo_distance
--------------
6218.38637
(1 row)
select
geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
SELECT
geo_distance('(0,0)'::point,'(90,0)'::point)::numeric(20,5);
geo_distance
--------------
6218.38637
(1 row)
select
geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
SELECT
geo_distance('(0,0)'::point,'(1,0)'::point)::numeric(20,5);
geo_distance
--------------
69.09318
(1 row)
select
geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
SELECT
geo_distance('(0,0)'::point,'(0,1)'::point)::numeric(20,5);
geo_distance
--------------
69.09318
(1 row)
select
geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
SELECT
geo_distance('(0,30)'::point,'(1,30)'::point)::numeric(20,5);
geo_distance
--------------
59.83626
(1 row)
select
geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
SELECT
geo_distance('(0,30)'::point,'(0,31)'::point)::numeric(20,5);
geo_distance
--------------
69.09318
(1 row)
select
geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
SELECT
geo_distance('(0,60)'::point,'(1,60)'::point)::numeric(20,5);
geo_distance
--------------
34.54626
(1 row)
select
geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
SELECT
geo_distance('(0,60)'::point,'(0,61)'::point)::numeric(20,5);
geo_distance
--------------
69.09318
(1 row)
select
geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
SELECT
geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)::numeric(20,5);
geo_distance
--------------
1129.18983
(1 row)
select
(geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
SELECT
(geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
numeric
---------------
1817254.87730
...
...
@@ -631,73 +631,73 @@ select (geo_distance('(87.6,41.8)'::point,'(106.7,35.1)'::point)*5280.*12.*2.54/
--
-- Test getting the distance between two points using the <@> operator.
--
select
('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
SELECT
('(0,0)'::point <@> '(0,0)'::point)::numeric(20,5);
numeric
---------
0.00000
(1 row)
select
('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
SELECT
('(0,0)'::point <@> '(180,0)'::point)::numeric(20,5);
numeric
-------------
12436.77274
(1 row)
select
('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
SELECT
('(0,0)'::point <@> '(0,90)'::point)::numeric(20,5);
numeric
------------
6218.38637
(1 row)
select
('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
SELECT
('(0,0)'::point <@> '(90,0)'::point)::numeric(20,5);
numeric
------------
6218.38637
(1 row)
select
('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
SELECT
('(0,0)'::point <@> '(1,0)'::point)::numeric(20,5);
numeric
----------
69.09318
(1 row)
select
('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
SELECT
('(0,0)'::point <@> '(0,1)'::point)::numeric(20,5);
numeric
----------
69.09318
(1 row)
select
('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
SELECT
('(0,30)'::point <@> '(1,30)'::point)::numeric(20,5);
numeric
----------
59.83626
(1 row)
select
('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
SELECT
('(0,30)'::point <@> '(0,31)'::point)::numeric(20,5);
numeric
----------
69.09318
(1 row)
select
('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
SELECT
('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
numeric
----------
34.54626
(1 row)
select
('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
SELECT
('(0,60)'::point <@> '(0,61)'::point)::numeric(20,5);
numeric
----------
69.09318
(1 row)
select
('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
SELECT
('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)::numeric(20,5);
numeric
------------
1129.18983
(1 row)
select
(('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
SELECT
(('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
numeric
---------------
1817254.87730
...
...
@@ -706,7 +706,7 @@ select (('(87.6,41.8)'::point <@> '(106.7,35.1)'::point)*5280.*12.*2.54/100.)::n
--
-- Test getting a bounding box around points.
--
select
cube_ll_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5),
SELECT
cube_ll_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5),
cube_ll_coord(earth_box(ll_to_earth(0,0),112000),2)::numeric(20,5),
cube_ll_coord(earth_box(ll_to_earth(0,0),112000),3)::numeric(20,5),
cube_ur_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5),
...
...
@@ -717,7 +717,7 @@ select cube_ll_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5),
6266169.43896 | -111998.56104 | -111998.56104 | 6490166.56104 | 111998.56104 | 111998.56104
(1 row)
select
cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5),
SELECT
cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5),
cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),2)::numeric(20,5),
cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),3)::numeric(20,5),
cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5),
...
...
@@ -728,7 +728,7 @@ select cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5),
-6378168.00000 | -12756336.00000 | -12756336.00000 | 19134504.00000 | 12756336.00000 | 12756336.00000
(1 row)
select
cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
SELECT
cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),2)::numeric(20,5),
cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),3)::numeric(20,5),
cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
...
...
@@ -742,7 +742,7 @@ select cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
--
-- Test for points that should be in bounding boxes.
--
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @
ll_to_earth(0,1);
?column?
...
...
@@ -750,7 +750,7 @@ select earth_box(ll_to_earth(0,0),
t
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @
ll_to_earth(0,0.1);
?column?
...
...
@@ -758,7 +758,7 @@ select earth_box(ll_to_earth(0,0),
t
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @
ll_to_earth(0,0.01);
?column?
...
...
@@ -766,7 +766,7 @@ select earth_box(ll_to_earth(0,0),
t
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @
ll_to_earth(0,0.001);
?column?
...
...
@@ -774,7 +774,7 @@ select earth_box(ll_to_earth(0,0),
t
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @
ll_to_earth(0,0.0001);
?column?
...
...
@@ -782,7 +782,7 @@ select earth_box(ll_to_earth(0,0),
t
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @
ll_to_earth(0.0001,0.0001);
?column?
...
...
@@ -790,7 +790,7 @@ select earth_box(ll_to_earth(0,0),
t
(1 row)
select
earth_box(ll_to_earth(45,45),
SELECT
earth_box(ll_to_earth(45,45),
earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @
ll_to_earth(45.0001,45.0001);
?column?
...
...
@@ -798,7 +798,7 @@ select earth_box(ll_to_earth(45,45),
t
(1 row)
select
earth_box(ll_to_earth(90,180),
SELECT
earth_box(ll_to_earth(90,180),
earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @
ll_to_earth(90.0001,180.0001);
?column?
...
...
@@ -811,7 +811,7 @@ select earth_box(ll_to_earth(90,180),
-- to make points way outside, since some points close may be in the box
-- but further away than the distance we are testing.
--
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @
ll_to_earth(0,1);
?column?
...
...
@@ -819,7 +819,7 @@ select earth_box(ll_to_earth(0,0),
f
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @
ll_to_earth(0,0.1);
?column?
...
...
@@ -827,7 +827,7 @@ select earth_box(ll_to_earth(0,0),
f
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @
ll_to_earth(0,0.01);
?column?
...
...
@@ -835,7 +835,7 @@ select earth_box(ll_to_earth(0,0),
f
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @
ll_to_earth(0,0.001);
?column?
...
...
@@ -843,7 +843,7 @@ select earth_box(ll_to_earth(0,0),
f
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @
ll_to_earth(0,0.0001);
?column?
...
...
@@ -851,7 +851,7 @@ select earth_box(ll_to_earth(0,0),
f
(1 row)
select
earth_box(ll_to_earth(0,0),
SELECT
earth_box(ll_to_earth(0,0),
earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @
ll_to_earth(0.0001,0.0001);
?column?
...
...
@@ -859,7 +859,7 @@ select earth_box(ll_to_earth(0,0),
f
(1 row)
select
earth_box(ll_to_earth(45,45),
SELECT
earth_box(ll_to_earth(45,45),
earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @
ll_to_earth(45.0001,45.0001);
?column?
...
...
@@ -867,7 +867,7 @@ select earth_box(ll_to_earth(45,45),
f
(1 row)
select
earth_box(ll_to_earth(90,180),
SELECT
earth_box(ll_to_earth(90,180),
earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @
ll_to_earth(90.0001,180.0001);
?column?
...
...
@@ -878,68 +878,68 @@ select earth_box(ll_to_earth(90,180),
--
-- Test the recommended constraints.
--
select
is_point(ll_to_earth(0,0));
SELECT
is_point(ll_to_earth(0,0));
ERROR: Function is_point(earth) does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
select
cube_dim(ll_to_earth(0,0)) <= 3;
SELECT
cube_dim(ll_to_earth(0,0)) <= 3;
?column?
----------
t
(1 row)
select
abs(cube_distance(ll_to_earth(0,0), '(0)'::cube) / earth() - 1) <
SELECT
abs(cube_distance(ll_to_earth(0,0), '(0)'::cube) / earth() - 1) <
'10e-12'::float8;
?column?
----------
t
(1 row)
select
is_point(ll_to_earth(30,60));
SELECT
is_point(ll_to_earth(30,60));
ERROR: Function is_point(earth) does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
select
cube_dim(ll_to_earth(30,60)) <= 3;
SELECT
cube_dim(ll_to_earth(30,60)) <= 3;
?column?
----------
t
(1 row)
select
abs(cube_distance(ll_to_earth(30,60), '(0)'::cube) / earth() - 1) <
SELECT
abs(cube_distance(ll_to_earth(30,60), '(0)'::cube) / earth() - 1) <
'10e-12'::float8;
?column?
----------
t
(1 row)
select
is_point(ll_to_earth(60,90));
SELECT
is_point(ll_to_earth(60,90));
ERROR: Function is_point(earth) does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
select
cube_dim(ll_to_earth(60,90)) <= 3;
SELECT
cube_dim(ll_to_earth(60,90)) <= 3;
?column?
----------
t
(1 row)
select
abs(cube_distance(ll_to_earth(60,90), '(0)'::cube) / earth() - 1) <
SELECT
abs(cube_distance(ll_to_earth(60,90), '(0)'::cube) / earth() - 1) <
'10e-12'::float8;
?column?
----------
t
(1 row)
select
is_point(ll_to_earth(-30,-90));
SELECT
is_point(ll_to_earth(-30,-90));
ERROR: Function is_point(earth) does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
select
cube_dim(ll_to_earth(-30,-90)) <= 3;
SELECT
cube_dim(ll_to_earth(-30,-90)) <= 3;
?column?
----------
t
(1 row)
select
abs(cube_distance(ll_to_earth(-30,-90), '(0)'::cube) / earth() - 1) <
SELECT
abs(cube_distance(ll_to_earth(-30,-90), '(0)'::cube) / earth() - 1) <
'10e-12'::float8;
?column?
----------
...
...
contrib/earthdistance/sql/earthdistance.sql
View file @
a5715eec
...
...
@@ -15,71 +15,71 @@
-- The radius of the Earth we are using.
--
select
earth
()::
numeric
(
20
,
5
);
SELECT
earth
()::
numeric
(
20
,
5
);
--
-- Convert straight line distances to great circle distances.
--
select
(
pi
()
*
earth
())::
numeric
(
20
,
5
);
select
sec_to_gc
(
0
)::
numeric
(
20
,
5
);
select
sec_to_gc
(
2
*
earth
())::
numeric
(
20
,
5
);
select
sec_to_gc
(
10
*
earth
())::
numeric
(
20
,
5
);
select
sec_to_gc
(
-
earth
())::
numeric
(
20
,
5
);
select
sec_to_gc
(
1000
)::
numeric
(
20
,
5
);
select
sec_to_gc
(
10000
)::
numeric
(
20
,
5
);
select
sec_to_gc
(
100000
)::
numeric
(
20
,
5
);
select
sec_to_gc
(
1000000
)::
numeric
(
20
,
5
);
SELECT
(
pi
()
*
earth
())::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
0
)::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
2
*
earth
())::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
10
*
earth
())::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
-
earth
())::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
1000
)::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
10000
)::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
100000
)::
numeric
(
20
,
5
);
SELECT
sec_to_gc
(
1000000
)::
numeric
(
20
,
5
);
--
-- Convert great circle distances to straight line distances.
--
select
gc_to_sec
(
0
)::
numeric
(
20
,
5
);
select
gc_to_sec
(
sec_to_gc
(
2
*
earth
()))::
numeric
(
20
,
5
);
select
gc_to_sec
(
10
*
earth
())::
numeric
(
20
,
5
);
select
gc_to_sec
(
pi
()
*
earth
())::
numeric
(
20
,
5
);
select
gc_to_sec
(
-
1000
)::
numeric
(
20
,
5
);
select
gc_to_sec
(
1000
)::
numeric
(
20
,
5
);
select
gc_to_sec
(
10000
)::
numeric
(
20
,
5
);
select
gc_to_sec
(
100000
)::
numeric
(
20
,
5
);
select
gc_to_sec
(
1000000
)::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
0
)::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
sec_to_gc
(
2
*
earth
()))::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
10
*
earth
())::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
pi
()
*
earth
())::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
-
1000
)::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
1000
)::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
10000
)::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
100000
)::
numeric
(
20
,
5
);
SELECT
gc_to_sec
(
1000000
)::
numeric
(
20
,
5
);
--
-- Set coordinates using latitude and longitude.
-- Extract each coordinate separately so we can round them.
--
select
cube_ll_coord
(
ll_to_earth
(
0
,
0
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
0
,
0
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
0
,
0
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
0
,
0
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
360
,
360
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
360
,
360
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
360
,
360
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
360
,
360
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
180
,
180
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
180
,
180
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
180
,
180
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
180
,
180
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
180
,
360
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
180
,
360
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
180
,
360
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
180
,
360
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
-
180
,
-
360
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
-
180
,
-
360
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
-
180
,
-
360
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
-
180
,
-
360
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
0
,
180
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
0
,
180
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
0
,
180
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
0
,
180
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
0
,
-
180
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
0
,
-
180
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
0
,
-
180
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
0
,
-
180
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
90
,
0
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
90
,
0
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
90
,
0
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
90
,
0
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
90
,
180
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
90
,
180
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
90
,
180
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
90
,
180
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
-
90
,
0
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
-
90
,
0
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
-
90
,
0
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
-
90
,
0
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
ll_to_earth
(
-
90
,
180
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
ll_to_earth
(
-
90
,
180
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
-
90
,
180
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
ll_to_earth
(
-
90
,
180
),
3
)::
numeric
(
20
,
5
);
...
...
@@ -87,51 +87,51 @@ select cube_ll_coord(ll_to_earth(-90,180),1)::numeric(20,5),
-- Test getting the latitude of a location.
--
select
latitude
(
ll_to_earth
(
0
,
0
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
45
,
0
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
90
,
0
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
45
,
0
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
90
,
0
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
0
,
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
45
,
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
90
,
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
45
,
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
90
,
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
0
,
180
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
45
,
180
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
90
,
180
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
45
,
180
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
90
,
180
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
0
,
-
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
45
,
-
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
90
,
-
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
45
,
-
90
))::
numeric
(
20
,
10
);
select
latitude
(
ll_to_earth
(
-
90
,
-
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
0
,
0
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
45
,
0
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
90
,
0
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
45
,
0
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
90
,
0
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
0
,
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
45
,
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
90
,
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
45
,
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
90
,
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
0
,
180
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
45
,
180
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
90
,
180
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
45
,
180
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
90
,
180
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
0
,
-
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
45
,
-
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
90
,
-
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
45
,
-
90
))::
numeric
(
20
,
10
);
SELECT
latitude
(
ll_to_earth
(
-
90
,
-
90
))::
numeric
(
20
,
10
);
--
-- Test getting the longitude of a location.
--
select
longitude
(
ll_to_earth
(
0
,
0
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
45
,
0
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
90
,
0
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
45
,
0
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
90
,
0
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
0
,
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
45
,
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
90
,
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
45
,
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
90
,
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
0
,
180
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
45
,
180
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
90
,
180
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
45
,
180
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
90
,
180
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
0
,
-
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
45
,
-
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
90
,
-
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
45
,
-
90
))::
numeric
(
20
,
10
);
select
longitude
(
ll_to_earth
(
-
90
,
-
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
0
,
0
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
45
,
0
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
90
,
0
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
45
,
0
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
90
,
0
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
0
,
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
45
,
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
90
,
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
45
,
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
90
,
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
0
,
180
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
45
,
180
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
90
,
180
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
45
,
180
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
90
,
180
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
0
,
-
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
45
,
-
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
90
,
-
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
45
,
-
90
))::
numeric
(
20
,
10
);
SELECT
longitude
(
ll_to_earth
(
-
90
,
-
90
))::
numeric
(
20
,
10
);
--
-- For the distance tests the following is some real life data.
...
...
@@ -146,71 +146,71 @@ select longitude(ll_to_earth(-90,-90))::numeric(20,10);
-- Test getting the distance between two points using earth_distance.
--
select
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
180
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
90
,
0
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
90
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
1
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
1
,
0
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
30
,
0
),
ll_to_earth
(
30
,
1
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
30
,
0
),
ll_to_earth
(
31
,
0
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
60
,
0
),
ll_to_earth
(
60
,
1
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
60
,
0
),
ll_to_earth
(
61
,
0
))::
numeric
(
20
,
5
);
select
earth_distance
(
ll_to_earth
(
41
.
8
,
87
.
6
),
ll_to_earth
(
35
.
1
,
106
.
7
))::
numeric
(
20
,
5
);
select
(
earth_distance
(
ll_to_earth
(
41
.
8
,
87
.
6
),
ll_to_earth
(
35
.
1
,
106
.
7
))
*
SELECT
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
180
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
90
,
0
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
90
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
1
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
1
,
0
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
30
,
0
),
ll_to_earth
(
30
,
1
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
30
,
0
),
ll_to_earth
(
31
,
0
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
60
,
0
),
ll_to_earth
(
60
,
1
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
60
,
0
),
ll_to_earth
(
61
,
0
))::
numeric
(
20
,
5
);
SELECT
earth_distance
(
ll_to_earth
(
41
.
8
,
87
.
6
),
ll_to_earth
(
35
.
1
,
106
.
7
))::
numeric
(
20
,
5
);
SELECT
(
earth_distance
(
ll_to_earth
(
41
.
8
,
87
.
6
),
ll_to_earth
(
35
.
1
,
106
.
7
))
*
100
.
/
2
.
54
/
12
.
/
5280
.)::
numeric
(
20
,
5
);
--
-- Test getting the distance between two points using geo_distance.
--
select
geo_distance
(
'(0,0)'
::
point
,
'(0,0)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,0)'
::
point
,
'(180,0)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,0)'
::
point
,
'(0,90)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,0)'
::
point
,
'(90,0)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,0)'
::
point
,
'(1,0)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,0)'
::
point
,
'(0,1)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,30)'
::
point
,
'(1,30)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,30)'
::
point
,
'(0,31)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,60)'
::
point
,
'(1,60)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(0,60)'
::
point
,
'(0,61)'
::
point
)::
numeric
(
20
,
5
);
select
geo_distance
(
'(87.6,41.8)'
::
point
,
'(106.7,35.1)'
::
point
)::
numeric
(
20
,
5
);
select
(
geo_distance
(
'(87.6,41.8)'
::
point
,
'(106.7,35.1)'
::
point
)
*
5280
.
*
12
.
*
2
.
54
/
100
.)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,0)'
::
point
,
'(0,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,0)'
::
point
,
'(180,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,0)'
::
point
,
'(0,90)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,0)'
::
point
,
'(90,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,0)'
::
point
,
'(1,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,0)'
::
point
,
'(0,1)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,30)'
::
point
,
'(1,30)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,30)'
::
point
,
'(0,31)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,60)'
::
point
,
'(1,60)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(0,60)'
::
point
,
'(0,61)'
::
point
)::
numeric
(
20
,
5
);
SELECT
geo_distance
(
'(87.6,41.8)'
::
point
,
'(106.7,35.1)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
geo_distance
(
'(87.6,41.8)'
::
point
,
'(106.7,35.1)'
::
point
)
*
5280
.
*
12
.
*
2
.
54
/
100
.)::
numeric
(
20
,
5
);
--
-- Test getting the distance between two points using the <@> operator.
--
select
(
'(0,0)'
::
point
<@>
'(0,0)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,0)'
::
point
<@>
'(180,0)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,0)'
::
point
<@>
'(0,90)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,0)'
::
point
<@>
'(90,0)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,0)'
::
point
<@>
'(1,0)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,0)'
::
point
<@>
'(0,1)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,30)'
::
point
<@>
'(1,30)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,30)'
::
point
<@>
'(0,31)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,60)'
::
point
<@>
'(1,60)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(0,60)'
::
point
<@>
'(0,61)'
::
point
)::
numeric
(
20
,
5
);
select
(
'(87.6,41.8)'
::
point
<@>
'(106.7,35.1)'
::
point
)::
numeric
(
20
,
5
);
select
((
'(87.6,41.8)'
::
point
<@>
'(106.7,35.1)'
::
point
)
*
5280
.
*
12
.
*
2
.
54
/
100
.)::
numeric
(
20
,
5
);
SELECT
(
'(0,0)'
::
point
<@>
'(0,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,0)'
::
point
<@>
'(180,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,0)'
::
point
<@>
'(0,90)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,0)'
::
point
<@>
'(90,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,0)'
::
point
<@>
'(1,0)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,0)'
::
point
<@>
'(0,1)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,30)'
::
point
<@>
'(1,30)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,30)'
::
point
<@>
'(0,31)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,60)'
::
point
<@>
'(1,60)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(0,60)'
::
point
<@>
'(0,61)'
::
point
)::
numeric
(
20
,
5
);
SELECT
(
'(87.6,41.8)'
::
point
<@>
'(106.7,35.1)'
::
point
)::
numeric
(
20
,
5
);
SELECT
((
'(87.6,41.8)'
::
point
<@>
'(106.7,35.1)'
::
point
)
*
5280
.
*
12
.
*
2
.
54
/
100
.)::
numeric
(
20
,
5
);
--
-- Test getting a bounding box around points.
--
select
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
3
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
1
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
2
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
112000
),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
3
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
1
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
2
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
pi
()
*
earth
()),
3
)::
numeric
(
20
,
5
);
select
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
10
*
earth
()),
1
)::
numeric
(
20
,
5
),
SELECT
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
10
*
earth
()),
1
)::
numeric
(
20
,
5
),
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
10
*
earth
()),
2
)::
numeric
(
20
,
5
),
cube_ll_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
10
*
earth
()),
3
)::
numeric
(
20
,
5
),
cube_ur_coord
(
earth_box
(
ll_to_earth
(
0
,
0
),
10
*
earth
()),
1
)::
numeric
(
20
,
5
),
...
...
@@ -221,28 +221,28 @@ select cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
-- Test for points that should be in bounding boxes.
--
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
1
))
*
1
.
00001
)
@
ll_to_earth
(
0
,
1
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
1
))
*
1
.
00001
)
@
ll_to_earth
(
0
,
0
.
1
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
01
))
*
1
.
00001
)
@
ll_to_earth
(
0
,
0
.
01
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
001
))
*
1
.
00001
)
@
ll_to_earth
(
0
,
0
.
001
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
0001
))
*
1
.
00001
)
@
ll_to_earth
(
0
,
0
.
0001
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
.
0001
,
0
.
0001
))
*
1
.
00001
)
@
ll_to_earth
(
0
.
0001
,
0
.
0001
);
select
earth_box
(
ll_to_earth
(
45
,
45
),
SELECT
earth_box
(
ll_to_earth
(
45
,
45
),
earth_distance
(
ll_to_earth
(
45
,
45
),
ll_to_earth
(
45
.
0001
,
45
.
0001
))
*
1
.
00001
)
@
ll_to_earth
(
45
.
0001
,
45
.
0001
);
select
earth_box
(
ll_to_earth
(
90
,
180
),
SELECT
earth_box
(
ll_to_earth
(
90
,
180
),
earth_distance
(
ll_to_earth
(
90
,
180
),
ll_to_earth
(
90
.
0001
,
180
.
0001
))
*
1
.
00001
)
@
ll_to_earth
(
90
.
0001
,
180
.
0001
);
...
...
@@ -252,28 +252,28 @@ select earth_box(ll_to_earth(90,180),
-- but further away than the distance we are testing.
--
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
1
))
*
.
57735
)
@
ll_to_earth
(
0
,
1
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
1
))
*
.
57735
)
@
ll_to_earth
(
0
,
0
.
1
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
01
))
*
.
57735
)
@
ll_to_earth
(
0
,
0
.
01
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
001
))
*
.
57735
)
@
ll_to_earth
(
0
,
0
.
001
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
,
0
.
0001
))
*
.
57735
)
@
ll_to_earth
(
0
,
0
.
0001
);
select
earth_box
(
ll_to_earth
(
0
,
0
),
SELECT
earth_box
(
ll_to_earth
(
0
,
0
),
earth_distance
(
ll_to_earth
(
0
,
0
),
ll_to_earth
(
0
.
0001
,
0
.
0001
))
*
.
57735
)
@
ll_to_earth
(
0
.
0001
,
0
.
0001
);
select
earth_box
(
ll_to_earth
(
45
,
45
),
SELECT
earth_box
(
ll_to_earth
(
45
,
45
),
earth_distance
(
ll_to_earth
(
45
,
45
),
ll_to_earth
(
45
.
0001
,
45
.
0001
))
*
.
57735
)
@
ll_to_earth
(
45
.
0001
,
45
.
0001
);
select
earth_box
(
ll_to_earth
(
90
,
180
),
SELECT
earth_box
(
ll_to_earth
(
90
,
180
),
earth_distance
(
ll_to_earth
(
90
,
180
),
ll_to_earth
(
90
.
0001
,
180
.
0001
))
*
.
57735
)
@
ll_to_earth
(
90
.
0001
,
180
.
0001
);
...
...
@@ -281,19 +281,19 @@ select earth_box(ll_to_earth(90,180),
-- Test the recommended constraints.
--
select
is_point
(
ll_to_earth
(
0
,
0
));
select
cube_dim
(
ll_to_earth
(
0
,
0
))
<=
3
;
select
abs
(
cube_distance
(
ll_to_earth
(
0
,
0
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
SELECT
is_point
(
ll_to_earth
(
0
,
0
));
SELECT
cube_dim
(
ll_to_earth
(
0
,
0
))
<=
3
;
SELECT
abs
(
cube_distance
(
ll_to_earth
(
0
,
0
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
'10e-12'
::
float8
;
select
is_point
(
ll_to_earth
(
30
,
60
));
select
cube_dim
(
ll_to_earth
(
30
,
60
))
<=
3
;
select
abs
(
cube_distance
(
ll_to_earth
(
30
,
60
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
SELECT
is_point
(
ll_to_earth
(
30
,
60
));
SELECT
cube_dim
(
ll_to_earth
(
30
,
60
))
<=
3
;
SELECT
abs
(
cube_distance
(
ll_to_earth
(
30
,
60
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
'10e-12'
::
float8
;
select
is_point
(
ll_to_earth
(
60
,
90
));
select
cube_dim
(
ll_to_earth
(
60
,
90
))
<=
3
;
select
abs
(
cube_distance
(
ll_to_earth
(
60
,
90
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
SELECT
is_point
(
ll_to_earth
(
60
,
90
));
SELECT
cube_dim
(
ll_to_earth
(
60
,
90
))
<=
3
;
SELECT
abs
(
cube_distance
(
ll_to_earth
(
60
,
90
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
'10e-12'
::
float8
;
select
is_point
(
ll_to_earth
(
-
30
,
-
90
));
select
cube_dim
(
ll_to_earth
(
-
30
,
-
90
))
<=
3
;
select
abs
(
cube_distance
(
ll_to_earth
(
-
30
,
-
90
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
SELECT
is_point
(
ll_to_earth
(
-
30
,
-
90
));
SELECT
cube_dim
(
ll_to_earth
(
-
30
,
-
90
))
<=
3
;
SELECT
abs
(
cube_distance
(
ll_to_earth
(
-
30
,
-
90
),
'(0)'
::
cube
)
/
earth
()
-
1
)
<
'10e-12'
::
float8
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment