Create a new internal node, calculating the new measure range for the node, and storing pointers to the child nodes.
236 double offset1, dist, D, r1, ri;
239 LWDEBUGF(3,
"called with %d nodes --", num_nodes);
246 new_center = c[0]->
center;
247 new_radius = c[0]->
radius;
251 for ( i = 1; i < num_nodes; i++ )
261 if ( ! new_geom_type )
269 if ( new_geom_type != c[i]->geom_type )
285 LWDEBUGF(3,
"distance between new (%g %g) and %i (%g %g) is %g", c1.
lon, c1.
lat, i, c[i]->center.lon, c[i]->center.lat, dist);
289 LWDEBUG(3,
" distance between centers is zero");
290 new_radius = r1 + 2*dist;
293 else if ( dist < fabs(r1 - ri) )
306 new_center = c[i]->
center;
312 LWDEBUG(3,
" calculating new center");
318 new_radius = D / 2.0;
321 offset1 = ri + (D - (2.0*r1 + 2.0*ri)) / 2.0;
322 LWDEBUGF(3,
" offset1 is %g", offset1);
334 LWDEBUGF(3,
" new center is (%g %g) new radius is %g", new_center.
lon, new_center.
lat, new_radius);
340 node->
center = new_center;
341 node->
radius = new_radius;
uint32_t lwtype_get_collectiontype(uint8_t type)
Given an lwtype number, what homogeneous collection can hold it?
int lwtype_is_collection(uint8_t type)
Determine whether a type number is a collection or not.
void * lwalloc(size_t size)
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
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 ...
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.
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
Point in spherical coordinates on the world.
struct circ_node ** nodes
Note that p1 and p2 are pointers into an independent POINTARRAY, do not free them.