mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-11 11:52:11 +00:00
Merge branch 'develop' of github.com:boostorg/geometry into develop
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
#include <boost/geometry/core/tag_cast.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/convert.hpp>
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
#include <boost/geometry/strategies/centroid.hpp>
|
||||
|
||||
@@ -110,7 +110,7 @@ struct distance
|
||||
static inline typename return_type<Strategy, Point, typename point_type<Linestring>::type>::type
|
||||
apply(Point const& point,
|
||||
Linestring const& linestring,
|
||||
Strategy const& strategy)
|
||||
Strategy const&)
|
||||
{
|
||||
typedef typename detail::distance::default_ps_strategy
|
||||
<
|
||||
@@ -143,7 +143,7 @@ struct distance
|
||||
|
||||
static inline return_type apply(Point const& point,
|
||||
Ring const& ring,
|
||||
Strategy const& strategy)
|
||||
Strategy const&)
|
||||
{
|
||||
typedef typename detail::distance::default_ps_strategy
|
||||
<
|
||||
@@ -181,7 +181,7 @@ struct distance
|
||||
|
||||
static inline return_type apply(Point const& point,
|
||||
Polygon const& polygon,
|
||||
Strategy const& strategy)
|
||||
Strategy const&)
|
||||
{
|
||||
typedef typename detail::distance::default_ps_strategy
|
||||
<
|
||||
|
||||
@@ -43,6 +43,7 @@ struct distance
|
||||
>::type
|
||||
apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(strategy);
|
||||
return strategy.apply(box1, box2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -390,10 +390,11 @@ struct distance
|
||||
Segment const& segment,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
|
||||
typename point_type<Segment>::type p[2];
|
||||
geometry::detail::assign_point_from_index<0>(segment, p[0]);
|
||||
geometry::detail::assign_point_from_index<1>(segment, p[1]);
|
||||
|
||||
boost::ignore_unused_variable_warning(strategy);
|
||||
return strategy.apply(point, p[0], p[1]);
|
||||
}
|
||||
};
|
||||
@@ -413,6 +414,7 @@ struct distance
|
||||
>::type
|
||||
apply(Point const& point, Box const& box, Strategy const& strategy)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(strategy);
|
||||
return strategy.apply(point, box);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -106,6 +106,7 @@ private:
|
||||
SegmentPoints const& segment_points,
|
||||
ComparableStrategy const& strategy)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(strategy);
|
||||
return strategy.apply(point, segment_points[0], segment_points[1]);
|
||||
}
|
||||
};
|
||||
@@ -126,6 +127,8 @@ private:
|
||||
BoxPoints const& box_points,
|
||||
ComparableStrategy const& strategy)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(strategy);
|
||||
|
||||
comparable_return_type cd_min =
|
||||
strategy.apply(point, box_points[0], box_points[3]);
|
||||
|
||||
|
||||
@@ -81,6 +81,9 @@ private:
|
||||
{
|
||||
typedef cast_to_result<ReturnType> cast;
|
||||
|
||||
boost::ignore_unused_variable_warning(pp_strategy);
|
||||
boost::ignore_unused_variable_warning(ps_strategy);
|
||||
|
||||
// assert that the segment has non-negative slope
|
||||
BOOST_ASSERT( (math::equals(geometry::get<0>(p0),
|
||||
geometry::get<0>(p1))
|
||||
@@ -217,6 +220,9 @@ private:
|
||||
{
|
||||
typedef cast_to_result<ReturnType> cast;
|
||||
|
||||
boost::ignore_unused_variable_warning(pp_strategy);
|
||||
boost::ignore_unused_variable_warning(ps_strategy);
|
||||
|
||||
// assert that the segment has negative slope
|
||||
BOOST_ASSERT
|
||||
( geometry::get<0>(p0) < geometry::get<0>(p1)
|
||||
|
||||
@@ -289,7 +289,7 @@ protected:
|
||||
public:
|
||||
template <typename TurnIterator, typename OutputIterator>
|
||||
static inline OutputIterator
|
||||
apply(Linestring const& linestring, Linear const& linear,
|
||||
apply(Linestring const& linestring, Linear const&,
|
||||
TurnIterator first, TurnIterator beyond,
|
||||
OutputIterator oit)
|
||||
{
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// 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_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace intersection
|
||||
{
|
||||
|
||||
template <std::size_t Dimension, std::size_t DimensionCount>
|
||||
struct intersection_box_box
|
||||
{
|
||||
template
|
||||
<
|
||||
typename Box1, typename Box2,
|
||||
typename RobustPolicy,
|
||||
typename BoxOut,
|
||||
typename Strategy
|
||||
>
|
||||
static inline bool apply(Box1 const& box1,
|
||||
Box2 const& box2,
|
||||
RobustPolicy const& robust_policy,
|
||||
BoxOut& box_out,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename coordinate_type<BoxOut>::type ct;
|
||||
|
||||
ct min1 = get<min_corner, Dimension>(box1);
|
||||
ct min2 = get<min_corner, Dimension>(box2);
|
||||
ct max1 = get<max_corner, Dimension>(box1);
|
||||
ct max2 = get<max_corner, Dimension>(box2);
|
||||
|
||||
if (max1 < min2 || max2 < min1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Set dimensions of output coordinate
|
||||
set<min_corner, Dimension>(box_out, min1 < min2 ? min2 : min1);
|
||||
set<max_corner, Dimension>(box_out, max1 > max2 ? max2 : max1);
|
||||
|
||||
return intersection_box_box<Dimension + 1, DimensionCount>
|
||||
::apply(box1, box2, robust_policy, box_out, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <std::size_t DimensionCount>
|
||||
struct intersection_box_box<DimensionCount, DimensionCount>
|
||||
{
|
||||
template
|
||||
<
|
||||
typename Box1, typename Box2,
|
||||
typename RobustPolicy,
|
||||
typename BoxOut,
|
||||
typename Strategy
|
||||
>
|
||||
static inline bool apply(Box1 const&, Box2 const&,
|
||||
RobustPolicy const&, BoxOut&, Strategy const&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::intersection
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP
|
||||
@@ -24,7 +24,7 @@ namespace detail { namespace turns
|
||||
template <typename Turns, bool Enable>
|
||||
struct filter_continue_turns
|
||||
{
|
||||
static inline void apply(Turns& turns) {}
|
||||
static inline void apply(Turns&) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace detail { namespace turns
|
||||
template <typename Turns, bool Enable>
|
||||
struct remove_duplicate_turns
|
||||
{
|
||||
static inline void apply(Turns& turns) {}
|
||||
static inline void apply(Turns&) {}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp>
|
||||
#include <boost/geometry/algorithms/intersects.hpp>
|
||||
#include <boost/geometry/policies/robustness/get_rescale_policy.hpp>
|
||||
|
||||
@@ -19,68 +20,6 @@
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace intersection
|
||||
{
|
||||
|
||||
template <std::size_t Dimension, std::size_t DimensionCount>
|
||||
struct intersection_box_box
|
||||
{
|
||||
template
|
||||
<
|
||||
typename Box1, typename Box2,
|
||||
typename RobustPolicy,
|
||||
typename BoxOut,
|
||||
typename Strategy
|
||||
>
|
||||
static inline bool apply(Box1 const& box1,
|
||||
Box2 const& box2,
|
||||
RobustPolicy const& robust_policy,
|
||||
BoxOut& box_out,
|
||||
Strategy const& strategy)
|
||||
{
|
||||
typedef typename coordinate_type<BoxOut>::type ct;
|
||||
|
||||
ct min1 = get<min_corner, Dimension>(box1);
|
||||
ct min2 = get<min_corner, Dimension>(box2);
|
||||
ct max1 = get<max_corner, Dimension>(box1);
|
||||
ct max2 = get<max_corner, Dimension>(box2);
|
||||
|
||||
if (max1 < min2 || max2 < min1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Set dimensions of output coordinate
|
||||
set<min_corner, Dimension>(box_out, min1 < min2 ? min2 : min1);
|
||||
set<max_corner, Dimension>(box_out, max1 > max2 ? max2 : max1);
|
||||
|
||||
return intersection_box_box<Dimension + 1, DimensionCount>
|
||||
::apply(box1, box2, robust_policy, box_out, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <std::size_t DimensionCount>
|
||||
struct intersection_box_box<DimensionCount, DimensionCount>
|
||||
{
|
||||
template
|
||||
<
|
||||
typename Box1, typename Box2,
|
||||
typename RobustPolicy,
|
||||
typename BoxOut,
|
||||
typename Strategy
|
||||
>
|
||||
static inline bool apply(Box1 const&, Box2 const&,
|
||||
RobustPolicy const&, BoxOut&, Strategy const&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::intersection
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/intersection.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/index/detail/algorithms/content.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail {
|
||||
@@ -25,7 +26,12 @@ inline typename default_content_result<Box>::type intersection_content(Box const
|
||||
if ( geometry::intersects(box1, box2) )
|
||||
{
|
||||
Box box_intersection;
|
||||
geometry::intersection(box1, box2, box_intersection);
|
||||
|
||||
strategy_intersection_empty dummy;
|
||||
geometry::detail::intersection::intersection_box_box
|
||||
<
|
||||
0, geometry::dimension<Box>::value
|
||||
>::apply(box1, box2, box_intersection, dummy);
|
||||
return detail::content(box_intersection);
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <boost/type_traits.hpp>
|
||||
|
||||
#include <boost/geometry/policies/robustness/segment_ratio.hpp>
|
||||
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
|
||||
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ public:
|
||||
typedef RobustPolicy rescale_policy_type;
|
||||
};
|
||||
|
||||
|
||||
// Version for box_box intersection or other detail calls not needing a strategy
|
||||
struct strategy_intersection_empty {};
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
@@ -47,6 +47,7 @@ test-suite boost-geometry-algorithms
|
||||
[ run intersects.cpp : : : <toolset>msvc:<cxxflags>/bigobj ]
|
||||
[ run length.cpp ]
|
||||
[ run make.cpp ]
|
||||
[ run num_points.cpp ]
|
||||
[ run overlaps.cpp ]
|
||||
[ run perimeter.cpp ]
|
||||
[ run point_on_surface.cpp ]
|
||||
|
||||
@@ -1,14 +1,27 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Tests
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// 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_FROM_WKT_HPP
|
||||
#define BOOST_GEOMETRY_TEST_FROM_WKT_HPP
|
||||
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
#include <boost/geometry/multi/io/wkt/read.hpp>
|
||||
|
||||
template <typename Geometry>
|
||||
Geometry from_wkt(std::string const& wkt)
|
||||
inline Geometry from_wkt(std::string const& wkt)
|
||||
{
|
||||
Geometry res;
|
||||
boost::geometry::read_wkt(wkt, res);
|
||||
return res;
|
||||
Geometry result;
|
||||
boost::geometry::read_wkt(wkt, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_FROM_WKT_HPP
|
||||
|
||||
65
test/algorithms/num_points.cpp
Normal file
65
test/algorithms/num_points.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2014 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2014 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// 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_TEST_MODULE
|
||||
#define BOOST_TEST_MODULE test_num_points
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/test/included/unit_test.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/num_points.hpp>
|
||||
#include <boost/geometry/multi/algorithms/num_points.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/multi/geometries/multi_geometries.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
#include <boost/geometry/multi/io/wkt/read.hpp>
|
||||
|
||||
template <typename Geometry>
|
||||
inline void test_num_points(std::string const& wkt, std::size_t expected)
|
||||
{
|
||||
namespace bg = boost::geometry;
|
||||
Geometry geometry;
|
||||
boost::geometry::read_wkt(wkt, geometry);
|
||||
std::size_t detected = bg::num_points(geometry);
|
||||
BOOST_CHECK_EQUAL(expected, detected);
|
||||
detected = bg::num_points(geometry, false);
|
||||
BOOST_CHECK_EQUAL(expected, detected);
|
||||
detected = bg::num_points(geometry, true);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( test_num_points_closed )
|
||||
{
|
||||
namespace bg = boost::geometry;
|
||||
typedef bg::model::point<double,2,bg::cs::cartesian> point;
|
||||
typedef bg::model::linestring<point> linestring;
|
||||
typedef bg::model::segment<point> segment;
|
||||
typedef bg::model::box<point> box;
|
||||
typedef bg::model::ring<point> ring;
|
||||
typedef bg::model::polygon<point> polygon;
|
||||
typedef bg::model::multi_point<point> multi_point;
|
||||
typedef bg::model::multi_linestring<linestring> multi_linestring;
|
||||
typedef bg::model::multi_polygon<polygon> multi_polygon;
|
||||
|
||||
test_num_points<point>("POINT(0 0)", 1u);
|
||||
test_num_points<linestring>("LINESTRING(0 0,1 1)", 2u);
|
||||
test_num_points<segment>("LINESTRING(0 0,1 1)", 2u);
|
||||
test_num_points<box>("POLYGON((0 0,10 10))", 4u);
|
||||
test_num_points<ring>("POLYGON((0 0,1 1,0 1,0 0))", 4u);
|
||||
test_num_points<polygon>("POLYGON((0 0,10 10,0 10,0 0))", 4u);
|
||||
test_num_points<polygon>("POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))", 10u);
|
||||
test_num_points<multi_point>("MULTIPOINT((0 0),(1 1))", 2u);
|
||||
test_num_points<multi_linestring>("MULTILINESTRING((0 0,1 1),(2 2,3 3,4 4))", 5u);
|
||||
test_num_points<multi_polygon>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 9u);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ struct multilinestring_equals
|
||||
template <typename MultiLinestring>
|
||||
struct unique<MultiLinestring, false>
|
||||
{
|
||||
void operator()(MultiLinestring& mls)
|
||||
void operator()(MultiLinestring&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <boost/geometry/algorithms/detail/relate/turns.hpp>
|
||||
|
||||
template <typename G, typename Turns, typename Mapper>
|
||||
inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool enrich = false)
|
||||
inline void turns_to_svg(Turns const& turns, Mapper & mapper, bool /*enrich*/ = false)
|
||||
{
|
||||
// turn points in orange, + enrichment/traversal info
|
||||
typedef typename bg::coordinate_type<G>::type coordinate_type;
|
||||
@@ -196,7 +196,7 @@ struct to_svg_assign_policy
|
||||
};
|
||||
|
||||
template <typename G>
|
||||
inline void to_svg(G const& g, std::string const& filename, bool sort = true)
|
||||
inline void to_svg(G const& g, std::string const& filename, bool /*sort*/ = true)
|
||||
{
|
||||
namespace bg = boost::geometry;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user