PostGIS  2.5.0dev-r@@SVN_REVISION@@
POINT3D * lonlat_to_cart ( const double_t  raw_lon,
const double_t  raw_lat 
)

Definition at line 207 of file geography_centroid.c.

References lwalloc(), POINT3D::x, POINT3D::y, and POINT3D::z.

Referenced by geography_centroid_from_wpoints().

208 {
209  double_t lat, lon;
210  double_t sin_lat;
211 
212  POINT3D* point = lwalloc(sizeof(POINT3D));;
213 
214  // prepare coordinate for trigonometric functions from [-90, 90] -> [0, pi]
215  lat = (raw_lat + 90) / 180 * M_PI;
216 
217  // prepare coordinate for trigonometric functions from [-180, 180] -> [-pi, pi]
218  lon = raw_lon / 180 * M_PI;
219 
220  /* calculate value only once */
221  sin_lat = sinl(lat);
222 
223  /* convert to 3D cartesian coordinates */
224  point->x = sin_lat * cosl(lon);
225  point->y = sin_lat * sinl(lon);
226  point->z = cosl(lat);
227 
228  return point;
229 }
double y
Definition: liblwgeom.h:339
double x
Definition: liblwgeom.h:339
double z
Definition: liblwgeom.h:339
void * lwalloc(size_t size)
Definition: lwutil.c:229

Here is the call graph for this function:

Here is the caller graph for this function: