// Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2014-2020. // Modifications copyright (c) 2014-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_TEST_STRATEGIES_TEST_WITHIN_HPP #define BOOST_GEOMETRY_TEST_STRATEGIES_TEST_WITHIN_HPP #include #include #include #include #include #include #include #include #include #include #include // TEMP #include #include #include #include #include #include #include template inline const char * strategy_name(Strategy const&) { return typeid(Strategy).name(); } template inline const char * strategy_name(bg::strategy::within::crossings_multiply const&) { return "crossings_multiply"; } template inline const char * strategy_name(bg::strategy::within::franklin const&) { return "franklin"; } template inline const char * strategy_name(bg::strategy::within::winding const&) { return "winding"; } template void test_point_in_polygon(std::string const& case_id, Point const& point, Polygon const& polygon, Strategy const& strategy, bool expected, bool use_within = true) { BOOST_CONCEPT_ASSERT( (bg::concepts::WithinStrategyPolygonal) ); bool detected = use_within ? bg::within(point, polygon, strategy) : bg::covered_by(point, polygon, strategy); BOOST_CHECK_MESSAGE(detected == expected, (use_within ? "within: " : "covered_by: ") << case_id << " strategy: " << strategy_name(strategy) << " output expected: " << int(expected) << " detected: " << int(detected) ); } template void test_geometry(std::string const& case_id, std::string const& wkt_point, std::string const& wkt_polygon, Strategy const& strategy, bool expected, bool use_within = true) { Point point; Polygon polygon; bg::read_wkt(wkt_point, point); bg::read_wkt(wkt_polygon, polygon); test_point_in_polygon(case_id, point, polygon, strategy, expected, use_within); } #endif // BOOST_GEOMETRY_TEST_STRATEGIES_TEST_WITHIN_HPP