Skip to content

Commit 595ecc9

Browse files
committed
Fix found problems after review
1 parent 9d5fa49 commit 595ecc9

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

Diff for: expected/poly.out

+5-5
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,18 @@ SELECT spoly(NULL::spoint[]);
350350
(1 row)
351351

352352
SELECT spoly(ARRAY[]::spoint[]);
353-
ERROR: spoly_deg: invalid number of arguments (must be >= 3)
353+
ERROR: spherepoly_from_point_array: invalid number of arguments (must be >= 3)
354354
SELECT spoly(ARRAY[spoint_deg(0, 0)]);
355-
ERROR: spoly_deg: invalid number of arguments (must be >= 3)
355+
ERROR: spherepoly_from_point_array: invalid number of arguments (must be >= 3)
356356
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0)]);
357-
ERROR: spoly_deg: invalid number of arguments (must be >= 3)
358-
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10)]);
357+
ERROR: spherepoly_from_point_array: invalid number of arguments (must be >= 3)
358+
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10)]);
359359
spoly
360360
------------------------------------
361361
{(0d , 0d),(10d , 0d),(10d , 10d)}
362362
(1 row)
363363

364-
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10), spoint_deg(0, 10)]);
364+
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10), spoint_deg(0, 10)]);
365365
spoly
366366
-----------------------------------------------
367367
{(0d , 0d),(10d , 0d),(10d , 10d),(0d , 10d)}

Diff for: sql/poly.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ SELECT spoly(ARRAY[spoint_deg(0, 0)]);
9696

9797
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0)]);
9898

99-
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10)]);
99+
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10)]);
100100

101-
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10,10), spoint_deg(0, 10)]);
101+
SELECT spoly(ARRAY[spoint_deg(0, 0), spoint_deg(10, 0), spoint_deg(10, 10), spoint_deg(0, 10)]);
102102

103103
--- incorrect input -----
104104

Diff for: src/polygon.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -1010,21 +1010,21 @@ spherepoly_deg(PG_FUNCTION_ARGS)
10101010
Datum
10111011
spherepoly_from_point_array(PG_FUNCTION_ARGS)
10121012
{
1013-
int np;
1014-
ArrayType *inarr = PG_GETARG_ARRAYTYPE_P(0);
10151013
SPoint *points;
1016-
1017-
np = ArrayGetNItems(ARR_NDIM(inarr), ARR_DIMS(inarr));
1014+
ArrayType *inarr = PG_GETARG_ARRAYTYPE_P(0);
1015+
const int np = ArrayGetNItems(ARR_NDIM(inarr), ARR_DIMS(inarr));
10181016

10191017
if (np < 3)
10201018
{
1021-
elog(ERROR, "spoly_deg: invalid number of arguments (must be >= 3)");
1019+
elog(ERROR, "spherepoly_from_point_array: "
1020+
"invalid number of arguments (must be >= 3)");
10221021
PG_RETURN_NULL();
10231022
}
10241023

10251024
if (ARR_HASNULL(inarr))
10261025
{
1027-
elog(ERROR, "spoly_deg: input array is invalid because if has null values");
1026+
elog(ERROR, "spherepoly_from_point_array: "
1027+
"input array is invalid because it has null values");
10281028
PG_RETURN_NULL();
10291029
}
10301030

Diff for: src/polygon.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,22 @@ Datum spherepoly_get_point(PG_FUNCTION_ARGS);
8787
int8 poly_line_pos(const SPOLY *poly, const SLine *line);
8888

8989
/*
90-
* Input of a spherical from array of pair-consecutive numbers (lng, lat), in radians.
90+
* Creates a spherical polygon (spoly) from an array of pair-consecutive
91+
* numbers (lng, lat), in radians.
9192
*/
9293
Datum spherepoly_rad(PG_FUNCTION_ARGS);
9394

9495
/*
95-
* Input of a spherical from array of pair-consecutive numbers (lng, lat), in degrees.
96+
* Creates a spherical polygon (spoly) from an array of pair-consecutive
97+
* numbers (lng, lat), in degrees.
9698
*/
9799
Datum spherepoly_deg(PG_FUNCTION_ARGS);
98100

101+
/*
102+
* Creates a spherical polygon (spoly) from an array of spoint elements.
103+
*/
104+
Datum spherepoly_from_point_array(PG_FUNCTION_ARGS);
105+
99106
/*
100107
* Input of a spherical polygon.
101108
*/

0 commit comments

Comments
 (0)