mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
fix compilation error (svg), warnings (unused), style (return), examples and cmake (C++14)
This commit is contained in:
parent
da9ad1eccf
commit
4960865920
@ -4,6 +4,7 @@
|
|||||||
# https://www.boost.org/LICENSE_1_0.txt
|
# https://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.5...3.16)
|
cmake_minimum_required(VERSION 3.5...3.16)
|
||||||
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
|
||||||
project(boost_geometry VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
project(boost_geometry VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
|
||||||
|
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
#include <boost/geometry/geometry.hpp>
|
#include <boost/geometry/geometry.hpp>
|
||||||
#include <boost/geometry/geometries/linestring.hpp>
|
#include <boost/geometry/geometries/linestring.hpp>
|
||||||
#include <boost/geometry/geometries/point_xy.hpp>
|
#include <boost/geometry/geometries/point_xy.hpp>
|
||||||
@ -39,7 +36,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
namespace bg = boost::geometry;
|
namespace bg = boost::geometry;
|
||||||
|
|
||||||
typedef bg::model::d2::point_xy<double> point_2d;
|
using point_2d = bg::model::d2::point_xy<double>;
|
||||||
|
|
||||||
bg::model::linestring<point_2d> ls;
|
bg::model::linestring<point_2d> ls;
|
||||||
{
|
{
|
||||||
@ -67,16 +64,16 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Calculate intersection points (turn points)
|
// Calculate intersection points (turn points)
|
||||||
typedef bg::detail::segment_ratio_type<point_2d, bg::detail::no_rescale_policy>::type segment_ratio;
|
using segment_ratio = bg::detail::segment_ratio_type<point_2d, bg::detail::no_rescale_policy>::type;
|
||||||
typedef bg::detail::overlay::turn_info<point_2d, segment_ratio> turn_info;
|
using turn_info = bg::detail::overlay::turn_info<point_2d, segment_ratio>;
|
||||||
std::vector<turn_info> turns;
|
std::vector<turn_info> turns;
|
||||||
bg::detail::get_turns::no_interrupt_policy policy;
|
bg::detail::get_turns::no_interrupt_policy policy;
|
||||||
bg::detail::no_rescale_policy rescale_policy;
|
bg::detail::no_rescale_policy rescale_policy;
|
||||||
bg::strategy::intersection::services::default_strategy<typename bg::cs_tag<point_2d>::type>::type intersection_strategy;
|
bg::strategies::relate::services::default_strategy<bg::model::linestring<point_2d>, bg::model::polygon<point_2d>>::type strategy;
|
||||||
bg::get_turns<false, false, bg::detail::overlay::assign_null_policy>(ls, p, intersection_strategy, rescale_policy, turns, policy);
|
bg::get_turns<false, false, bg::detail::overlay::assign_null_policy>(ls, p, strategy, rescale_policy, turns, policy);
|
||||||
|
|
||||||
std::cout << "Intersection of linestring/polygon" << std::endl;
|
std::cout << "Intersection of linestring/polygon" << std::endl;
|
||||||
BOOST_FOREACH(turn_info const& turn, turns)
|
for (turn_info const& turn : turns)
|
||||||
{
|
{
|
||||||
std::string action = "intersecting";
|
std::string action = "intersecting";
|
||||||
if (turn.operations[0].operation
|
if (turn.operations[0].operation
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
template<typename DegreeOrRadian>
|
template<typename DegreeOrRadian>
|
||||||
struct martian
|
struct martian
|
||||||
{
|
{
|
||||||
typedef DegreeOrRadian units;
|
using units = DegreeOrRadian;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 2: give it also a family
|
// 2: give it also a family
|
||||||
@ -35,28 +35,12 @@ namespace boost { namespace geometry { namespace traits
|
|||||||
template <typename DegreeOrRadian>
|
template <typename DegreeOrRadian>
|
||||||
struct cs_tag<martian<DegreeOrRadian> >
|
struct cs_tag<martian<DegreeOrRadian> >
|
||||||
{
|
{
|
||||||
typedef martian_tag type;
|
using type = martian_tag;
|
||||||
};
|
};
|
||||||
|
|
||||||
}}} // namespaces
|
}}} // namespaces
|
||||||
|
|
||||||
|
|
||||||
// NOTE: if the next steps would not be here,
|
|
||||||
// compiling a distance function call with martian coordinates
|
|
||||||
// would result in a MPL assertion
|
|
||||||
|
|
||||||
// 4: so register a distance strategy as its default strategy
|
|
||||||
namespace boost { namespace geometry { namespace strategy { namespace distance { namespace services
|
|
||||||
{
|
|
||||||
|
|
||||||
template <typename Point1, typename Point2>
|
|
||||||
struct default_strategy<point_tag, point_tag, Point1, Point2, martian_tag, martian_tag>
|
|
||||||
{
|
|
||||||
typedef haversine<double> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
}}}}} // namespaces
|
|
||||||
|
|
||||||
// 5: not worked out. To implement a specific distance strategy for Mars,
|
// 5: not worked out. To implement a specific distance strategy for Mars,
|
||||||
// e.g. with the Mars radius given by default,
|
// e.g. with the Mars radius given by default,
|
||||||
// you will have to implement (/register) several other metafunctions:
|
// you will have to implement (/register) several other metafunctions:
|
||||||
@ -67,36 +51,37 @@ struct default_strategy<point_tag, point_tag, Point1, Point2, martian_tag, marti
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
typedef boost::geometry::model::point
|
using mars_point = boost::geometry::model::point
|
||||||
<
|
<
|
||||||
double, 2, martian<boost::geometry::degree>
|
double, 2, martian<boost::geometry::degree>
|
||||||
> mars_point;
|
>;
|
||||||
|
|
||||||
// Declare two points
|
// Declare two points
|
||||||
// (Source: http://nssdc.gsfc.nasa.gov/planetary/mars_mileage_guide.html)
|
// (Source: http://nssdc.gsfc.nasa.gov/planetary/mars_mileage_guide.html)
|
||||||
// (Other sources: Wiki and Google give slightly different coordinates, resulting
|
// (Other sources: Wiki and Google give slightly different coordinates, resulting
|
||||||
// in other distance, 20 km off)
|
// in other distance, 20 km off)
|
||||||
mars_point viking1(-48.23, 22.54); // Viking 1 landing site in Chryse Planitia
|
mars_point const viking1(-48.23, 22.54); // Viking 1 landing site in Chryse Planitia
|
||||||
mars_point pathfinder(-33.55, 19.33); // Pathfinder landing site in Ares Vallis
|
mars_point const pathfinder(-33.55, 19.33); // Pathfinder landing site in Ares Vallis
|
||||||
|
|
||||||
double d = boost::geometry::distance(viking1, pathfinder); // Distance in radians on unit-sphere
|
// To calculate distance, declare and construct a strategy with Mars mean radius, in KM
|
||||||
|
|
||||||
// Using the Mars mean radius
|
|
||||||
// (Source: http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html)
|
// (Source: http://nssdc.gsfc.nasa.gov/planetary/factsheet/marsfact.html)
|
||||||
|
boost::geometry::strategies::distance::spherical<> const spherical(3389.5);
|
||||||
|
|
||||||
|
double d = boost::geometry::distance(viking1, pathfinder, spherical);
|
||||||
|
|
||||||
std::cout << "Distance between Viking1 and Pathfinder landing sites: "
|
std::cout << "Distance between Viking1 and Pathfinder landing sites: "
|
||||||
<< d * 3389.5 << " km" << std::endl;
|
<< d << " km" << std::endl;
|
||||||
|
|
||||||
// We would get 832.616 here, same order as the 835 (rounded on 5 km) listed
|
// We would get 832.616 here, same order as the 835 (rounded on 5 km) listed
|
||||||
// on the mentioned site
|
// on the mentioned site
|
||||||
|
|
||||||
#ifdef OPTIONALLY_ELLIPSOIDAL
|
// The distance can be calculated more accurately by an Ellipsoidal approach,
|
||||||
// Optionally the distance can be calculated more accurate by an Ellipsoidal approach,
|
|
||||||
// giving 834.444 km
|
// giving 834.444 km
|
||||||
d = boost::geometry::distance(viking1, pathfinder,
|
boost::geometry::srs::spheroid<double> spheroid(3396.2, 3376.2);
|
||||||
boost::geometry::strategy::distance::andoyer<mars_point>
|
boost::geometry::strategy::distance::geographic<> const ellipsoidal(spheroid);
|
||||||
(boost::geometry::srs::spheroid<double>(3396.2, 3376.2)));
|
|
||||||
|
d = boost::geometry::distance(viking1, pathfinder, ellipsoidal);
|
||||||
std::cout << "Ellipsoidal distance: " << d << " km" << std::endl;
|
std::cout << "Ellipsoidal distance: " << d << " km" << std::endl;
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,9 @@ struct linear_areal
|
|||||||
relate::set<exterior, exterior, result_dimension<Geometry2>::value, TransposeResult>(result);// FFFFFFFFd, d in [1,9] or T
|
relate::set<exterior, exterior, result_dimension<Geometry2>::value, TransposeResult>(result);// FFFFFFFFd, d in [1,9] or T
|
||||||
|
|
||||||
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// get and analyse turns
|
// get and analyse turns
|
||||||
using turn_type = typename turn_info_type<Geometry1, Geometry2, Strategy>::type;
|
using turn_type = typename turn_info_type<Geometry1, Geometry2, Strategy>::type;
|
||||||
@ -371,9 +373,9 @@ struct linear_areal
|
|||||||
|
|
||||||
turns::get_turns<Geometry1, Geometry2>::apply(turns, geometry1, geometry2, interrupt_policy, strategy);
|
turns::get_turns<Geometry1, Geometry2>::apply(turns, geometry1, geometry2, interrupt_policy, strategy);
|
||||||
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
typedef typename Strategy::cs_tag cs_tag;
|
|
||||||
|
|
||||||
typedef boundary_checker
|
typedef boundary_checker
|
||||||
<
|
<
|
||||||
@ -395,21 +397,29 @@ struct linear_areal
|
|||||||
boundary_checker1);
|
boundary_checker1);
|
||||||
for_each_disjoint_geometry_if<0, Geometry1>::apply(turns.begin(), turns.end(), geometry1, pred1);
|
for_each_disjoint_geometry_if<0, Geometry1>::apply(turns.begin(), turns.end(), geometry1, pred1);
|
||||||
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
no_turns_la_areal_pred<Result, !TransposeResult> pred2(result);
|
no_turns_la_areal_pred<Result, !TransposeResult> pred2(result);
|
||||||
for_each_disjoint_geometry_if<1, Geometry2>::apply(turns.begin(), turns.end(), geometry2, pred2);
|
for_each_disjoint_geometry_if<1, Geometry2>::apply(turns.begin(), turns.end(), geometry2, pred2);
|
||||||
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( turns.empty() )
|
if ( turns.empty() )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// This is set here because in the case if empty Areal geometry were passed
|
// This is set here because in the case if empty Areal geometry were passed
|
||||||
// those shouldn't be set
|
// those shouldn't be set
|
||||||
relate::set<exterior, interior, '2', TransposeResult>(result);// FFFFFF2Fd
|
relate::set<exterior, interior, '2', TransposeResult>(result);// FFFFFF2Fd
|
||||||
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
sort_dispatch(turns.begin(), turns.end(), strategy, util::is_multi<Geometry2>());
|
sort_dispatch(turns.begin(), turns.end(), strategy, util::is_multi<Geometry2>());
|
||||||
@ -422,7 +432,9 @@ struct linear_areal
|
|||||||
strategy);
|
strategy);
|
||||||
|
|
||||||
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If 'c' (insersection_boundary) was not found we know that any Ls isn't equal to one of the Rings
|
// If 'c' (insersection_boundary) was not found we know that any Ls isn't equal to one of the Rings
|
||||||
@ -552,7 +564,9 @@ struct linear_areal
|
|||||||
static void for_each_equal_range(It first, It last, Pred pred, Comp comp)
|
static void for_each_equal_range(It first, It last, Pred pred, Comp comp)
|
||||||
{
|
{
|
||||||
if ( first == last )
|
if ( first == last )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
It first_equal = first;
|
It first_equal = first;
|
||||||
It prev = first;
|
It prev = first;
|
||||||
@ -565,7 +579,9 @@ struct linear_areal
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( first == last )
|
if ( first == last )
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1305,7 +1321,9 @@ struct linear_areal
|
|||||||
Strategy const& strategy)
|
Strategy const& strategy)
|
||||||
{
|
{
|
||||||
if ( first == last )
|
if ( first == last )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for ( TurnIt it = first ; it != last ; ++it )
|
for ( TurnIt it = first ; it != last ; ++it )
|
||||||
{
|
{
|
||||||
@ -1315,7 +1333,9 @@ struct linear_areal
|
|||||||
strategy);
|
strategy);
|
||||||
|
|
||||||
if ( BOOST_GEOMETRY_CONDITION( res.interrupt ) )
|
if ( BOOST_GEOMETRY_CONDITION( res.interrupt ) )
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
analyser.apply(res, first, last,
|
analyser.apply(res, first, last,
|
||||||
|
@ -278,7 +278,6 @@ struct linear_linear
|
|||||||
overlay::operation_type const op = it->operations[op_id].operation;
|
overlay::operation_type const op = it->operations[op_id].operation;
|
||||||
|
|
||||||
segment_identifier const& seg_id = it->operations[op_id].seg_id;
|
segment_identifier const& seg_id = it->operations[op_id].seg_id;
|
||||||
segment_identifier const& other_id = it->operations[other_op_id].seg_id;
|
|
||||||
|
|
||||||
bool const first_in_range = m_seg_watcher.update(seg_id);
|
bool const first_in_range = m_seg_watcher.update(seg_id);
|
||||||
|
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
#include "../test_set_ops_linear_linear.hpp"
|
#include "../test_set_ops_linear_linear.hpp"
|
||||||
#include "../check_turn_less.hpp"
|
#include "../check_turn_less.hpp"
|
||||||
#include <from_wkt.hpp>
|
#include <from_wkt.hpp>
|
||||||
|
#ifdef TEST_WITH_SVG
|
||||||
#include <to_svg.hpp>
|
#include <to_svg.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
//! Contains (optional) settings such as tolerance
|
//! Contains (optional) settings such as tolerance
|
||||||
//! and to skip some test configurations
|
//! and to skip some test configurations
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
#include "../test_set_ops_linear_linear.hpp"
|
#include "../test_set_ops_linear_linear.hpp"
|
||||||
#include "../alternative_robustness_strategy.hpp"
|
#include "../alternative_robustness_strategy.hpp"
|
||||||
#include <from_wkt.hpp>
|
#include <from_wkt.hpp>
|
||||||
|
#ifdef TEST_WITH_SVG
|
||||||
#include <to_svg.hpp>
|
#include <to_svg.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//! Contains (optional) settings such as tolerance
|
//! Contains (optional) settings such as tolerance
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
#include <boost/geometry/geometry.hpp>
|
#include <boost/geometry/geometry.hpp>
|
||||||
#include "../test_set_ops_linear_linear.hpp"
|
#include "../test_set_ops_linear_linear.hpp"
|
||||||
#include <from_wkt.hpp>
|
#include <from_wkt.hpp>
|
||||||
|
#ifdef TEST_WITH_SVG
|
||||||
#include <to_svg.hpp>
|
#include <to_svg.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
@ -76,6 +78,10 @@ private:
|
|||||||
>::type strategy_type;
|
>::type strategy_type;
|
||||||
bg::sym_difference(geometry1, geometry2, mls_output, strategy_type());
|
bg::sym_difference(geometry1, geometry2, mls_output, strategy_type());
|
||||||
|
|
||||||
|
#ifdef TEST_WITH_SVG
|
||||||
|
to_svg(geometry1, geometry2, mls_output, case_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
check_result(geometry1, geometry2, mls_output, mls_sym_diff, case_id, tolerance);
|
check_result(geometry1, geometry2, mls_output, mls_sym_diff, case_id, tolerance);
|
||||||
|
|
||||||
// Check normal behaviour
|
// Check normal behaviour
|
||||||
@ -161,11 +167,6 @@ public:
|
|||||||
{
|
{
|
||||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||||
std::cout << "test case: " << case_id << std::endl;
|
std::cout << "test case: " << case_id << std::endl;
|
||||||
std::stringstream sstr;
|
|
||||||
sstr << "svgs/" << case_id << ".svg";
|
|
||||||
#ifdef TEST_WITH_SVG
|
|
||||||
to_svg(geometry1, geometry2, sstr.str());
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Geometry1 rg1(geometry1);
|
Geometry1 rg1(geometry1);
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
#include <boost/geometry/geometry.hpp>
|
#include <boost/geometry/geometry.hpp>
|
||||||
#include "../test_set_ops_linear_linear.hpp"
|
#include "../test_set_ops_linear_linear.hpp"
|
||||||
#include <from_wkt.hpp>
|
#include <from_wkt.hpp>
|
||||||
|
#ifdef TEST_WITH_SVG
|
||||||
#include <to_svg.hpp>
|
#include <to_svg.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//==================================================================
|
//==================================================================
|
||||||
@ -83,6 +85,10 @@ private:
|
|||||||
bg::clear(mls_output);
|
bg::clear(mls_output);
|
||||||
bg::union_(geometry1, geometry2, mls_output);
|
bg::union_(geometry1, geometry2, mls_output);
|
||||||
|
|
||||||
|
#ifdef TEST_WITH_SVG
|
||||||
|
to_svg(geometry1, geometry2, mls_output, case_id);
|
||||||
|
#endif
|
||||||
|
|
||||||
check_result(geometry1, geometry2, mls_output, mls_union1, case_id, tolerance);
|
check_result(geometry1, geometry2, mls_output, mls_union1, case_id, tolerance);
|
||||||
|
|
||||||
set_operation_output("union", case_id,
|
set_operation_output("union", case_id,
|
||||||
@ -158,9 +164,6 @@ public:
|
|||||||
{
|
{
|
||||||
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
#ifdef BOOST_GEOMETRY_TEST_DEBUG
|
||||||
std::cout << "test case: " << case_id << std::endl;
|
std::cout << "test case: " << case_id << std::endl;
|
||||||
std::stringstream sstr;
|
|
||||||
sstr << "svgs/" << case_id << ".svg";
|
|
||||||
to_svg(geometry1, geometry2, sstr.str());
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Geometry1 rg1(geometry1);
|
Geometry1 rg1(geometry1);
|
||||||
|
@ -190,7 +190,7 @@ inline void to_svg(G1 const& g1, G2 const& g2, G3 const& g3,
|
|||||||
|
|
||||||
bg::detail::relate::turns::get_turns
|
bg::detail::relate::turns::get_turns
|
||||||
<
|
<
|
||||||
G1, G2, point_type, turn_policy
|
G1, G2, turn_policy
|
||||||
>::apply(turns, g1, g2, interrupt_policy, strategy);
|
>::apply(turns, g1, g2, interrupt_policy, strategy);
|
||||||
{
|
{
|
||||||
using less = bg::detail::relate::turns::less
|
using less = bg::detail::relate::turns::less
|
||||||
@ -200,7 +200,7 @@ inline void to_svg(G1 const& g1, G2 const& g2, G3 const& g3,
|
|||||||
<
|
<
|
||||||
0, bg::detail::relate::turns::op_to_int<>
|
0, bg::detail::relate::turns::op_to_int<>
|
||||||
>,
|
>,
|
||||||
typename bg::cs_tag<G1>::type
|
strategy_type
|
||||||
>;
|
>;
|
||||||
std::sort(boost::begin(turns), boost::end(turns), less());
|
std::sort(boost::begin(turns), boost::end(turns), less());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user