121{
122 const uint32_t segments = 4*segments_per_quarter;
123 double theta;
127 uint32_t i;
128
129 if (segments_per_quarter == 0)
130 {
131 lwerror(
"Need at least one segment per quarter-circle.");
132 return NULL;
133 }
134
135 if (radius < 0)
136 {
137 lwerror(
"Radius must be positive.");
138 return NULL;
139 }
140
141 theta = 2*M_PI / segments;
142
145
146 if (exterior)
147 radius *= sqrt(1 + pow(tan(theta/2), 2));
148
149 for (i = 0; i <= segments; i++)
150 {
151 pt.
x =
x + radius*sin(i * theta);
152 pt.
y =
y + radius*cos(i * theta);
154 }
155
157 return lwpoly;
158}
POINTARRAY * ptarray_construct_empty(char hasz, char hasm, uint32_t maxpoints)
Create a new POINTARRAY with no points.
int ptarray_append_point(POINTARRAY *pa, const POINT4D *pt, int allow_duplicates)
Append a point to the end of an existing POINTARRAY If allow_duplicate is LW_FALSE,...
#define LW_TRUE
Return types for functions with status returns.
void void lwerror(const char *fmt,...) __attribute__((format(printf
Write a notice out to the error handler.
int lwpoly_add_ring(LWPOLY *poly, POINTARRAY *pa)
Add a ring to a polygon.
LWPOLY * lwpoly_construct_empty(int32_t srid, char hasz, char hasm)