PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ lonlat_to_cart()

POINT3D * lonlat_to_cart ( const double_t  raw_lon,
const double_t  raw_lat 
)

Definition at line 208 of file geography_centroid.c.

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

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

Referenced by geography_centroid_from_wpoints().

Here is the call graph for this function:
Here is the caller graph for this function: