PostGIS  2.4.9dev-r@@SVN_REVISION@@
lwgeodetic.h File Reference
#include <math.h>
Include dependency graph for lwgeodetic.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GEOGRAPHIC_POINT
 Point in spherical coordinates on the world. More...
 
struct  GEOGRAPHIC_EDGE
 Two-point great circle segment from a to b. More...
 
struct  DISTANCE_ORDER
 Holder for sorting points in distance algorithm. More...
 

Macros

#define _GNU_SOURCE
 
#define NAN   0.0/0.0
 
#define POW2(x)   ((x)*(x))
 
#define deg2rad(d)   (M_PI * (d) / 180.0)
 Conversion functions. More...
 
#define rad2deg(r)   (180.0 * (r) / M_PI)
 
#define PIR_NO_INTERACT   0x00
 Bitmask elements for edge_intersects() return value. More...
 
#define PIR_INTERSECTS   0x01
 
#define PIR_COLINEAR   0x02
 
#define PIR_A_TOUCH_RIGHT   0x04
 
#define PIR_A_TOUCH_LEFT   0x08
 
#define PIR_B_TOUCH_RIGHT   0x10
 
#define PIR_B_TOUCH_LEFT   0x20
 

Functions

void geog2cart (const GEOGRAPHIC_POINT *g, POINT3D *p)
 Convert spherical coordinates to cartesion coordinates on unit sphere. More...
 
void cart2geog (const POINT3D *p, GEOGRAPHIC_POINT *g)
 Convert cartesion coordinates on unit sphere to spherical coordinates. More...
 
void robust_cross_product (const GEOGRAPHIC_POINT *p, const GEOGRAPHIC_POINT *q, POINT3D *a)
 Computes the cross product of two vectors using their lat, lng representations. More...
 
void x_to_z (POINT3D *p)
 
void y_to_z (POINT3D *p)
 
int edge_point_on_plane (const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
 Returns true if the point p is on the great circle plane. More...
 
int edge_point_in_cone (const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
 Returns true if the point p is inside the cone defined by the two ends of the edge e. More...
 
int edge_contains_coplanar_point (const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
 True if the longitude of p is within the range of the longitude of the ends of e. More...
 
int edge_contains_point (const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
 Returns true if the point p is on the minor edge defined by the end points of e. More...
 
double z_to_latitude (double z, int top)
 Used in great circle to compute the pole of the great circle. More...
 
int clairaut_cartesian (const POINT3D *start, const POINT3D *end, GEOGRAPHIC_POINT *g_top, GEOGRAPHIC_POINT *g_bottom)
 Computes the pole of the great circle disk which is the intersection of the great circle with the line of maximum/minimum gradiant that lies on the great circle plane. More...
 
int clairaut_geographic (const GEOGRAPHIC_POINT *start, const GEOGRAPHIC_POINT *end, GEOGRAPHIC_POINT *g_top, GEOGRAPHIC_POINT *g_bottom)
 Computes the pole of the great circle disk which is the intersection of the great circle with the line of maximum/minimum gradiant that lies on the great circle plane. More...
 
double sphere_distance (const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
 Given two points on a unit sphere, calculate their distance apart in radians. More...
 
double sphere_distance_cartesian (const POINT3D *s, const POINT3D *e)
 Given two unit vectors, calculate their distance apart in radians. More...
 
int sphere_project (const GEOGRAPHIC_POINT *r, double distance, double azimuth, GEOGRAPHIC_POINT *n)
 Given a starting location r, a distance and an azimuth to the new point, compute the location of the projected point on the unit sphere. More...
 
int edge_calculate_gbox_slow (const GEOGRAPHIC_EDGE *e, GBOX *gbox)
 
int edge_calculate_gbox (const POINT3D *A1, const POINT3D *A2, GBOX *gbox)
 The magic function, given an edge in spherical coordinates, calculate a 3D bounding box that fully contains it, taking into account the curvature of the sphere on which it is inscribed. More...
 
int edge_intersection (const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *g)
 Returns true if an intersection can be calculated, and places it in *g. More...
 
int edge_intersects (const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
 Returns non-zero if edges A and B interact. More...
 
double edge_distance_to_point (const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
 
double edge_distance_to_edge (const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2)
 Calculate the distance between two edges. More...
 
void geographic_point_init (double lon, double lat, GEOGRAPHIC_POINT *g)
 Initialize a geographic point. More...
 
int ptarray_contains_point_sphere (const POINTARRAY *pa, const POINT2D *pt_outside, const POINT2D *pt_to_test)
 This routine returns LW_TRUE if the stabline joining the pt_outside and pt_to_test crosses the ring an odd number of times, or if the pt_to_test is on the ring boundary itself, returning LW_FALSE otherwise. More...
 
int lwpoly_covers_point2d (const LWPOLY *poly, const POINT2D *pt_to_test)
 Given a polygon (lon/lat decimal degrees) and point (lon/lat decimal degrees) and a guaranteed outside point (lon/lat decimal degrees) (calculate with gbox_pt_outside()) return LW_TRUE if point is inside or on edge of polygon. More...
 
int lwpoly_covers_lwpoly (const LWPOLY *lwpoly1, const LWPOLY *lwpoly2)
 Given a polygon1 check if all points of polygon2 are inside polygon1 and no intersections of the polygon edges occur. More...
 
int lwpoly_covers_pointarray (const LWPOLY *lwpoly, const POINTARRAY *pta)
 return LW_TRUE if all points are inside the polygon More...
 
int lwpoly_covers_lwline (const LWPOLY *poly, const LWLINE *line)
 
int lwline_covers_lwline (const LWLINE *lwline1, const LWLINE *lwline2)
 Check if first and last point of line2 are covered by line1 and then each point in between has to be one line1 in the exact same order return LW_TRUE if all edge points of line2 are on line1. More...
 
int lwline_covers_lwpoint (const LWLINE *lwline, const LWPOINT *lwpoint)
 return LW_TRUE if any of the line segments covers the point More...
 
int lwpoly_intersects_line (const LWPOLY *lwpoly, const POINTARRAY *line)
 Checks if any edges of lwpoly intersect with the line formed by the pointarray return LW_TRUE if any intersection beetween the given polygon and the line. More...
 
int lwpoly_pt_outside (const LWPOLY *poly, POINT2D *pt_outside)
 
int ptarray_point_in_ring (const POINTARRAY *pa, const POINT2D *pt_outside, const POINT2D *pt_to_test)
 
double ptarray_area_sphere (const POINTARRAY *pa)
 Returns the area of the ring (ring must be closed) in square radians (surface of the sphere is 4*PI). More...
 
double latitude_degrees_normalize (double lat)
 Convert a latitude to the range of -90,90. More...
 
double longitude_degrees_normalize (double lon)
 Convert a longitude to the range of -180,180. More...
 
double ptarray_length_spheroid (const POINTARRAY *pa, const SPHEROID *s)
 
int geographic_point_equals (const GEOGRAPHIC_POINT *g1, const GEOGRAPHIC_POINT *g2)
 
int crosses_dateline (const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
 
void point_shift (GEOGRAPHIC_POINT *p, double shift)
 Shift a point around by a number of radians. More...
 
double longitude_radians_normalize (double lon)
 Convert a longitude to the range of -PI,PI. More...
 
double latitude_radians_normalize (double lat)
 Convert a latitude to the range of -PI/2,PI/2. More...
 
void vector_sum (const POINT3D *a, const POINT3D *b, POINT3D *n)
 Calculate the sum of two vectors. More...
 
void vector_scale (POINT3D *a, double s)
 Scale a vector out by a factor. More...
 
double vector_angle (const POINT3D *v1, const POINT3D *v2)
 Angle between two unit vectors. More...
 
void vector_rotate (const POINT3D *v1, const POINT3D *v2, double angle, POINT3D *n)
 Rotates v1 through an angle (in radians) within the plane defined by v1/v2, returns the rotated vector in n. More...
 
void normalize (POINT3D *p)
 Normalize to a unit vector. More...
 
void unit_normal (const POINT3D *P1, const POINT3D *P2, POINT3D *normal)
 Calculates the unit normal to two vectors, trying to avoid problems with over-narrow or over-wide cases. More...
 
double sphere_direction (const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e, double d)
 Given two points on a unit sphere, calculate the direction from s to e. More...
 
void ll2cart (const POINT2D *g, POINT3D *p)
 Convert lon/lat coordinates to cartesion coordinates on unit sphere. More...
 
double spheroid_distance (const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
 Computes the shortest distance along the surface of the spheroid between two points. More...
 
double spheroid_direction (const GEOGRAPHIC_POINT *r, const GEOGRAPHIC_POINT *s, const SPHEROID *spheroid)
 Computes the direction of the geodesic joining two points on the spheroid. More...
 
int spheroid_project (const GEOGRAPHIC_POINT *r, const SPHEROID *spheroid, double distance, double azimuth, GEOGRAPHIC_POINT *g)
 Given a location, an azimuth and a distance, computes the location of the projected point. More...
 

Variables

int gbox_geocentric_slow
 For testing geodetic bounding box, we have a magic global variable. More...