Merge pull request #175 from mkaravel/fix/cartesian_segments_intersection

Fix/cartesian segments intersection
This commit is contained in:
Adam Wulkiewicz
2014-11-04 22:20:56 +01:00
3 changed files with 37 additions and 0 deletions

View File

@@ -351,6 +351,12 @@ private:
// b1/b2 (4..4)
// Ratio: (4-2)/(6-2)
RatioType const ratio(d - s1, s2 - s1);
if (!ratio.on_segment())
{
return Policy::disjoint();
}
return Policy::one_degenerate(degenerate_segment, ratio, a_degenerate);
}
};

View File

@@ -75,6 +75,10 @@ void test_distance_segment_linestring(Strategy const& strategy)
tester::apply("segment(1 1,2 2)",
"linestring(2 1,1 2,4 0)",
0, 0, strategy);
tester::apply("segment(1 1,2 2)",
"linestring(3 3,3 3)",
sqrt(2.0), 2, strategy);
}
//===========================================================================
@@ -155,6 +159,10 @@ void test_distance_segment_multilinestring(Strategy const& strategy)
tester::apply("segment(1 1,2 2)",
"multilinestring((2 1,1 2),(4 0,4 10))",
0, 0, strategy);
tester::apply("segment(1 1,2 2)",
"multilinestring((2.5 0,4 0,5 0),(3 3,3 3))",
sqrt(2.0), 2, strategy);
}
//===========================================================================
@@ -179,6 +187,14 @@ void test_distance_linestring_multilinestring(Strategy const& strategy)
tester::apply("linestring(1 1,2 2,3 3)",
"multilinestring((1 -10,2 0,2.1 -10,4 0),(1 -10,2 1.9,2.1 -10,4 0))",
sqrt(0.005), 0.005, strategy, true);
tester::apply("linestring(1 1,2 2)",
"multilinestring((2.5 0,4 0,5 0),(3 3,3 3))",
sqrt(2.0), 2, strategy);
tester::apply("linestring(1 1,2 2,3 3,4 4,5 5,6 6,7 7,8 8,9 9)",
"multilinestring((2.5 0,4 0,5 0),(10 10,10 10))",
sqrt(2.0), 2, strategy);
}
//===========================================================================

View File

@@ -99,6 +99,18 @@ void test_distance_point_multilinestring(Strategy const& strategy)
tester::apply("point(2.5 0)",
"multilinestring((-5 0,-3 0),(2 0,3 0))",
0, 0, strategy);
tester::apply("POINT(0 0)",
"MULTILINESTRING((10 10,10 0),(0.0 -0.0,0.0 -0.0))",
0, 0, strategy);
tester::apply("POINT(0 0)",
"MULTILINESTRING((10 10,10 0),(1 1,1 1))",
sqrt(2.0), 2, strategy);
tester::apply("POINT(0 0)",
"MULTILINESTRING((10 10,10 0),(1 1,2 2))",
sqrt(2.0), 2, strategy);
tester::apply("POINT(0 0)",
"MULTILINESTRING((10 10,10 0),(20 20,20 20))",
10, 100, strategy);
}
//===========================================================================
@@ -180,6 +192,9 @@ void test_distance_multipoint_segment(Strategy const& strategy)
tester::apply("multipoint(0 0,1 0,0 1,1 1)",
"segment(3 3,4 4)",
sqrt(8.0), 8, strategy);
tester::apply("multipoint(4 4,5 5,2 2,3 3)",
"segment(0 0,1 1)",
sqrt(2.0), 2, strategy);
}
//===========================================================================