PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ interpolate_point4d_spheroid()

static void interpolate_point4d_spheroid ( const POINT4D p1,
const POINT4D p2,
POINT4D p,
const SPHEROID s,
double  f 
)
static

Find interpolation point p between geography points p1 and p2 so that the len(p1,p) == len(p1,p2) f and p falls on p1,p2 segment.

Definition at line 60 of file lwgeodetic_measures.c.

64{
65 GEOGRAPHIC_POINT g, g1, g2;
66 geographic_point_init(p1->x, p1->y, &g1);
67 geographic_point_init(p2->x, p2->y, &g2);
68 int success;
69 double dist, dir;
70
71 /* Special sphere case */
72 if ( s == NULL || s->a == s->b )
73 {
74 /* Calculate distance and direction between g1 and g2 */
75 dist = sphere_distance(&g1, &g2);
76 dir = sphere_direction(&g1, &g2, dist);
77 /* Compute interpolation point */
78 success = sphere_project(&g1, dist*f, dir, &g);
79 }
80 /* Spheroid case */
81 else
82 {
83 /* Calculate distance and direction between g1 and g2 */
84 dist = spheroid_distance(&g1, &g2, s);
85 dir = spheroid_direction(&g1, &g2, s);
86 /* Compute interpolation point */
87 success = spheroid_project(&g1, s, dist*f, dir, &g);
88 }
89
90 /* If success, use newly computed lat and lon,
91 * otherwise return precomputed cartesian result */
92 if (success == LW_SUCCESS)
93 {
96 }
97}
char * s
Definition cu_in_wkt.c:23
#define LW_SUCCESS
Definition liblwgeom.h:97
double longitude_radians_normalize(double lon)
Convert a longitude to the range of -PI,PI.
Definition lwgeodetic.c:50
double latitude_radians_normalize(double lat)
Convert a latitude to the range of -PI/2,PI/2.
Definition lwgeodetic.c:78
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 ...
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition lwgeodetic.c:180
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
Definition lwgeodetic.c:896
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.
Definition lwgeodetic.c:927
#define rad2deg(r)
Definition lwgeodetic.h:81
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,...
Definition lwspheroid.c:79
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.
Definition lwspheroid.c:128
double spheroid_direction(const GEOGRAPHIC_POINT *r, const GEOGRAPHIC_POINT *s, const SPHEROID *spheroid)
Computes the forward azimuth of the geodesic joining two points on the spheroid, using the inverse ge...
Definition lwspheroid.c:105
Point in spherical coordinates on the world.
Definition lwgeodetic.h:54
double x
Definition liblwgeom.h:414
double y
Definition liblwgeom.h:414

References geographic_point_init(), GEOGRAPHIC_POINT::lat, latitude_radians_normalize(), GEOGRAPHIC_POINT::lon, longitude_radians_normalize(), LW_SUCCESS, rad2deg, s, sphere_direction(), sphere_distance(), sphere_project(), spheroid_direction(), spheroid_distance(), spheroid_project(), POINT4D::x, and POINT4D::y.

Referenced by geography_interpolate_points(), and geography_substring().

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