| 821 | |
| 822 | |
| 823 | void PathObjectTest::calcIntersectionsTest() |
| 824 | { |
| 825 | { |
| 826 | // Line-Line perpendicular intersection |
| 827 | PathObject perpendicular1{Map::getCoveringRedLine()}; |
| 828 | perpendicular1.addCoordinate(MapCoord(10, 20)); |
| 829 | perpendicular1.addCoordinate(MapCoord(30, 20)); |
| 830 | |
| 831 | PathObject perpendicular2{Map::getCoveringRedLine()}; |
| 832 | perpendicular2.addCoordinate(MapCoord(20, 10)); |
| 833 | perpendicular2.addCoordinate(MapCoord(20, 30)); |
| 834 | |
| 835 | PathObject::Intersection intersection{}; |
| 836 | intersection.coord = MapCoordF(20, 20); |
| 837 | intersection.length = 10; |
| 838 | intersection.other_length = 10; |
| 839 | |
| 840 | PathObject::Intersections intersections_perpendicular; |
| 841 | intersections_perpendicular.reserve(1); |
| 842 | intersections_perpendicular.push_back(intersection); |
| 843 | |
| 844 | QCOMPARE(calculateIntersections(perpendicular1, perpendicular2), intersections_perpendicular); |
| 845 | QCOMPARE(calculateIntersections(perpendicular2, perpendicular1), intersections_perpendicular); |
| 846 | |
| 847 | perpendicular1.reverse(); |
| 848 | QCOMPARE(calculateIntersections(perpendicular1, perpendicular2), intersections_perpendicular); |
| 849 | } |
| 850 | |
| 851 | { |
| 852 | // Intersection at explicit common point |
| 853 | PathObject common_point_path1{Map::getCoveringRedLine()}; |
| 854 | common_point_path1.addCoordinate(MapCoord(10, 30)); |
| 855 | common_point_path1.addCoordinate(MapCoord(30, 30)); |
| 856 | common_point_path1.addCoordinate(MapCoord(50, 30)); |
| 857 | |
| 858 | PathObject common_point_path2{Map::getCoveringRedLine()}; |
| 859 | common_point_path2.addCoordinate(MapCoord(30, 10)); |
| 860 | common_point_path2.addCoordinate(MapCoord(30, 30)); |
| 861 | common_point_path2.addCoordinate(MapCoord(30, 50)); |
| 862 | |
| 863 | PathObject::Intersection intersection{}; |
| 864 | intersection.coord = MapCoordF(30, 30); |
| 865 | intersection.length = 20; |
| 866 | intersection.other_length = 20; |
| 867 | |
| 868 | PathObject::Intersections intersections_point; |
| 869 | intersections_point.reserve(1); |
| 870 | intersections_point.push_back(intersection); |
| 871 | |
| 872 | QCOMPARE(calculateIntersections(common_point_path1, common_point_path2), intersections_point); |
| 873 | } |
| 874 | |
| 875 | { |
| 876 | // Line-Line parallel intersection |
| 877 | PathObject parallel1{Map::getCoveringRedLine()}; |
| 878 | parallel1.addCoordinate(MapCoord(10, 0)); |
| 879 | parallel1.addCoordinate(MapCoord(30, 0)); |
| 880 | parallel1.addCoordinate(MapCoord(50, 0)); |
nothing calls this directly
no test coverage detected