(NULL == CU_add_test(pSuite, "test_edge_distance_to_point()", test_edge_distance_to_point)) ||
(NULL == CU_add_test(pSuite, "test_ptarray_point_in_ring_winding()", test_ptarray_point_in_ring_winding)) ||
(NULL == CU_add_test(pSuite, "test_edge_distance_to_edge()", test_edge_distance_to_edge)) ||
- (NULL == CU_add_test(pSuite, "test_lwgeom_distance_sphere()", test_lwgeom_distance_sphere))
+ (NULL == CU_add_test(pSuite, "test_lwgeom_distance_sphere()", test_lwgeom_distance_sphere)) ||
+ (NULL == CU_add_test(pSuite, "test_ptarray_point_in_ring()", test_ptarray_point_in_ring))
)
{
CU_cleanup_registry();
CU_ASSERT_DOUBLE_EQUAL(c2.lon, 0.0, 0.00001);
}
+
+void test_ptarray_point_in_ring(void)
+{
+ LWGEOM *lwg;
+ LWPOLY *poly;
+ POINT2D pt_to_test;
+ POINT2D pt_outside;
+ int result;
+
+ return;
+
+ lwg = lwgeom_from_ewkt("0103000020E61000000100000025000000ACAD6F91DDB65EC03F84A86D57264540CCABC279DDB65EC0FCE6926B57264540B6DEAA62DDB65EC0A79F6B63572645402E0BE84CDDB65EC065677155572645405D0B1D39DDB65EC0316310425726454082B5DB27DDB65EC060A4E12957264540798BB619DDB65EC0C393A10D57264540D4BC160FDDB65EC0BD0320EE56264540D7AC4E08DDB65EC096C862CC56264540AFD29205DDB65EC02A1F68A956264540363AFA06DDB65EC0722E418656264540B63A780CDDB65EC06E9B0064562645409614E215DDB65EC0E09DA84356264540FF71EF22DDB65EC0B48145265626454036033F33DDB65EC081B8A60C5626454066FB4546DDB65EC08A47A6F7552645409061785BDDB65EC0F05AE0E755264540D4B63772DDB65EC05C86CEDD55264540D2E4C689DDB65EC09B6EBFD95526454082E573A1DDB65EC0C90BD5DB552645401ABE85B8DDB65EC06692FCE35526454039844ECEDDB65EC04D8AF6F155264540928319E2DDB65EC0AD8D570556264540D31055F3DDB65EC02D618F1D56264540343B7A01DEB65EC0EB70CF3956264540920A1A0CDEB65EC03B00515956264540911BE212DEB65EC0E43A0E7B56264540E3F69D15DEB65EC017E4089E562645408D903614DEB65EC0F0D42FC1562645402191B80EDEB65EC0586870E35626454012B84E05DEB65EC09166C80357264540215B41F8DDB65EC08F832B21572645408392F7E7DDB65EC01138C13A57264540F999F0D4DDB65EC0E4A9C14F57264540AC3FB8BFDDB65EC0EED6875F57264540D3DCFEA8DDB65EC04F6C996957264540ACAD6F91DDB65EC03F84A86D57264540", PARSER_CHECK_NONE);
+// lwg = lwgeom_from_ewkt("POLYGON((-122.857273444234 42.2995431015811,-122.857267799481 42.2995428530976,-122.857262293687 42.2995418811327,-122.857257105451 42.2995402148943,-122.85725238644 42.299537904741,-122.857248272476 42.2995350219505,-122.857244900004 42.2995316542579,-122.857242366986 42.2995278984376,-122.857240750152 42.2995238764135,-122.857240098364 42.2995197065741,-122.857240433085 42.299515516116,-122.857241742526 42.2995114329304,-122.857243986875 42.2995075772594,-122.857247098764 42.2995040740383,-122.857250987564 42.2995010198656,-122.857255524008 42.299498516265,-122.857260577736 42.2994966359601,-122.857266001137 42.2994954355642,-122.857271618111 42.299494951699,-122.85727726286 42.2994952001823,-122.857282763107 42.2994961722623,-122.857287956883 42.2994978383837,-122.857292675892 42.2995001485354,-122.85729678447 42.2995030355545,-122.857300156943 42.2995064032455,-122.857302689963 42.2995101590645,-122.857304306801 42.2995141810877,-122.857304958593 42.2995183509267,-122.857304623876 42.299522541385,-122.857303314439 42.2995266245713,-122.857301070093 42.2995304802436,-122.857297958206 42.2995339834662,-122.857294074793 42.2995370334103,-122.857289538348 42.2995395370124,-122.857284479075 42.2995414174346,-122.857279061212 42.2995426177155,-122.857273444234 42.2995431015811))", PARSER_CHECK_NONE);
+ poly = (LWPOLY*)lwg;
+ pt_to_test.x = -122.819436560680316;
+ pt_to_test.y = 42.2702301207017328;
+ pt_outside.x = 120.695136159150778;
+ pt_outside.y = 40.6920926049588516;
+ result = ptarray_point_in_ring(poly->rings[0], pt_outside, pt_to_test);
+ CU_ASSERT_EQUAL(result, LW_FALSE);
+ lwgeom_free(lwg);
+
+}
+
+
+
void test_lwgeom_distance_sphere(void)
{
LWGEOM *lwg1, *lwg2;
normalize(&ea);
robust_cross_product(e2.start, e2.end, &eb);
normalize(&eb);
- LWDEBUGF(4, "e1 cross product == POINT(%.8g %.8g %.8g)", ea.x, ea.y, ea.z);
- LWDEBUGF(4, "e2 cross product == POINT(%.8g %.8g %.8g)", eb.x, eb.y, eb.z);
+ LWDEBUGF(4, "e1 cross product == POINT(%.12g %.12g %.12g)", ea.x, ea.y, ea.z);
+ LWDEBUGF(4, "e2 cross product == POINT(%.12g %.12g %.12g)", eb.x, eb.y, eb.z);
+ LWDEBUGF(4, "fabs(dot_product(ea, eb)) == %.14g", fabs(dot_product(ea, eb)));
if( FP_EQUALS(fabs(dot_product(ea, eb)), 1.0) )
{
LWDEBUGF(4, "parallel edges found! dot_product = %.12g", dot_product(ea, eb));
* to derive one in postgis, or the gbox_pt_outside() function if you don't mind burning CPU cycles
* building a gbox first).
*/
-static int ptarray_point_in_ring(POINTARRAY *pa, POINT2D pt_outside, POINT2D pt_to_test)
+int ptarray_point_in_ring(POINTARRAY *pa, POINT2D pt_outside, POINT2D pt_to_test)
{
GEOGRAPHIC_EDGE crossing_edge, edge;
POINT2D p;
/* Does stab line cross, and if so, not on the first point. We except the
first point to avoid double counting crossings at vertices. */
LWDEBUG(4,"testing edge crossing");
- if( edge_intersection(edge, crossing_edge, &g) && ! geographic_point_equals(g, edge.start) )
+ if( edge_intersection(edge, crossing_edge, &g) )
{
- LWDEBUG(4,"edge crossing found!");
- count++;
+ if( ! geographic_point_equals(g, edge.start) )
+ {
+ LWDEBUG(4,"edge crossing found!");
+ count++;
+ if ( geographic_point_equals(g, edge.end) )
+ {
+ LWDEBUG(4,"got end point cross");
+ }
+ }
+ else
+ {
+ LWDEBUG(4,"got start point cross");
+ }
}
}
/* An odd number of crossings implies containment! */
pt_outside.x = rad2deg(g.lon);
pt_outside.y = rad2deg(g.lat);
- LWDEBUGF(4, "pt_outside POINT(%.8g %.8g)", pt_outside.x, pt_outside.y);
- LWDEBUGF(4, "pt_to_test POINT(%.8g %.8g)", pt_to_test.x, pt_to_test.y);
+ LWDEBUGF(4, "pt_outside POINT(%.18g %.18g)", pt_outside.x, pt_outside.y);
+ LWDEBUGF(4, "pt_to_test POINT(%.18g %.18g)", pt_to_test.x, pt_to_test.y);
LWDEBUGF(4, "polygon %s", lwgeom_to_ewkt((LWGEOM*)poly, PARSER_CHECK_NONE));
LWDEBUGF(4, "gbox %s", gbox_to_string(gbox));