Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf88a3c

Browse files
committed
Install proper earthdistance file, regression passes.
1 parent7bf1c8b commitdf88a3c

File tree

1 file changed

+0
-255
lines changed

1 file changed

+0
-255
lines changed

‎contrib/earthdistance/sql/earthdistance.sql

Lines changed: 0 additions & 255 deletions
Original file line numberDiff line numberDiff line change
@@ -7,159 +7,9 @@
77
-- does not depend on contents of earthdistance.sql or cube.sql.
88
--
99
\set ECHO none
10-
\i ../cube/cube.sql
1110
\iearthdistance.sql
1211
\set ECHO all
1312

14-
--
15-
-- The radius of the Earth we are using.
16-
--
17-
18-
select earth()::numeric(20,5);
19-
20-
--
21-
-- Convert straight line distances to great circle distances.
22-
--
23-
select (pi()*earth())::numeric(20,5);
24-
select sec_to_gc(0)::numeric(20,5);
25-
select sec_to_gc(2*earth())::numeric(20,5);
26-
select sec_to_gc(10*earth())::numeric(20,5);
27-
select sec_to_gc(-earth())::numeric(20,5);
28-
select sec_to_gc(1000)::numeric(20,5);
29-
select sec_to_gc(10000)::numeric(20,5);
30-
select sec_to_gc(100000)::numeric(20,5);
31-
select sec_to_gc(1000000)::numeric(20,5);
32-
33-
--
34-
-- Convert great circle distances to straight line distances.
35-
--
36-
37-
select gc_to_sec(0)::numeric(20,5);
38-
select gc_to_sec(sec_to_gc(2*earth()))::numeric(20,5);
39-
select gc_to_sec(10*earth())::numeric(20,5);
40-
select gc_to_sec(pi()*earth())::numeric(20,5);
41-
select gc_to_sec(-1000)::numeric(20,5);
42-
select gc_to_sec(1000)::numeric(20,5);
43-
select gc_to_sec(10000)::numeric(20,5);
44-
select gc_to_sec(100000)::numeric(20,5);
45-
select gc_to_sec(1000000)::numeric(20,5);
46-
47-
--
48-
-- Set coordinates using latitude and longitude.
49-
-- Extract each coordinate separately so we can round them.
50-
--
51-
52-
select cube_ll_coord(ll_to_earth(0,0),1)::numeric(20,5),
53-
cube_ll_coord(ll_to_earth(0,0),2)::numeric(20,5),
54-
cube_ll_coord(ll_to_earth(0,0),3)::numeric(20,5);
55-
select cube_ll_coord(ll_to_earth(360,360),1)::numeric(20,5),
56-
cube_ll_coord(ll_to_earth(360,360),2)::numeric(20,5),
57-
cube_ll_coord(ll_to_earth(360,360),3)::numeric(20,5);
58-
select cube_ll_coord(ll_to_earth(180,180),1)::numeric(20,5),
59-
cube_ll_coord(ll_to_earth(180,180),2)::numeric(20,5),
60-
cube_ll_coord(ll_to_earth(180,180),3)::numeric(20,5);
61-
select cube_ll_coord(ll_to_earth(180,360),1)::numeric(20,5),
62-
cube_ll_coord(ll_to_earth(180,360),2)::numeric(20,5),
63-
cube_ll_coord(ll_to_earth(180,360),3)::numeric(20,5);
64-
select cube_ll_coord(ll_to_earth(-180,-360),1)::numeric(20,5),
65-
cube_ll_coord(ll_to_earth(-180,-360),2)::numeric(20,5),
66-
cube_ll_coord(ll_to_earth(-180,-360),3)::numeric(20,5);
67-
select cube_ll_coord(ll_to_earth(0,180),1)::numeric(20,5),
68-
cube_ll_coord(ll_to_earth(0,180),2)::numeric(20,5),
69-
cube_ll_coord(ll_to_earth(0,180),3)::numeric(20,5);
70-
select cube_ll_coord(ll_to_earth(0,-180),1)::numeric(20,5),
71-
cube_ll_coord(ll_to_earth(0,-180),2)::numeric(20,5),
72-
cube_ll_coord(ll_to_earth(0,-180),3)::numeric(20,5);
73-
select cube_ll_coord(ll_to_earth(90,0),1)::numeric(20,5),
74-
cube_ll_coord(ll_to_earth(90,0),2)::numeric(20,5),
75-
cube_ll_coord(ll_to_earth(90,0),3)::numeric(20,5);
76-
select cube_ll_coord(ll_to_earth(90,180),1)::numeric(20,5),
77-
cube_ll_coord(ll_to_earth(90,180),2)::numeric(20,5),
78-
cube_ll_coord(ll_to_earth(90,180),3)::numeric(20,5);
79-
select cube_ll_coord(ll_to_earth(-90,0),1)::numeric(20,5),
80-
cube_ll_coord(ll_to_earth(-90,0),2)::numeric(20,5),
81-
cube_ll_coord(ll_to_earth(-90,0),3)::numeric(20,5);
82-
select cube_ll_coord(ll_to_earth(-90,180),1)::numeric(20,5),
83-
cube_ll_coord(ll_to_earth(-90,180),2)::numeric(20,5),
84-
cube_ll_coord(ll_to_earth(-90,180),3)::numeric(20,5);
85-
86-
--
87-
-- Test getting the latitude of a location.
88-
--
89-
90-
select latitude(ll_to_earth(0,0))::numeric(20,10);
91-
select latitude(ll_to_earth(45,0))::numeric(20,10);
92-
select latitude(ll_to_earth(90,0))::numeric(20,10);
93-
select latitude(ll_to_earth(-45,0))::numeric(20,10);
94-
select latitude(ll_to_earth(-90,0))::numeric(20,10);
95-
select latitude(ll_to_earth(0,90))::numeric(20,10);
96-
select latitude(ll_to_earth(45,90))::numeric(20,10);
97-
select latitude(ll_to_earth(90,90))::numeric(20,10);
98-
select latitude(ll_to_earth(-45,90))::numeric(20,10);
99-
select latitude(ll_to_earth(-90,90))::numeric(20,10);
100-
select latitude(ll_to_earth(0,180))::numeric(20,10);
101-
select latitude(ll_to_earth(45,180))::numeric(20,10);
102-
select latitude(ll_to_earth(90,180))::numeric(20,10);
103-
select latitude(ll_to_earth(-45,180))::numeric(20,10);
104-
select latitude(ll_to_earth(-90,180))::numeric(20,10);
105-
select latitude(ll_to_earth(0,-90))::numeric(20,10);
106-
select latitude(ll_to_earth(45,-90))::numeric(20,10);
107-
select latitude(ll_to_earth(90,-90))::numeric(20,10);
108-
select latitude(ll_to_earth(-45,-90))::numeric(20,10);
109-
select latitude(ll_to_earth(-90,-90))::numeric(20,10);
110-
111-
--
112-
-- Test getting the longitude of a location.
113-
--
114-
115-
select longitude(ll_to_earth(0,0))::numeric(20,10);
116-
select longitude(ll_to_earth(45,0))::numeric(20,10);
117-
select longitude(ll_to_earth(90,0))::numeric(20,10);
118-
select longitude(ll_to_earth(-45,0))::numeric(20,10);
119-
select longitude(ll_to_earth(-90,0))::numeric(20,10);
120-
select longitude(ll_to_earth(0,90))::numeric(20,10);
121-
select longitude(ll_to_earth(45,90))::numeric(20,10);
122-
select longitude(ll_to_earth(90,90))::numeric(20,10);
123-
select longitude(ll_to_earth(-45,90))::numeric(20,10);
124-
select longitude(ll_to_earth(-90,90))::numeric(20,10);
125-
select longitude(ll_to_earth(0,180))::numeric(20,10);
126-
select longitude(ll_to_earth(45,180))::numeric(20,10);
127-
select longitude(ll_to_earth(90,180))::numeric(20,10);
128-
select longitude(ll_to_earth(-45,180))::numeric(20,10);
129-
select longitude(ll_to_earth(-90,180))::numeric(20,10);
130-
select longitude(ll_to_earth(0,-90))::numeric(20,10);
131-
select longitude(ll_to_earth(45,-90))::numeric(20,10);
132-
select longitude(ll_to_earth(90,-90))::numeric(20,10);
133-
select longitude(ll_to_earth(-45,-90))::numeric(20,10);
134-
select longitude(ll_to_earth(-90,-90))::numeric(20,10);
135-
136-
--
137-
-- For the distance tests the following is some real life data.
138-
--
139-
-- Chicago has a latitude of 41.8 and a longitude of 87.6.
140-
-- Albuquerque has a latitude of 35.1 and a longitude of 106.7.
141-
-- (Note that latitude and longitude are specified differently
142-
-- in the cube based functions than for the point based functions.)
143-
--
144-
145-
--
146-
-- Test getting the distance between two points using earth_distance.
147-
--
148-
149-
select earth_distance(ll_to_earth(0,0),ll_to_earth(0,0))::numeric(20,5);
150-
select earth_distance(ll_to_earth(0,0),ll_to_earth(0,180))::numeric(20,5);
151-
select earth_distance(ll_to_earth(0,0),ll_to_earth(90,0))::numeric(20,5);
152-
select earth_distance(ll_to_earth(0,0),ll_to_earth(0,90))::numeric(20,5);
153-
select earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))::numeric(20,5);
154-
select earth_distance(ll_to_earth(0,0),ll_to_earth(1,0))::numeric(20,5);
155-
select earth_distance(ll_to_earth(30,0),ll_to_earth(30,1))::numeric(20,5);
156-
select earth_distance(ll_to_earth(30,0),ll_to_earth(31,0))::numeric(20,5);
157-
select earth_distance(ll_to_earth(60,0),ll_to_earth(60,1))::numeric(20,5);
158-
select earth_distance(ll_to_earth(60,0),ll_to_earth(61,0))::numeric(20,5);
159-
select earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))::numeric(20,5);
160-
select (earth_distance(ll_to_earth(41.8,87.6),ll_to_earth(35.1,106.7))*
161-
100./2.54/12./5280.)::numeric(20,5);
162-
16313
--
16414
-- Test getting the distance between two points using geo_distance.
16515
--
@@ -193,108 +43,3 @@ select ('(0,60)'::point <@> '(1,60)'::point)::numeric(20,5);
19343
select ('(0,60)'::point<@>'(0,61)'::point)::numeric(20,5);
19444
select ('(87.6,41.8)'::point<@>'(106.7,35.1)'::point)::numeric(20,5);
19545
select (('(87.6,41.8)'::point<@>'(106.7,35.1)'::point)*5280.*12.*2.54/100.)::numeric(20,5);
196-
197-
--
198-
-- Test getting a bounding box around points.
199-
--
200-
201-
select cube_ll_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5),
202-
cube_ll_coord(earth_box(ll_to_earth(0,0),112000),2)::numeric(20,5),
203-
cube_ll_coord(earth_box(ll_to_earth(0,0),112000),3)::numeric(20,5),
204-
cube_ur_coord(earth_box(ll_to_earth(0,0),112000),1)::numeric(20,5),
205-
cube_ur_coord(earth_box(ll_to_earth(0,0),112000),2)::numeric(20,5),
206-
cube_ur_coord(earth_box(ll_to_earth(0,0),112000),3)::numeric(20,5);
207-
select cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5),
208-
cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),2)::numeric(20,5),
209-
cube_ll_coord(earth_box(ll_to_earth(0,0),pi()*earth()),3)::numeric(20,5),
210-
cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),1)::numeric(20,5),
211-
cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),2)::numeric(20,5),
212-
cube_ur_coord(earth_box(ll_to_earth(0,0),pi()*earth()),3)::numeric(20,5);
213-
select cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
214-
cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),2)::numeric(20,5),
215-
cube_ll_coord(earth_box(ll_to_earth(0,0),10*earth()),3)::numeric(20,5),
216-
cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),1)::numeric(20,5),
217-
cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),2)::numeric(20,5),
218-
cube_ur_coord(earth_box(ll_to_earth(0,0),10*earth()),3)::numeric(20,5);
219-
220-
--
221-
-- Test for points that should be in bounding boxes.
222-
--
223-
224-
select earth_box(ll_to_earth(0,0),
225-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*1.00001) @
226-
ll_to_earth(0,1);
227-
select earth_box(ll_to_earth(0,0),
228-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*1.00001) @
229-
ll_to_earth(0,0.1);
230-
select earth_box(ll_to_earth(0,0),
231-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*1.00001) @
232-
ll_to_earth(0,0.01);
233-
select earth_box(ll_to_earth(0,0),
234-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*1.00001) @
235-
ll_to_earth(0,0.001);
236-
select earth_box(ll_to_earth(0,0),
237-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*1.00001) @
238-
ll_to_earth(0,0.0001);
239-
select earth_box(ll_to_earth(0,0),
240-
earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*1.00001) @
241-
ll_to_earth(0.0001,0.0001);
242-
select earth_box(ll_to_earth(45,45),
243-
earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*1.00001) @
244-
ll_to_earth(45.0001,45.0001);
245-
select earth_box(ll_to_earth(90,180),
246-
earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*1.00001) @
247-
ll_to_earth(90.0001,180.0001);
248-
249-
--
250-
-- Test for points that shouldn't be in bounding boxes. Note that we need
251-
-- to make points way outside, since some points close may be in the box
252-
-- but further away than the distance we are testing.
253-
--
254-
255-
select earth_box(ll_to_earth(0,0),
256-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,1))*.57735) @
257-
ll_to_earth(0,1);
258-
select earth_box(ll_to_earth(0,0),
259-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.1))*.57735) @
260-
ll_to_earth(0,0.1);
261-
select earth_box(ll_to_earth(0,0),
262-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.01))*.57735) @
263-
ll_to_earth(0,0.01);
264-
select earth_box(ll_to_earth(0,0),
265-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.001))*.57735) @
266-
ll_to_earth(0,0.001);
267-
select earth_box(ll_to_earth(0,0),
268-
earth_distance(ll_to_earth(0,0),ll_to_earth(0,0.0001))*.57735) @
269-
ll_to_earth(0,0.0001);
270-
select earth_box(ll_to_earth(0,0),
271-
earth_distance(ll_to_earth(0,0),ll_to_earth(0.0001,0.0001))*.57735) @
272-
ll_to_earth(0.0001,0.0001);
273-
select earth_box(ll_to_earth(45,45),
274-
earth_distance(ll_to_earth(45,45),ll_to_earth(45.0001,45.0001))*.57735) @
275-
ll_to_earth(45.0001,45.0001);
276-
select earth_box(ll_to_earth(90,180),
277-
earth_distance(ll_to_earth(90,180),ll_to_earth(90.0001,180.0001))*.57735) @
278-
ll_to_earth(90.0001,180.0001);
279-
280-
--
281-
-- Test the recommended constraints.
282-
--
283-
284-
select is_point(ll_to_earth(0,0));
285-
select cube_dim(ll_to_earth(0,0))<=3;
286-
select abs(cube_distance(ll_to_earth(0,0),'(0)'::cube)/ earth()-1)<
287-
'10e-12'::float8;
288-
select is_point(ll_to_earth(30,60));
289-
select cube_dim(ll_to_earth(30,60))<=3;
290-
select abs(cube_distance(ll_to_earth(30,60),'(0)'::cube)/ earth()-1)<
291-
'10e-12'::float8;
292-
select is_point(ll_to_earth(60,90));
293-
select cube_dim(ll_to_earth(60,90))<=3;
294-
select abs(cube_distance(ll_to_earth(60,90),'(0)'::cube)/ earth()-1)<
295-
'10e-12'::float8;
296-
select is_point(ll_to_earth(-30,-90));
297-
select cube_dim(ll_to_earth(-30,-90))<=3;
298-
select abs(cube_distance(ll_to_earth(-30,-90),'(0)'::cube)/ earth()-1)<
299-
'10e-12'::float8;
300-
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp