fix compilation error (svg), warnings (unused), style (return), examples and cmake (C++14)

This commit is contained in:
Barend Gehrels 2022-05-22 12:31:52 +02:00
parent da9ad1eccf
commit 4960865920
10 changed files with 64 additions and 54 deletions

View File

@ -4,6 +4,7 @@
# https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.5...3.16)
set(CMAKE_CXX_STANDARD 14)
project(boost_geometry VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

View File

@ -19,9 +19,6 @@
#include <string>
#include <vector>
#include <boost/foreach.hpp>
#include <boost/geometry/geometry.hpp>
#include <boost/geometry/geometries/linestring.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
@ -39,7 +36,7 @@ int main(void)
{
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;
{
@ -67,16 +64,16 @@ int main(void)
#endif
// Calculate intersection points (turn points)
typedef bg::detail::segment_ratio_type<point_2d, bg::detail::no_rescale_policy>::type segment_ratio;
typedef bg::detail::overlay::turn_info<point_2d, segment_ratio> turn_info;
using segment_ratio = bg::detail::segment_ratio_type<point_2d, bg::detail::no_rescale_policy>::type;
using turn_info = bg::detail::overlay::turn_info<point_2d, segment_ratio>;
std::vector<turn_info> turns;
bg::detail::get_turns::no_interrupt_policy 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::get_turns<false, false, bg::detail::overlay::assign_null_policy>(ls, p, intersection_strategy, rescale_policy, turns, policy);
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, strategy, rescale_policy, turns, policy);
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";
if (turn.operations[0].operation

View File

@ -21,7 +21,7 @@
template<typename DegreeOrRadian>
struct martian
{
typedef DegreeOrRadian units;
using units = DegreeOrRadian;
};
// 2: give it also a family
@ -35,28 +35,12 @@ namespace boost { namespace geometry { namespace traits
template <typename DegreeOrRadian>
struct cs_tag<martian<DegreeOrRadian> >
{
typedef martian_tag type;
using type = martian_tag;
};
}}} // 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,
// e.g. with the Mars radius given by default,
// 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()
{
typedef boost::geometry::model::point
using mars_point = boost::geometry::model::point
<
double, 2, martian<boost::geometry::degree>
> mars_point;
>;
// Declare two points
// (Source: http://nssdc.gsfc.nasa.gov/planetary/mars_mileage_guide.html)
// (Other sources: Wiki and Google give slightly different coordinates, resulting
// in other distance, 20 km off)
mars_point 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 viking1(-48.23, 22.54); // Viking 1 landing site in Chryse Planitia
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
// Using the Mars mean radius
// To calculate distance, declare and construct a strategy with Mars mean radius, in KM
// (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: "
<< 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
// on the mentioned site
#ifdef OPTIONALLY_ELLIPSOIDAL
// Optionally the distance can be calculated more accurate by an Ellipsoidal approach,
// The distance can be calculated more accurately by an Ellipsoidal approach,
// giving 834.444 km
d = boost::geometry::distance(viking1, pathfinder,
boost::geometry::strategy::distance::andoyer<mars_point>
(boost::geometry::srs::spheroid<double>(3396.2, 3376.2)));
boost::geometry::srs::spheroid<double> spheroid(3396.2, 3376.2);
boost::geometry::strategy::distance::geographic<> const ellipsoidal(spheroid);
d = boost::geometry::distance(viking1, pathfinder, ellipsoidal);
std::cout << "Ellipsoidal distance: " << d << " km" << std::endl;
#endif
return 0;
}

View File

@ -361,7 +361,9 @@ struct linear_areal
relate::set<exterior, exterior, result_dimension<Geometry2>::value, TransposeResult>(result);// FFFFFFFFd, d in [1,9] or T
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
{
return;
}
// get and analyse turns
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);
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
{
return;
typedef typename Strategy::cs_tag cs_tag;
}
typedef boundary_checker
<
@ -395,21 +397,29 @@ struct linear_areal
boundary_checker1);
for_each_disjoint_geometry_if<0, Geometry1>::apply(turns.begin(), turns.end(), geometry1, pred1);
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
{
return;
}
no_turns_la_areal_pred<Result, !TransposeResult> pred2(result);
for_each_disjoint_geometry_if<1, Geometry2>::apply(turns.begin(), turns.end(), geometry2, pred2);
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
{
return;
}
if ( turns.empty() )
{
return;
}
// This is set here because in the case if empty Areal geometry were passed
// those shouldn't be set
relate::set<exterior, interior, '2', TransposeResult>(result);// FFFFFF2Fd
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
{
return;
}
{
sort_dispatch(turns.begin(), turns.end(), strategy, util::is_multi<Geometry2>());
@ -422,7 +432,9 @@ struct linear_areal
strategy);
if ( BOOST_GEOMETRY_CONDITION( result.interrupt ) )
{
return;
}
}
// 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)
{
if ( first == last )
{
return;
}
It first_equal = first;
It prev = first;
@ -565,7 +579,9 @@ struct linear_areal
}
if ( first == last )
{
break;
}
}
}
@ -1305,7 +1321,9 @@ struct linear_areal
Strategy const& strategy)
{
if ( first == last )
{
return;
}
for ( TurnIt it = first ; it != last ; ++it )
{
@ -1315,7 +1333,9 @@ struct linear_areal
strategy);
if ( BOOST_GEOMETRY_CONDITION( res.interrupt ) )
{
return;
}
}
analyser.apply(res, first, last,

View File

@ -278,7 +278,6 @@ struct linear_linear
overlay::operation_type const op = it->operations[op_id].operation;
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);

View File

@ -19,7 +19,9 @@
#include "../test_set_ops_linear_linear.hpp"
#include "../check_turn_less.hpp"
#include <from_wkt.hpp>
#ifdef TEST_WITH_SVG
#include <to_svg.hpp>
#endif
//! Contains (optional) settings such as tolerance
//! and to skip some test configurations

View File

@ -19,7 +19,9 @@
#include "../test_set_ops_linear_linear.hpp"
#include "../alternative_robustness_strategy.hpp"
#include <from_wkt.hpp>
#ifdef TEST_WITH_SVG
#include <to_svg.hpp>
#endif
//! Contains (optional) settings such as tolerance

View File

@ -18,7 +18,9 @@
#include <boost/geometry/geometry.hpp>
#include "../test_set_ops_linear_linear.hpp"
#include <from_wkt.hpp>
#ifdef TEST_WITH_SVG
#include <to_svg.hpp>
#endif
//==================================================================
@ -76,6 +78,10 @@ private:
>::type 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 normal behaviour
@ -161,11 +167,6 @@ public:
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
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
Geometry1 rg1(geometry1);

View File

@ -18,7 +18,9 @@
#include <boost/geometry/geometry.hpp>
#include "../test_set_ops_linear_linear.hpp"
#include <from_wkt.hpp>
#ifdef TEST_WITH_SVG
#include <to_svg.hpp>
#endif
//==================================================================
@ -83,6 +85,10 @@ private:
bg::clear(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);
set_operation_output("union", case_id,
@ -158,9 +164,6 @@ public:
{
#ifdef BOOST_GEOMETRY_TEST_DEBUG
std::cout << "test case: " << case_id << std::endl;
std::stringstream sstr;
sstr << "svgs/" << case_id << ".svg";
to_svg(geometry1, geometry2, sstr.str());
#endif
Geometry1 rg1(geometry1);

View File

@ -190,7 +190,7 @@ inline void to_svg(G1 const& g1, G2 const& g2, G3 const& g3,
bg::detail::relate::turns::get_turns
<
G1, G2, point_type, turn_policy
G1, G2, turn_policy
>::apply(turns, g1, g2, interrupt_policy, strategy);
{
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<>
>,
typename bg::cs_tag<G1>::type
strategy_type
>;
std::sort(boost::begin(turns), boost::end(turns), less());
}