Skip to content

Commit

Permalink
Merge branch 'bg-prepare'
Browse files Browse the repository at this point in the history
  • Loading branch information
barendgehrels committed Nov 27, 2015
2 parents 2854191 + c220373 commit 00321c0
Show file tree
Hide file tree
Showing 50 changed files with 2,157 additions and 884 deletions.
8 changes: 6 additions & 2 deletions doc/release_notes.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,17 @@

[*Solved tickets]

* [@https://svn.boost.org/trac/boost/ticket/10803 10803] Union algorithm returning invalid geometry
* [@https://svn.boost.org/trac/boost/ticket/11522 11522] Namespace clash in buffer for traits::detail
* [@https://svn.boost.org/trac/boost/ticket/11533 11533] Assert failure in rtree caused by a bug in remove() if min elements number is 1
* [@https://svn.boost.org/trac/boost/ticket/11607 11607] Private geometry::exception::what()
* [@https://svn.boost.org/trac/boost/ticket/11709 11709] is_simple segfault
* [@https://svn.boost.org/trac/boost/ticket/11710 11710] is_simple - empty geometry logic
* [@https://svn.boost.org/trac/boost/ticket/11711 11711] is_simple and is_valid - Points that are NaN or Infinity

[*Bugfixes]

* Fix colocations of touching interior ring / exterior ring, where it also touches another polygon
* Fix removing values from an empty rtree - no effect and 0 returned instead of assertion failure.

[/=================]
Expand Down Expand Up @@ -139,8 +145,6 @@
[heading Boost 1.57]
[/=================]

[*Additional functionality]

[*Improvements]

* The support of parameters convertible to value_type in rtree insert(), remove() and count() functions
Expand Down
23 changes: 13 additions & 10 deletions include/boost/geometry/algorithms/centroid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,22 @@ struct centroid_range_state
iterator_type it = boost::begin(view);
iterator_type end = boost::end(view);

typename PointTransformer::result_type
previous_pt = transformer.apply(*it);

for ( ++it ; it != end ; ++it)
if (it != end)
{
typename PointTransformer::result_type
pt = transformer.apply(*it);
previous_pt = transformer.apply(*it);

strategy.apply(static_cast<point_type const&>(previous_pt),
static_cast<point_type const&>(pt),
state);

previous_pt = pt;
for ( ++it ; it != end ; ++it)
{
typename PointTransformer::result_type
pt = transformer.apply(*it);

strategy.apply(static_cast<point_type const&>(previous_pt),
static_cast<point_type const&>(pt),
state);

previous_pt = pt;
}
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ struct buffered_piece_collection
typename cs_tag<Ring>::type
>::type side_strategy_type;

enrich_intersection_points<false, false>(m_turns,
enrich_intersection_points<false, false, overlay_union>(m_turns,
detail::overlay::operation_union,
offsetted_rings, offsetted_rings,
m_robust_policy, side_strategy_type());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,36 @@ namespace traits


template <typename Ring>
struct tag<detail::buffer::buffered_ring<Ring> >
struct tag<geometry::detail::buffer::buffered_ring<Ring> >
{
typedef ring_tag type;
};


template <typename Ring>
struct point_order<detail::buffer::buffered_ring<Ring> >
struct point_order<geometry::detail::buffer::buffered_ring<Ring> >
{
static const order_selector value = geometry::point_order<Ring>::value;
};


template <typename Ring>
struct closure<detail::buffer::buffered_ring<Ring> >
struct closure<geometry::detail::buffer::buffered_ring<Ring> >
{
static const closure_selector value = geometry::closure<Ring>::value;
};


template <typename Ring>
struct point_type<detail::buffer::buffered_ring_collection<Ring> >
struct point_type<geometry::detail::buffer::buffered_ring_collection<Ring> >
{
typedef typename geometry::point_type<Ring>::type type;
};

template <typename Ring>
struct tag<detail::buffer::buffered_ring_collection<Ring> >
struct tag<geometry::detail::buffer::buffered_ring_collection<Ring> >
{
typedef detail::buffer::buffered_ring_collection_tag type;
typedef geometry::detail::buffer::buffered_ring_collection_tag type;
};


Expand Down
12 changes: 6 additions & 6 deletions include/boost/geometry/algorithms/detail/is_simple/areal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ struct is_simple_ring
static inline bool apply(Ring const& ring)
{
simplicity_failure_policy policy;
return
!detail::is_valid::has_duplicates
<
Ring, geometry::closure<Ring>::value
>::apply(ring, policy);
return ! boost::empty(ring)
&& ! detail::is_valid::has_duplicates
<
Ring, geometry::closure<Ring>::value
>::apply(ring, policy);
}
};

Expand Down Expand Up @@ -128,7 +128,7 @@ struct is_simple<MultiPolygon, multi_polygon_tag>
<
typename boost::range_value<MultiPolygon>::type
>,
false // do not allow empty multi-polygon
true // allow empty multi-polygon
>::apply(boost::begin(multipolygon), boost::end(multipolygon));
}
};
Expand Down
5 changes: 3 additions & 2 deletions include/boost/geometry/algorithms/detail/is_simple/linear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ struct is_simple_linestring
static inline bool apply(Linestring const& linestring)
{
simplicity_failure_policy policy;
return ! detail::is_valid::has_duplicates
return ! boost::empty(linestring)
&& ! detail::is_valid::has_duplicates
<
Linestring, closed
>::apply(linestring, policy)
Expand Down Expand Up @@ -263,7 +264,7 @@ struct is_simple_multilinestring
typename boost::range_value<MultiLinestring>::type,
false // do not compute self-intersections
>,
false // do not allow empty multilinestring
true // allow empty multilinestring
>::apply(boost::begin(multilinestring),
boost::end(multilinestring))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ struct is_simple_multipoint
{
static inline bool apply(MultiPoint const& multipoint)
{
if ( boost::size(multipoint) == 0 )
if (boost::empty(multipoint))
{
return false;
return true;
}

MultiPoint mp(multipoint);
Expand Down
17 changes: 16 additions & 1 deletion include/boost/geometry/algorithms/detail/is_valid/box.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <boost/geometry/core/coordinate_dimension.hpp>

#include <boost/geometry/algorithms/validity_failure_type.hpp>
#include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
#include <boost/geometry/algorithms/dispatch/is_valid.hpp>


Expand Down Expand Up @@ -66,6 +67,20 @@ struct has_valid_corners<Box, 0>
}
};


template <typename Box>
struct is_valid_box
{
template <typename VisitPolicy>
static inline bool apply(Box const& box, VisitPolicy& visitor)
{
return
! has_invalid_coordinate<Box>::apply(box, visitor)
&&
has_valid_corners<Box, dimension<Box>::value>::apply(box, visitor);
}
};

}} // namespace detail::is_valid
#endif // DOXYGEN_NO_DETAIL

Expand All @@ -85,7 +100,7 @@ namespace dispatch
// Reference (for polygon validity): OGC 06-103r4 (6.1.11.1)
template <typename Box>
struct is_valid<Box, box_tag>
: detail::is_valid::has_valid_corners<Box, dimension<Box>::value>
: detail::is_valid::is_valid_box<Box>
{};


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)

// Copyright (c) 2014-2015, Oracle and/or its affiliates.

// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle

// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html

#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_INVALID_COORDINATE_HPP
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_INVALID_COORDINATE_HPP

#include <cstddef>

#include <boost/type_traits/is_floating_point.hpp>

#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/point_type.hpp>

#include <boost/geometry/util/has_non_finite_coordinate.hpp>

#include <boost/geometry/iterators/point_iterator.hpp>
#include <boost/geometry/views/detail/indexed_point_view.hpp>
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>


namespace boost { namespace geometry
{

#ifndef DOXYGEN_NO_DETAIL
namespace detail { namespace is_valid
{

struct always_valid
{
template <typename Geometry, typename VisitPolicy>
static inline bool apply(Geometry const&, VisitPolicy& visitor)
{
return ! visitor.template apply<no_failure>();
}
};

struct point_has_invalid_coordinate
{
template <typename Point, typename VisitPolicy>
static inline bool apply(Point const& point, VisitPolicy& visitor)
{
boost::ignore_unused(visitor);

return
geometry::has_non_finite_coordinate(point)
?
(! visitor.template apply<failure_invalid_coordinate>())
:
(! visitor.template apply<no_failure>());
}

template <typename Point>
static inline bool apply(Point const& point)
{
return geometry::has_non_finite_coordinate(point);
}
};

struct indexed_has_invalid_coordinate
{
template <typename Geometry, typename VisitPolicy>
static inline bool apply(Geometry const& geometry, VisitPolicy& visitor)
{
geometry::detail::indexed_point_view<Geometry const, 0> p0(geometry);
geometry::detail::indexed_point_view<Geometry const, 1> p1(geometry);

return point_has_invalid_coordinate::apply(p0, visitor)
|| point_has_invalid_coordinate::apply(p1, visitor);
}
};


struct range_has_invalid_coordinate
{
struct point_has_valid_coordinates
{
template <typename Point>
static inline bool apply(Point const& point)
{
return ! point_has_invalid_coordinate::apply(point);
}
};

template <typename Geometry, typename VisitPolicy>
static inline bool apply(Geometry const& geometry, VisitPolicy& visitor)
{
boost::ignore_unused(visitor);

bool const has_valid_coordinates = detail::check_iterator_range
<
point_has_valid_coordinates,
true // do not consider an empty range as problematic
>::apply(geometry::points_begin(geometry),
geometry::points_end(geometry));

return has_valid_coordinates
?
(! visitor.template apply<no_failure>())
:
(! visitor.template apply<failure_invalid_coordinate>());
}
};


template
<
typename Geometry,
typename Tag = typename tag<Geometry>::type,
bool HasFloatingPointCoordinates = boost::is_floating_point
<
typename coordinate_type<Geometry>::type
>::value
>
struct has_invalid_coordinate
: range_has_invalid_coordinate
{};

template <typename Geometry, typename Tag>
struct has_invalid_coordinate<Geometry, Tag, false>
: always_valid
{};

template <typename Point>
struct has_invalid_coordinate<Point, point_tag, true>
: point_has_invalid_coordinate
{};

template <typename Segment>
struct has_invalid_coordinate<Segment, segment_tag, true>
: indexed_has_invalid_coordinate
{};

template <typename Box>
struct has_invalid_coordinate<Box, box_tag, true>
: indexed_has_invalid_coordinate
{};


}} // namespace detail::is_valid
#endif // DOXYGEN_NO_DETAIL

}} // namespace boost::geometry

#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_IS_VALID_HAS_INVALID_COORDINATE_HPP
6 changes: 6 additions & 0 deletions include/boost/geometry/algorithms/detail/is_valid/linear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <boost/geometry/algorithms/equals.hpp>
#include <boost/geometry/algorithms/validity_failure_type.hpp>
#include <boost/geometry/algorithms/detail/check_iterator_range.hpp>
#include <boost/geometry/algorithms/detail/is_valid/has_invalid_coordinate.hpp>
#include <boost/geometry/algorithms/detail/is_valid/has_spikes.hpp>
#include <boost/geometry/algorithms/detail/num_distinct_consecutive_points.hpp>

Expand All @@ -46,6 +47,11 @@ struct is_valid_linestring
static inline bool apply(Linestring const& linestring,
VisitPolicy& visitor)
{
if (has_invalid_coordinate<Linestring>::apply(linestring, visitor))
{
return false;
}

if (boost::size(linestring) < 2)
{
return visitor.template apply<failure_few_points>();
Expand Down
Loading

0 comments on commit 00321c0

Please sign in to comment.