PostGIS  2.2.7dev-r@@SVN_REVISION@@
static int circ_center_cartesian ( const GEOGRAPHIC_POINT c1,
double  distance,
double  offset,

Where the circ_center_spherical() function fails, we need a fall-back.

The failures happen in short arcs, where the spherical distance between two points is practically the same as the straight-line distance, so our fallback will be to use the straight-line between the two to calculate the new projected center. For proportions far from 0.5 this will be increasingly more incorrect.

Definition at line 165 of file lwgeodetic_tree.c.

References cart2geog(), distance(), geog2cart(), LW_SUCCESS, LWDEBUG, normalize(), POINT3D::x, POINT3D::y, and POINT3D::z.

Referenced by circ_node_internal_new().

166 {
167  POINT3D p1, p2;
168  POINT3D p1p2, pc;
169  double proportion = offset/distance;
171  LWDEBUG(4,"calculating cartesian center");
173  geog2cart(c1, &p1);
174  geog2cart(c2, &p2);
176  /* Difference between p2 and p1 */
177  p1p2.x = p2.x - p1.x;
178  p1p2.y = p2.y - p1.y;
179  p1p2.z = p2.z - p1.z;
181  /* Scale difference to proportion */
182  p1p2.x *= proportion;
183  p1p2.y *= proportion;
184  p1p2.z *= proportion;
186  /* Add difference to p1 to get approximate center point */
187  pc.x = p1.x + p1p2.x;
188  pc.y = p1.y + p1p2.y;
189  pc.z = p1.z + p1p2.z;
190  normalize(&pc);
192  /* Convert center point to geographics */
193  cart2geog(&pc, center);
195  return LW_SUCCESS;
196 }
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:565
double y
Definition: liblwgeom.h:324
#define LW_SUCCESS
Definition: liblwgeom.h:65
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Convert cartesion coordinates on unit sphere to spherical coordinates.
Definition: lwgeodetic.c:364
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:50
double x
Definition: liblwgeom.h:324
double z
Definition: liblwgeom.h:324
Datum distance(PG_FUNCTION_ARGS)
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesion coordinates on unit sphere.
Definition: lwgeodetic.c:354

Here is the call graph for this function:

Here is the caller graph for this function: