-
-// calculate the center of a list of points, by taking the halfway
-// point between the min and max points.
-static Point3D calc_center( point_list& wgs84_nodes ) {
- Point3D p, min, max;
-
- if ( wgs84_nodes.size() ) {
- min = max = wgs84_nodes[0];
- } else {
- min = max = Point3D( 0 );
- }
-
- for ( int i = 0; i < (int)wgs84_nodes.size(); ++i ) {
- p = wgs84_nodes[i];
-
- if ( p.x() < min.x() ) { min.setx( p.x() ); }
- if ( p.y() < min.y() ) { min.sety( p.y() ); }
- if ( p.z() < min.z() ) { min.setz( p.z() ); }
-
- if ( p.x() > max.x() ) { max.setx( p.x() ); }
- if ( p.y() > max.y() ) { max.sety( p.y() ); }
- if ( p.z() > max.z() ) { max.setz( p.z() ); }
- }
-
- return ( min + max ) / 2.0;
-}
-
-// calculate the bounding sphere. Center is the center of the
-// tile and zero elevation
-double sgCalcBoundingRadius( Point3D center, point_list& wgs84_nodes ) {
- double dist_squared;
- double radius_squared = 0;
-
- for ( int i = 0; i < (int)wgs84_nodes.size(); ++i ) {
- dist_squared = center.distance3Dsquared( wgs84_nodes[i] );
- if ( dist_squared > radius_squared ) {
- radius_squared = dist_squared;
- }
- }
-
- return sqrt(radius_squared);
-}
-
-
-