Merge branch 'develop' of https://github.com/boostorg/geometry into feature/is_simple

This commit is contained in:
Menelaos Karavelas
2014-06-16 12:20:38 +03:00
15 changed files with 99 additions and 29 deletions

View File

@@ -2,7 +2,7 @@
[table
[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]]
[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]

View File

@@ -1,8 +1,8 @@
[heading Supported geometries]
[table
[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]]
[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]]
[[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Segment][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]]
[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]

View File

@@ -1,8 +1,8 @@
[heading Supported geometries]
[table
[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]]
[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Segment][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]]
[[Point][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Segment][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ]]
[[Box][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Linestring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]
[[Ring][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]

View File

@@ -2,7 +2,7 @@
[table
[[ ][Point][Segment][Box][Linestring][Ring][Polygon][MultiPoint][MultiLinestring][MultiPolygon][Variant]]
[[Point][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Segment][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Segment][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Box][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Linestring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ]]
[[Ring][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/nyi.png] ][ [$img/ok.png] ][ [$img/ok.png] ][ [$img/ok.png] ]]

View File

@@ -19,8 +19,9 @@
[*Additional functionality]
* added remove_spikes, algorithm to remove spikes from a ring, polygon or multi_polygon.
* added point_on_surface, generating a point lying on the surface (interior) of the polygon
* New algorithm buffer for inflating/deflating geometries (buffer itself already existed but that was only to enlarge a box)
* New algorithm remove_spikes, algorithm to remove spikes from a ring, polygon or multi_polygon.
* New algorithm point_on_surface, generating a point lying on the surface (interior) of the polygon
[*Solved tickets]
@@ -28,14 +29,12 @@
* [@https://svn.boost.org/trac/boost/ticket/9081 9081] Booleans create self-intersecting polygons from non-self-intersecting polygons
* [@https://svn.boost.org/trac/boost/ticket/8310 8310] Wrong results with overlapping polygons (fixed using point_on_surface for disjoint)
* [@https://svn.boost.org/trac/boost/ticket/9871 9871] Remove spike in polygon with only a spike
* [@https://svn.boost.org/trac/boost/ticket/9563 9563] (Sym)difference not successful, fixed by rescaling to robust type
[*Bugfixes]
* intersects(polygon) could return a self-intersection-point for its closing point, fixed
[*Solved tickets]
* [@https://svn.boost.org/trac/boost/ticket/9563 9563] (Sym)difference not successful, fixed by rescaling to robust type
[/=================]
[heading Boost 1.55]

View File

@@ -114,6 +114,11 @@ struct covered_by<Point, MultiPoint, point_tag, multi_point_tag>
// P/L
template <typename Point, typename Segment>
struct covered_by<Point, Segment, point_tag, segment_tag>
: public detail::covered_by::use_point_in_geometry
{};
template <typename Point, typename Linestring>
struct covered_by<Point, Linestring, point_tag, linestring_tag>
: public detail::covered_by::use_point_in_geometry

View File

@@ -65,14 +65,11 @@ int point_in_range(Point const& point, Range const& range, Strategy const& strat
iterator_type it = boost::begin(range);
iterator_type end = boost::end(range);
bool stop = false;
for ( iterator_type previous = it++ ;
it != end && ! stop ;
++previous, ++it )
for ( iterator_type previous = it++ ; it != end ; ++previous, ++it )
{
if ( ! strategy.apply(point, *previous, *it, state) )
{
stop = true;
break;
}
}
@@ -138,6 +135,8 @@ namespace detail_dispatch { namespace within {
// returns 0 if P is on the boundry of G
// returns -1 if P is in the exterior of G
// TODO: replace magic numbers with enum
template <typename Geometry,
typename Tag = typename geometry::tag<Geometry>::type>
struct point_in_geometry
@@ -155,6 +154,35 @@ struct point_in_geometry<Point2, point_tag>
}
};
template <typename Segment>
struct point_in_geometry<Segment, segment_tag>
{
template <typename Point, typename Strategy> static inline
int apply(Point const& point, Segment const& segment, Strategy const& strategy)
{
typedef typename geometry::point_type<Segment>::type point_type;
point_type p0, p1;
// TODO: don't copy points
detail::assign_point_from_index<0>(segment, p0);
detail::assign_point_from_index<1>(segment, p1);
typename Strategy::state_type state;
strategy.apply(point, p0, p1, state);
int r = detail::within::check_result_type(strategy.result(state));
if ( r != 0 )
return -1; // exterior
// if the point is equal to the one of the terminal points
if ( detail::equals::equals_point_point(point, p0)
|| detail::equals::equals_point_point(point, p1) )
return 0; // boundary
else
return 1; // interior
}
};
template <typename Linestring>
struct point_in_geometry<Linestring, linestring_tag>
{
@@ -165,17 +193,17 @@ struct point_in_geometry<Linestring, linestring_tag>
if ( count > 1 )
{
if ( detail::within::point_in_range(point, linestring, strategy) != 0 )
return -1;
return -1; // exterior
// if the linestring doesn't have a boundary
if ( detail::equals::equals_point_point(*boost::begin(linestring), *(--boost::end(linestring))) )
return 1;
return 1; // interior
// else if the point is equal to the one of the terminal points
else if ( detail::equals::equals_point_point(point, *boost::begin(linestring))
|| detail::equals::equals_point_point(point, *(--boost::end(linestring))) )
return 0;
return 0; // boundary
else
return 1;
return 1; // interior
}
// TODO: for now degenerated linestrings are ignored
// throw an exception here?
@@ -185,7 +213,7 @@ struct point_in_geometry<Linestring, linestring_tag>
return 1;
}*/
return -1;
return -1; // exterior
}
};

View File

@@ -136,6 +136,11 @@ struct within<Point, MultiPoint, point_tag, multi_point_tag>
// P/L
template <typename Point, typename Segment>
struct within<Point, Segment, point_tag, segment_tag>
: public detail::within::use_point_in_geometry
{};
template <typename Point, typename Linestring>
struct within<Point, Linestring, point_tag, linestring_tag>
: public detail::within::use_point_in_geometry

View File

@@ -12,17 +12,15 @@
#ifndef BOOST_GEOMETRY_INDEX_RTREE_HPP
#define BOOST_GEOMETRY_INDEX_RTREE_HPP
// STD
#include <algorithm>
// Boost
#include <boost/tuple/tuple.hpp>
#include <boost/move/move.hpp>
//#include <boost/geometry/geometry.hpp>
// START
#include <boost/geometry/strategies/strategies.hpp>
#include <boost/geometry/algorithms/comparable_distance.hpp>
#include <boost/geometry/algorithms/distance.hpp>
// Boost.Geometry
#include <boost/geometry/algorithms/detail/comparable_distance/interface.hpp>
#include <boost/geometry/algorithms/centroid.hpp>
#include <boost/geometry/algorithms/covered_by.hpp>
#include <boost/geometry/algorithms/disjoint.hpp>
@@ -34,8 +32,10 @@
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
// END
#include <boost/geometry/strategies/strategies.hpp>
// Boost.Geometry.Index
#include <boost/geometry/index/detail/config_begin.hpp>
#include <boost/geometry/index/detail/assert.hpp>
@@ -1798,6 +1798,9 @@ inline void swap(rtree<Value, Parameters, IndexableGetter, EqualTo, Allocator> &
}}} // namespace boost::geometry::index
// TODO: don't include the implementation at the end of the file
#include <boost/geometry/algorithms/detail/comparable_distance/implementation.hpp>
#include <boost/geometry/index/detail/config_end.hpp>
#endif // BOOST_GEOMETRY_INDEX_RTREE_HPP

View File

@@ -13,7 +13,8 @@
#ifndef BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_WEIGHTED_LENGTH_HPP
#define BOOST_GEOMETRY_STRATEGIES_CARTESIAN_CENTROID_WEIGHTED_LENGTH_HPP
#include <boost/geometry/algorithms/distance.hpp>
#include <boost/geometry/algorithms/detail/distance/interface.hpp>
#include <boost/geometry/algorithms/detail/distance/point_to_geometry.hpp>
#include <boost/geometry/arithmetic/arithmetic.hpp>
#include <boost/geometry/util/select_most_precise.hpp>
#include <boost/geometry/strategies/centroid.hpp>

View File

@@ -39,6 +39,11 @@ void test_all()
*/
typedef bg::model::segment<P> seg;
test_geometry<P, seg>("POINT(1 1)", "LINESTRING(0 0, 2 2)", true);
test_geometry<P, seg>("POINT(0 0)", "LINESTRING(0 0, 1 1)", true);
test_geometry<P, seg>("POINT(1 0)", "LINESTRING(0 0, 1 1)", false);
// linestrings
typedef bg::model::linestring<P> ls;
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0,1 1,2 2)", true);

View File

@@ -123,6 +123,16 @@ void test_intersects_point_linestring()
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true);
}
template <typename P>
void test_intersects_point_segment()
{
typedef bg::model::segment<P> seg;
test_geometry<P, seg>("POINT(0 0)", "LINESTRING(0 0,2 2)", true);
test_geometry<P, seg>("POINT(1 1)", "LINESTRING(0 0,2 2)", true);
test_geometry<P, seg>("POINT(1 0)", "LINESTRING(0 0,2 2)", false);
}
template <typename P>
void test_all()
{
@@ -146,6 +156,7 @@ void test_all()
"POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
"BOX(1941 2066, 2055 2166)", true);
test_intersects_point_segment<P>();
test_intersects_point_linestring<P>();
test_intersects_polygon_polygon<P>();
test_intersects_linestring_polygon<P>();

View File

@@ -14,6 +14,7 @@
#include <boost/core/ignore_unused.hpp>
#include <boost/foreach.hpp>
#include <boost/variant/variant.hpp>
#include <boost/geometry/algorithms/intersection.hpp>
#include <boost/geometry/algorithms/area.hpp>

View File

@@ -37,9 +37,14 @@ void test_p_p()
template <typename P>
void test_p_l()
{
typedef bg::model::segment<P> seg;
typedef bg::model::linestring<P> ls;
typedef bg::model::multi_linestring<ls> mls;
test_geometry<P, seg>("POINT(1 1)", "LINESTRING(0 0, 2 2)", true);
test_geometry<P, seg>("POINT(0 0)", "LINESTRING(0 0, 1 1)", false);
test_geometry<P, seg>("POINT(1 0)", "LINESTRING(0 0, 1 1)", false);
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0,1 1,2 2)", false);
test_geometry<P, ls>("POINT(3 3)", "LINESTRING(0 0,1 1,2 2)", false);
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,3 3)", true);

View File

@@ -27,6 +27,7 @@
# pragma warning( disable : 4101 )
#endif
#include <boost/core/ignore_unused.hpp>
#include <boost/timer.hpp>
#include <boost/typeof/typeof.hpp>
@@ -184,6 +185,12 @@ inline void test_services()
<
bg::box_tag, bg::point_tag, Box, Point
>::type reversed_pythagoras_pb_strategy_type;
boost::ignore_unused
<
pythagoras_pb_strategy_type,
reversed_pythagoras_pb_strategy_type
>();
}
Point p;