Create a new internal node, calculating the new measure range for the node, and storing pointers to the child nodes.
234 double offset1, dist, D, r1, ri;
235 int i, new_geom_type;
237 LWDEBUGF(3,
"called with %d nodes --", num_nodes);
244 new_center = c[0]->
center;
245 new_radius = c[0]->
radius;
249 for ( i = 1; i < num_nodes; i++ )
259 if ( ! new_geom_type )
267 if ( new_geom_type != c[i]->geom_type )
287 LWDEBUG(3,
" distance between centers is zero");
288 new_radius = r1 + 2*dist;
291 else if ( dist < fabs(r1 - ri) )
304 new_center = c[i]->
center;
310 LWDEBUG(3,
" calculating new center");
316 new_radius = D / 2.0;
319 offset1 = ri + (D - (2.0*r1 + 2.0*ri)) / 2.0;
320 LWDEBUGF(3,
" offset1 is %g", offset1);
332 LWDEBUGF(3,
" new center is (%g %g) new radius is %g", new_center.
lon, new_center.
lat, new_radius);
338 node->
center = new_center;
339 node->
radius = new_radius;
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.
int lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
#define LWDEBUG(level, msg)
static int circ_center_spherical(const GEOGRAPHIC_POINT *c1, const GEOGRAPHIC_POINT *c2, double distance, double offset, GEOGRAPHIC_POINT *center)
Given the centers of two circles, and the offset distance we want to put the new center between them ...
Point in spherical coordinates on the world.
static int circ_center_cartesian(const GEOGRAPHIC_POINT *c1, const GEOGRAPHIC_POINT *c2, double distance, double offset, GEOGRAPHIC_POINT *center)
Where the circ_center_spherical() function fails, we need a fall-back.
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
void * lwalloc(size_t size)
#define LWDEBUGF(level, msg,...)
struct circ_node ** nodes