Skip to content

Commit ca6cfa8

Browse files
committed
More refactoring.
1 parent ee9d5fc commit ca6cfa8

File tree

18 files changed

+261
-322
lines changed

18 files changed

+261
-322
lines changed

box.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,13 @@ sbox_check(SBOX *box)
9999
/*
100100
* Puts "center" of box "b" into point "c" and returns it.
101101
*/
102-
static SPoint *
102+
static void
103103
sbox_center(SPoint *c, const SBOX *b)
104104
{
105105
c->lat = (b->ne.lat + b->sw.lat) / 2.0;
106106
c->lng = (b->ne.lng + b->sw.lng) / 2.0;
107107
if (FPgt(b->sw.lng, b->ne.lng))
108-
{
109108
c->lng += PI;
110-
}
111-
return c;
112109
}
113110

114111

circle.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,16 @@ spoint_in_circle(const SPoint *p, const SCIRCLE *c)
4444

4545
if (FPle(dist, c->radius))
4646
{
47-
return (TRUE);
47+
return true;
4848
}
49-
return (FALSE);
49+
return false;
5050
}
5151

52-
SCIRCLE *
52+
void
5353
euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se)
5454
{
5555
euler_spoint_trans(&out->center, &in->center, se);
5656
out->radius = in->radius;
57-
return out;
5857
}
5958

6059
Datum
@@ -392,11 +391,12 @@ spherecircle_circ(PG_FUNCTION_ARGS)
392391
Datum
393392
spheretrans_circle(PG_FUNCTION_ARGS)
394393
{
395-
SCIRCLE *sc = (SCIRCLE *) PG_GETARG_POINTER(0);
394+
SCIRCLE *sc = (SCIRCLE *) PG_GETARG_POINTER(0);
396395
SEuler *se = (SEuler *) PG_GETARG_POINTER(1);
397-
SCIRCLE *out = (SCIRCLE *) palloc(sizeof(SCIRCLE));
396+
SCIRCLE *out = (SCIRCLE *) palloc(sizeof(SCIRCLE));
398397

399-
PG_RETURN_POINTER(euler_scircle_trans(out, sc, se));
398+
euler_scircle_trans(out, sc, se);
399+
PG_RETURN_POINTER(out);
400400
}
401401

402402
Datum

circle.h

Lines changed: 91 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -3,155 +3,155 @@
33

44
#include "euler.h"
55

6-
/*
7-
* Spherical circle declarations
8-
*/
6+
/*
7+
* Spherical circle declarations
8+
*/
99

10-
/*
11-
* Spherical circle data structure: center and radius.
12-
*/
10+
/*
11+
* Spherical circle data structure: center and radius.
12+
*/
1313
typedef struct
1414
{
1515
SPoint center; /* the center of circle */
1616
float8 radius; /* the circle radius in radians */
1717
} SCIRCLE;
1818

19-
/*
20-
* Checks whether two circles are equal.
21-
*/
19+
/*
20+
* Checks whether two circles are equal.
21+
*/
2222
bool scircle_eq(const SCIRCLE *c1, const SCIRCLE *c2);
2323

24-
/*
25-
* Checks whether circle contains point.
26-
*/
24+
/*
25+
* Checks whether circle contains point.
26+
*/
2727
bool spoint_in_circle(const SPoint *p, const SCIRCLE *c);
2828

29-
/*
30-
* Transforms a circle using Euler transformation.
31-
*/
32-
SCIRCLE *euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se);
29+
/*
30+
* Transforms a circle using Euler transformation.
31+
*/
32+
void euler_scircle_trans(SCIRCLE *out, const SCIRCLE *in, const SEuler *se);
3333

34-
/*
35-
* Takes the input and stores it as spherical circle.
36-
*/
34+
/*
35+
* Takes the input and stores it as spherical circle.
36+
*/
3737
Datum spherecircle_in(PG_FUNCTION_ARGS);
3838

39-
/*
40-
* Checks whether two circles are equal.
41-
*/
39+
/*
40+
* Checks whether two circles are equal.
41+
*/
4242
Datum spherecircle_equal(PG_FUNCTION_ARGS);
4343

44-
/*
45-
* Checks whether two circles are not equal.
46-
*/
44+
/*
45+
* Checks whether two circles are not equal.
46+
*/
4747
Datum spherecircle_equal_neg(PG_FUNCTION_ARGS);
4848

49-
/*
50-
* Calculate the distance of two circles. If overlapping, this function
51-
* returns 0.0.
52-
*/
49+
/*
50+
* Calculate the distance of two circles. If overlapping, this function
51+
* returns 0.0.
52+
*/
5353
Datum spherecircle_distance(PG_FUNCTION_ARGS);
5454

55-
/*
56-
* Calculate the distance of circle and point. If circle contains point,
57-
* this function returns 0.0.
58-
*/
55+
/*
56+
* Calculate the distance of circle and point. If circle contains point,
57+
* this function returns 0.0.
58+
*/
5959
Datum spherecircle_point_distance(PG_FUNCTION_ARGS);
6060

61-
/*
62-
* Calculate the distance of point and circle. If circle contains point,
63-
* this function returns 0.0.
64-
*/
61+
/*
62+
* Calculate the distance of point and circle. If circle contains point,
63+
* this function returns 0.0.
64+
*/
6565
Datum spherecircle_point_distance_com(PG_FUNCTION_ARGS);
6666

67-
/*
68-
* Checks whether circle contains point.
69-
*/
67+
/*
68+
* Checks whether circle contains point.
69+
*/
7070
Datum spherepoint_in_circle(PG_FUNCTION_ARGS);
7171

72-
/*
73-
* Checks whether circle doesn't contain point.
74-
*/
72+
/*
73+
* Checks whether circle doesn't contain point.
74+
*/
7575
Datum spherepoint_in_circle_neg(PG_FUNCTION_ARGS);
7676

77-
/*
78-
* Checks whether circle contains point.
79-
*/
77+
/*
78+
* Checks whether circle contains point.
79+
*/
8080
Datum spherepoint_in_circle_com(PG_FUNCTION_ARGS);
8181

82-
/*
83-
* Checks whether circle doesn't contain point.
84-
*/
82+
/*
83+
* Checks whether circle doesn't contain point.
84+
*/
8585
Datum spherepoint_in_circle_com_neg(PG_FUNCTION_ARGS);
8686

87-
/*
88-
* Checks whether circle is contained by other circle.
89-
*/
87+
/*
88+
* Checks whether circle is contained by other circle.
89+
*/
9090
Datum spherecircle_in_circle(PG_FUNCTION_ARGS);
9191

92-
/*
93-
* Checks whether circle is not contained by other circle.
94-
*/
92+
/*
93+
* Checks whether circle is not contained by other circle.
94+
*/
9595
Datum spherecircle_in_circle_neg(PG_FUNCTION_ARGS);
9696

97-
/*
98-
* Checks whether circle contains other circle.
99-
*/
97+
/*
98+
* Checks whether circle contains other circle.
99+
*/
100100
Datum spherecircle_in_circle_com(PG_FUNCTION_ARGS);
101101

102-
/*
103-
* Checks whether circle does not contain other circle.
104-
*/
102+
/*
103+
* Checks whether circle does not contain other circle.
104+
*/
105105
Datum spherecircle_in_circle_com_neg(PG_FUNCTION_ARGS);
106106

107-
/*
108-
* Checks whether two circle overlap.
109-
*/
107+
/*
108+
* Checks whether two circle overlap.
109+
*/
110110
Datum spherecircle_overlap(PG_FUNCTION_ARGS);
111111

112-
/*
113-
* Checks whether two circle overlap.
114-
*/
112+
/*
113+
* Checks whether two circle overlap.
114+
*/
115115
Datum spherecircle_overlap_neg(PG_FUNCTION_ARGS);
116116

117-
/*
118-
* Returns the center of circle.
119-
*/
117+
/*
118+
* Returns the center of circle.
119+
*/
120120
Datum spherecircle_center(PG_FUNCTION_ARGS);
121121

122-
/*
123-
* Returns the radius of circle.
124-
*/
122+
/*
123+
* Returns the radius of circle.
124+
*/
125125
Datum spherecircle_radius(PG_FUNCTION_ARGS);
126126

127-
/*
128-
* Converts a point to a circle.
129-
*/
127+
/*
128+
* Converts a point to a circle.
129+
*/
130130
Datum spherepoint_to_circle(PG_FUNCTION_ARGS);
131131

132-
/*
133-
* Creates a circle from center and radius.
134-
*/
132+
/*
133+
* Creates a circle from center and radius.
134+
*/
135135
Datum spherecircle_by_center(PG_FUNCTION_ARGS);
136136

137-
/*
138-
* Calculates the area of a circle in square radians.
139-
*/
137+
/*
138+
* Calculates the area of a circle in square radians.
139+
*/
140140
Datum spherecircle_area(PG_FUNCTION_ARGS);
141141

142-
/*
143-
* Calculates the circumference of a circle in radians.
144-
*/
142+
/*
143+
* Calculates the circumference of a circle in radians.
144+
*/
145145
Datum spherecircle_circ(PG_FUNCTION_ARGS);
146146

147-
/*
148-
* Transforms a circle using Euler transformation.
149-
*/
147+
/*
148+
* Transforms a circle using Euler transformation.
149+
*/
150150
Datum spheretrans_circle(PG_FUNCTION_ARGS);
151151

152-
/*
153-
* Inverse transformation of a circle using Euler transformation.
154-
*/
152+
/*
153+
* Inverse transformation of a circle using Euler transformation.
154+
*/
155155
Datum spheretrans_circle_inverse(PG_FUNCTION_ARGS);
156156

157157
#endif

0 commit comments

Comments
 (0)