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

Commit30a17c7

Browse files
author
stepan-neretin7
committed
[ISSUE#22] Created spoint_deg, scircle_deg functions.
1 parent612f06b commit30a17c7

20 files changed

+267
-19
lines changed

‎Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ DATA_built = $(RELEASE_SQL) \
2727
pg_sphere--1.1.5beta4gavo--1.2.0.sql\
2828
pg_sphere--1.2.0--1.2.1.sql\
2929
pg_sphere--1.2.1--1.2.2.sql\
30-
pg_sphere--1.2.2--1.2.3.sql
30+
pg_sphere--1.2.2--1.2.3.sql\
31+
pg_sphere--1.2.3--1.3.0.sql
3132

3233
DOCS = README.pg_sphere COPYRIGHT.pg_sphere
3334
REGRESS = init tables points euler circle line ellipse poly path box index\
@@ -260,6 +261,9 @@ endif
260261
pg_sphere--1.2.2--1.2.3.sql:
261262
cat upgrade_scripts/$@.in>$@
262263

264+
pg_sphere--1.2.3--1.3.0.sql:
265+
cat upgrade_scripts/$@.in>$@
266+
263267
# end of local stuff
264268

265269
src/sscan.o : src/sparse.c

‎expected/circle.out

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
(1 row)
66

77
-- Input/Output ---
8+
SELECT scircle_deg(spoint(10,10), 90);
9+
scircle_deg
10+
------------------------------------------
11+
<(0.57522204 , -0.57522204) , 1.5707963>
12+
(1 row)
13+
14+
SELECT scircle_deg(spoint(10,10), 91);
15+
ERROR: radius must not be greater than 90 degrees or less than 0
16+
SELECT scircle_deg(spoint(0,0), 0);
17+
scircle_deg
18+
---------------
19+
<(0 , 0) , 0>
20+
(1 row)
21+
22+
SELECT scircle_deg(spoint(10,10), -1);
23+
ERROR: radius must not be greater than 90 degrees or less than 0
824
SELECT set_sphere_output( 'RAD' );
925
set_sphere_output
1026
-------------------

‎expected/init_test.out.in

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,19 @@ psql:pg_sphere.test.sql:108: NOTICE: argument type sellipse is only a shell
1818
psql:pg_sphere.test.sql:126: NOTICE: type "spoly" is not yet defined
1919
DETAIL: Creating a shell type definition.
2020
psql:pg_sphere.test.sql:133: NOTICE: argument type spoly is only a shell
21-
psql:pg_sphere.test.sql:152: NOTICE: type "spath" is not yet defined
21+
psql:pg_sphere.test.sql:139: NOTICE: return type spoly is only a shell
22+
psql:pg_sphere.test.sql:163: NOTICE: type "spath" is not yet defined
2223
DETAIL: Creating a shell type definition.
23-
psql:pg_sphere.test.sql:159: NOTICE: argument type spath is only a shell
24-
psql:pg_sphere.test.sql:178: NOTICE: type "sbox" is not yet defined
24+
psql:pg_sphere.test.sql:170: NOTICE: argument type spath is only a shell
25+
psql:pg_sphere.test.sql:189: NOTICE: type "sbox" is not yet defined
2526
DETAIL: Creating a shell type definition.
26-
psql:pg_sphere.test.sql:185: NOTICE: argument type sbox is only a shell
27-
psql:pg_sphere.test.sql:8540: NOTICE: type "spherekey" is not yet defined
27+
psql:pg_sphere.test.sql:196: NOTICE: argument type sbox is only a shell
28+
psql:pg_sphere.test.sql:8568: NOTICE: type "spherekey" is not yet defined
2829
DETAIL: Creating a shell type definition.
29-
psql:pg_sphere.test.sql:8547: NOTICE: argument type spherekey is only a shell
30-
psql:pg_sphere.test.sql:8561: NOTICE: type "pointkey" is not yet defined
30+
psql:pg_sphere.test.sql:8575: NOTICE: argument type spherekey is only a shell
31+
psql:pg_sphere.test.sql:8589: NOTICE: type "pointkey" is not yet defined
3132
DETAIL: Creating a shell type definition.
32-
psql:pg_sphere.test.sql:8568: NOTICE: argument type pointkey is only a shell
33-
psql:pg_sphere.test.sql:8574: NOTICE: argument type pointkey is only a shell
34-
psql:pg_sphere.test.sql:8580: NOTICE: argument type pointkey is only a shell
35-
psql:pg_sphere.test.sql:8586: NOTICE: argument type pointkey is only a shell
33+
psql:pg_sphere.test.sql:8596: NOTICE: argument type pointkey is only a shell
34+
psql:pg_sphere.test.sql:8602: NOTICE: argument type pointkey is only a shell
35+
psql:pg_sphere.test.sql:8608: NOTICE: argument type pointkey is only a shell
36+
psql:pg_sphere.test.sql:8614: NOTICE: argument type pointkey is only a shell

‎expected/init_test_healpix.out.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
psql:pg_sphere.test.sql:9153: NOTICE: return type smoc is only a shell
2-
psql:pg_sphere.test.sql:9159: NOTICE: argument type smoc is only a shell
1+
psql:pg_sphere.test.sql:9181: NOTICE: return type smoc is only a shell
2+
psql:pg_sphere.test.sql:9187: NOTICE: argument type smoc is only a shell

‎expected/points.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,24 @@ SELECT spoint(0.0109083078249646 , -0.000727220521664407);
239239
(0.625d , -0.041666667d)
240240
(1 row)
241241

242+
SELECT spoint_deg(57.2958, 57.2958);
243+
spoint_deg
244+
-----------------------
245+
(57.2958d , 57.2958d)
246+
(1 row)
247+
248+
SELECT spoint_deg(0, 0);
249+
spoint_deg
250+
------------
251+
(0d , 0d)
252+
(1 row)
253+
254+
SELECT spoint_deg(114.5916, 0);
255+
spoint_deg
256+
------------------
257+
(114.5916d , 0d)
258+
(1 row)
259+
242260
SELECT set_sphere_output( 'RAD' );
243261
set_sphere_output
244262
-------------------

‎expected/poly.out

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,11 +318,37 @@ SELECT spoly '{(10d,0d),(10d,1d),(15d,0d)}';
318318
{(10d , 0d),(10d , 1d),(15d , 0d)}
319319
(1 row)
320320

321+
SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0, 6.0]);
322+
spoly_deg
323+
----------------------------------------------------------------------------------
324+
{(237.29578d , 65.408441d),(351.88734d , -49.183118d),(286.4789d , -16.225323d)}
325+
(1 row)
326+
327+
SELECT spoly_deg(ARRAY[10.0, 0.0, 10.0, 1.0, 15.0, 0.0]);
328+
spoly_deg
329+
--------------------------------------------------------------
330+
{(212.9578d , 0d),(212.9578d , 57.29578d),(139.43669d , 0d)}
331+
(1 row)
332+
321333
-- incorrect input -----
322334
SELECT spoly '{(10d,0d),(10d,1d)}';
323335
ERROR: spherepoly_in: more than two points needed
324336
LINE 1: SELECT spoly '{(10d,0d),(10d,1d)}';
325337
^
338+
SELECT spoly_deg(ARRAY[1.0, 2.0, 3.0, 4.0, 5.0]);
339+
ERROR: Invalid arguments count. It must be even and >= 6
340+
SELECT spoly_deg(ARRAY[]::float8[]);
341+
spoly_deg
342+
-----------
343+
344+
(1 row)
345+
346+
SELECT spoly_deg(NULL::float8[]);
347+
spoly_deg
348+
-----------
349+
350+
(1 row)
351+
326352
--- self-crossing input -----
327353
SELECT spoly '{(0d,0d),(10d,10d),(0d,10d),(10d,0d)}';
328354
ERROR: spherepoly_from_array: a line segment overlaps or polygon too large

‎pgs_circle.sql.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ CREATE FUNCTION scircle(spoint, float8)
3232
COMMENT ON FUNCTION scircle(spoint, float8) IS
3333
'spherical circle with spherical point as center and float8 as radius in radians';
3434

35+
CREATE FUNCTION scircle_deg(spoint, float8)
36+
RETURNS scircle
37+
AS 'MODULE_PATHNAME' , 'spherecircle_by_center_deg'
38+
LANGUAGE 'c'
39+
IMMUTABLE STRICT PARALLEL SAFE;
40+
41+
COMMENT ON FUNCTION scircle_deg(spoint, float8) IS
42+
'spherical circle with spherical point as center and float8 as radius in degrees';
3543

3644
--
3745
-- Casting point as circle

‎pgs_point.sql.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ CREATE FUNCTION spoint(FLOAT8, FLOAT8)
1515
LANGUAGE 'c'
1616
IMMUTABLE STRICT PARALLEL SAFE;
1717

18+
CREATE FUNCTION spoint_deg(FLOAT8, FLOAT8)
19+
RETURNS spoint
20+
AS 'MODULE_PATHNAME', 'spherepoint_from_long_lat_deg'
21+
LANGUAGE 'c'
22+
IMMUTABLE STRICT PARALLEL SAFE;
23+
1824
CREATE FUNCTION set_sphere_output_precision(INT4)
1925
RETURNS CSTRING
2026
AS 'MODULE_PATHNAME', 'set_sphere_output_precision'
@@ -28,6 +34,9 @@ CREATE FUNCTION set_sphere_output(CSTRING)
2834
COMMENT ON FUNCTION spoint(FLOAT8, FLOAT8) IS
2935
'returns a spherical point from longitude (arg1), latitude (arg2)';
3036

37+
COMMENT ON FUNCTION spoint_deg(FLOAT8, FLOAT8) IS
38+
'returns a spherical point from longitude(in degrees) (arg1), latitude(in degrees) (arg2)';
39+
3140
CREATE FUNCTION long(spoint)
3241
RETURNS FLOAT8
3342
AS 'MODULE_PATHNAME', 'spherepoint_long'

‎pgs_types.sql.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,17 @@ CREATE FUNCTION spoly_out(spoly)
132132
LANGUAGE 'c'
133133
IMMUTABLE STRICT;
134134

135+
CREATE FUNCTION spoly_deg(float8[])
136+
RETURNS spoly
137+
AS 'MODULE_PATHNAME', 'spherepoly_deg'
138+
LANGUAGE 'c'
139+
IMMUTABLE STRICT;
140+
141+
COMMENT ON FUNCTION spoly_deg(float8[]) IS
142+
' -- Create spoly from array of points.
143+
-- Two consecutive numbers among those present
144+
-- refer to the same occurrence and cover its
145+
-- longitude and latitude, respectively.';
135146

136147
CREATE TYPE spoly (
137148
internallength = VARIABLE,

‎sql/circle.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ SET extra_float_digits = 0;
55

66
-- Input/Output ---
77

8+
SELECT scircle_deg(spoint(10,10),90);
9+
10+
SELECT scircle_deg(spoint(10,10),91);
11+
12+
SELECT scircle_deg(spoint(0,0),0);
13+
14+
SELECT scircle_deg(spoint(10,10),-1);
15+
816
SELECT set_sphere_output('RAD' );
917

1018
SELECT'< (1h 2m 30s , +1d 2m 30s), 1.0d >'::scircle;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp