]> granicus.if.org Git - postgis/commitdiff
Add edge-edge distance tests.
authorPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 30 Sep 2009 23:03:29 +0000 (23:03 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Wed, 30 Sep 2009 23:03:29 +0000 (23:03 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@4568 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/cunit/cu_geodetic.c
liblwgeom/cunit/cu_geodetic.h

index f9b160815b2aa13e76657bc6b6fdf7d9a060cf2f..56ed0f799b801dbdc64732a2479aef0c28cf3115 100644 (file)
@@ -33,7 +33,8 @@ CU_pSuite register_geodetic_suite(void)
            (NULL == CU_add_test(pSuite, "test_gserialized_get_gbox_geocentric()", test_gserialized_get_gbox_geocentric))  ||
            (NULL == CU_add_test(pSuite, "test_clairaut()", test_clairaut))  || 
            (NULL == CU_add_test(pSuite, "test_edge_intersection()", test_edge_intersection)) ||
-           (NULL == CU_add_test(pSuite, "test_edge_distance_to_point()", test_edge_distance_to_point)) 
+           (NULL == CU_add_test(pSuite, "test_edge_distance_to_point()", test_edge_distance_to_point)) ||
+           (NULL == CU_add_test(pSuite, "test_edge_distance_to_edge()", test_edge_distance_to_edge)) 
        )
        {
                CU_cleanup_registry();
@@ -386,5 +387,29 @@ void test_edge_distance_to_point(void)
 
 }
 
+void test_edge_distance_to_edge(void)
+{
+       GEOGRAPHIC_EDGE e1, e2;
+       GEOGRAPHIC_POINT c1, c2;
+       double d;
+
+       /* closest point at origin, one degree away */
+       edge_set(-50.0, 0.0, 50.0, 0.0, &e1);
+       edge_set(-5.0, 20.0, 0.0, 1.0, &e2);
+       d = edge_distance_to_edge(e1, e2, &c1, &c2);
+#if 0
+       printf("LINESTRING(%.8g %.8g, %.8g %.8g)\n", e1.start.lon,  e1.start.lat, e1.end.lon,  e1.end.lat);
+       printf("LINESTRING(%.8g %.8g, %.8g %.8g)\n", e2.start.lon,  e2.start.lat, e2.end.lon,  e2.end.lat);
+       printf("\nDISTANCE == %.8g\n", d);
+#endif
+       CU_ASSERT_DOUBLE_EQUAL(d, M_PI / 180.0, 0.00001);
+       CU_ASSERT_DOUBLE_EQUAL(c1.lat, 0.0, 0.00001);
+       CU_ASSERT_DOUBLE_EQUAL(c2.lat, M_PI / 180.0, 0.00001);
+       CU_ASSERT_DOUBLE_EQUAL(c1.lon, 0.0, 0.00001);
+       CU_ASSERT_DOUBLE_EQUAL(c2.lon, 0.0, 0.00001);
+}
+
+
+
 
 
index 1caaf153512a0025de15a48f7e340e3489445e5a..b3c6738cafd1b8704514a5c6bc67978cde034c07 100644 (file)
@@ -30,4 +30,5 @@ void test_gserialized_get_gbox_geocentric(void);
 void test_clairaut(void);
 void test_gbox_calculation(void);
 void test_edge_intersection(void);
-void test_edge_distance_to_point(void);
\ No newline at end of file
+void test_edge_distance_to_point(void);
+void test_edge_distance_to_edge(void);