PostGIS  2.1.10dev-r@@SVN_REVISION@@
static void test_sphere_project ( void  )
static

Definition at line 90 of file cu_geodetic.c.

References geographic_point_init(), GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, s, sphere_direction(), sphere_distance(), and sphere_project().

Referenced by geodetic_suite_setup().

91 {
93  double dir1, dist1, dir2, dist2;
94 
95  dir1 = M_PI/2;
96  dist1 = 0.1;
97 
98  geographic_point_init(0, 0, &s);
99  sphere_project(&s, dist1, dir1, &e);
100 
101  dist2 = sphere_distance(&s, &e);
102  dir2 = sphere_direction(&s, &e, dist1);
103 
104  CU_ASSERT_DOUBLE_EQUAL(dist1, dist2, 0.0001);
105  CU_ASSERT_DOUBLE_EQUAL(dir1, dir2, 0.0001);
106 
107  dist1 = sphere_distance(&e, &s);
108  dir1 = sphere_direction(&e, &s, dist1);
109  sphere_project(&e, dist1, dir1, &s);
110 
111  CU_ASSERT_DOUBLE_EQUAL(s.lon, 0.0, 0.0001);
112  CU_ASSERT_DOUBLE_EQUAL(s.lat, 0.0, 0.0001);
113 
114  geographic_point_init(0, 0.2, &e);
115  geographic_point_init(0, 0.4, &s);
116  dist1 = sphere_distance(&s, &e);
117  dir1 = sphere_direction(&e, &s, dist1);
118  CU_ASSERT_DOUBLE_EQUAL(dir1, 0.0, 0.0001);
119 
120  geographic_point_init(0, 1, &s);
121  geographic_point_init(0, 2, &e);
122  dist2 = sphere_distance(&s, &e);
123  dir2 = sphere_direction(&s, &e, dist2);
124  CU_ASSERT_DOUBLE_EQUAL(dir2, 0.0, 0.0001);
125 
126  geographic_point_init(1, 1, &e);
127  dist2 = sphere_distance(&s, &e);
128  dir2 = sphere_direction(&s, &e, dist2);
129  CU_ASSERT_DOUBLE_EQUAL(dir2, 1.57064, 0.0001);
130 
131  geographic_point_init(0, 0, &e);
132  dist2 = sphere_distance(&s, &e);
133  dir2 = sphere_direction(&s, &e, dist2);
134  CU_ASSERT_DOUBLE_EQUAL(dir2, 3.14159, 0.0001);
135 
136  geographic_point_init(-1, 1, &e);
137  dist2 = sphere_distance(&s, &e);
138  dir2 = sphere_direction(&s, &e, dist2);
139  CU_ASSERT_DOUBLE_EQUAL(dir2, -1.57064, 0.0001);
140 
141  geographic_point_init(1, 2, &e);
142  dist2 = sphere_distance(&s, &e);
143  dir2 = sphere_direction(&s, &e, dist2);
144  CU_ASSERT_DOUBLE_EQUAL(dir2, 0.785017, 0.0001);
145 
146  geographic_point_init(-1, 0, &e);
147  dist2 = sphere_distance(&s, &e);
148  dir2 = sphere_direction(&s, &e, dist2);
149  CU_ASSERT_DOUBLE_EQUAL(dir2, -2.35612, 0.0001);
150 }
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:897
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 ...
Definition: lwgeodetic.c:1261
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:33
char * s
Definition: cu_in_wkt.c:24
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
Definition: lwgeodetic.c:157
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:924

Here is the call graph for this function:

Here is the caller graph for this function: