mirror of
https://github.com/boostorg/geometry.git
synced 2025-05-11 13:34:10 +00:00
Merge branch 'develop' into feature/cluster_touch
Conflicts: include/boost/geometry/algorithms/detail/overlay/handle_touch.hpp test/algorithms/overlay/Jamfile.v2 test/algorithms/set_operations/difference/difference.cpp test/algorithms/set_operations/union/union.cpp
This commit is contained in:
commit
b46805107b
@ -12,8 +12,8 @@ Boost.Geometry, part of collection of the [Boost C++ Libraries](http://github.co
|
||||
|
||||
@ | Build | Coverage | Regression
|
||||
------------|---------------|----------------|------------
|
||||
**master** | [](https://circleci.com/gh/awulkiew/geometry/tree/master) | [](https://coveralls.io/r/awulkiew/geometry?branch=master) | [](http://www.boost.org/development/tests/master/developer/geometry.html) [](http://www.boost.org/development/tests/master/developer/geometry-index.html)
|
||||
**develop** | [](https://circleci.com/gh/awulkiew/geometry/tree/develop) | [](https://coveralls.io/r/awulkiew/geometry?branch=develop) | [](http://www.boost.org/development/tests/develop/developer/geometry.html) [](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html)
|
||||
**master** | [](https://circleci.com/gh/boostorg/geometry/tree/master) | [](https://coveralls.io/github/boostorg/geometry?branch=master) | [](http://www.boost.org/development/tests/master/developer/geometry.html) [](http://www.boost.org/development/tests/master/developer/geometry-index.html)
|
||||
**develop** | [](https://circleci.com/gh/boostorg/geometry/tree/develop) | [](https://coveralls.io/github/boostorg/geometry?branch=develop) | [](http://www.boost.org/development/tests/develop/developer/geometry.html) [](http://www.boost.org/development/tests/develop/developer/geometry-index.html) [](http://www.boost.org/development/tests/develop/developer/geometry-extensions.html)
|
||||
|
||||
### Directories
|
||||
|
||||
|
@ -154,8 +154,8 @@ test:
|
||||
#parallel: true
|
||||
|
||||
## ... alter the json file
|
||||
- jq -c ".service_name = \"circle-ci\" | .service_job_id = \"$CIRCLE_BUILD_NUM\" | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json
|
||||
#- jq -c ".service_name = \"circle-ci\" | .service_job_id = \"$CIRCLE_BUILD_NUM\" | .parallel = true | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json #:
|
||||
- jq -c ".service_name = \"circle-ci\" | .service_number = \"$CIRCLE_BUILD_NUM\" | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json
|
||||
#- jq -c ".service_name = \"circle-ci\" | .service_number = \"$CIRCLE_BUILD_NUM\" | .parallel = true | .git .branch =\"$CIRCLE_BRANCH\"" $COVERAGE_ROOT/coverage.json > $COVERAGE_ROOT/processed.json #:
|
||||
#parallel: true
|
||||
|
||||
## ... send it to Coveralls
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
This file was modified by Oracle on 2015, 2016.
|
||||
Modifications copyright (c) 2015-2016, 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
|
||||
|
||||
@ -19,6 +18,19 @@
|
||||
|
||||
[section:release_notes Release Notes]
|
||||
|
||||
[/=================]
|
||||
[heading Boost 1.62]
|
||||
[/=================]
|
||||
|
||||
[*Improvements]
|
||||
|
||||
* SVG: support boost::variant of geometries
|
||||
|
||||
[*Solved tickets]
|
||||
|
||||
* [@https://svn.boost.org/trac/boost/ticket/12189 12189] Relational operations not compiling when point types of inputs are different
|
||||
* [@https://svn.boost.org/trac/boost/ticket/12287 12287] Invalid result of rtree.query() for contains() predicate
|
||||
|
||||
[/=================]
|
||||
[heading Boost 1.61]
|
||||
[/=================]
|
||||
@ -33,6 +45,7 @@
|
||||
|
||||
[*Solved tickets]
|
||||
|
||||
* [@https://svn.boost.org/trac/boost/ticket/9162 9162] Invalid result of relational operations for non-cartesian Point/Areal.
|
||||
* [@https://svn.boost.org/trac/boost/ticket/10866 10866] union_ doesn't work in 1.56 and 1.57.
|
||||
* [@https://svn.boost.org/trac/boost/ticket/11018 11018] Invalid geometry intersection
|
||||
* [@https://svn.boost.org/trac/boost/ticket/11576 11576] Intersection gives wrong results.
|
||||
@ -49,9 +62,9 @@
|
||||
|
||||
[*Bugfixes]
|
||||
|
||||
* Fix intersects and disjoints for Segment/Box in cartesian coordinate system when Segment is parallel to Box's face.
|
||||
* Fix intersects and disjoint for Segment/Box in cartesian coordinate system when Segment is parallel to Box's face.
|
||||
* Fix relation operations for Point/Areal in spherical and geographic coordinate systems for edge cases.
|
||||
* Fix intersect and disjoint for Point/Box and Box/Box in spherical and geographic coordinate systems for some cases.
|
||||
* Fix intersects and disjoint for Point/Box and Box/Box in spherical and geographic coordinate systems for some cases.
|
||||
* Fix within and covered_by for Point/Box in spherical and geographic coordinate systems for some cases.
|
||||
|
||||
[/=================]
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
|
||||
#if defined(HAVE_SVG)
|
||||
# include <boost/geometry/io/svg/write_svg.hpp>
|
||||
# include <boost/geometry/io/svg/write.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/random.hpp>
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <boost/geometry/geometries/register/point.hpp>
|
||||
#include <boost/geometry/geometries/multi_polygon.hpp>
|
||||
|
||||
#include <boost/geometry/io/svg/write_svg.hpp>
|
||||
#include <boost/geometry/io/svg/write.hpp>
|
||||
#include <boost/geometry/extensions/gis/latlong/latlong.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/project_transformer.hpp>
|
||||
|
||||
|
@ -49,7 +49,7 @@ struct azimuth<ReturnType, geographic_tag>
|
||||
template <typename P1, typename P2, typename Spheroid>
|
||||
static inline ReturnType apply(P1 const& p1, P2 const& p2, Spheroid const& spheroid)
|
||||
{
|
||||
return geometry::detail::vincenty_inverse<ReturnType, false, true>
|
||||
return geometry::detail::vincenty_inverse<ReturnType, false, true>().apply
|
||||
( get_as_radian<0>(p1), get_as_radian<1>(p1),
|
||||
get_as_radian<0>(p2), get_as_radian<1>(p2),
|
||||
spheroid ).azimuth;
|
||||
|
@ -58,14 +58,14 @@ public :
|
||||
static inline void apply(std::size_t size_at_start,
|
||||
Rings& rings, typename boost::range_value<Rings>::type& ring,
|
||||
Turns& turns,
|
||||
typename boost::range_value<Turns>::type const& turn,
|
||||
typename boost::range_value<Turns>::type const& /*turn*/,
|
||||
Operation& operation,
|
||||
detail::overlay::traverse_error_type traverse_error,
|
||||
detail::overlay::traverse_error_type /*traverse_error*/,
|
||||
Geometry const& ,
|
||||
Geometry const& ,
|
||||
RobustPolicy const& ,
|
||||
state_type& state,
|
||||
Visitor& visitor
|
||||
Visitor& /*visitor*/
|
||||
)
|
||||
{
|
||||
#if defined(BOOST_GEOMETRY_COUNT_BACKTRACK_WARNINGS)
|
||||
@ -92,17 +92,17 @@ g_backtrack_warning_count++;
|
||||
struct buffer_overlay_visitor
|
||||
{
|
||||
public :
|
||||
void print(char const* header)
|
||||
void print(char const* /*header*/)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Turns>
|
||||
void print(char const* header, Turns const& turns, int turn_index)
|
||||
void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Turns>
|
||||
void print(char const* header, Turns const& turns, int turn_index, int op_index)
|
||||
void print(char const* /*header*/, Turns const& /*turns*/, int /*turn_index*/, int /*op_index*/)
|
||||
{
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ public :
|
||||
void visit_clusters(Clusters const& , Turns const& ) {}
|
||||
|
||||
template <typename Turns, typename Turn, typename Operation>
|
||||
void visit_traverse(Turns const& turns, Turn const& turn, Operation const& op, const char* header)
|
||||
void visit_traverse(Turns const& /*turns*/, Turn const& /*turn*/, Operation const& /*op*/, const char* /*header*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -92,7 +92,7 @@ inline void transform_units(GeometryIn const& geometry_in,
|
||||
<
|
||||
GeometryIn, GeometryOut
|
||||
>::apply(geometry_in, geometry_out);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}} // namespace detail::envelope
|
||||
|
@ -19,11 +19,14 @@
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
|
||||
#include <boost/geometry/algorithms/detail/normalize.hpp>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/formulas/spherical.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
@ -33,31 +36,61 @@
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
// TODO: if Boost.LA of Emil Dotchevski is accepted, adapt this
|
||||
template <typename T>
|
||||
// Since these vectors (though ray would be a better name) are used in the
|
||||
// implementation of equals() for Areal geometries the internal representation
|
||||
// should be consistent with the default side strategy for CS because currently
|
||||
// it's used in other relops.
|
||||
|
||||
template <
|
||||
typename T,
|
||||
typename Geometry,
|
||||
typename CSTag = typename cs_tag<Geometry>::type
|
||||
>
|
||||
struct collected_vector
|
||||
{
|
||||
typedef T type;
|
||||
|
||||
|
||||
inline collected_vector()
|
||||
{}
|
||||
|
||||
inline collected_vector(T const& px, T const& py,
|
||||
T const& pdx, T const& pdy)
|
||||
T const& pdx, T const& pdy)
|
||||
: x(px)
|
||||
, y(py)
|
||||
, dx(pdx)
|
||||
, dy(pdy)
|
||||
, dx_0(T())
|
||||
, dy_0(T())
|
||||
//, dx_0(dx)
|
||||
//, dy_0(dy)
|
||||
{}
|
||||
|
||||
T x, y;
|
||||
T dx, dy;
|
||||
T dx_0, dy_0;
|
||||
template <typename Point>
|
||||
inline collected_vector(Point const& p1, Point const& p2)
|
||||
: x(get<0>(p1))
|
||||
, y(get<1>(p1))
|
||||
, dx(get<0>(p2) - x)
|
||||
, dy(get<1>(p2) - y)
|
||||
//, dx_0(dx)
|
||||
//, dy_0(dy)
|
||||
{}
|
||||
|
||||
bool normalize()
|
||||
{
|
||||
T magnitude = math::sqrt(
|
||||
boost::numeric_cast<T>(dx * dx + dy * dy));
|
||||
|
||||
// NOTE: shouldn't here math::equals() be called?
|
||||
if (magnitude > 0)
|
||||
{
|
||||
dx /= magnitude;
|
||||
dy /= magnitude;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// For sorting
|
||||
inline bool operator<(collected_vector<T> const& other) const
|
||||
inline bool operator<(collected_vector const& other) const
|
||||
{
|
||||
if (math::equals(x, other.x))
|
||||
{
|
||||
@ -74,7 +107,21 @@ struct collected_vector
|
||||
return x < other.x;
|
||||
}
|
||||
|
||||
inline bool same_direction(collected_vector<T> const& other) const
|
||||
inline bool next_is_collinear(collected_vector const& other) const
|
||||
{
|
||||
return same_direction(other);
|
||||
}
|
||||
|
||||
// For std::equals
|
||||
inline bool operator==(collected_vector const& other) const
|
||||
{
|
||||
return math::equals(x, other.x)
|
||||
&& math::equals(y, other.y)
|
||||
&& same_direction(other);
|
||||
}
|
||||
|
||||
private:
|
||||
inline bool same_direction(collected_vector const& other) const
|
||||
{
|
||||
// For high precision arithmetic, we have to be
|
||||
// more relaxed then using ==
|
||||
@ -84,13 +131,156 @@ struct collected_vector
|
||||
&& math::equals_with_epsilon(dy, other.dy);
|
||||
}
|
||||
|
||||
// For std::equals
|
||||
inline bool operator==(collected_vector<T> const& other) const
|
||||
T x, y;
|
||||
T dx, dy;
|
||||
//T dx_0, dy_0;
|
||||
};
|
||||
|
||||
template <typename T, typename Geometry>
|
||||
struct collected_vector<T, Geometry, spherical_equatorial_tag>
|
||||
{
|
||||
typedef T type;
|
||||
|
||||
typedef typename coordinate_system<Geometry>::type cs_type;
|
||||
typedef model::point<T, 2, cs_type> point_type;
|
||||
typedef model::point<T, 3, cs::cartesian> vector_type;
|
||||
|
||||
collected_vector()
|
||||
{}
|
||||
|
||||
template <typename Point>
|
||||
collected_vector(Point const& p1, Point const& p2)
|
||||
: origin(get<0>(p1), get<1>(p1))
|
||||
{
|
||||
return math::equals(x, other.x)
|
||||
&& math::equals(y, other.y)
|
||||
&& same_direction(other);
|
||||
origin = detail::return_normalized<point_type>(origin);
|
||||
|
||||
using namespace geometry::formula;
|
||||
prev = sph_to_cart3d<vector_type>(p1);
|
||||
next = sph_to_cart3d<vector_type>(p2);
|
||||
direction = cross_product(prev, next);
|
||||
}
|
||||
|
||||
bool normalize()
|
||||
{
|
||||
T magnitude_sqr = dot_product(direction, direction);
|
||||
|
||||
// NOTE: shouldn't here math::equals() be called?
|
||||
if (magnitude_sqr > 0)
|
||||
{
|
||||
divide_value(direction, math::sqrt(magnitude_sqr));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool operator<(collected_vector const& other) const
|
||||
{
|
||||
if (math::equals(get<0>(origin), get<0>(other.origin)))
|
||||
{
|
||||
if (math::equals(get<1>(origin), get<1>(other.origin)))
|
||||
{
|
||||
if (math::equals(get<0>(direction), get<0>(other.direction)))
|
||||
{
|
||||
if (math::equals(get<1>(direction), get<1>(other.direction)))
|
||||
{
|
||||
return get<2>(direction) < get<2>(other.direction);
|
||||
}
|
||||
return get<1>(direction) < get<1>(other.direction);
|
||||
}
|
||||
return get<0>(direction) < get<0>(other.direction);
|
||||
}
|
||||
return get<1>(origin) < get<1>(other.origin);
|
||||
}
|
||||
return get<0>(origin) < get<0>(other.origin);
|
||||
}
|
||||
|
||||
// For consistency with side and intersection strategies used by relops
|
||||
// IMPORTANT: this method should be called for previous vector
|
||||
// and next vector should be passed as parameter
|
||||
bool next_is_collinear(collected_vector const& other) const
|
||||
{
|
||||
return formula::sph_side_value(direction, other.next) == 0;
|
||||
}
|
||||
|
||||
// For std::equals
|
||||
bool operator==(collected_vector const& other) const
|
||||
{
|
||||
return math::equals(get<0>(origin), get<0>(other.origin))
|
||||
&& math::equals(get<1>(origin), get<1>(other.origin))
|
||||
&& is_collinear(other);
|
||||
}
|
||||
|
||||
private:
|
||||
// For consistency with side and intersection strategies used by relops
|
||||
bool is_collinear(collected_vector const& other) const
|
||||
{
|
||||
return formula::sph_side_value(direction, other.prev) == 0
|
||||
&& formula::sph_side_value(direction, other.next) == 0;
|
||||
}
|
||||
|
||||
/*bool same_direction(collected_vector const& other) const
|
||||
{
|
||||
return math::equals_with_epsilon(get<0>(direction), get<0>(other.direction))
|
||||
&& math::equals_with_epsilon(get<1>(direction), get<1>(other.direction))
|
||||
&& math::equals_with_epsilon(get<2>(direction), get<2>(other.direction));
|
||||
}*/
|
||||
|
||||
point_type origin; // used for sorting and equality check
|
||||
vector_type direction; // used for sorting, only in operator<
|
||||
vector_type prev; // used for collinearity check, only in operator==
|
||||
vector_type next; // used for collinearity check
|
||||
};
|
||||
|
||||
template <typename T, typename Geometry>
|
||||
struct collected_vector<T, Geometry, spherical_polar_tag>
|
||||
: public collected_vector<T, Geometry, spherical_equatorial_tag>
|
||||
{
|
||||
typedef collected_vector<T, Geometry, spherical_equatorial_tag> base_type;
|
||||
|
||||
collected_vector() {}
|
||||
|
||||
template <typename Point>
|
||||
collected_vector(Point const& p1, Point const& p2)
|
||||
: base_type(to_equatorial(p1), to_equatorial(p2))
|
||||
{}
|
||||
|
||||
private:
|
||||
template <typename Point>
|
||||
Point polar_to_equatorial(Point const& p)
|
||||
{
|
||||
typedef typename coordinate_type<Point>::type coord_type;
|
||||
|
||||
typedef math::detail::constants_on_spheroid
|
||||
<
|
||||
coord_type,
|
||||
typename coordinate_system<Point>::type::units
|
||||
> constants;
|
||||
|
||||
coord_type const pi_2 = constants::half_period() / 2;
|
||||
|
||||
Point res = p;
|
||||
set<1>(res, pi_2 - get<1>(p));
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
// This is consistent with the currently used default geographic side
|
||||
// and intersection strategies. Spherical strategies are used by default.
|
||||
// When default strategies are changed in the future this specialization
|
||||
// should be changed too.
|
||||
template <typename T, typename Geometry>
|
||||
struct collected_vector<T, Geometry, geographic_tag>
|
||||
: public collected_vector<T, Geometry, spherical_equatorial_tag>
|
||||
{
|
||||
typedef collected_vector<T, Geometry, spherical_equatorial_tag> base_type;
|
||||
|
||||
collected_vector() {}
|
||||
|
||||
template <typename Point>
|
||||
collected_vector(Point const& p1, Point const& p2)
|
||||
: base_type(p1, p2)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
@ -117,39 +307,26 @@ struct range_collect_vectors
|
||||
|
||||
typedef typename boost::range_iterator<Range const>::type iterator;
|
||||
|
||||
bool first = true;
|
||||
bool is_first = true;
|
||||
iterator it = boost::begin(range);
|
||||
|
||||
for (iterator prev = it++;
|
||||
it != boost::end(range);
|
||||
prev = it++)
|
||||
{
|
||||
typename boost::range_value<Collection>::type v;
|
||||
|
||||
v.x = get<0>(*prev);
|
||||
v.y = get<1>(*prev);
|
||||
v.dx = get<0>(*it) - v.x;
|
||||
v.dy = get<1>(*it) - v.y;
|
||||
v.dx_0 = v.dx;
|
||||
v.dy_0 = v.dy;
|
||||
typename boost::range_value<Collection>::type v(*prev, *it);
|
||||
|
||||
// Normalize the vector -> this results in points+direction
|
||||
// and is comparible between geometries
|
||||
calculation_type magnitude = math::sqrt(
|
||||
boost::numeric_cast<calculation_type>(v.dx * v.dx + v.dy * v.dy));
|
||||
|
||||
// Avoid non-duplicate points (AND division by zero)
|
||||
if (magnitude > 0)
|
||||
if (v.normalize())
|
||||
{
|
||||
v.dx /= magnitude;
|
||||
v.dy /= magnitude;
|
||||
|
||||
// Avoid non-direction changing points
|
||||
if (first || ! v.same_direction(collection.back()))
|
||||
if (is_first || ! collection.back().next_is_collinear(v))
|
||||
{
|
||||
collection.push_back(v);
|
||||
}
|
||||
first = false;
|
||||
is_first = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,7 +337,7 @@ struct range_collect_vectors
|
||||
typedef typename boost::range_iterator<Collection>::type c_iterator;
|
||||
c_iterator first = range::pos(collection, c_old_size);
|
||||
|
||||
if ( first->same_direction(collection.back()) )
|
||||
if (collection.back().next_is_collinear(*first) )
|
||||
{
|
||||
//collection.erase(first);
|
||||
// O(1) instead of O(N)
|
||||
@ -172,7 +349,8 @@ struct range_collect_vectors
|
||||
};
|
||||
|
||||
|
||||
template <typename Box, typename Collection>
|
||||
// Default version (cartesian)
|
||||
template <typename Box, typename Collection, typename CSTag = typename cs_tag<Box>::type>
|
||||
struct box_collect_vectors
|
||||
{
|
||||
// Calculate on coordinate type, but if it is integer,
|
||||
@ -183,9 +361,9 @@ struct box_collect_vectors
|
||||
static inline void apply(Collection& collection, Box const& box)
|
||||
{
|
||||
typename point_type<Box>::type lower_left, lower_right,
|
||||
upper_left, upper_right;
|
||||
upper_left, upper_right;
|
||||
geometry::detail::assign_box_corners(box, lower_left, lower_right,
|
||||
upper_left, upper_right);
|
||||
upper_left, upper_right);
|
||||
|
||||
typedef typename boost::range_value<Collection>::type item;
|
||||
|
||||
@ -196,6 +374,37 @@ struct box_collect_vectors
|
||||
}
|
||||
};
|
||||
|
||||
// NOTE: This is not fully correct because Box in spherical and geographic
|
||||
// cordinate systems cannot be seen as Polygon
|
||||
template <typename Box, typename Collection>
|
||||
struct box_collect_vectors<Box, Collection, spherical_equatorial_tag>
|
||||
{
|
||||
static inline void apply(Collection& collection, Box const& box)
|
||||
{
|
||||
typename point_type<Box>::type lower_left, lower_right,
|
||||
upper_left, upper_right;
|
||||
geometry::detail::assign_box_corners(box, lower_left, lower_right,
|
||||
upper_left, upper_right);
|
||||
|
||||
typedef typename boost::range_value<Collection>::type item;
|
||||
|
||||
collection.push_back(item(lower_left, upper_left));
|
||||
collection.push_back(item(upper_left, upper_right));
|
||||
collection.push_back(item(upper_right, lower_right));
|
||||
collection.push_back(item(lower_right, lower_left));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Box, typename Collection>
|
||||
struct box_collect_vectors<Box, Collection, spherical_polar_tag>
|
||||
: box_collect_vectors<Box, Collection, spherical_equatorial_tag>
|
||||
{};
|
||||
|
||||
template <typename Box, typename Collection>
|
||||
struct box_collect_vectors<Box, Collection, geographic_tag>
|
||||
: box_collect_vectors<Box, Collection, spherical_equatorial_tag>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Polygon, typename Collection>
|
||||
struct polygon_collect_vectors
|
||||
|
@ -123,7 +123,7 @@ struct intersection
|
||||
= geometry::get_rescale_policy<rescale_policy_type>(geometry1,
|
||||
geometry2);
|
||||
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<Geometry1>::type,
|
||||
Geometry1,
|
||||
|
@ -66,7 +66,7 @@ inline void enrich_sort(Operations& operations,
|
||||
Geometry1 const& geometry1,
|
||||
Geometry2 const& geometry2,
|
||||
RobustPolicy const& robust_policy,
|
||||
Strategy const& strategy)
|
||||
Strategy const& /*strategy*/)
|
||||
{
|
||||
std::sort(boost::begin(operations),
|
||||
boost::end(operations),
|
||||
|
@ -49,7 +49,7 @@ struct get_turn_without_info
|
||||
RobustPolicy const& robust_policy,
|
||||
OutputIterator out)
|
||||
{
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<typename TurnInfo::point_type>::type,
|
||||
Point1,
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_GET_RELATIVE_ORDER_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_strategies.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_strategies.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/convert.hpp>
|
||||
#include <boost/geometry/algorithms/detail/overlay/turn_info.hpp>
|
||||
@ -989,6 +989,7 @@ struct get_turn_info
|
||||
// Swap p/q
|
||||
side_calculator
|
||||
<
|
||||
typename inters_info::cs_tag,
|
||||
typename inters_info::robust_point2_type,
|
||||
typename inters_info::robust_point1_type
|
||||
> swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(),
|
||||
|
@ -400,6 +400,8 @@ struct get_turn_info_for_endpoint
|
||||
IntersectionInfo const& inters, unsigned int ip_index,
|
||||
operation_type & op1, operation_type & op2)
|
||||
{
|
||||
typedef typename cs_tag<typename TurnInfo::point_type>::type cs_tag;
|
||||
|
||||
boost::ignore_unused_variable_warning(i2);
|
||||
boost::ignore_unused_variable_warning(j2);
|
||||
boost::ignore_unused_variable_warning(ip_index);
|
||||
@ -425,7 +427,7 @@ struct get_turn_info_for_endpoint
|
||||
}
|
||||
else if ( ip_j2 )
|
||||
{
|
||||
side_calculator<RobustPoint1, RobustPoint2, RobustPoint2>
|
||||
side_calculator<cs_tag, RobustPoint1, RobustPoint2, RobustPoint2>
|
||||
side_calc(ri2, ri1, rj1, ri2, rj2, rk2);
|
||||
|
||||
std::pair<operation_type, operation_type>
|
||||
@ -476,7 +478,7 @@ struct get_turn_info_for_endpoint
|
||||
}
|
||||
else if ( ip_j2 )
|
||||
{
|
||||
side_calculator<RobustPoint1, RobustPoint2, RobustPoint2>
|
||||
side_calculator<cs_tag, RobustPoint1, RobustPoint2, RobustPoint2>
|
||||
side_calc(ri2, rj1, ri1, ri2, rj2, rk2);
|
||||
|
||||
std::pair<operation_type, operation_type>
|
||||
|
@ -36,14 +36,19 @@ struct turn_operation_linear
|
||||
bool is_collinear; // valid only for Linear geometry
|
||||
};
|
||||
|
||||
template <typename PointP, typename PointQ,
|
||||
template <typename TurnPointCSTag, typename PointP, typename PointQ,
|
||||
typename Pi = PointP, typename Pj = PointP, typename Pk = PointP,
|
||||
typename Qi = PointQ, typename Qj = PointQ, typename Qk = PointQ
|
||||
>
|
||||
struct side_calculator
|
||||
{
|
||||
// todo: get from coordinate system
|
||||
typedef boost::geometry::strategy::side::side_by_triangle<> side;
|
||||
// This strategy should be the same as side strategy defined in
|
||||
// intersection_strategies<> which is used in various places
|
||||
// of the library
|
||||
typedef typename strategy::side::services::default_strategy
|
||||
<
|
||||
TurnPointCSTag
|
||||
>::type side;
|
||||
|
||||
inline side_calculator(Pi const& pi, Pj const& pj, Pk const& pk,
|
||||
Qi const& qi, Qj const& qj, Qk const& qk)
|
||||
@ -94,7 +99,7 @@ struct robust_points
|
||||
robust_point2_type m_rqi, m_rqj, m_rqk;
|
||||
};
|
||||
|
||||
template <typename Point1, typename Point2, typename RobustPolicy>
|
||||
template <typename Point1, typename Point2, typename TurnPoint, typename RobustPolicy>
|
||||
class intersection_info_base
|
||||
: private robust_points<Point1, Point2, RobustPolicy>
|
||||
{
|
||||
@ -107,7 +112,9 @@ public:
|
||||
typedef typename base::robust_point1_type robust_point1_type;
|
||||
typedef typename base::robust_point2_type robust_point2_type;
|
||||
|
||||
typedef side_calculator<robust_point1_type, robust_point2_type> side_calculator_type;
|
||||
typedef typename cs_tag<TurnPoint>::type cs_tag;
|
||||
|
||||
typedef side_calculator<cs_tag, robust_point1_type, robust_point2_type> side_calculator_type;
|
||||
|
||||
intersection_info_base(Point1 const& pi, Point1 const& pj, Point1 const& pk,
|
||||
Point2 const& qi, Point2 const& qj, Point2 const& qk,
|
||||
@ -148,8 +155,8 @@ private:
|
||||
point2_type const& m_qk;
|
||||
};
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
class intersection_info_base<Point1, Point2, detail::no_rescale_policy>
|
||||
template <typename Point1, typename Point2, typename TurnPoint>
|
||||
class intersection_info_base<Point1, Point2, TurnPoint, detail::no_rescale_policy>
|
||||
{
|
||||
public:
|
||||
typedef Point1 point1_type;
|
||||
@ -158,7 +165,9 @@ public:
|
||||
typedef Point1 robust_point1_type;
|
||||
typedef Point2 robust_point2_type;
|
||||
|
||||
typedef side_calculator<Point1, Point2> side_calculator_type;
|
||||
typedef typename cs_tag<TurnPoint>::type cs_tag;
|
||||
|
||||
typedef side_calculator<cs_tag, Point1, Point2> side_calculator_type;
|
||||
|
||||
intersection_info_base(Point1 const& pi, Point1 const& pj, Point1 const& pk,
|
||||
Point2 const& qi, Point2 const& qj, Point2 const& qk,
|
||||
@ -197,13 +206,13 @@ template
|
||||
typename RobustPolicy
|
||||
>
|
||||
class intersection_info
|
||||
: public intersection_info_base<Point1, Point2, RobustPolicy>
|
||||
: public intersection_info_base<Point1, Point2, TurnPoint, RobustPolicy>
|
||||
{
|
||||
typedef intersection_info_base<Point1, Point2, RobustPolicy> base;
|
||||
typedef intersection_info_base<Point1, Point2, TurnPoint, RobustPolicy> base;
|
||||
|
||||
typedef typename strategy_intersection
|
||||
typedef typename intersection_strategies
|
||||
<
|
||||
typename cs_tag<TurnPoint>::type,
|
||||
typename base::cs_tag,
|
||||
Point1,
|
||||
Point2,
|
||||
TurnPoint,
|
||||
@ -298,9 +307,9 @@ private:
|
||||
{
|
||||
typedef model::referring_segment<Point const> seg;
|
||||
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<Point>::type, Point, Point, Point, RobustPolicy
|
||||
typename base::cs_tag, Point, Point, Point, RobustPolicy
|
||||
> si;
|
||||
|
||||
typedef typename si::segment_intersection_strategy_type strategy;
|
||||
|
@ -106,6 +106,7 @@ struct get_turn_info_linear_areal
|
||||
// Swap p/q
|
||||
side_calculator
|
||||
<
|
||||
typename inters_info::cs_tag,
|
||||
typename inters_info::robust_point2_type,
|
||||
typename inters_info::robust_point1_type
|
||||
> swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(),
|
||||
@ -752,6 +753,7 @@ struct get_turn_info_linear_areal
|
||||
{
|
||||
side_calculator
|
||||
<
|
||||
typename IntersectionInfo::cs_tag,
|
||||
typename IntersectionInfo::robust_point1_type,
|
||||
typename IntersectionInfo::robust_point2_type,
|
||||
typename IntersectionInfo::robust_point2_type
|
||||
@ -770,6 +772,7 @@ struct get_turn_info_linear_areal
|
||||
{
|
||||
side_calculator
|
||||
<
|
||||
typename IntersectionInfo::cs_tag,
|
||||
typename IntersectionInfo::robust_point1_type,
|
||||
typename IntersectionInfo::robust_point2_type,
|
||||
typename IntersectionInfo::robust_point2_type,
|
||||
@ -826,6 +829,7 @@ struct get_turn_info_linear_areal
|
||||
{
|
||||
side_calculator
|
||||
<
|
||||
typename IntersectionInfo::cs_tag,
|
||||
typename IntersectionInfo::robust_point1_type,
|
||||
typename IntersectionInfo::robust_point2_type,
|
||||
typename IntersectionInfo::robust_point2_type
|
||||
|
@ -101,6 +101,7 @@ struct get_turn_info_linear_linear
|
||||
// Swap p/q
|
||||
side_calculator
|
||||
<
|
||||
typename inters_info::cs_tag,
|
||||
typename inters_info::robust_point2_type,
|
||||
typename inters_info::robust_point1_type
|
||||
> swapped_side_calc(inters.rqi(), inters.rqj(), inters.rqk(),
|
||||
|
@ -3,8 +3,8 @@
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2016.
|
||||
// Modifications copyright (c) 2014, 2016 Oracle and/or its affiliates.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -46,7 +46,7 @@
|
||||
#include <boost/geometry/iterators/ever_circling_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/cart_intersect.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_strategies.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/disjoint/box_box.hpp>
|
||||
|
@ -213,7 +213,7 @@ inline void handle_colocation_cluster(Turns& turns,
|
||||
signed_size_type& cluster_id,
|
||||
ClusterPerSegment& cluster_per_segment,
|
||||
Operations const& operations,
|
||||
Geometry1 const& geometry1, Geometry2 const& geometry2)
|
||||
Geometry1 const& /*geometry1*/, Geometry2 const& /*geometry2*/)
|
||||
{
|
||||
typedef typename boost::range_value<Turns>::type turn_type;
|
||||
typedef typename turn_type::turn_operation_type turn_operation_type;
|
||||
|
@ -1042,7 +1042,7 @@ inline OutputIterator intersection_insert(Geometry1 const& geometry1,
|
||||
typename geometry::point_type<Geometry1>::type // TODO from both
|
||||
>::type rescale_policy_type;
|
||||
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<GeometryOut>::type,
|
||||
Geometry1,
|
||||
|
@ -1149,6 +1149,8 @@ struct linear_areal
|
||||
Geometry2 const& geometry2,
|
||||
Turn const& turn)
|
||||
{
|
||||
typedef typename cs_tag<typename Turn::point_type>::type cs_tag;
|
||||
|
||||
if ( turn.operations[op_id].position == overlay::position_front )
|
||||
return false;
|
||||
|
||||
@ -1192,7 +1194,7 @@ struct linear_areal
|
||||
boost::end(range2));
|
||||
|
||||
// Will this sequence of points be always correct?
|
||||
overlay::side_calculator<point1_type, point2_type> side_calc(qi_conv, new_pj, pi, qi, qj, *qk_it);
|
||||
overlay::side_calculator<cs_tag, point1_type, point2_type> side_calc(qi_conv, new_pj, pi, qi, qj, *qk_it);
|
||||
|
||||
return calculate_from_inside_sides(side_calc);
|
||||
}
|
||||
@ -1201,7 +1203,7 @@ struct linear_areal
|
||||
point1_type new_qj;
|
||||
geometry::convert(turn.point, new_qj);
|
||||
|
||||
overlay::side_calculator<point1_type, point2_type> side_calc(qi_conv, new_pj, pi, qi, new_qj, qj);
|
||||
overlay::side_calculator<cs_tag, point1_type, point2_type> side_calc(qi_conv, new_pj, pi, qi, new_qj, qj);
|
||||
|
||||
return calculate_from_inside_sides(side_calc);
|
||||
}
|
||||
@ -1414,10 +1416,14 @@ struct linear_areal
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
struct areal_linear
|
||||
{
|
||||
typedef linear_areal<Geometry2, Geometry1, true> linear_areal_type;
|
||||
|
||||
static const bool interruption_enabled = linear_areal_type::interruption_enabled;
|
||||
|
||||
template <typename Result>
|
||||
static inline void apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Result & result)
|
||||
{
|
||||
linear_areal<Geometry2, Geometry1, true>::apply(geometry2, geometry1, result);
|
||||
linear_areal_type::apply(geometry2, geometry1, result);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/algorithms/envelope.hpp>
|
||||
#include <boost/geometry/algorithms/expand.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
|
||||
@ -268,6 +269,49 @@ struct assign_loop<T, Count, Count>
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CSTag>
|
||||
struct box_first_in_section
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box & box, Point const& prev, Point const& curr)
|
||||
{
|
||||
geometry::model::referring_segment<Point const> seg(prev, curr);
|
||||
geometry::envelope(seg, box);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct box_first_in_section<cartesian_tag>
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box & box, Point const& prev, Point const& curr)
|
||||
{
|
||||
geometry::envelope(prev, box);
|
||||
geometry::expand(box, curr);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename CSTag>
|
||||
struct box_next_in_section
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box & box, Point const& prev, Point const& curr)
|
||||
{
|
||||
geometry::model::referring_segment<Point const> seg(prev, curr);
|
||||
geometry::expand(box, seg);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct box_next_in_section<cartesian_tag>
|
||||
{
|
||||
template <typename Box, typename Point>
|
||||
static inline void apply(Box & box, Point const& , Point const& curr)
|
||||
{
|
||||
geometry::expand(box, curr);
|
||||
}
|
||||
};
|
||||
|
||||
/// @brief Helper class to create sections of a part of a range, on the fly
|
||||
template
|
||||
<
|
||||
@ -402,10 +446,19 @@ struct sectionalize_part
|
||||
int, 0, dimension_count
|
||||
>::apply(direction_classes, section.directions);
|
||||
|
||||
geometry::expand(section.bounding_box, previous_robust_point);
|
||||
// In cartesian this is envelope of previous point expanded with current point
|
||||
// in non-cartesian this is envelope of a segment
|
||||
box_first_in_section<typename cs_tag<robust_point_type>::type>
|
||||
::apply(section.bounding_box, previous_robust_point, current_robust_point);
|
||||
}
|
||||
else
|
||||
{
|
||||
// In cartesian this is expand with current point
|
||||
// in non-cartesian this is expand with a segment
|
||||
box_next_in_section<typename cs_tag<robust_point_type>::type>
|
||||
::apply(section.bounding_box, previous_robust_point, current_robust_point);
|
||||
}
|
||||
|
||||
geometry::expand(section.bounding_box, current_robust_point);
|
||||
section.end_index = index + 1;
|
||||
section.count++;
|
||||
if (! duplicate)
|
||||
|
@ -101,7 +101,7 @@ inline OutputIterator difference_insert(Geometry1 const& geometry1,
|
||||
concept::check<Geometry2 const>();
|
||||
concept::check<GeometryOut>();
|
||||
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<GeometryOut>::type,
|
||||
Geometry1,
|
||||
|
@ -5,8 +5,8 @@
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2015.
|
||||
// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2015, 2016.
|
||||
// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
@ -161,8 +161,13 @@ struct equals_by_collection
|
||||
double
|
||||
>::type calculation_type;
|
||||
|
||||
typedef std::vector<collected_vector<calculation_type> > v;
|
||||
v c1, c2;
|
||||
typedef geometry::collected_vector
|
||||
<
|
||||
calculation_type,
|
||||
Geometry1
|
||||
> collected_vector;
|
||||
|
||||
std::vector<collected_vector> c1, c2;
|
||||
|
||||
geometry::collect_vectors(c1, geometry1);
|
||||
geometry::collect_vectors(c2, geometry2);
|
||||
@ -323,6 +328,17 @@ struct equals
|
||||
: detail::equals::equals_by_collection<detail::equals::area_check>
|
||||
{};
|
||||
|
||||
template <typename MultiPolygon, typename Ring, bool Reverse>
|
||||
struct equals
|
||||
<
|
||||
MultiPolygon, Ring,
|
||||
multi_polygon_tag, ring_tag,
|
||||
2,
|
||||
Reverse
|
||||
>
|
||||
: detail::equals::equals_by_collection<detail::equals::area_check>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
@ -276,7 +276,7 @@ inline OutputIterator sym_difference_insert(Geometry1 const& geometry1,
|
||||
concept::check<Geometry2 const>();
|
||||
concept::check<GeometryOut>();
|
||||
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<GeometryOut>::type,
|
||||
Geometry1,
|
||||
|
@ -373,7 +373,7 @@ struct touches<Linear, Areal, Tag1, Tag2, linear_tag, areal_tag, false>
|
||||
|
||||
// A/L
|
||||
template <typename Linear, typename Areal, typename Tag1, typename Tag2>
|
||||
struct touches<Linear, Areal, Tag1, Tag2, linear_tag, areal_tag, true>
|
||||
struct touches<Areal, Linear, Tag1, Tag2, areal_tag, linear_tag, false>
|
||||
: detail::relate::relate_impl
|
||||
<
|
||||
detail::de9im::static_mask_touches_type,
|
||||
|
@ -214,7 +214,7 @@ inline OutputIterator union_insert(Geometry1 const& geometry1,
|
||||
Geometry2
|
||||
>::type rescale_policy_type;
|
||||
|
||||
typedef strategy_intersection
|
||||
typedef intersection_strategies
|
||||
<
|
||||
typename cs_tag<GeometryOut>::type,
|
||||
Geometry1,
|
||||
|
128
include/boost/geometry/arithmetic/cross_product.hpp
Normal file
128
include/boost/geometry/arithmetic/cross_product.hpp
Normal file
@ -0,0 +1,128 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_ARITHMETIC_CROSS_PRODUCT_HPP
|
||||
#define BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/mpl/size_t.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <std::size_t Dimension>
|
||||
struct cross_product
|
||||
{
|
||||
// We define cross product only for 2d (see Wolfram) and 3d.
|
||||
// In Math, it is also well-defined for 7-dimension.
|
||||
// Generalisation of cross product to n-dimension is defined as
|
||||
// wedge product but it is not direct analogue to binary cross product.
|
||||
BOOST_MPL_ASSERT_MSG((false),
|
||||
NOT_IMPLEMENTED_FOR_THIS_DIMENSION,
|
||||
(mpl::size_t<Dimension>));
|
||||
};
|
||||
|
||||
template <>
|
||||
struct cross_product<2>
|
||||
{
|
||||
template <typename P1, typename P2, typename ResultP>
|
||||
static inline void apply(P1 const& p1, P2 const& p2, ResultP& result)
|
||||
{
|
||||
assert_dimension<P1, 2>();
|
||||
assert_dimension<P2, 2>();
|
||||
assert_dimension<ResultP, 2>();
|
||||
|
||||
// For 2-dimensions, analog of the cross product U(x,y) and V(x,y) is
|
||||
// Ux * Vy - Uy * Vx
|
||||
// which is returned as 0-component (or X) of 2d vector, 1-component is undefined.
|
||||
set<0>(result, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct cross_product<3>
|
||||
{
|
||||
template <typename P1, typename P2, typename ResultP>
|
||||
static inline void apply(P1 const& p1, P2 const& p2, ResultP& result)
|
||||
{
|
||||
assert_dimension<P1, 3>();
|
||||
assert_dimension<P2, 3>();
|
||||
assert_dimension<ResultP, 3>();
|
||||
|
||||
set<0>(result, get<1>(p1) * get<2>(p2) - get<2>(p1) * get<1>(p2));
|
||||
set<1>(result, get<2>(p1) * get<0>(p2) - get<0>(p1) * get<2>(p2));
|
||||
set<2>(result, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
/*!
|
||||
\brief Computes the cross product of two vectors.
|
||||
\details All vectors should have the same dimension, 3 or 2.
|
||||
\ingroup arithmetic
|
||||
\param p1 first vector
|
||||
\param p2 second vector
|
||||
\return the cross product vector
|
||||
*/
|
||||
template <typename ResultP, typename P1, typename P2>
|
||||
inline ResultP cross_product(P1 const& p1, P2 const& p2)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concept::Point<ResultP>) );
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P1>) );
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P2>) );
|
||||
|
||||
ResultP result;
|
||||
detail::cross_product<dimension<ResultP>::value>::apply(p1, p2, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Computes the cross product of two vectors.
|
||||
\details All vectors should have the same dimension, 3 or 2.
|
||||
\ingroup arithmetic
|
||||
\param p1 first vector
|
||||
\param p2 second vector
|
||||
\return the cross product vector
|
||||
*/
|
||||
template <typename P>
|
||||
inline P cross_product(P const& p1, P const& p2)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT((concept::Point<P>));
|
||||
BOOST_CONCEPT_ASSERT((concept::ConstPoint<P>));
|
||||
|
||||
P result;
|
||||
detail::cross_product<dimension<P>::value>::apply(p1, p2, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ARITHMETIC_CROSS_PRODUCT_HPP
|
@ -278,7 +278,7 @@ class range_split_rings
|
||||
typedef typename geometry::ring_type<Range>::type ring_type;
|
||||
|
||||
|
||||
typedef typename strategy_intersection
|
||||
typedef typename intersection_strategies
|
||||
<
|
||||
typename cs_tag<point_type>::type,
|
||||
point_type,
|
||||
|
@ -1,110 +0,0 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
|
||||
// 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_EXTENSIONS_ARITHMETIC_CROSS_PRODUCT_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_ARITHMETIC_CROSS_PRODUCT_HPP
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
#include <boost/geometry/util/select_coordinate_type.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename P1, typename P2, std::size_t Dimension>
|
||||
struct cross_product
|
||||
{
|
||||
// We define cross product only for 2d (see Wolfram) and 3d.
|
||||
// In Math, it is also well-defined for 7-dimension.
|
||||
// Generalisation of cross product to n-dimension is defined as
|
||||
// wedge product but it is not direct analogue to binary cross product.
|
||||
};
|
||||
|
||||
template <typename P1, typename P2>
|
||||
struct cross_product<P1, P2, 2>
|
||||
{
|
||||
typedef P1 return_type;
|
||||
|
||||
static inline return_type apply(P1 const& p1, P2 const& p2)
|
||||
{
|
||||
assert_dimension<P1, 2>();
|
||||
assert_dimension<P2, 2>();
|
||||
|
||||
// For 2-dimensions, analog of the cross product U(x,y) and V(x,y) is
|
||||
// Ux * Vy - Uy * Vx
|
||||
// which is returned as 0-component (or X) of 2d vector, 1-component is undefined.
|
||||
return_type v;
|
||||
set<0>(v, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename P1, typename P2>
|
||||
struct cross_product<P1, P2, 3>
|
||||
{
|
||||
typedef P1 return_type;
|
||||
|
||||
static inline return_type apply(P1 const& p1, P2 const& p2)
|
||||
{
|
||||
assert_dimension<P1, 3>();
|
||||
assert_dimension<P2, 3>();
|
||||
|
||||
return_type v;
|
||||
set<0>(v, get<1>(p1) * get<2>(p2) - get<2>(p1) * get<1>(p2));
|
||||
set<1>(v, get<2>(p1) * get<0>(p2) - get<0>(p1) * get<2>(p2));
|
||||
set<2>(v, get<0>(p1) * get<1>(p2) - get<1>(p1) * get<0>(p2));
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
// TODO: This is a simple draft. If relevant, it can be extended to:
|
||||
// - accept vectors of different coordinate_type, but common coordinate_system
|
||||
// - if vectors are of mixed 2d and 3d, lower dimension is used
|
||||
// - define result_type that will generate type of vector based on:
|
||||
// -- select_coordinate_type
|
||||
// -- selection of lower dimension
|
||||
|
||||
/*!
|
||||
\brief Computes the cross product of two vectors.
|
||||
\details Both vectors shall be of the same type.
|
||||
This type also determines type of result vector.
|
||||
\ingroup arithmetic
|
||||
\param p1 first vector
|
||||
\param p2 second vector
|
||||
\return the cross product vector
|
||||
*/
|
||||
template <typename P1, typename P2>
|
||||
inline P1 cross_product(P1 const& p1, P2 const& p2)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P1>) );
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P2>) );
|
||||
|
||||
return detail::cross_product
|
||||
<
|
||||
P1, P2,
|
||||
dimension<P1>::type::value
|
||||
>::apply(p1, p2);
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_ARITHMETIC_CROSS_PRODUCT_HPP
|
96
include/boost/geometry/formulas/spherical.hpp
Normal file
96
include/boost/geometry/formulas/spherical.hpp
Normal file
@ -0,0 +1,96 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_FORMULAS_SPHERICAL_HPP
|
||||
#define BOOST_GEOMETRY_FORMULAS_SPHERICAL_HPP
|
||||
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
|
||||
//#include <boost/geometry/arithmetic/arithmetic.hpp>
|
||||
#include <boost/geometry/arithmetic/cross_product.hpp>
|
||||
#include <boost/geometry/arithmetic/dot_product.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
|
||||
#include <boost/geometry/util/select_coordinate_type.hpp>
|
||||
|
||||
namespace boost { namespace geometry {
|
||||
|
||||
namespace formula {
|
||||
|
||||
template <typename Point3d, typename PointSph>
|
||||
static inline Point3d sph_to_cart3d(PointSph const& point_sph)
|
||||
{
|
||||
typedef typename coordinate_type<Point3d>::type calc_t;
|
||||
|
||||
Point3d res;
|
||||
|
||||
calc_t lon = get_as_radian<0>(point_sph);
|
||||
calc_t lat = get_as_radian<1>(point_sph);
|
||||
|
||||
calc_t const cos_lat = cos(lat);
|
||||
set<0>(res, cos_lat * cos(lon));
|
||||
set<1>(res, cos_lat * sin(lon));
|
||||
set<2>(res, sin(lat));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename PointSph, typename Point3d>
|
||||
static inline PointSph cart3d_to_sph(Point3d const& point_3d)
|
||||
{
|
||||
typedef typename coordinate_type<PointSph>::type coord_t;
|
||||
typedef typename coordinate_type<Point3d>::type calc_t;
|
||||
|
||||
PointSph res;
|
||||
|
||||
calc_t const x = get<0>(point_3d);
|
||||
calc_t const y = get<1>(point_3d);
|
||||
calc_t const z = get<2>(point_3d);
|
||||
|
||||
set_from_radian<0>(res, atan2(y, x));
|
||||
set_from_radian<1>(res, asin(z));
|
||||
|
||||
coord_t lon = get<0>(res);
|
||||
coord_t lat = get<1>(res);
|
||||
|
||||
math::normalize_spheroidal_coordinates
|
||||
<
|
||||
typename coordinate_system<PointSph>::type::units,
|
||||
coord_t
|
||||
>(lon, lat);
|
||||
|
||||
set<0>(res, lon);
|
||||
set<1>(res, lat);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// -1 right
|
||||
// 1 left
|
||||
// 0 on
|
||||
template <typename Point3d1, typename Point3d2>
|
||||
static inline int sph_side_value(Point3d1 const& norm, Point3d2 const& pt)
|
||||
{
|
||||
typedef typename select_coordinate_type<Point3d1, Point3d2>::type calc_t;
|
||||
calc_t c0 = 0;
|
||||
calc_t d = dot_product(norm, pt);
|
||||
return math::equals(d, c0) ? 0
|
||||
: d > c0 ? 1
|
||||
: -1; // d < 0
|
||||
}
|
||||
|
||||
} // namespace formula
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_FORMULAS_SPHERICAL_HPP
|
@ -4,8 +4,8 @@
|
||||
// Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2015.
|
||||
// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2015, 2016.
|
||||
// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
@ -110,7 +110,7 @@
|
||||
#include <boost/geometry/io/io.hpp>
|
||||
#include <boost/geometry/io/dsv/write.hpp>
|
||||
#include <boost/geometry/io/svg/svg_mapper.hpp>
|
||||
#include <boost/geometry/io/svg/write_svg.hpp>
|
||||
#include <boost/geometry/io/svg/write.hpp>
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
#include <boost/geometry/io/wkt/write.hpp>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// boxes union/intersection area/volume
|
||||
//
|
||||
// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2011-2016 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
|
||||
@ -12,7 +12,7 @@
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP
|
||||
|
||||
#include <boost/geometry/algorithms/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_strategies.hpp>
|
||||
#include <boost/geometry/index/detail/algorithms/content.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace index { namespace detail {
|
||||
|
@ -298,7 +298,7 @@ struct predicate_check<predicates::satisfies<Fun, Negated>, bounds_tag>
|
||||
// NOT NEGATED
|
||||
// value_tag bounds_tag
|
||||
// ---------------------------
|
||||
// contains(I,G) contains(I,G)
|
||||
// contains(I,G) covers(I,G)
|
||||
// covered_by(I,G) intersects(I,G)
|
||||
// covers(I,G) covers(I,G)
|
||||
// disjoint(I,G) !covered_by(I,G)
|
||||
@ -329,7 +329,7 @@ struct predicate_check<predicates::spatial_predicate<Geometry, predicates::conta
|
||||
template <typename Value, typename Indexable>
|
||||
static inline bool apply(Pred const& p, Value const&, Indexable const& i)
|
||||
{
|
||||
return spatial_predicate_call<predicates::contains_tag>::apply(i, p.geometry);
|
||||
return spatial_predicate_call<predicates::covers_tag>::apply(i, p.geometry);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <boost/geometry/strategies/transform/map_transformer.hpp>
|
||||
#include <boost/geometry/views/segment_view.hpp>
|
||||
|
||||
#include <boost/geometry/io/svg/write_svg.hpp>
|
||||
#include <boost/geometry/io/svg/write.hpp>
|
||||
|
||||
// Helper geometries (all points are transformed to integer-points)
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
@ -191,6 +191,68 @@ struct svg_map<multi_tag, Multi>
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
struct devarianted_svg_map
|
||||
{
|
||||
template <typename TransformStrategy>
|
||||
static inline void apply(std::ostream& stream,
|
||||
std::string const& style,
|
||||
int size,
|
||||
Geometry const& geometry,
|
||||
TransformStrategy const& strategy)
|
||||
{
|
||||
svg_map
|
||||
<
|
||||
typename tag_cast
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
multi_tag
|
||||
>::type,
|
||||
typename boost::remove_const<Geometry>::type
|
||||
>::apply(stream, style, size, geometry, strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
||||
struct devarianted_svg_map<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
{
|
||||
template <typename TransformStrategy>
|
||||
struct visitor: static_visitor<void>
|
||||
{
|
||||
std::ostream& m_os;
|
||||
std::string const& m_style;
|
||||
int m_size;
|
||||
TransformStrategy const& m_strategy;
|
||||
|
||||
visitor(std::ostream& os,
|
||||
std::string const& style,
|
||||
int size,
|
||||
TransformStrategy const& strategy)
|
||||
: m_os(os)
|
||||
, m_style(style)
|
||||
, m_size(size)
|
||||
, m_strategy(strategy)
|
||||
{}
|
||||
|
||||
template <typename Geometry>
|
||||
inline void operator()(Geometry const& geometry) const
|
||||
{
|
||||
devarianted_svg_map<Geometry>::apply(m_os, m_style, m_size, geometry, m_strategy);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TransformStrategy>
|
||||
static inline void apply(std::ostream& stream,
|
||||
std::string const& style,
|
||||
int size,
|
||||
variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
|
||||
TransformStrategy const& strategy)
|
||||
{
|
||||
boost::apply_visitor(visitor<TransformStrategy>(stream, style, size, strategy), geometry);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif
|
||||
|
||||
@ -200,15 +262,8 @@ inline void svg_map(std::ostream& stream,
|
||||
std::string const& style, int size,
|
||||
Geometry const& geometry, TransformStrategy const& strategy)
|
||||
{
|
||||
dispatch::svg_map
|
||||
<
|
||||
typename tag_cast
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
multi_tag
|
||||
>::type,
|
||||
typename boost::remove_const<Geometry>::type
|
||||
>::apply(stream, style, size, geometry, strategy);
|
||||
dispatch::devarianted_svg_map<Geometry>::apply(stream, style, size,
|
||||
geometry, strategy);
|
||||
}
|
||||
|
||||
|
||||
|
417
include/boost/geometry/io/svg/write.hpp
Normal file
417
include/boost/geometry/io/svg/write.hpp
Normal file
@ -0,0 +1,417 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2009-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, 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_IO_SVG_WRITE_HPP
|
||||
#define BOOST_GEOMETRY_IO_SVG_WRITE_HPP
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/variant/apply_visitor.hpp>
|
||||
#include <boost/variant/static_visitor.hpp>
|
||||
#include <boost/variant/variant_fwd.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/core/exterior_ring.hpp>
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace svg
|
||||
{
|
||||
|
||||
|
||||
template <typename Point>
|
||||
struct svg_point
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Point const& p, std::string const& style, int size)
|
||||
{
|
||||
os << "<circle cx=\"" << geometry::get<0>(p)
|
||||
<< "\" cy=\"" << geometry::get<1>(p)
|
||||
<< "\" r=\"" << (size < 0 ? 5 : size)
|
||||
<< "\" style=\"" << style << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Box>
|
||||
struct svg_box
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Box const& box, std::string const& style, int )
|
||||
{
|
||||
// Prevent invisible boxes, making them >=1, using "max"
|
||||
BOOST_USING_STD_MAX();
|
||||
|
||||
typedef typename coordinate_type<Box>::type ct;
|
||||
ct x = geometry::get<geometry::min_corner, 0>(box);
|
||||
ct y = geometry::get<geometry::min_corner, 1>(box);
|
||||
ct width = max BOOST_PREVENT_MACRO_SUBSTITUTION (ct(1),
|
||||
geometry::get<geometry::max_corner, 0>(box) - x);
|
||||
ct height = max BOOST_PREVENT_MACRO_SUBSTITUTION (ct(1),
|
||||
geometry::get<geometry::max_corner, 1>(box) - y);
|
||||
|
||||
os << "<rect x=\"" << x << "\" y=\"" << y
|
||||
<< "\" width=\"" << width << "\" height=\"" << height
|
||||
<< "\" style=\"" << style << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Segment>
|
||||
struct svg_segment
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Segment const& segment, std::string const& style, int)
|
||||
{
|
||||
typedef typename coordinate_type<Segment>::type ct;
|
||||
ct x1 = geometry::get<0, 0>(segment);
|
||||
ct y1 = geometry::get<0, 1>(segment);
|
||||
ct x2 = geometry::get<1, 0>(segment);
|
||||
ct y2 = geometry::get<1, 1>(segment);
|
||||
|
||||
os << "<line x1=\"" << x1 << "\" y1=\"" << y1
|
||||
<< "\" x2=\"" << x2 << "\" y2=\"" << y2
|
||||
<< "\" style=\"" << style << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Stream ranges as SVG
|
||||
\note policy is used to select type (polyline/polygon)
|
||||
*/
|
||||
template <typename Range, typename Policy>
|
||||
struct svg_range
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Range const& range, std::string const& style, int )
|
||||
{
|
||||
typedef typename boost::range_iterator<Range const>::type iterator;
|
||||
|
||||
bool first = true;
|
||||
|
||||
os << "<" << Policy::prefix() << " points=\"";
|
||||
|
||||
for (iterator it = boost::begin(range);
|
||||
it != boost::end(range);
|
||||
++it, first = false)
|
||||
{
|
||||
os << (first ? "" : " " )
|
||||
<< geometry::get<0>(*it)
|
||||
<< ","
|
||||
<< geometry::get<1>(*it);
|
||||
}
|
||||
os << "\" style=\"" << style << Policy::style() << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename Polygon>
|
||||
struct svg_poly
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Polygon const& polygon, std::string const& style, int )
|
||||
{
|
||||
typedef typename geometry::ring_type<Polygon>::type ring_type;
|
||||
typedef typename boost::range_iterator<ring_type const>::type iterator_type;
|
||||
|
||||
bool first = true;
|
||||
os << "<g fill-rule=\"evenodd\"><path d=\"";
|
||||
|
||||
ring_type const& ring = geometry::exterior_ring(polygon);
|
||||
for (iterator_type it = boost::begin(ring);
|
||||
it != boost::end(ring);
|
||||
++it, first = false)
|
||||
{
|
||||
os << (first ? "M" : " L") << " "
|
||||
<< geometry::get<0>(*it)
|
||||
<< ","
|
||||
<< geometry::get<1>(*it);
|
||||
}
|
||||
|
||||
// Inner rings:
|
||||
{
|
||||
typename interior_return_type<Polygon const>::type
|
||||
rings = interior_rings(polygon);
|
||||
for (typename detail::interior_iterator<Polygon const>::type
|
||||
rit = boost::begin(rings); rit != boost::end(rings); ++rit)
|
||||
{
|
||||
first = true;
|
||||
for (typename detail::interior_ring_iterator<Polygon const>::type
|
||||
it = boost::begin(*rit); it != boost::end(*rit);
|
||||
++it, first = false)
|
||||
{
|
||||
os << (first ? "M" : " L") << " "
|
||||
<< geometry::get<0>(*it)
|
||||
<< ","
|
||||
<< geometry::get<1>(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
os << " z \" style=\"" << style << "\"/></g>";
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct prefix_linestring
|
||||
{
|
||||
static inline const char* prefix() { return "polyline"; }
|
||||
static inline const char* style() { return ";fill:none"; }
|
||||
};
|
||||
|
||||
|
||||
struct prefix_ring
|
||||
{
|
||||
static inline const char* prefix() { return "polygon"; }
|
||||
static inline const char* style() { return ""; }
|
||||
};
|
||||
|
||||
|
||||
template <typename MultiGeometry, typename Policy>
|
||||
struct svg_multi
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
MultiGeometry const& multi, std::string const& style, int size)
|
||||
{
|
||||
for (typename boost::range_iterator<MultiGeometry const>::type
|
||||
it = boost::begin(multi);
|
||||
it != boost::end(multi);
|
||||
++it)
|
||||
{
|
||||
Policy::apply(os, *it, style, size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}} // namespace detail::svg
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Dispatching base struct for SVG streaming, specialized below per geometry type
|
||||
\details Specializations should implement a static method "stream" to stream a geometry
|
||||
The static method should have the signature:
|
||||
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os, G const& geometry)
|
||||
*/
|
||||
template <typename Geometry, typename Tag = typename tag<Geometry>::type>
|
||||
struct svg
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG
|
||||
(
|
||||
false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
|
||||
, (Geometry)
|
||||
);
|
||||
};
|
||||
|
||||
template <typename Point>
|
||||
struct svg<Point, point_tag> : detail::svg::svg_point<Point> {};
|
||||
|
||||
template <typename Segment>
|
||||
struct svg<Segment, segment_tag> : detail::svg::svg_segment<Segment> {};
|
||||
|
||||
template <typename Box>
|
||||
struct svg<Box, box_tag> : detail::svg::svg_box<Box> {};
|
||||
|
||||
template <typename Linestring>
|
||||
struct svg<Linestring, linestring_tag>
|
||||
: detail::svg::svg_range<Linestring, detail::svg::prefix_linestring> {};
|
||||
|
||||
template <typename Ring>
|
||||
struct svg<Ring, ring_tag>
|
||||
: detail::svg::svg_range<Ring, detail::svg::prefix_ring> {};
|
||||
|
||||
template <typename Polygon>
|
||||
struct svg<Polygon, polygon_tag>
|
||||
: detail::svg::svg_poly<Polygon> {};
|
||||
|
||||
template <typename MultiPoint>
|
||||
struct svg<MultiPoint, multi_point_tag>
|
||||
: detail::svg::svg_multi
|
||||
<
|
||||
MultiPoint,
|
||||
detail::svg::svg_point
|
||||
<
|
||||
typename boost::range_value<MultiPoint>::type
|
||||
>
|
||||
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename MultiLinestring>
|
||||
struct svg<MultiLinestring, multi_linestring_tag>
|
||||
: detail::svg::svg_multi
|
||||
<
|
||||
MultiLinestring,
|
||||
detail::svg::svg_range
|
||||
<
|
||||
typename boost::range_value<MultiLinestring>::type,
|
||||
detail::svg::prefix_linestring
|
||||
>
|
||||
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename MultiPolygon>
|
||||
struct svg<MultiPolygon, multi_polygon_tag>
|
||||
: detail::svg::svg_multi
|
||||
<
|
||||
MultiPolygon,
|
||||
detail::svg::svg_poly
|
||||
<
|
||||
typename boost::range_value<MultiPolygon>::type
|
||||
>
|
||||
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
struct devarianted_svg
|
||||
{
|
||||
template <typename OutputStream>
|
||||
static inline void apply(OutputStream& os,
|
||||
Geometry const& geometry,
|
||||
std::string const& style,
|
||||
int size)
|
||||
{
|
||||
svg<Geometry>::apply(os, geometry, style, size);
|
||||
}
|
||||
};
|
||||
|
||||
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
|
||||
struct devarianted_svg<variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
|
||||
{
|
||||
template <typename OutputStream>
|
||||
struct visitor: static_visitor<void>
|
||||
{
|
||||
OutputStream& m_os;
|
||||
std::string const& m_style;
|
||||
int m_size;
|
||||
|
||||
visitor(OutputStream& os, std::string const& style, int size)
|
||||
: m_os(os)
|
||||
, m_style(style)
|
||||
, m_size(size)
|
||||
{}
|
||||
|
||||
template <typename Geometry>
|
||||
inline void operator()(Geometry const& geometry) const
|
||||
{
|
||||
devarianted_svg<Geometry>::apply(m_os, geometry, m_style, m_size);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename OutputStream>
|
||||
static inline void apply(
|
||||
OutputStream& os,
|
||||
variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& geometry,
|
||||
std::string const& style,
|
||||
int size
|
||||
)
|
||||
{
|
||||
boost::apply_visitor(visitor<OutputStream>(os, style, size), geometry);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
/*!
|
||||
\brief Generic geometry template manipulator class, takes corresponding output class from traits class
|
||||
\ingroup svg
|
||||
\details Stream manipulator, streams geometry classes as SVG (Scalable Vector Graphics)
|
||||
*/
|
||||
template <typename Geometry>
|
||||
class svg_manipulator
|
||||
{
|
||||
public:
|
||||
|
||||
inline svg_manipulator(Geometry const& g, std::string const& style, int size)
|
||||
: m_geometry(g)
|
||||
, m_style(style)
|
||||
, m_size(size)
|
||||
{}
|
||||
|
||||
template <typename Char, typename Traits>
|
||||
inline friend std::basic_ostream<Char, Traits>& operator<<(
|
||||
std::basic_ostream<Char, Traits>& os, svg_manipulator const& m)
|
||||
{
|
||||
dispatch::devarianted_svg<Geometry>::apply(os,
|
||||
m.m_geometry,
|
||||
m.m_style,
|
||||
m.m_size);
|
||||
os.flush();
|
||||
return os;
|
||||
}
|
||||
|
||||
private:
|
||||
Geometry const& m_geometry;
|
||||
std::string const& m_style;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Manipulator to stream geometries as SVG
|
||||
\tparam Geometry \tparam_geometry
|
||||
\param geometry \param_geometry
|
||||
\param style String containing verbatim SVG style information
|
||||
\param size Optional size (used for SVG points) in SVG pixels. For linestrings,
|
||||
specify linewidth in the SVG style information
|
||||
\ingroup svg
|
||||
*/
|
||||
template <typename Geometry>
|
||||
inline svg_manipulator<Geometry> svg(Geometry const& geometry, std::string const& style, int size = -1)
|
||||
{
|
||||
concept::check<Geometry const>();
|
||||
|
||||
return svg_manipulator<Geometry>(geometry, style, size);
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_IO_SVG_WRITE_HPP
|
@ -18,288 +18,11 @@
|
||||
#ifndef BOOST_GEOMETRY_IO_SVG_WRITE_SVG_HPP
|
||||
#define BOOST_GEOMETRY_IO_SVG_WRITE_SVG_HPP
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/interior_iterator.hpp>
|
||||
|
||||
#include <boost/geometry/core/exterior_ring.hpp>
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
// THIS FILE WAS LEFT HERE FOR BACKWARD COMPATIBILITY
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
#include <boost/geometry/io/svg/write.hpp>
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace svg
|
||||
{
|
||||
|
||||
|
||||
template <typename Point>
|
||||
struct svg_point
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Point const& p, std::string const& style, int size)
|
||||
{
|
||||
os << "<circle cx=\"" << geometry::get<0>(p)
|
||||
<< "\" cy=\"" << geometry::get<1>(p)
|
||||
<< "\" r=\"" << (size < 0 ? 5 : size)
|
||||
<< "\" style=\"" << style << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Box>
|
||||
struct svg_box
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Box const& box, std::string const& style, int )
|
||||
{
|
||||
// Prevent invisible boxes, making them >=1, using "max"
|
||||
BOOST_USING_STD_MAX();
|
||||
|
||||
typedef typename coordinate_type<Box>::type ct;
|
||||
ct x = geometry::get<geometry::min_corner, 0>(box);
|
||||
ct y = geometry::get<geometry::min_corner, 1>(box);
|
||||
ct width = max BOOST_PREVENT_MACRO_SUBSTITUTION (ct(1),
|
||||
geometry::get<geometry::max_corner, 0>(box) - x);
|
||||
ct height = max BOOST_PREVENT_MACRO_SUBSTITUTION (ct(1),
|
||||
geometry::get<geometry::max_corner, 1>(box) - y);
|
||||
|
||||
os << "<rect x=\"" << x << "\" y=\"" << y
|
||||
<< "\" width=\"" << width << "\" height=\"" << height
|
||||
<< "\" style=\"" << style << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Segment>
|
||||
struct svg_segment
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Segment const& segment, std::string const& style, int)
|
||||
{
|
||||
typedef typename coordinate_type<Segment>::type ct;
|
||||
ct x1 = geometry::get<0, 0>(segment);
|
||||
ct y1 = geometry::get<0, 1>(segment);
|
||||
ct x2 = geometry::get<1, 0>(segment);
|
||||
ct y2 = geometry::get<1, 1>(segment);
|
||||
|
||||
os << "<line x1=\"" << x1 << "\" y1=\"" << y1
|
||||
<< "\" x2=\"" << x2 << "\" y2=\"" << y2
|
||||
<< "\" style=\"" << style << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Stream ranges as SVG
|
||||
\note policy is used to select type (polyline/polygon)
|
||||
*/
|
||||
template <typename Range, typename Policy>
|
||||
struct svg_range
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Range const& range, std::string const& style, int )
|
||||
{
|
||||
typedef typename boost::range_iterator<Range const>::type iterator;
|
||||
|
||||
bool first = true;
|
||||
|
||||
os << "<" << Policy::prefix() << " points=\"";
|
||||
|
||||
for (iterator it = boost::begin(range);
|
||||
it != boost::end(range);
|
||||
++it, first = false)
|
||||
{
|
||||
os << (first ? "" : " " )
|
||||
<< geometry::get<0>(*it)
|
||||
<< ","
|
||||
<< geometry::get<1>(*it);
|
||||
}
|
||||
os << "\" style=\"" << style << Policy::style() << "\"/>";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename Polygon>
|
||||
struct svg_poly
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
Polygon const& polygon, std::string const& style, int )
|
||||
{
|
||||
typedef typename geometry::ring_type<Polygon>::type ring_type;
|
||||
typedef typename boost::range_iterator<ring_type const>::type iterator_type;
|
||||
|
||||
bool first = true;
|
||||
os << "<g fill-rule=\"evenodd\"><path d=\"";
|
||||
|
||||
ring_type const& ring = geometry::exterior_ring(polygon);
|
||||
for (iterator_type it = boost::begin(ring);
|
||||
it != boost::end(ring);
|
||||
++it, first = false)
|
||||
{
|
||||
os << (first ? "M" : " L") << " "
|
||||
<< geometry::get<0>(*it)
|
||||
<< ","
|
||||
<< geometry::get<1>(*it);
|
||||
}
|
||||
|
||||
// Inner rings:
|
||||
{
|
||||
typename interior_return_type<Polygon const>::type
|
||||
rings = interior_rings(polygon);
|
||||
for (typename detail::interior_iterator<Polygon const>::type
|
||||
rit = boost::begin(rings); rit != boost::end(rings); ++rit)
|
||||
{
|
||||
first = true;
|
||||
for (typename detail::interior_ring_iterator<Polygon const>::type
|
||||
it = boost::begin(*rit); it != boost::end(*rit);
|
||||
++it, first = false)
|
||||
{
|
||||
os << (first ? "M" : " L") << " "
|
||||
<< geometry::get<0>(*it)
|
||||
<< ","
|
||||
<< geometry::get<1>(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
os << " z \" style=\"" << style << "\"/></g>";
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct prefix_linestring
|
||||
{
|
||||
static inline const char* prefix() { return "polyline"; }
|
||||
static inline const char* style() { return ";fill:none"; }
|
||||
};
|
||||
|
||||
|
||||
struct prefix_ring
|
||||
{
|
||||
static inline const char* prefix() { return "polygon"; }
|
||||
static inline const char* style() { return ""; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace detail::svg
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Dispatching base struct for SVG streaming, specialized below per geometry type
|
||||
\details Specializations should implement a static method "stream" to stream a geometry
|
||||
The static method should have the signature:
|
||||
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os, G const& geometry)
|
||||
*/
|
||||
template <typename GeometryTag, typename Geometry>
|
||||
struct svg
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG
|
||||
(
|
||||
false, NOT_OR_NOT_YET_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE
|
||||
, (Geometry)
|
||||
);
|
||||
};
|
||||
|
||||
template <typename Point>
|
||||
struct svg<point_tag, Point> : detail::svg::svg_point<Point> {};
|
||||
|
||||
template <typename Segment>
|
||||
struct svg<segment_tag, Segment> : detail::svg::svg_segment<Segment> {};
|
||||
|
||||
template <typename Box>
|
||||
struct svg<box_tag, Box> : detail::svg::svg_box<Box> {};
|
||||
|
||||
template <typename Linestring>
|
||||
struct svg<linestring_tag, Linestring>
|
||||
: detail::svg::svg_range<Linestring, detail::svg::prefix_linestring> {};
|
||||
|
||||
template <typename Ring>
|
||||
struct svg<ring_tag, Ring>
|
||||
: detail::svg::svg_range<Ring, detail::svg::prefix_ring> {};
|
||||
|
||||
template <typename Polygon>
|
||||
struct svg<polygon_tag, Polygon>
|
||||
: detail::svg::svg_poly<Polygon> {};
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
/*!
|
||||
\brief Generic geometry template manipulator class, takes corresponding output class from traits class
|
||||
\ingroup svg
|
||||
\details Stream manipulator, streams geometry classes as SVG (Scalable Vector Graphics)
|
||||
*/
|
||||
template <typename G>
|
||||
class svg_manipulator
|
||||
{
|
||||
public:
|
||||
|
||||
inline svg_manipulator(G const& g, std::string const& style, int size)
|
||||
: m_geometry(g)
|
||||
, m_style(style)
|
||||
, m_size(size)
|
||||
{}
|
||||
|
||||
template <typename Char, typename Traits>
|
||||
inline friend std::basic_ostream<Char, Traits>& operator<<(
|
||||
std::basic_ostream<Char, Traits>& os, svg_manipulator const& m)
|
||||
{
|
||||
dispatch::svg
|
||||
<
|
||||
typename tag<G>::type, G
|
||||
>::apply(os, m.m_geometry, m.m_style, m.m_size);
|
||||
os.flush();
|
||||
return os;
|
||||
}
|
||||
|
||||
private:
|
||||
G const& m_geometry;
|
||||
std::string const& m_style;
|
||||
int m_size;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Manipulator to stream geometries as SVG
|
||||
\tparam Geometry \tparam_geometry
|
||||
\param geometry \param_geometry
|
||||
\param style String containing verbatim SVG style information
|
||||
\param size Optional size (used for SVG points) in SVG pixels. For linestrings,
|
||||
specify linewidth in the SVG style information
|
||||
\ingroup svg
|
||||
*/
|
||||
template <typename Geometry>
|
||||
inline svg_manipulator<Geometry> svg(Geometry const& geometry, std::string const& style, int size = -1)
|
||||
{
|
||||
concept::check<Geometry const>();
|
||||
|
||||
return svg_manipulator<Geometry>(geometry, style, size);
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_IO_SVG_WRITE_SVG_HPP
|
||||
|
@ -18,92 +18,10 @@
|
||||
#define BOOST_GEOMETRY_IO_SVG_WRITE_SVG_MULTI_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/io/svg/write_svg.hpp>
|
||||
// THIS FILE WAS LEFT HERE FOR BACKWARD COMPATIBILITY
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace svg
|
||||
{
|
||||
|
||||
|
||||
template <typename MultiGeometry, typename Policy>
|
||||
struct svg_multi
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void apply(std::basic_ostream<Char, Traits>& os,
|
||||
MultiGeometry const& multi, std::string const& style, int size)
|
||||
{
|
||||
for (typename boost::range_iterator<MultiGeometry const>::type
|
||||
it = boost::begin(multi);
|
||||
it != boost::end(multi);
|
||||
++it)
|
||||
{
|
||||
Policy::apply(os, *it, style, size);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace detail::svg
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
template <typename MultiPoint>
|
||||
struct svg<multi_point_tag, MultiPoint>
|
||||
: detail::svg::svg_multi
|
||||
<
|
||||
MultiPoint,
|
||||
detail::svg::svg_point
|
||||
<
|
||||
typename boost::range_value<MultiPoint>::type
|
||||
>
|
||||
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename MultiLinestring>
|
||||
struct svg<multi_linestring_tag, MultiLinestring>
|
||||
: detail::svg::svg_multi
|
||||
<
|
||||
MultiLinestring,
|
||||
detail::svg::svg_range
|
||||
<
|
||||
typename boost::range_value<MultiLinestring>::type,
|
||||
detail::svg::prefix_linestring
|
||||
>
|
||||
|
||||
>
|
||||
{};
|
||||
|
||||
template <typename MultiPolygon>
|
||||
struct svg<multi_polygon_tag, MultiPolygon>
|
||||
: detail::svg::svg_multi
|
||||
<
|
||||
MultiPolygon,
|
||||
detail::svg::svg_poly
|
||||
<
|
||||
typename boost::range_value<MultiPolygon>::type
|
||||
>
|
||||
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
#include <boost/geometry/io/svg/write.hpp>
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_IO_SVG_WRITE_SVG_MULTI_HPP
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -13,17 +17,10 @@
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/assert.hpp>
|
||||
#include <boost/geometry/strategies/side_info.hpp>
|
||||
#include <boost/geometry/util/promote_integral.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
#include <boost/geometry/util/select_most_precise.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
@ -43,45 +40,6 @@ struct segments_intersection_points
|
||||
{
|
||||
typedef ReturnType return_type;
|
||||
|
||||
template
|
||||
<
|
||||
typename Point,
|
||||
typename Segment,
|
||||
typename SegmentRatio,
|
||||
typename T
|
||||
>
|
||||
static inline void assign(Point& point,
|
||||
Segment const& segment,
|
||||
SegmentRatio const& ratio,
|
||||
T const& dx, T const& dy)
|
||||
{
|
||||
typedef typename geometry::coordinate_type<Point>::type coordinate_type;
|
||||
|
||||
// Calculate the intersection point based on segment_ratio
|
||||
// Up to now, division was postponed. Here we divide using numerator/
|
||||
// denominator. In case of integer this results in an integer
|
||||
// division.
|
||||
BOOST_GEOMETRY_ASSERT(ratio.denominator() != 0);
|
||||
|
||||
typedef typename promote_integral<coordinate_type>::type promoted_type;
|
||||
|
||||
promoted_type const numerator
|
||||
= boost::numeric_cast<promoted_type>(ratio.numerator());
|
||||
promoted_type const denominator
|
||||
= boost::numeric_cast<promoted_type>(ratio.denominator());
|
||||
promoted_type const dx_promoted = boost::numeric_cast<promoted_type>(dx);
|
||||
promoted_type const dy_promoted = boost::numeric_cast<promoted_type>(dy);
|
||||
|
||||
set<0>(point, get<0, 0>(segment) + boost::numeric_cast
|
||||
<
|
||||
coordinate_type
|
||||
>(numerator * dx_promoted / denominator));
|
||||
set<1>(point, get<0, 1>(segment) + boost::numeric_cast
|
||||
<
|
||||
coordinate_type
|
||||
>(numerator * dy_promoted / denominator));
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Segment1,
|
||||
@ -112,8 +70,8 @@ struct segments_intersection_points
|
||||
{
|
||||
// Prefer shorter segment
|
||||
typedef typename SegmentIntersectionInfo::promoted_type ptype;
|
||||
ptype const len_a = sinfo.dx_a * sinfo.dx_a + sinfo.dy_a * sinfo.dy_a;
|
||||
ptype const len_b = sinfo.dx_b * sinfo.dx_b + sinfo.dy_b * sinfo.dy_b;
|
||||
ptype const len_a = sinfo.comparable_length_a();
|
||||
ptype const len_b = sinfo.comparable_length_b();
|
||||
if (len_b < len_a)
|
||||
{
|
||||
use_a = false;
|
||||
@ -123,13 +81,11 @@ struct segments_intersection_points
|
||||
|
||||
if (use_a)
|
||||
{
|
||||
assign(result.intersections[0], s1, sinfo.robust_ra,
|
||||
sinfo.dx_a, sinfo.dy_a);
|
||||
sinfo.assign_a(result.intersections[0], s1, s2);
|
||||
}
|
||||
else
|
||||
{
|
||||
assign(result.intersections[0], s2, sinfo.robust_rb,
|
||||
sinfo.dx_b, sinfo.dy_b);
|
||||
sinfo.assign_b(result.intersections[0], s1, s2);
|
||||
}
|
||||
|
||||
result.fractions[0].assign(sinfo);
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
// Copyright (c) 2013 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -190,7 +194,7 @@ public :
|
||||
|
||||
inline bool close_to(thistype const& other) const
|
||||
{
|
||||
return geometry::math::abs(m_approximation - other.m_approximation) < 2;
|
||||
return geometry::math::abs(m_approximation - other.m_approximation) < 50;
|
||||
}
|
||||
|
||||
inline bool operator< (thistype const& other) const
|
||||
|
@ -3,8 +3,8 @@
|
||||
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2016.
|
||||
// Modifications copyright (c) 2014-2016, 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
|
||||
@ -30,6 +30,7 @@
|
||||
#include <boost/geometry/algorithms/detail/recalculate.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/promote_integral.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
// Temporary / will be Strategy as template parameter
|
||||
@ -37,6 +38,7 @@
|
||||
#include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side_info.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
|
||||
#include <boost/geometry/policies/robustness/robust_point_type.hpp>
|
||||
@ -64,6 +66,69 @@ struct relate_cartesian_segments
|
||||
{
|
||||
typedef typename Policy::return_type return_type;
|
||||
|
||||
template <typename CoordinateType, typename SegmentRatio>
|
||||
struct segment_intersection_info
|
||||
{
|
||||
typedef typename select_most_precise
|
||||
<
|
||||
CoordinateType, double
|
||||
>::type promoted_type;
|
||||
|
||||
promoted_type comparable_length_a() const
|
||||
{
|
||||
return dx_a * dx_a + dy_a * dy_a;
|
||||
}
|
||||
|
||||
promoted_type comparable_length_b() const
|
||||
{
|
||||
return dx_b * dx_b + dy_b * dy_b;
|
||||
}
|
||||
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign_a(Point& point, Segment1 const& a, Segment2 const& ) const
|
||||
{
|
||||
assign(point, a, dx_a, dy_a, robust_ra);
|
||||
}
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign_b(Point& point, Segment1 const& , Segment2 const& b) const
|
||||
{
|
||||
assign(point, b, dx_b, dy_b, robust_rb);
|
||||
}
|
||||
|
||||
template <typename Point, typename Segment>
|
||||
void assign(Point& point, Segment const& segment, CoordinateType const& dx, CoordinateType const& dy, SegmentRatio const& ratio) const
|
||||
{
|
||||
// Calculate the intersection point based on segment_ratio
|
||||
// Up to now, division was postponed. Here we divide using numerator/
|
||||
// denominator. In case of integer this results in an integer
|
||||
// division.
|
||||
BOOST_GEOMETRY_ASSERT(ratio.denominator() != 0);
|
||||
|
||||
typedef typename promote_integral<CoordinateType>::type promoted_type;
|
||||
|
||||
promoted_type const numerator
|
||||
= boost::numeric_cast<promoted_type>(ratio.numerator());
|
||||
promoted_type const denominator
|
||||
= boost::numeric_cast<promoted_type>(ratio.denominator());
|
||||
promoted_type const dx_promoted = boost::numeric_cast<promoted_type>(dx);
|
||||
promoted_type const dy_promoted = boost::numeric_cast<promoted_type>(dy);
|
||||
|
||||
set<0>(point, get<0, 0>(segment) + boost::numeric_cast
|
||||
<
|
||||
CoordinateType
|
||||
>(numerator * dx_promoted / denominator));
|
||||
set<1>(point, get<0, 1>(segment) + boost::numeric_cast
|
||||
<
|
||||
CoordinateType
|
||||
>(numerator * dy_promoted / denominator));
|
||||
}
|
||||
|
||||
CoordinateType dx_a, dy_a;
|
||||
CoordinateType dx_b, dy_b;
|
||||
SegmentRatio robust_ra;
|
||||
SegmentRatio robust_rb;
|
||||
};
|
||||
|
||||
template <typename D, typename W, typename ResultType>
|
||||
static inline void cramers_rule(D const& dx_a, D const& dy_a,
|
||||
D const& dx_b, D const& dy_b, W const& wx, W const& wy,
|
||||
@ -108,17 +173,18 @@ struct relate_cartesian_segments
|
||||
}
|
||||
|
||||
// The main entry-routine, calculating intersections of segments a / b
|
||||
template <typename Segment1, typename Segment2, typename RobustPolicy, typename RobustPoint>
|
||||
// NOTE: Robust* types may be the same as Segments' point types
|
||||
template <typename Segment1, typename Segment2,
|
||||
typename RobustPolicy,
|
||||
typename RobustPoint1, typename RobustPoint2>
|
||||
static inline return_type apply(Segment1 const& a, Segment2 const& b,
|
||||
RobustPolicy const& robust_policy,
|
||||
RobustPoint const& robust_a1, RobustPoint const& robust_a2,
|
||||
RobustPoint const& robust_b1, RobustPoint const& robust_b2)
|
||||
RobustPolicy const& /*robust_policy*/,
|
||||
RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2,
|
||||
RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstSegment<Segment1>) );
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstSegment<Segment2>) );
|
||||
|
||||
boost::ignore_unused_variable_warning(robust_policy);
|
||||
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
bool const a_is_point = equals_point_point(robust_a1, robust_a2);
|
||||
bool const b_is_point = equals_point_point(robust_b1, robust_b2);
|
||||
@ -159,12 +225,8 @@ struct relate_cartesian_segments
|
||||
|
||||
typedef typename select_most_precise
|
||||
<
|
||||
coordinate_type, double
|
||||
>::type promoted_type;
|
||||
|
||||
typedef typename geometry::coordinate_type
|
||||
<
|
||||
RobustPoint
|
||||
typename geometry::coordinate_type<RobustPoint1>::type,
|
||||
typename geometry::coordinate_type<RobustPoint2>::type
|
||||
>::type robust_coordinate_type;
|
||||
|
||||
typedef typename segment_ratio_type
|
||||
@ -176,7 +238,6 @@ struct relate_cartesian_segments
|
||||
segment_intersection_info
|
||||
<
|
||||
coordinate_type,
|
||||
promoted_type,
|
||||
ratio_type
|
||||
> sinfo;
|
||||
|
||||
@ -300,12 +361,13 @@ private:
|
||||
typename RatioType,
|
||||
typename Segment1,
|
||||
typename Segment2,
|
||||
typename RobustPoint
|
||||
typename RobustPoint1,
|
||||
typename RobustPoint2
|
||||
>
|
||||
static inline return_type relate_collinear(Segment1 const& a,
|
||||
Segment2 const& b,
|
||||
RobustPoint const& robust_a1, RobustPoint const& robust_a2,
|
||||
RobustPoint const& robust_b1, RobustPoint const& robust_b2,
|
||||
RobustPoint1 const& robust_a1, RobustPoint1 const& robust_a2,
|
||||
RobustPoint2 const& robust_b1, RobustPoint2 const& robust_b2,
|
||||
bool a_is_point, bool b_is_point)
|
||||
{
|
||||
if (a_is_point)
|
||||
@ -335,12 +397,13 @@ private:
|
||||
typename RatioType,
|
||||
typename Segment1,
|
||||
typename Segment2,
|
||||
typename RobustType
|
||||
typename RobustType1,
|
||||
typename RobustType2
|
||||
>
|
||||
static inline return_type relate_collinear(Segment1 const& a
|
||||
, Segment2 const& b
|
||||
, RobustType oa_1, RobustType oa_2
|
||||
, RobustType ob_1, RobustType ob_2
|
||||
, RobustType1 oa_1, RobustType1 oa_2
|
||||
, RobustType2 ob_1, RobustType2 ob_2
|
||||
)
|
||||
{
|
||||
// Calculate the ratios where a starts in b, b starts in a
|
||||
@ -373,8 +436,8 @@ private:
|
||||
// b2 is located w.r.t. a at ratio: (5-2)/5=3/5 (on a)
|
||||
// a1 is located w.r.t. b at ratio: (2-8)/-3=6/3 (after b ends)
|
||||
// a2 is located w.r.t. b at ratio: (7-8)/-3=1/3 (on b)
|
||||
RobustType const length_a = oa_2 - oa_1; // no abs, see above
|
||||
RobustType const length_b = ob_2 - ob_1;
|
||||
RobustType1 const length_a = oa_2 - oa_1; // no abs, see above
|
||||
RobustType2 const length_b = ob_2 - ob_1;
|
||||
|
||||
RatioType ra_from(oa_1 - ob_1, length_b);
|
||||
RatioType ra_to(oa_2 - ob_1, length_b);
|
||||
@ -435,12 +498,13 @@ private:
|
||||
<
|
||||
typename RatioType,
|
||||
typename DegenerateSegment,
|
||||
typename RobustType
|
||||
typename RobustType1,
|
||||
typename RobustType2
|
||||
>
|
||||
static inline return_type relate_one_degenerate(
|
||||
DegenerateSegment const& degenerate_segment
|
||||
, RobustType d
|
||||
, RobustType s1, RobustType s2
|
||||
, RobustType1 d
|
||||
, RobustType2 s1, RobustType2 s2
|
||||
, bool a_degenerate
|
||||
)
|
||||
{
|
||||
@ -478,6 +542,20 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename Policy, typename CalculationType>
|
||||
struct default_strategy<cartesian_tag, Policy, CalculationType>
|
||||
{
|
||||
typedef relate_cartesian_segments<Policy, CalculationType> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::intersection
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
@ -1,92 +1,52 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_STRATEGIES_INTERSECTION_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
|
||||
#ifndef BOOST_GEOMETRY_STRATEGIES_SEGMENT_INTERSECTION_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SEGMENT_INTERSECTION_HPP
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
#include <boost/geometry/policies/relate/intersection_points.hpp>
|
||||
#include <boost/geometry/policies/relate/direction.hpp>
|
||||
#include <boost/geometry/policies/relate/tupled.hpp>
|
||||
#include <boost/geometry/strategies/tags.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/cart_intersect.hpp>
|
||||
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace intersection
|
||||
{
|
||||
|
||||
namespace services
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief "compound strategy", containing a segment-intersection-strategy
|
||||
and a side-strategy
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Tag,
|
||||
typename Geometry1,
|
||||
typename Geometry2,
|
||||
typename IntersectionPoint,
|
||||
typename RobustPolicy,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct strategy_intersection
|
||||
\brief Traits class binding a segments intersection strategy to a coordinate system
|
||||
\ingroup util
|
||||
\tparam CSTag tag of coordinate system of point-type
|
||||
\tparam Policy intersection policy
|
||||
\tparam CalculationType \tparam_calculation
|
||||
*/
|
||||
template <typename CSTag, typename Policy, typename CalculationType = void>
|
||||
struct default_strategy
|
||||
{
|
||||
private :
|
||||
// for development BOOST_STATIC_ASSERT((! boost::is_same<RobustPolicy, void>::type::value));
|
||||
|
||||
typedef typename geometry::point_type<Geometry1>::type point1_type;
|
||||
typedef typename geometry::point_type<Geometry2>::type point2_type;
|
||||
typedef typename model::referring_segment<point1_type const> segment1_type;
|
||||
typedef typename model::referring_segment<point2_type const> segment2_type;
|
||||
|
||||
typedef segment_intersection_points
|
||||
<
|
||||
IntersectionPoint,
|
||||
typename geometry::segment_ratio_type
|
||||
<
|
||||
IntersectionPoint, RobustPolicy
|
||||
>::type
|
||||
> ip_type;
|
||||
|
||||
public:
|
||||
typedef strategy::intersection::relate_cartesian_segments
|
||||
<
|
||||
policies::relate::segments_tupled
|
||||
<
|
||||
policies::relate::segments_intersection_points
|
||||
<
|
||||
ip_type
|
||||
> ,
|
||||
policies::relate::segments_direction
|
||||
>,
|
||||
CalculationType
|
||||
> segment_intersection_strategy_type;
|
||||
|
||||
typedef typename strategy::side::services::default_strategy
|
||||
<
|
||||
Tag,
|
||||
CalculationType
|
||||
>::type side_strategy_type;
|
||||
|
||||
typedef RobustPolicy rescale_policy_type;
|
||||
BOOST_MPL_ASSERT_MSG
|
||||
(
|
||||
false, NOT_IMPLEMENTED_FOR_THIS_TYPE
|
||||
, (types<CSTag>)
|
||||
);
|
||||
};
|
||||
|
||||
// Version for box_box intersection or other detail calls not needing a strategy
|
||||
struct strategy_intersection_empty {};
|
||||
} // namespace services
|
||||
|
||||
}} // namespace strategy::intersection
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SEGMENT_INTERSECTION_HPP
|
||||
|
@ -2,9 +2,8 @@
|
||||
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2015.
|
||||
// Modifications copyright (c) 2015 Oracle and/or its affiliates.
|
||||
|
||||
// This file was modified by Oracle on 2015, 2016.
|
||||
// Modifications copyright (c) 2015-2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
@ -73,19 +72,6 @@ struct segment_intersection_points
|
||||
{}
|
||||
};
|
||||
|
||||
// All assigned in cart_intersect, passed to intersection_points
|
||||
template <typename CoordinateType, typename PromotedType, typename SegmentRatio>
|
||||
struct segment_intersection_info
|
||||
{
|
||||
typedef PromotedType promoted_type;
|
||||
|
||||
CoordinateType dx_a, dy_a;
|
||||
CoordinateType dx_b, dy_b;
|
||||
SegmentRatio robust_ra;
|
||||
SegmentRatio robust_rb;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
|
100
include/boost/geometry/strategies/intersection_strategies.hpp
Normal file
100
include/boost/geometry/strategies/intersection_strategies.hpp
Normal file
@ -0,0 +1,100 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_STRATEGIES_INTERSECTION_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/geometries/segment.hpp>
|
||||
|
||||
#include <boost/geometry/policies/relate/intersection_points.hpp>
|
||||
#include <boost/geometry/policies/relate/direction.hpp>
|
||||
#include <boost/geometry/policies/relate/tupled.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/cartesian/cart_intersect.hpp>
|
||||
#include <boost/geometry/strategies/cartesian/side_by_triangle.hpp>
|
||||
#include <boost/geometry/strategies/spherical/intersection.hpp>
|
||||
#include <boost/geometry/strategies/spherical/ssf.hpp>
|
||||
|
||||
#include <boost/geometry/policies/robustness/segment_ratio_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief "compound strategy", containing a segment-intersection-strategy
|
||||
and a side-strategy
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename Tag,
|
||||
typename Geometry1,
|
||||
typename Geometry2,
|
||||
typename IntersectionPoint,
|
||||
typename RobustPolicy,
|
||||
typename CalculationType = void
|
||||
>
|
||||
struct intersection_strategies
|
||||
{
|
||||
private :
|
||||
// for development BOOST_STATIC_ASSERT((! boost::is_same<RobustPolicy, void>::type::value));
|
||||
|
||||
typedef typename geometry::point_type<Geometry1>::type point1_type;
|
||||
typedef typename geometry::point_type<Geometry2>::type point2_type;
|
||||
typedef typename model::referring_segment<point1_type const> segment1_type;
|
||||
typedef typename model::referring_segment<point2_type const> segment2_type;
|
||||
|
||||
typedef segment_intersection_points
|
||||
<
|
||||
IntersectionPoint,
|
||||
typename geometry::segment_ratio_type
|
||||
<
|
||||
IntersectionPoint, RobustPolicy
|
||||
>::type
|
||||
> ip_type;
|
||||
|
||||
public:
|
||||
typedef typename strategy::intersection::services::default_strategy
|
||||
<
|
||||
Tag,
|
||||
policies::relate::segments_tupled
|
||||
<
|
||||
policies::relate::segments_intersection_points
|
||||
<
|
||||
ip_type
|
||||
> ,
|
||||
policies::relate::segments_direction
|
||||
>,
|
||||
CalculationType
|
||||
>::type segment_intersection_strategy_type;
|
||||
|
||||
typedef typename strategy::side::services::default_strategy
|
||||
<
|
||||
Tag,
|
||||
CalculationType
|
||||
>::type side_strategy_type;
|
||||
|
||||
typedef RobustPolicy rescale_policy_type;
|
||||
};
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_INTERSECTION_HPP
|
701
include/boost/geometry/strategies/spherical/intersection.hpp
Normal file
701
include/boost/geometry/strategies/spherical/intersection.hpp
Normal file
@ -0,0 +1,701 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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_STRATEGIES_SPHERICAL_INTERSECTION_HPP
|
||||
#define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INTERSECTION_HPP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/assign_values.hpp>
|
||||
#include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
|
||||
#include <boost/geometry/algorithms/detail/recalculate.hpp>
|
||||
|
||||
#include <boost/geometry/arithmetic/arithmetic.hpp>
|
||||
#include <boost/geometry/arithmetic/cross_product.hpp>
|
||||
#include <boost/geometry/arithmetic/dot_product.hpp>
|
||||
#include <boost/geometry/formulas/spherical.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
#include <boost/geometry/geometries/concepts/segment_concept.hpp>
|
||||
|
||||
#include <boost/geometry/policies/robustness/segment_ratio.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/side_info.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_result.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace strategy { namespace intersection
|
||||
{
|
||||
|
||||
// NOTE:
|
||||
// The coordinates of crossing IP may be calculated with small precision in some cases.
|
||||
// For double, near the equator noticed error ~1e-9 so far greater than
|
||||
// machine epsilon which is ~1e-16. This error is ~0.04m.
|
||||
// E.g. consider two cases, one near the origin and the second one rotated by 90 deg around Z or SN axis.
|
||||
// After the conversion from spherical degrees to cartesian 3d the following coordinates
|
||||
// are calculated:
|
||||
// for sph (-1 -1, 1 1) deg cart3d ys are -0.017449748351250485 and 0.017449748351250485
|
||||
// for sph (89 -1, 91 1) deg cart3d xs are 0.017449748351250571 and -0.017449748351250450
|
||||
// During the conversion degrees must first be converted to radians and then radians
|
||||
// are passed into trigonometric functions. The error may have several causes:
|
||||
// 1. Radians cannot represent exactly the same angles as degrees.
|
||||
// 2. Different longitudes are passed into sin() for x, corresponding to cos() for y,
|
||||
// and for different angle the error of the result may be different.
|
||||
// 3. These non-corresponding cartesian coordinates are used in calculation,
|
||||
// e.g. multiplied several times in cross and dot products.
|
||||
// If it was a problem this strategy could e.g. "normalize" longitudes before the conversion using the source units
|
||||
// by rotating the globe around Z axis, so moving longitudes always the same way towards the origin,
|
||||
// assuming this could help which is not clear.
|
||||
// For now, intersection points near the endpoints are checked explicitly if needed (if the IP is near the endpoint)
|
||||
// to generate precise result for them. Only the crossing (i) case may suffer from lower precision.
|
||||
|
||||
template <typename Policy, typename CalculationType = void>
|
||||
struct relate_spherical_segments
|
||||
{
|
||||
typedef typename Policy::return_type return_type;
|
||||
|
||||
enum intersection_point_flag { ipi_inters = 0, ipi_at_a1, ipi_at_a2, ipi_at_b1, ipi_at_b2 };
|
||||
|
||||
template <typename CoordinateType, typename SegmentRatio, typename Vector3d>
|
||||
struct segment_intersection_info
|
||||
{
|
||||
typedef typename select_most_precise
|
||||
<
|
||||
CoordinateType, double
|
||||
>::type promoted_type;
|
||||
|
||||
promoted_type comparable_length_a() const
|
||||
{
|
||||
return robust_ra.denominator();
|
||||
}
|
||||
|
||||
promoted_type comparable_length_b() const
|
||||
{
|
||||
return robust_rb.denominator();
|
||||
}
|
||||
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign_a(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
assign(point, a, b);
|
||||
}
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign_b(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
assign(point, a, b);
|
||||
}
|
||||
|
||||
template <typename Point, typename Segment1, typename Segment2>
|
||||
void assign(Point& point, Segment1 const& a, Segment2 const& b) const
|
||||
{
|
||||
if (ip_flag == ipi_inters)
|
||||
{
|
||||
// TODO: assign the rest of coordinates
|
||||
point = formula::cart3d_to_sph<Point>(intersection_point);
|
||||
}
|
||||
else if (ip_flag == ipi_at_a1)
|
||||
{
|
||||
detail::assign_point_from_index<0>(a, point);
|
||||
}
|
||||
else if (ip_flag == ipi_at_a2)
|
||||
{
|
||||
detail::assign_point_from_index<1>(a, point);
|
||||
}
|
||||
else if (ip_flag == ipi_at_b1)
|
||||
{
|
||||
detail::assign_point_from_index<0>(b, point);
|
||||
}
|
||||
else // ip_flag == ipi_at_b2
|
||||
{
|
||||
detail::assign_point_from_index<1>(b, point);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3d intersection_point;
|
||||
SegmentRatio robust_ra;
|
||||
SegmentRatio robust_rb;
|
||||
intersection_point_flag ip_flag;
|
||||
};
|
||||
|
||||
// Relate segments a and b
|
||||
template <typename Segment1, typename Segment2, typename RobustPolicy>
|
||||
static inline return_type apply(Segment1 const& a, Segment2 const& b,
|
||||
RobustPolicy const& robust_policy)
|
||||
{
|
||||
typedef typename point_type<Segment1>::type point1_t;
|
||||
typedef typename point_type<Segment2>::type point2_t;
|
||||
point1_t a1, a2;
|
||||
point2_t b1, b2;
|
||||
|
||||
// TODO: use indexed_point_view if possible?
|
||||
detail::assign_point_from_index<0>(a, a1);
|
||||
detail::assign_point_from_index<1>(a, a2);
|
||||
detail::assign_point_from_index<0>(b, b1);
|
||||
detail::assign_point_from_index<1>(b, b2);
|
||||
|
||||
return apply(a, b, robust_policy, a1, a2, b1, b2);
|
||||
}
|
||||
|
||||
// Relate segments a and b
|
||||
template <typename Segment1, typename Segment2, typename RobustPolicy, typename Point1, typename Point2>
|
||||
static inline return_type apply(Segment1 const& a, Segment2 const& b,
|
||||
RobustPolicy const&,
|
||||
Point1 const& a1, Point1 const& a2, Point2 const& b1, Point2 const& b2)
|
||||
{
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstSegment<Segment1>) );
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstSegment<Segment2>) );
|
||||
|
||||
// TODO: check only 2 first coordinates here?
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
bool a_is_point = equals_point_point(a1, a2);
|
||||
bool b_is_point = equals_point_point(b1, b2);
|
||||
|
||||
if(a_is_point && b_is_point)
|
||||
{
|
||||
return equals_point_point(a1, b2)
|
||||
? Policy::degenerate(a, true)
|
||||
: Policy::disjoint()
|
||||
;
|
||||
}
|
||||
|
||||
typedef typename select_calculation_type
|
||||
<Segment1, Segment2, CalculationType>::type calc_t;
|
||||
|
||||
calc_t const c0 = 0;
|
||||
calc_t const c1 = 1;
|
||||
|
||||
typedef model::point<calc_t, 3, cs::cartesian> vec3d_t;
|
||||
|
||||
using namespace formula;
|
||||
vec3d_t const a1v = sph_to_cart3d<vec3d_t>(a1);
|
||||
vec3d_t const a2v = sph_to_cart3d<vec3d_t>(a2);
|
||||
vec3d_t const b1v = sph_to_cart3d<vec3d_t>(b1);
|
||||
vec3d_t const b2v = sph_to_cart3d<vec3d_t>(b2);
|
||||
|
||||
vec3d_t norm1 = cross_product(a1v, a2v);
|
||||
vec3d_t norm2 = cross_product(b1v, b2v);
|
||||
|
||||
side_info sides;
|
||||
// not normalized normals, the same as in SSF
|
||||
sides.set<0>(sph_side_value(norm2, a1v), sph_side_value(norm2, a2v));
|
||||
if (sides.same<0>())
|
||||
{
|
||||
// Both points are at same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
}
|
||||
// not normalized normals, the same as in SSF
|
||||
sides.set<1>(sph_side_value(norm1, b1v), sph_side_value(norm1, b2v));
|
||||
if (sides.same<1>())
|
||||
{
|
||||
// Both points are at same side of other segment, we can leave
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
// NOTE: at this point the segments may still be disjoint
|
||||
|
||||
bool collinear = sides.collinear();
|
||||
|
||||
calc_t const len1 = math::sqrt(dot_product(norm1, norm1));
|
||||
calc_t const len2 = math::sqrt(dot_product(norm2, norm2));
|
||||
|
||||
// point or opposite sides of a sphere, assume point
|
||||
if (math::equals(len1, c0))
|
||||
{
|
||||
a_is_point = true;
|
||||
if (sides.get<0, 0>() == 0 || sides.get<0, 1>() == 0)
|
||||
{
|
||||
sides.set<0>(0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// normalize
|
||||
divide_value(norm1, len1);
|
||||
}
|
||||
|
||||
if (math::equals(len2, c0))
|
||||
{
|
||||
b_is_point = true;
|
||||
if (sides.get<1, 0>() == 0 || sides.get<1, 1>() == 0)
|
||||
{
|
||||
sides.set<1>(0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// normalize
|
||||
divide_value(norm2, len2);
|
||||
}
|
||||
|
||||
// check both degenerated once more
|
||||
if (a_is_point && b_is_point)
|
||||
{
|
||||
return equals_point_point(a1, b2)
|
||||
? Policy::degenerate(a, true)
|
||||
: Policy::disjoint()
|
||||
;
|
||||
}
|
||||
|
||||
// NOTE: at this point one of the segments may be degenerated
|
||||
// and the segments may still be disjoint
|
||||
|
||||
calc_t dot_n1n2 = dot_product(norm1, norm2);
|
||||
|
||||
// NOTE: this is technically not needed since theoretically above sides
|
||||
// are calculated, but just in case check the normals.
|
||||
// Have in mind that SSF side strategy doesn't check this.
|
||||
// collinear if normals are equal or opposite: cos(a) in {-1, 1}
|
||||
if (!collinear && math::equals(math::abs(dot_n1n2), c1))
|
||||
{
|
||||
collinear = true;
|
||||
sides.set<0>(0, 0);
|
||||
sides.set<1>(0, 0);
|
||||
}
|
||||
|
||||
if (collinear)
|
||||
{
|
||||
if (a_is_point)
|
||||
{
|
||||
return collinear_one_degenerted<calc_t>(a, true, b1, b2, a1, a2, b1v, b2v, norm2, a1v);
|
||||
}
|
||||
else if (b_is_point)
|
||||
{
|
||||
// b2 used to be consistent with (degenerated) checks above (is it needed?)
|
||||
return collinear_one_degenerted<calc_t>(b, false, a1, a2, b1, b2, a1v, a2v, norm1, b1v);
|
||||
}
|
||||
else
|
||||
{
|
||||
calc_t dist_a1_a2, dist_a1_b1, dist_a1_b2;
|
||||
calc_t dist_b1_b2, dist_b1_a1, dist_b1_a2;
|
||||
// use shorter segment
|
||||
if (len1 <= len2)
|
||||
{
|
||||
calculate_collinear_data(a1, a2, b1, b2, a1v, a2v, norm1, b1v, dist_a1_a2, dist_a1_b1);
|
||||
calculate_collinear_data(a1, a2, b1, b2, a1v, a2v, norm1, b2v, dist_a1_a2, dist_a1_b2);
|
||||
dist_b1_b2 = dist_a1_b2 - dist_a1_b1;
|
||||
dist_b1_a1 = -dist_a1_b1;
|
||||
dist_b1_a2 = dist_a1_a2 - dist_a1_b1;
|
||||
}
|
||||
else
|
||||
{
|
||||
calculate_collinear_data(b1, b2, a1, a2, b1v, b2v, norm2, a1v, dist_b1_b2, dist_b1_a1);
|
||||
calculate_collinear_data(b1, b2, a1, a2, b1v, b2v, norm2, a2v, dist_b1_b2, dist_b1_a2);
|
||||
dist_a1_a2 = dist_b1_a2 - dist_b1_a1;
|
||||
dist_a1_b1 = -dist_b1_a1;
|
||||
dist_a1_b2 = dist_b1_b2 - dist_b1_a1;
|
||||
}
|
||||
|
||||
segment_ratio<calc_t> ra_from(dist_b1_a1, dist_b1_b2);
|
||||
segment_ratio<calc_t> ra_to(dist_b1_a2, dist_b1_b2);
|
||||
segment_ratio<calc_t> rb_from(dist_a1_b1, dist_a1_a2);
|
||||
segment_ratio<calc_t> rb_to(dist_a1_b2, dist_a1_a2);
|
||||
|
||||
// NOTE: this is probably not needed
|
||||
int const a1_wrt_b = position_value(c0, dist_a1_b1, dist_a1_b2);
|
||||
int const a2_wrt_b = position_value(dist_a1_a2, dist_a1_b1, dist_a1_b2);
|
||||
int const b1_wrt_a = position_value(c0, dist_b1_a1, dist_b1_a2);
|
||||
int const b2_wrt_a = position_value(dist_b1_b2, dist_b1_a1, dist_b1_a2);
|
||||
|
||||
if (a1_wrt_b == 1)
|
||||
{
|
||||
ra_from.assign(0, dist_b1_b2);
|
||||
rb_from.assign(0, dist_a1_a2);
|
||||
}
|
||||
else if (a1_wrt_b == 3)
|
||||
{
|
||||
ra_from.assign(dist_b1_b2, dist_b1_b2);
|
||||
rb_to.assign(0, dist_a1_a2);
|
||||
}
|
||||
|
||||
if (a2_wrt_b == 1)
|
||||
{
|
||||
ra_to.assign(0, dist_b1_b2);
|
||||
rb_from.assign(dist_a1_a2, dist_a1_a2);
|
||||
}
|
||||
else if (a2_wrt_b == 3)
|
||||
{
|
||||
ra_to.assign(dist_b1_b2, dist_b1_b2);
|
||||
rb_to.assign(dist_a1_a2, dist_a1_a2);
|
||||
}
|
||||
|
||||
if ((a1_wrt_b < 1 && a2_wrt_b < 1) || (a1_wrt_b > 3 && a2_wrt_b > 3))
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
bool const opposite = dot_n1n2 < c0;
|
||||
|
||||
return Policy::segments_collinear(a, b, opposite,
|
||||
a1_wrt_b, a2_wrt_b, b1_wrt_a, b2_wrt_a,
|
||||
ra_from, ra_to, rb_from, rb_to);
|
||||
}
|
||||
}
|
||||
else // crossing
|
||||
{
|
||||
if (a_is_point || b_is_point)
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
vec3d_t i1;
|
||||
intersection_point_flag ip_flag;
|
||||
calc_t dist_a1_a2, dist_a1_i1, dist_b1_b2, dist_b1_i1;
|
||||
if (calculate_ip_data(a1, a2, b1, b2, a1v, a2v, b1v, b2v, norm1, norm2, sides,
|
||||
i1, dist_a1_a2, dist_a1_i1, dist_b1_b2, dist_b1_i1, ip_flag))
|
||||
{
|
||||
// intersects
|
||||
segment_intersection_info
|
||||
<
|
||||
calc_t,
|
||||
segment_ratio<calc_t>,
|
||||
vec3d_t
|
||||
> sinfo;
|
||||
|
||||
sinfo.robust_ra.assign(dist_a1_i1, dist_a1_a2);
|
||||
sinfo.robust_rb.assign(dist_b1_i1, dist_b1_b2);
|
||||
sinfo.intersection_point = i1;
|
||||
sinfo.ip_flag = ip_flag;
|
||||
|
||||
return Policy::segments_crosses(sides, sinfo, a, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename CalcT, typename Segment, typename Point1, typename Point2, typename Vec3d>
|
||||
static inline return_type collinear_one_degenerted(Segment const& segment, bool degenerated_a,
|
||||
Point1 const& a1, Point1 const& a2,
|
||||
Point2 const& b1, Point2 const& b2,
|
||||
Vec3d const& v1, Vec3d const& v2, Vec3d const& norm,
|
||||
Vec3d const& vother)
|
||||
{
|
||||
CalcT dist_1_2, dist_1_o;
|
||||
return ! calculate_collinear_data(a1, a2, b1, b2, v1, v2, norm, vother, dist_1_2, dist_1_o)
|
||||
? Policy::disjoint()
|
||||
: Policy::one_degenerate(segment, segment_ratio<CalcT>(dist_1_o, dist_1_2), degenerated_a);
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2, typename Vec3d, typename CalcT>
|
||||
static inline bool calculate_collinear_data(Point1 const& a1, Point1 const& a2,
|
||||
Point2 const& b1, Point2 const& b2,
|
||||
Vec3d const& a1v, // in
|
||||
Vec3d const& a2v, // in
|
||||
Vec3d const& norm1, // in
|
||||
Vec3d const& b1v_or_b2v, // in
|
||||
CalcT& dist_a1_a2, CalcT& dist_a1_i1) // out
|
||||
{
|
||||
// calculate dist_a1_a2 and dist_a1_i1
|
||||
calculate_dists(a1v, a2v, norm1, b1v_or_b2v, dist_a1_a2, dist_a1_i1);
|
||||
|
||||
// if i1 is close to a1 and b1 or b2 is equal to a1
|
||||
if (is_endpoint_equal(dist_a1_i1, a1, b1, b2))
|
||||
{
|
||||
dist_a1_i1 = 0;
|
||||
return true;
|
||||
}
|
||||
// or i1 is close to a2 and b1 or b2 is equal to a2
|
||||
else if (is_endpoint_equal(dist_a1_a2 - dist_a1_i1, a2, b1, b2))
|
||||
{
|
||||
dist_a1_i1 = dist_a1_a2;
|
||||
return true;
|
||||
}
|
||||
|
||||
// or i1 is on b
|
||||
return segment_ratio<CalcT>(dist_a1_i1, dist_a1_a2).on_segment();
|
||||
}
|
||||
|
||||
template <typename Point1, typename Point2, typename Vec3d, typename CalcT>
|
||||
static inline bool calculate_ip_data(Point1 const& a1, Point1 const& a2, // in
|
||||
Point2 const& b1, Point2 const& b2, // in
|
||||
Vec3d const& a1v, Vec3d const& a2v, // in
|
||||
Vec3d const& b1v, Vec3d const& b2v, // in
|
||||
Vec3d const& norm1, Vec3d const& norm2, // in
|
||||
side_info const& sides, // in
|
||||
Vec3d & i1, // in-out
|
||||
CalcT& dist_a1_a2, CalcT& dist_a1_i1, // out
|
||||
CalcT& dist_b1_b2, CalcT& dist_b1_i1, // out
|
||||
intersection_point_flag& ip_flag) // out
|
||||
{
|
||||
// great circles intersections
|
||||
i1 = cross_product(norm1, norm2);
|
||||
// NOTE: the length should be greater than 0 at this point
|
||||
// if the normals were not normalized and their dot product
|
||||
// not checked before this function is called the length
|
||||
// should be checked here (math::equals(len, c0))
|
||||
CalcT const len = math::sqrt(dot_product(i1, i1));
|
||||
divide_value(i1, len); // normalize i1
|
||||
|
||||
calculate_dists(a1v, a2v, norm1, i1, dist_a1_a2, dist_a1_i1);
|
||||
|
||||
// choose the opposite side of the globe if the distance is shorter
|
||||
{
|
||||
CalcT const d = abs_distance(dist_a1_a2, dist_a1_i1);
|
||||
if (d > CalcT(0))
|
||||
{
|
||||
CalcT const dist_a1_i2 = dist_of_i2(dist_a1_i1);
|
||||
CalcT const d2 = abs_distance(dist_a1_a2, dist_a1_i2);
|
||||
if (d2 < d)
|
||||
{
|
||||
dist_a1_i1 = dist_a1_i2;
|
||||
multiply_value(i1, CalcT(-1)); // the opposite intersection
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool is_on_a = false, is_near_a1 = false, is_near_a2 = false;
|
||||
if (! is_potentially_crossing(dist_a1_a2, dist_a1_i1, is_on_a, is_near_a1, is_near_a2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
calculate_dists(b1v, b2v, norm2, i1, dist_b1_b2, dist_b1_i1);
|
||||
|
||||
bool is_on_b = false, is_near_b1 = false, is_near_b2 = false;
|
||||
if (! is_potentially_crossing(dist_b1_b2, dist_b1_i1, is_on_b, is_near_b1, is_near_b2))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// reassign the IP if some endpoints overlap
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
if (is_near_a1)
|
||||
{
|
||||
if (is_near_b1 && equals_point_point(a1, b1))
|
||||
{
|
||||
dist_a1_i1 = 0;
|
||||
dist_b1_i1 = 0;
|
||||
//i1 = a1v;
|
||||
ip_flag = ipi_at_a1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_near_b2 && equals_point_point(a1, b2))
|
||||
{
|
||||
dist_a1_i1 = 0;
|
||||
dist_b1_i1 = dist_b1_b2;
|
||||
//i1 = a1v;
|
||||
ip_flag = ipi_at_a1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_near_a2)
|
||||
{
|
||||
if (is_near_b1 && equals_point_point(a2, b1))
|
||||
{
|
||||
dist_a1_i1 = dist_a1_a2;
|
||||
dist_b1_i1 = 0;
|
||||
//i1 = a2v;
|
||||
ip_flag = ipi_at_a2;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_near_b2 && equals_point_point(a2, b2))
|
||||
{
|
||||
dist_a1_i1 = dist_a1_a2;
|
||||
dist_b1_i1 = dist_b1_b2;
|
||||
//i1 = a2v;
|
||||
ip_flag = ipi_at_a2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// at this point we know that the endpoints doesn't overlap
|
||||
// reassign IP and distance if the IP is on a segment and one of
|
||||
// the endpoints of the other segment lies on the former segment
|
||||
if (is_on_a)
|
||||
{
|
||||
if (is_near_b1 && sides.template get<1, 0>() == 0) // b1 wrt a
|
||||
{
|
||||
dist_b1_i1 = 0;
|
||||
//i1 = b1v;
|
||||
ip_flag = ipi_at_b1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_near_b2 && sides.template get<1, 1>() == 0) // b2 wrt a
|
||||
{
|
||||
dist_b1_i1 = dist_b1_b2;
|
||||
//i1 = b2v;
|
||||
ip_flag = ipi_at_b2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_on_b)
|
||||
{
|
||||
if (is_near_a1 && sides.template get<0, 0>() == 0) // a1 wrt b
|
||||
{
|
||||
dist_a1_i1 = 0;
|
||||
//i1 = a1v;
|
||||
ip_flag = ipi_at_a1;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (is_near_a2 && sides.template get<0, 1>() == 0) // a2 wrt b
|
||||
{
|
||||
dist_a1_i1 = dist_a1_a2;
|
||||
//i1 = a2v;
|
||||
ip_flag = ipi_at_a2;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
ip_flag = ipi_inters;
|
||||
|
||||
return is_on_a && is_on_b;
|
||||
}
|
||||
|
||||
template <typename Vec3d, typename CalcT>
|
||||
static inline void calculate_dists(Vec3d const& a1v, // in
|
||||
Vec3d const& a2v, // in
|
||||
Vec3d const& norm1, // in
|
||||
Vec3d const& i1, // in
|
||||
CalcT& dist_a1_a2, CalcT& dist_a1_i1) // out
|
||||
{
|
||||
CalcT const c0 = 0;
|
||||
CalcT const c1 = 1;
|
||||
CalcT const c2 = 2;
|
||||
CalcT const c4 = 4;
|
||||
|
||||
CalcT cos_a1_a2 = dot_product(a1v, a2v);
|
||||
dist_a1_a2 = -cos_a1_a2 + c1; // [1, -1] -> [0, 2] representing [0, pi]
|
||||
|
||||
CalcT cos_a1_i1 = dot_product(a1v, i1);
|
||||
dist_a1_i1 = -cos_a1_i1 + c1; // [0, 2] representing [0, pi]
|
||||
if (dot_product(norm1, cross_product(a1v, i1)) < c0) // left or right of a1 on a
|
||||
{
|
||||
dist_a1_i1 = -dist_a1_i1; // [0, 2] -> [0, -2] representing [0, -pi]
|
||||
}
|
||||
if (dist_a1_i1 <= -c2) // <= -pi
|
||||
{
|
||||
dist_a1_i1 += c4; // += 2pi
|
||||
}
|
||||
}
|
||||
|
||||
// the dist of the ip on the other side of the sphere
|
||||
template <typename CalcT>
|
||||
static inline CalcT dist_of_i2(CalcT const& dist_a1_i1)
|
||||
{
|
||||
CalcT const c2 = 2;
|
||||
CalcT const c4 = 4;
|
||||
|
||||
CalcT dist_a1_i2 = dist_a1_i1 - c2; // dist_a1_i2 = dist_a1_i1 - pi;
|
||||
if (dist_a1_i2 <= -c2) // <= -pi
|
||||
{
|
||||
dist_a1_i2 += c4; // += 2pi;
|
||||
}
|
||||
return dist_a1_i2;
|
||||
}
|
||||
|
||||
template <typename CalcT>
|
||||
static inline CalcT abs_distance(CalcT const& dist_a1_a2, CalcT const& dist_a1_i1)
|
||||
{
|
||||
if (dist_a1_i1 < CalcT(0))
|
||||
return -dist_a1_i1;
|
||||
else if (dist_a1_i1 > dist_a1_a2)
|
||||
return dist_a1_i1 - dist_a1_a2;
|
||||
else
|
||||
return CalcT(0);
|
||||
}
|
||||
|
||||
template <typename CalcT>
|
||||
static inline bool is_potentially_crossing(CalcT const& dist_a1_a2, CalcT const& dist_a1_i1, // in
|
||||
bool& is_on_a, bool& is_near_a1, bool& is_near_a2) // out
|
||||
{
|
||||
is_on_a = segment_ratio<CalcT>(dist_a1_i1, dist_a1_a2).on_segment();
|
||||
is_near_a1 = is_near(dist_a1_i1);
|
||||
is_near_a2 = is_near(dist_a1_a2 - dist_a1_i1);
|
||||
return is_on_a || is_near_a1 || is_near_a2;
|
||||
}
|
||||
|
||||
template <typename CalcT, typename P1, typename P2>
|
||||
static inline bool is_endpoint_equal(CalcT const& dist,
|
||||
P1 const& ai, P2 const& b1, P2 const& b2)
|
||||
{
|
||||
using geometry::detail::equals::equals_point_point;
|
||||
return is_near(dist) && (equals_point_point(ai, b1) || equals_point_point(ai, b2));
|
||||
}
|
||||
|
||||
template <typename CalcT>
|
||||
static inline bool is_near(CalcT const& dist)
|
||||
{
|
||||
CalcT const small_number = CalcT(boost::is_same<CalcT, float>::value ? 0.0001 : 0.00000001);
|
||||
return math::abs(dist) <= small_number;
|
||||
}
|
||||
|
||||
template <typename ProjCoord1, typename ProjCoord2>
|
||||
static inline int position_value(ProjCoord1 const& ca1,
|
||||
ProjCoord2 const& cb1,
|
||||
ProjCoord2 const& cb2)
|
||||
{
|
||||
// S1x 0 1 2 3 4
|
||||
// S2 |---------->
|
||||
return math::equals(ca1, cb1) ? 1
|
||||
: math::equals(ca1, cb2) ? 3
|
||||
: cb1 < cb2 ?
|
||||
( ca1 < cb1 ? 0
|
||||
: ca1 > cb2 ? 4
|
||||
: 2 )
|
||||
: ( ca1 > cb1 ? 0
|
||||
: ca1 < cb2 ? 4
|
||||
: 2 );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
/*template <typename Policy, typename CalculationType>
|
||||
struct default_strategy<spherical_polar_tag, Policy, CalculationType>
|
||||
{
|
||||
typedef relate_spherical_segments<Policy, CalculationType> type;
|
||||
};*/
|
||||
|
||||
template <typename Policy, typename CalculationType>
|
||||
struct default_strategy<spherical_equatorial_tag, Policy, CalculationType>
|
||||
{
|
||||
typedef relate_spherical_segments<Policy, CalculationType> type;
|
||||
};
|
||||
|
||||
template <typename Policy, typename CalculationType>
|
||||
struct default_strategy<geographic_tag, Policy, CalculationType>
|
||||
{
|
||||
typedef relate_spherical_segments<Policy, CalculationType> type;
|
||||
};
|
||||
|
||||
} // namespace services
|
||||
#endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace strategy::intersection
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_INTERSECTION_HPP
|
@ -4,8 +4,8 @@
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2014, 2015.
|
||||
// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014-2016.
|
||||
// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include <boost/geometry/strategies/convex_hull.hpp>
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/strategies/intersection.hpp>
|
||||
#include <boost/geometry/strategies/intersection_strategies.hpp> // for backward compatibility
|
||||
#include <boost/geometry/strategies/side.hpp>
|
||||
#include <boost/geometry/strategies/transform.hpp>
|
||||
#include <boost/geometry/strategies/within.hpp>
|
||||
@ -61,6 +62,7 @@
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
|
||||
#include <boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp>
|
||||
#include <boost/geometry/strategies/spherical/compare_circular.hpp>
|
||||
#include <boost/geometry/strategies/spherical/intersection.hpp>
|
||||
#include <boost/geometry/strategies/spherical/ssf.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/geographic/distance_andoyer.hpp>
|
||||
|
@ -12,8 +12,10 @@ build-project generated ;
|
||||
|
||||
test-suite boost-geometry-index-rtree
|
||||
:
|
||||
[ run rtree_contains_point.cpp ]
|
||||
[ run rtree_epsilon.cpp ]
|
||||
[ run rtree_insert_remove.cpp ]
|
||||
[ run rtree_intersects_geom.cpp ]
|
||||
[ run rtree_move_pack.cpp ]
|
||||
[ run rtree_non_cartesian.cpp ]
|
||||
[ run rtree_values.cpp ]
|
||||
|
45
index/test/rtree/rtree_contains_point.cpp
Normal file
45
index/test/rtree/rtree_contains_point.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
// Boost.Geometry Index
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 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)
|
||||
|
||||
#include <rtree/test_rtree.hpp>
|
||||
|
||||
#include <boost/geometry/index/rtree.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
template <typename Params>
|
||||
void test_one()
|
||||
{
|
||||
typedef bg::model::point<double, 2, bg::cs::cartesian> Pt;
|
||||
typedef bgi::rtree<Pt, Params> Rtree;
|
||||
Rtree rtree;
|
||||
|
||||
rtree.insert(Pt(0, 0));
|
||||
rtree.insert(Pt(1, 1));
|
||||
rtree.insert(Pt(2, 2));
|
||||
rtree.insert(Pt(3, 3));
|
||||
rtree.insert(Pt(4, 4));
|
||||
rtree.insert(Pt(4, 3));
|
||||
rtree.insert(Pt(0, 3));
|
||||
|
||||
for (typename Rtree::const_iterator it = rtree.begin() ; it != rtree.end() ; ++it)
|
||||
{
|
||||
std::vector<Pt> result;
|
||||
rtree.query(bgi::contains(*it), std::back_inserter(result));
|
||||
BOOST_CHECK(result.size() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_one< bgi::linear<4> >();
|
||||
test_one< bgi::quadratic<4> >();
|
||||
test_one< bgi::rstar<4> >();
|
||||
|
||||
return 0;
|
||||
}
|
55
index/test/rtree/rtree_intersects_geom.cpp
Normal file
55
index/test/rtree/rtree_intersects_geom.cpp
Normal file
@ -0,0 +1,55 @@
|
||||
// Boost.Geometry Index
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 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)
|
||||
|
||||
#include <rtree/test_rtree.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
template <typename Value, typename Point, typename Params>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::box<Point> Box;
|
||||
typedef bg::model::segment<Point> Seg;
|
||||
typedef bg::model::ring<Point> Ring;
|
||||
typedef bg::model::polygon<Point> Poly;
|
||||
typedef bg::model::multi_polygon<Poly> MPoly;
|
||||
typedef bg::model::linestring<Point> Ls;
|
||||
typedef bg::model::multi_linestring<Ls> MLs;
|
||||
typedef bg::model::multi_point<Point> MPt;
|
||||
|
||||
bgi::rtree<Value, Params> rt;
|
||||
std::vector<Value> found;
|
||||
|
||||
rt.query(bgi::intersects(Point()), back_inserter(found));
|
||||
rt.query(bgi::intersects(Seg()), back_inserter(found));
|
||||
rt.query(bgi::intersects(Box()), back_inserter(found));
|
||||
rt.query(bgi::intersects(Ring()), back_inserter(found));
|
||||
rt.query(bgi::intersects(Poly()), back_inserter(found));
|
||||
rt.query(bgi::intersects(MPoly()), back_inserter(found));
|
||||
rt.query(bgi::intersects(Ls()), back_inserter(found));
|
||||
rt.query(bgi::intersects(MLs()), back_inserter(found));
|
||||
rt.query(bgi::intersects(MPt()), back_inserter(found));
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
typedef bg::model::d2::point_xy<double> Pt;
|
||||
typedef bg::model::box<Pt> Box;
|
||||
|
||||
test_all< Pt, Pt, bgi::linear<16> >();
|
||||
test_all< Pt, Pt, bgi::quadratic<4> >();
|
||||
test_all< Pt, Pt, bgi::rstar<4> >();
|
||||
|
||||
test_all< Box, Pt, bgi::linear<16> >();
|
||||
test_all< Box, Pt, bgi::quadratic<4> >();
|
||||
test_all< Box, Pt, bgi::rstar<4> >();
|
||||
|
||||
return 0;
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
# This file was modified by Oracle on 2014, 2015, 2016.
|
||||
# Modifications copyright (c) 2014-2016, Oracle and/or its affiliates.
|
||||
#
|
||||
# Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
# Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
|
||||
# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
#
|
||||
@ -36,8 +37,6 @@ test-suite boost-geometry-algorithms
|
||||
[ run is_simple.cpp : : : : algorithms_is_simple ]
|
||||
[ run is_valid.cpp : : : : algorithms_is_valid ]
|
||||
[ run is_valid_failure.cpp : : : : algorithms_is_valid_failure ]
|
||||
[ run length.cpp : : : : algorithms_length ]
|
||||
[ run length_multi.cpp : : : : algorithms_length_multi ]
|
||||
[ run make.cpp : : : : algorithms_make ]
|
||||
[ run maximum_gap.cpp : : : : algorithms_maximum_gap ]
|
||||
[ run num_geometries.cpp : : : : algorithms_num_geometries ]
|
||||
@ -65,6 +64,8 @@ build-project buffer ;
|
||||
build-project detail ;
|
||||
build-project distance ;
|
||||
build-project envelope_expand ;
|
||||
build-project length ;
|
||||
build-project overlay ;
|
||||
build-project perimeter ;
|
||||
build-project relational_operations ;
|
||||
build-project set_operations ;
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -97,6 +101,8 @@ static std::string const mysql_report_2015_09_08a = "LINESTRING(1 1, 2 1, 1.7652
|
||||
static std::string const mysql_report_2015_09_08b = "LINESTRING(2199023255556 16777218, 32770 8194, 1.417733e+308 7.823620e+307, -8 -9, 2147483649 20)";
|
||||
static std::string const mysql_report_2015_09_08c = "LINESTRING(-5 -8, 2 8, 2.160023e+307 1.937208e+307, -4 -3, -5 -4, 8796093022208 281474976710653)";
|
||||
|
||||
static std::string const mysql_23023665 = "LINESTRING(0 0, 0 5, 5 5, 5 0, 0 0)";
|
||||
|
||||
template <bool Clockwise, typename P>
|
||||
void test_all()
|
||||
{
|
||||
@ -279,6 +285,9 @@ void test_all()
|
||||
test_one<linestring, polygon>("mysql_report_2015_09_08a", mysql_report_2015_09_08a, join_round32, end_round32, 0.0, 1.0);
|
||||
test_one<linestring, polygon>("mysql_report_2015_09_08b", mysql_report_2015_09_08b, join_round32, end_round32, 0.0, 1099511627778.0);
|
||||
test_one<linestring, polygon>("mysql_report_2015_09_08c", mysql_report_2015_09_08c, join_round32, end_round32, 0.0, 0xbe);
|
||||
|
||||
test_one<linestring, polygon>("mysql_23023665_1", mysql_23023665, join_round32, end_flat, 459.1051, 10);
|
||||
test_one<linestring, polygon>("mysql_23023665_2", mysql_23023665, join_round32, end_flat, 6877.6941, 50);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -35,6 +39,8 @@ static std::string const mysql_2015_04_10b = "MULTILINESTRING((-58 19, 61 88),
|
||||
static std::string const mysql_2015_09_08a = "MULTILINESTRING((7 -4, -3 -5), (72057594037927936 15, 72057594037927940 70368744177660, 32771 36028797018963964, 8589934589 2305843009213693953, 7 2, 9.300367e+307 9.649737e+307, -4092 -274877906946, 5 10, -3 4))";
|
||||
static std::string const mysql_2015_09_08b = "MULTILINESTRING((-9 -10, 0 -1, 5 -10, -6 7, -7 7, 5.041061e+307 9.926906e+307, 6.870356e+307 1.064454e+307, 35184372088830 288230376151711743, 183673728842483250000000000000000000000.000000 244323751784861950000000000000000000000.000000), (-23530 -7131, -6 1, 1 1, 2 -6, 32766 -4194302, -4 -6), (134217725 0, 50336782742294697000000000000000000000.000000 36696596077212901000000000000000000000.000000, 7434 16486, 3.025467e+307 8.926790e+307), (2147483646 67108868, 71328904281592545000000000000000000000.000000 225041650340452780000000000000000000000.000000, -7 4, 1.667154e+307 3.990414e+307))";
|
||||
|
||||
static std::string const mysql_23023665_1 = "MULTILINESTRING((-5 15, 7 15, 19 -10, -11 -2),(2 13, 2 -9))";
|
||||
|
||||
template <bool Clockwise, typename P>
|
||||
void test_all()
|
||||
{
|
||||
@ -139,6 +145,13 @@ void test_all()
|
||||
mysql_2015_09_08b, join_round32, end_round32,
|
||||
1.32832149026508268e+19, 2061380362.0,
|
||||
same_distance, true, 1.0e12);
|
||||
|
||||
#ifdef BOOST_GEOMETRY_TEST_INCLUDE_FAILING_TESTS
|
||||
test_one<multi_linestring_type, polygon>("mysql_23023665_1",
|
||||
mysql_23023665_1, join_round32, end_round32,
|
||||
1, 1, 186.55043107613727, 1.0,
|
||||
same_distance, true, 1.0e12);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
// Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -342,25 +346,25 @@ void test_all()
|
||||
test_one<multi_polygon_type, polygon_type>("nested_10", nested, join_round, end_flat, 254.279, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_10", nested, join_round, end_flat, 1.721, -1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_25", nested, join_round, end_flat, 355.622, 2.5);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_25", nested, join_round, end_flat, 0, -2.5);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_25", nested, join_round, end_flat, 0.0, -2.5);
|
||||
// 3.0 is exactly touching (for the deflate case)
|
||||
test_one<multi_polygon_type, polygon_type>("nested_30", nested, join_round, end_flat, 392.256, 3.0);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_30", nested, join_round, end_flat, 0, -3.0);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_30", nested, join_round, end_flat, 0.0, -3.0);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_29", nested, join_round, end_flat, 384.803, 2.9);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_29", nested, join_round, end_flat, 0, -2.9);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_29", nested, join_round, end_flat, 0.0, -2.9);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_31", nested, join_round, end_flat, 399.771, 3.1);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_31", nested, join_round, end_flat, 0, -3.1);
|
||||
test_one<multi_polygon_type, polygon_type>("nested_31", nested, join_round, end_flat, 0.0, -3.1);
|
||||
|
||||
test_one<multi_polygon_type, polygon_type>("degenerate0", degenerate0, join_round, end_flat, 0.0, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("degenerate1", degenerate1, join_round, end_flat, 5.708, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("degenerate2", degenerate2, join_round, end_flat, 133.0166, 0.75);
|
||||
|
||||
test_one<multi_polygon_type, polygon_type>("rt_a", rt_a, join_round, end_flat, 34.5381, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_a", rt_a, join_miter, end_flat, 36, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_a", rt_a, join_miter, end_flat, 36.0, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_b", rt_b, join_round, end_flat, 31.4186, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_b", rt_b, join_miter, end_flat, 34, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_b", rt_b, join_miter, end_flat, 34.0, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_c", rt_c, join_round, end_flat, 14.7093, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_c", rt_c, join_miter, end_flat, 16, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_c", rt_c, join_miter, end_flat, 16.0, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_d", rt_d, join_round, end_flat, 18.8726, 0.3);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_e", rt_e, join_round, end_flat, 14.1866, 0.3);
|
||||
|
||||
@ -409,7 +413,7 @@ void test_all()
|
||||
test_one<multi_polygon_type, polygon_type>("rt_p4", rt_p4, join_miter, end_flat, 33.0563, 1.0);
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
|
||||
test_one<multi_polygon_type, polygon_type>("rt_p5", rt_p5, join_miter, end_flat, 17, 1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("rt_p5", rt_p5, join_miter, end_flat, 17.0, 1.0);
|
||||
#endif
|
||||
|
||||
test_one<multi_polygon_type, polygon_type>("rt_p6", rt_p6, join_miter, end_flat, 18.4853, 1.0);
|
||||
@ -487,24 +491,24 @@ void test_all()
|
||||
|
||||
test_one<multi_polygon_type, polygon_type>("neighbouring_small",
|
||||
neighbouring,
|
||||
join_round32, end_round32, 128, -1);
|
||||
join_round32, end_round32, 128.0, -1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("neighbouring_with_holes_small",
|
||||
neighbouring_with_holes,
|
||||
join_round32, end_round32, 97.757, -1);
|
||||
join_round32, end_round32, 97.757, -1.0);
|
||||
test_one<multi_polygon_type, polygon_type>("neighbouring_large",
|
||||
neighbouring,
|
||||
join_round32, end_round32, 0, -10);
|
||||
join_round32, end_round32, 0.0, -10.0);
|
||||
test_one<multi_polygon_type, polygon_type>("neighbouring_with_holes_large",
|
||||
neighbouring_with_holes,
|
||||
join_round32, end_round32, 0, -10);
|
||||
join_round32, end_round32, 0.0, -10.0);
|
||||
|
||||
test_one<multi_polygon_type, polygon_type>("mysql_report_2015_07_05_1",
|
||||
mysql_report_2015_07_05_1,
|
||||
join_round32, end_round32, 6.04454566324708726e+23, 5526,
|
||||
join_round32, end_round32, 6.04454566324708726e+23, 5526.0,
|
||||
same_distance, false, 1e+020);
|
||||
test_one<multi_polygon_type, polygon_type>("mysql_report_2015_07_05_2",
|
||||
mysql_report_2015_07_05_2,
|
||||
join_round32, end_round32, 0, 948189399);
|
||||
join_round32, end_round32, 0.0, 948189399.0);
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
|
@ -3,6 +3,10 @@
|
||||
|
||||
// Copyright (c) 2012-2014 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -350,13 +354,13 @@ void test_all()
|
||||
test_one<polygon_type, polygon_type>("snake16", snake, join_miter, end_flat, 114.24, 1.6);
|
||||
#endif
|
||||
|
||||
test_one<polygon_type, polygon_type>("funnelgate2", funnelgate, join_miter, end_flat, 120.982, 2);
|
||||
test_one<polygon_type, polygon_type>("funnelgate3", funnelgate, join_miter, end_flat, 13*13, 3);
|
||||
test_one<polygon_type, polygon_type>("funnelgate4", funnelgate, join_miter, end_flat, 15*15, 4);
|
||||
test_one<polygon_type, polygon_type>("gammagate1", gammagate, join_miter, end_flat, 88, 1);
|
||||
test_one<polygon_type, polygon_type>("fork_a1", fork_a, join_miter, end_flat, 88, 1);
|
||||
test_one<polygon_type, polygon_type>("fork_b1", fork_b, join_miter, end_flat, 154, 1);
|
||||
test_one<polygon_type, polygon_type>("fork_c1", fork_c, join_miter, end_flat, 152, 1);
|
||||
test_one<polygon_type, polygon_type>("funnelgate2", funnelgate, join_miter, end_flat, 120.982, 2.0);
|
||||
test_one<polygon_type, polygon_type>("funnelgate3", funnelgate, join_miter, end_flat, 13.0*13.0, 3.0);
|
||||
test_one<polygon_type, polygon_type>("funnelgate4", funnelgate, join_miter, end_flat, 15.0*15.0, 4.0);
|
||||
test_one<polygon_type, polygon_type>("gammagate1", gammagate, join_miter, end_flat, 88.0, 1.0);
|
||||
test_one<polygon_type, polygon_type>("fork_a1", fork_a, join_miter, end_flat, 88.0, 1.0);
|
||||
test_one<polygon_type, polygon_type>("fork_b1", fork_b, join_miter, end_flat, 154.0, 1.0);
|
||||
test_one<polygon_type, polygon_type>("fork_c1", fork_c, join_miter, end_flat, 152.0, 1.0);
|
||||
test_one<polygon_type, polygon_type>("triangle", triangle, join_miter, end_flat, 14.6569, 1.0);
|
||||
|
||||
test_one<polygon_type, polygon_type>("degenerate0", degenerate0, join_round, end_round, 0.0, 1.0);
|
||||
@ -364,7 +368,7 @@ void test_all()
|
||||
test_one<polygon_type, polygon_type>("degenerate2", degenerate2, join_round, end_round, 3.1389, 1.0);
|
||||
test_one<polygon_type, polygon_type>("degenerate3", degenerate3, join_round, end_round, 143.1395, 1.0);
|
||||
|
||||
test_one<polygon_type, polygon_type>("gammagate2", gammagate, join_miter, end_flat, 130, 2);
|
||||
test_one<polygon_type, polygon_type>("gammagate2", gammagate, join_miter, end_flat, 130.0, 2.0);
|
||||
|
||||
test_one<polygon_type, polygon_type>("flower1", flower, join_miter, end_flat, 67.614, 0.1);
|
||||
test_one<polygon_type, polygon_type>("flower20", flower, join_miter, end_flat, 74.894, 0.20);
|
||||
@ -548,41 +552,41 @@ void test_all()
|
||||
join_round32, end_round32, 48.879, -1);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_02_17_1_d5",
|
||||
mysql_report_2015_02_17_1,
|
||||
join_round32, end_round32, 0, -5);
|
||||
join_round32, end_round32, 0.0, -5.0);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_02_17_1_d6",
|
||||
mysql_report_2015_02_17_1,
|
||||
join_round32, end_round32, 0, -6);
|
||||
join_round32, end_round32, 0.0, -6.0);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_02_17_1_d10",
|
||||
mysql_report_2015_02_17_1,
|
||||
join_round32, end_round32, 0, -10);
|
||||
join_round32, end_round32, 0.0, -10.0);
|
||||
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_02_17_2_d1",
|
||||
mysql_report_2015_02_17_2,
|
||||
join_round32, end_round32, 64, -1);
|
||||
join_round32, end_round32, 64.0, -1.0);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_02_17_2_d10",
|
||||
mysql_report_2015_02_17_2,
|
||||
join_round32, end_round32, 0, -10);
|
||||
join_round32, end_round32, 0.0, -10.0);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_02_17_3_d1",
|
||||
mysql_report_2015_02_17_3,
|
||||
join_round32, end_round32, 64, -1);
|
||||
join_round32, end_round32, 64.0, -1.0);
|
||||
|
||||
{
|
||||
double high_tolerance = 1.0e+20;
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_0", mysql_report_2015_07_05_0,
|
||||
join_round32, end_round32, 700643542.242915988, 6);
|
||||
join_round32, end_round32, 700643542.242915988, 6.0);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_1", mysql_report_2015_07_05_1,
|
||||
join_round32, end_round32, 2.07548405999982264e+19, 6);
|
||||
join_round32, end_round32, 2.07548405999982264e+19, 6.0);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_2", mysql_report_2015_07_05_2,
|
||||
join_round32, end_round32, 9.48681585720922691e+23, 549755813889,
|
||||
join_round32, end_round32, 9.48681585720922691e+23, 549755813889.0,
|
||||
same_distance, true, high_tolerance);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_3", mysql_report_2015_07_05_3,
|
||||
join_round32, end_round32, 6.10005339242509925e+22, 49316,
|
||||
join_round32, end_round32, 6.10005339242509925e+22, 49316.0,
|
||||
same_distance, false, high_tolerance);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_4", mysql_report_2015_07_05_4,
|
||||
join_round32, end_round32, 4.25405937213774089e+23, 1479986,
|
||||
join_round32, end_round32, 4.25405937213774089e+23, 1479986.0,
|
||||
same_distance, false, high_tolerance);
|
||||
test_one<polygon_type, polygon_type>("mysql_report_2015_07_05_5", mysql_report_2015_07_05_5,
|
||||
join_round32, end_round32, 644489321051.62439, 38141,
|
||||
join_round32, end_round32, 644489321051.62439, 38141.0,
|
||||
same_distance, false, 10000.0);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,11 @@
|
||||
// Unit Test Helper
|
||||
|
||||
// Copyright (c) 2010-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -30,6 +35,7 @@
|
||||
#include <boost/geometry/algorithms/intersects.hpp>
|
||||
#include <boost/geometry/algorithms/is_empty.hpp>
|
||||
#include <boost/geometry/algorithms/is_valid.hpp>
|
||||
#include <boost/geometry/algorithms/num_interior_rings.hpp>
|
||||
#include <boost/geometry/algorithms/union.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/overlay/debug_turn_info.hpp>
|
||||
@ -128,7 +134,10 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
|
||||
DistanceStrategy const& distance_strategy,
|
||||
SideStrategy const& side_strategy,
|
||||
PointStrategy const& point_strategy,
|
||||
bool check_self_intersections, double expected_area,
|
||||
bool check_self_intersections,
|
||||
int expected_count,
|
||||
int expected_holes_count,
|
||||
double expected_area,
|
||||
double tolerance,
|
||||
std::size_t* self_ip_count)
|
||||
{
|
||||
@ -262,6 +271,29 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
|
||||
// std::cout << "OUTPUT env: " << bg::wkt(envelope_output) << std::endl;
|
||||
// std::cout << bg::wkt(buffered) << std::endl;
|
||||
|
||||
if (expected_count >= 0)
|
||||
{
|
||||
BOOST_CHECK_MESSAGE
|
||||
(
|
||||
int(buffered.size()) == expected_count,
|
||||
"#outputs not as expected."
|
||||
<< " Expected: " << expected_count
|
||||
<< " Detected: " << buffered.size()
|
||||
);
|
||||
}
|
||||
|
||||
if (expected_holes_count >= 0)
|
||||
{
|
||||
std::size_t nholes = bg::num_interior_rings(buffered);
|
||||
BOOST_CHECK_MESSAGE
|
||||
(
|
||||
int(nholes) == expected_holes_count,
|
||||
"#holes not as expected."
|
||||
<< " Expected: " << expected_holes_count
|
||||
<< " Detected: " << nholes
|
||||
);
|
||||
}
|
||||
|
||||
if (expected_area > -0.1)
|
||||
{
|
||||
double const difference = area - expected_area;
|
||||
@ -352,6 +384,31 @@ void test_buffer(std::string const& caseid, Geometry const& geometry,
|
||||
}
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename GeometryOut,
|
||||
typename JoinStrategy,
|
||||
typename EndStrategy,
|
||||
typename DistanceStrategy,
|
||||
typename SideStrategy,
|
||||
typename PointStrategy,
|
||||
typename Geometry
|
||||
>
|
||||
void test_buffer(std::string const& caseid, Geometry const& geometry,
|
||||
JoinStrategy const& join_strategy,
|
||||
EndStrategy const& end_strategy,
|
||||
DistanceStrategy const& distance_strategy,
|
||||
SideStrategy const& side_strategy,
|
||||
PointStrategy const& point_strategy,
|
||||
bool check_self_intersections,
|
||||
double expected_area,
|
||||
double tolerance,
|
||||
std::size_t* self_ip_count)
|
||||
{
|
||||
test_buffer<GeometryOut>(caseid, geometry,
|
||||
join_strategy, end_strategy, distance_strategy, side_strategy, point_strategy,
|
||||
check_self_intersections, -1, -1, expected_area, tolerance, self_ip_count);
|
||||
}
|
||||
|
||||
#ifdef BOOST_GEOMETRY_CHECK_WITH_POSTGIS
|
||||
static int counter = 0;
|
||||
@ -366,7 +423,7 @@ template
|
||||
>
|
||||
void test_one(std::string const& caseid, std::string const& wkt,
|
||||
JoinStrategy const& join_strategy, EndStrategy const& end_strategy,
|
||||
double expected_area,
|
||||
int expected_count, int expected_holes_count, double expected_area,
|
||||
double distance_left, double distance_right = same_distance,
|
||||
bool check_self_intersections = true,
|
||||
double tolerance = 0.01)
|
||||
@ -404,7 +461,8 @@ void test_one(std::string const& caseid, std::string const& wkt,
|
||||
(caseid, g,
|
||||
join_strategy, end_strategy,
|
||||
distance_strategy, side_strategy, circle_strategy,
|
||||
check_self_intersections, expected_area,
|
||||
check_self_intersections,
|
||||
expected_count, expected_holes_count, expected_area,
|
||||
tolerance, NULL);
|
||||
|
||||
#if !defined(BOOST_GEOMETRY_COMPILER_MODE_DEBUG) && defined(BOOST_GEOMETRY_COMPILER_MODE_RELEASE)
|
||||
@ -422,13 +480,33 @@ void test_one(std::string const& caseid, std::string const& wkt,
|
||||
(caseid + "_sym", g,
|
||||
join_strategy, end_strategy,
|
||||
sym_distance_strategy, side_strategy, circle_strategy,
|
||||
check_self_intersections, expected_area,
|
||||
check_self_intersections,
|
||||
expected_count, expected_holes_count, expected_area,
|
||||
tolerance, NULL);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
template
|
||||
<
|
||||
typename Geometry,
|
||||
typename GeometryOut,
|
||||
typename JoinStrategy,
|
||||
typename EndStrategy
|
||||
>
|
||||
void test_one(std::string const& caseid, std::string const& wkt,
|
||||
JoinStrategy const& join_strategy, EndStrategy const& end_strategy,
|
||||
double expected_area,
|
||||
double distance_left, double distance_right = same_distance,
|
||||
bool check_self_intersections = true,
|
||||
double tolerance = 0.01)
|
||||
{
|
||||
test_one<Geometry, GeometryOut>(caseid, wkt, join_strategy, end_strategy,
|
||||
-1 ,-1, expected_area,
|
||||
distance_left, distance_right, check_self_intersections, tolerance);
|
||||
}
|
||||
|
||||
// Version (currently for the Aimes test) counting self-ip's instead of checking
|
||||
template
|
||||
<
|
||||
|
17
test/algorithms/length/Jamfile.v2
Normal file
17
test/algorithms/length/Jamfile.v2
Normal file
@ -0,0 +1,17 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
#
|
||||
# Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
#
|
||||
# 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)
|
||||
|
||||
test-suite boost-geometry-algorithms-length
|
||||
:
|
||||
[ run length.cpp : : : : algorithms_length ]
|
||||
[ run length_multi.cpp : : : : algorithms_length_multi ]
|
||||
[ run length_sph.cpp : : : : algorithms_length_sph ]
|
||||
[ run length_geo.cpp : : : : algorithms_length_geo ]
|
||||
;
|
121
test/algorithms/length/length_geo.cpp
Normal file
121
test/algorithms/length/length_geo.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include <algorithms/test_length.hpp>
|
||||
#include <algorithms/length/linestring_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/adapted/std_pair_as_segment.hpp>
|
||||
|
||||
#include <test_geometries/all_custom_linestring.hpp>
|
||||
#include <test_geometries/wrapped_boost_array.hpp>
|
||||
|
||||
template <typename P>
|
||||
struct geo_strategies
|
||||
{
|
||||
// Set radius type, but for integer coordinates we want to have floating
|
||||
// point radius type
|
||||
typedef typename bg::promote_floating_point
|
||||
<
|
||||
typename bg::coordinate_type<P>::type
|
||||
>::type rtype;
|
||||
|
||||
typedef bg::srs::spheroid<rtype> stype;
|
||||
typedef bg::strategy::distance::andoyer<stype> andoyer_type;
|
||||
typedef bg::strategy::distance::thomas<stype> thomas_type;
|
||||
typedef bg::strategy::distance::vincenty<stype> vincenty_type;
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
void test_default() //this should use andoyer strategy
|
||||
{
|
||||
for(std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::linestring<P> >(Ls_data_geo[i],
|
||||
1116814.237 + 1116152.605);
|
||||
}
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0);
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0);
|
||||
}
|
||||
|
||||
template <typename P, typename N, typename Strategy>
|
||||
void test_with_strategy(N exp_length, Strategy strategy)
|
||||
{
|
||||
for(std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::linestring<P> >(Ls_data_geo[i],
|
||||
exp_length,
|
||||
strategy);
|
||||
}
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0, strategy);
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0,
|
||||
strategy);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_andoyer()
|
||||
{
|
||||
typename geo_strategies<P>::andoyer_type andoyer;
|
||||
test_with_strategy<P>(1116814.237 + 1116152.605, andoyer);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_thomas()
|
||||
{
|
||||
typename geo_strategies<P>::thomas_type thomas;
|
||||
test_with_strategy<P>(1116825.795 + 1116158.7417, thomas);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_vincenty()
|
||||
{
|
||||
typename geo_strategies<P>::vincenty_type vincenty;
|
||||
test_with_strategy<P>(1116828.8624 + 1116161.625, vincenty);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_default<P>();
|
||||
test_andoyer<P>();
|
||||
test_thomas<P>();
|
||||
test_vincenty<P>();
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_empty_input()
|
||||
{
|
||||
test_empty_input(bg::model::linestring<P>());
|
||||
test_empty_input(bg::model::multi_linestring<P>());
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
// Works only for double(?!)
|
||||
//test_all<bg::model::d2::point_xy<int,
|
||||
// bg::cs::geographic<bg::degree> > >();
|
||||
//test_all<bg::model::d2::point_xy<float,
|
||||
// bg::cs::geographic<bg::degree> > >();
|
||||
test_all<bg::model::d2::point_xy<double,
|
||||
bg::cs::geographic<bg::degree> > >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
//test_empty_input<bg::model::d2::point_xy<double,
|
||||
// bg::cs::geographic<bg::degree> > >();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
@ -19,6 +18,12 @@ void test_all()
|
||||
("MULTILINESTRING((0 0,3 4,4 3))", 5 + sqrt(2.0));
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_empty_input()
|
||||
{
|
||||
test_empty_input(bg::model::multi_linestring<P>());
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
@ -27,5 +32,7 @@ int test_main( int , char* [] )
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
// test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
87
test/algorithms/length/length_sph.cpp
Normal file
87
test/algorithms/length/length_sph.cpp
Normal file
@ -0,0 +1,87 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include <algorithms/test_length.hpp>
|
||||
#include <algorithms/length/linestring_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/adapted/std_pair_as_segment.hpp>
|
||||
|
||||
#include <test_geometries/all_custom_linestring.hpp>
|
||||
#include <test_geometries/wrapped_boost_array.hpp>
|
||||
|
||||
template <typename P>
|
||||
void test_all_default() //test the default strategy
|
||||
{
|
||||
double const pi = boost::math::constants::pi<double>();
|
||||
|
||||
for(std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::linestring<P> >(Ls_data_sph[i], 2 * pi);
|
||||
}
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0);
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))", 0);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all_haversine(double const mean_radius)
|
||||
{
|
||||
double const pi = boost::math::constants::pi<double>();
|
||||
bg::strategy::distance::haversine<float> haversine_strategy(mean_radius);
|
||||
|
||||
for(std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::linestring<P> >(Ls_data_sph[i],
|
||||
2 * pi * mean_radius,
|
||||
haversine_strategy);
|
||||
}
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0, haversine_strategy);
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,0 1,1 1,1 0,0 0))",
|
||||
0, haversine_strategy);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_empty_input()
|
||||
{
|
||||
test_empty_input(bg::model::linestring<P>());
|
||||
test_empty_input(bg::model::multi_linestring<P>());
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
//Earth radius estimation in Km
|
||||
//(see https://en.wikipedia.org/wiki/Earth_radius)
|
||||
double const mean_radius = 6371.0;
|
||||
|
||||
test_all_default<bg::model::d2::point_xy<int,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
test_all_default<bg::model::d2::point_xy<float,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
test_all_default<bg::model::d2::point_xy<double,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
|
||||
test_all_haversine<bg::model::d2::point_xy<int,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
|
||||
test_all_haversine<bg::model::d2::point_xy<float,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
|
||||
test_all_haversine<bg::model::d2::point_xy<double,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
//test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
17
test/algorithms/length/linestring_cases.hpp
Normal file
17
test/algorithms/length/linestring_cases.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef LINESTRING_CASES_HPP
|
||||
#define LINESTRING_CASES_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
static std::string Ls_data_geo[] = {"LINESTRING(0 90,1 80,1 70)",
|
||||
"LINESTRING(0 90,1 80,1 80,1 80,1 70,1 70)",
|
||||
"LINESTRING(0 90,1 80,1 79,1 78,1 77,1 76,1 75,1 74,\
|
||||
1 73,1 72,1 71,1 70)"};
|
||||
|
||||
static std::string Ls_data_sph[] = {"LINESTRING(0 0,180 0,180 180)",
|
||||
"LINESTRING(0 0,180 0,180 0,180 0,180 180,180 180)",
|
||||
"LINESTRING(0 0,180 0,180 10,180 20,180 30,180 40,180 50,180 60,\
|
||||
180 70,180 80,180 90,180 100,180 110,180 120,180 130,\
|
||||
180 140,180 150,180 160,180 170,180 180)"};
|
||||
|
||||
#endif // LINESTRING_CASES_HPP
|
@ -4,8 +4,8 @@
|
||||
# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
#
|
||||
# This file was modified by Oracle on 2014, 2015.
|
||||
# Modifications copyright (c) 2014-2015 Oracle and/or its affiliates.
|
||||
# This file was modified by Oracle on 2014, 2015, 2016.
|
||||
# Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
|
||||
#
|
||||
# Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
#
|
||||
@ -15,17 +15,21 @@
|
||||
|
||||
test-suite boost-geometry-algorithms-overlay
|
||||
:
|
||||
[ run assemble.cpp : : : : algorithms_assemble ]
|
||||
[ run get_turn_info.cpp : : : : algorithms_get_turn_info ]
|
||||
[ run get_turns.cpp : : : : algorithms_get_turns ]
|
||||
[ run get_turns_areal_areal.cpp : : : : algorithms_get_turns_areal_areal ]
|
||||
[ run get_turns_linear_areal.cpp : : : : algorithms_get_turns_linear_areal ]
|
||||
[ run get_turns_linear_linear.cpp : : : : algorithms_get_turns_linear_linear ]
|
||||
[ run overlay.cpp : : : : algorithms_overlay ]
|
||||
[ run relative_order.cpp : : : : algorithms_relative_order ]
|
||||
[ run select_rings.cpp : : : : algorithms_select_rings ]
|
||||
[ run self_intersection_points.cpp : : : : algorithms_self_intersection_points ]
|
||||
#[ run traverse.cpp : : : : algorithms_traverse ]
|
||||
#[ run traverse_ccw.cpp : : : : algorithms_traverse_ccw ]
|
||||
#[ run traverse_multi.cpp : : : : algorithms_traverse_multi ]
|
||||
[ run assemble.cpp : : : : algorithms_assemble ]
|
||||
[ run get_turn_info.cpp : : : : algorithms_get_turn_info ]
|
||||
[ run get_turns.cpp : : : : algorithms_get_turns ]
|
||||
[ run get_turns_areal_areal.cpp : : : : algorithms_get_turns_areal_areal ]
|
||||
[ run get_turns_areal_areal_sph.cpp : : : : algorithms_get_turns_areal_areal_sph ]
|
||||
[ run get_turns_linear_areal.cpp : : : : algorithms_get_turns_linear_areal ]
|
||||
[ run get_turns_linear_areal_sph.cpp : : : : algorithms_get_turns_linear_areal_sph ]
|
||||
[ run get_turns_linear_linear.cpp : : : : algorithms_get_turns_linear_linear ]
|
||||
[ run get_turns_linear_linear_sph.cpp : : : : algorithms_get_turns_linear_linear_sph ]
|
||||
[ run overlay.cpp : : : : algorithms_overlay ]
|
||||
#[ run handle_touch.cpp : : : : algorithms_handle_touch ]
|
||||
[ run relative_order.cpp : : : : algorithms_relative_order ]
|
||||
[ run select_rings.cpp : : : : algorithms_select_rings ]
|
||||
[ run self_intersection_points.cpp : : : : algorithms_self_intersection_points ]
|
||||
#[ run traverse.cpp : : : : algorithms_traverse ]
|
||||
#[ run traverse_ccw.cpp : : : : algorithms_traverse_ccw ]
|
||||
#[ run traverse_multi.cpp : : : : algorithms_traverse_multi ]
|
||||
;
|
||||
|
@ -35,13 +35,13 @@ void test_all()
|
||||
// cw(duplicated point)
|
||||
test_geometry<poly, poly>("POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))",
|
||||
"POLYGON((-7901 -1485,-7901 529,-7901 529, 15802 544, 15802 -1485, -7901 -1485))",
|
||||
expected_pusher<0>()("iiu")("iui")("mcc")("cui"));
|
||||
expected("iiu")("iui")("mcc")("cui"));
|
||||
//to_svg<poly, poly>("POLYGON((-8042 -1485,-8042 250,15943 254,15943 -1485,-8042 -1485))",
|
||||
// "POLYGON((-7901 -1485,-7901 529,15802 544, 15802 -1485, -7901 -1485))",
|
||||
// "poly_poly_1.svg");
|
||||
test_geometry<poly, poly>("POLYGON((-7901 -1485,-7901 529,-7901 529, 15802 544, 15802 -1485, -7901 -1485))",
|
||||
"POLYGON((-8042 -1485,-8042 250,-8042 250,15943 254,15943 -1485,-8042 -1485))",
|
||||
expected_pusher<0>()("iui")("iiu")("mcc")("ciu"));
|
||||
expected("iui")("iiu")("mcc")("ciu"));
|
||||
}
|
||||
}
|
||||
|
||||
|
80
test/algorithms/overlay/get_turns_areal_areal_sph.cpp
Normal file
80
test/algorithms/overlay/get_turns_areal_areal_sph.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
// Boost.Geometry
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016, Oracle and/or its affiliates.
|
||||
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
|
||||
#include "test_get_turns.hpp"
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <algorithms/overlay/overlay_cases.hpp>
|
||||
|
||||
|
||||
template <typename T>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::point<T, 2, bg::cs::spherical_equatorial<bg::degree> > pt;
|
||||
//typedef bg::model::ring<pt> ring;
|
||||
typedef bg::model::polygon<pt> poly;
|
||||
//typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<poly, poly>(case_1[0], case_1[1],
|
||||
expected("iiu")("iui")("iiu")("iui")("iiu")("iui"));
|
||||
test_geometry<poly, poly>(case_2[0], case_2[1],
|
||||
expected("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu"));
|
||||
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
|
||||
expected("miu")("miu")("miu")("miu"));
|
||||
test_geometry<poly, poly>(case_4[0], case_4[1],
|
||||
expected("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui"));
|
||||
test_geometry<poly, poly>(case_5[0], case_5[1],
|
||||
expected("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui"));
|
||||
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
|
||||
expected("ccc")("eui")("mcc"));
|
||||
|
||||
test_geometry<poly, poly>(case_7[0], case_7[1],
|
||||
expected("txu")("tux"));
|
||||
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
|
||||
expected("mux")("cxu"));
|
||||
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
|
||||
expected("muu"));
|
||||
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
|
||||
expected("cxu")("mux")("txx"));
|
||||
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
|
||||
expected("mui"));
|
||||
test_geometry<poly, poly>(case_12[0], case_12[1],
|
||||
expected("iiu")("iui")("iiu")("iui")("iiu")("iui")("iiu")("iui"));
|
||||
|
||||
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
|
||||
expected("mxu")("mux"));
|
||||
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
|
||||
expected("cxu")("mux"));
|
||||
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
|
||||
expected("cxu")("mux"));
|
||||
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
|
||||
expected("txx")("txx")("tux")("cxu"));
|
||||
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
|
||||
expected("mcc")("cui"));
|
||||
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
|
||||
expected("mcc")("ccc")("ccc")("cui"));
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<float>();
|
||||
test_all<double>();
|
||||
|
||||
//#if ! defined(_MSC_VER)
|
||||
// test_all<long double>();
|
||||
//#endif
|
||||
|
||||
//#if defined(HAVE_TTMATH)
|
||||
// test_all<ttmath_big>();
|
||||
//#endif
|
||||
return 0;
|
||||
}
|
241
test/algorithms/overlay/get_turns_linear_areal_sph.cpp
Normal file
241
test/algorithms/overlay/get_turns_linear_areal_sph.cpp
Normal file
@ -0,0 +1,241 @@
|
||||
// Boost.Geometry
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
|
||||
#include "test_get_turns.hpp"
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
|
||||
template <typename T>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::point<T, 2, bg::cs::spherical_equatorial<bg::degree> > pt;
|
||||
typedef bg::model::linestring<pt> ls;
|
||||
typedef bg::model::polygon<pt> poly;
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(15 5,24 5,20 2,19 0,13 -4,1 0,10 0,13 3.0027386970408236,15 7,16 10.096620161421658,10 10.151081711048134,8 10.145026423873857,4 6.0128694190616088,2 8.0210217579873273,1 10.028657322246225)",
|
||||
"POLYGON((0 0,5 5,0 10,20 10,20 2,19 0,0 0)(10 3,15 3,15 7,10 7,10 3))",
|
||||
expected("miu+")("iuu+")("tcc+")("tuu=")("mcu+")("mic=")("muu+")
|
||||
("tiu+")("mcu+")("mic=")("mcc+")("miu=")("mxu+"));
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
"miu+", "mxu+");
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,5 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
"tiu+", "txu+");
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,5 0,5 5,10 5,10 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
expected("tcu+")("mic=")("mcc+")("txu="));
|
||||
test_geometry<ls, poly>("LINESTRING(10 0,5 0,5 5,10 5,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
expected("tcc+")("miu=")("mcu+")("txc="));
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10.151081711048134)",
|
||||
"POLYGON((0 0,5 5,0 10,20 10,20 2,19 0,0 0)(10 3,15 3,15 7,10 7,10 3))",
|
||||
expected("tcu+")("mic=")("mcu+")("mic=")("mxu+"));
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(11 1,10 0,0 0)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
"tcc+", "txu=");
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 0,11 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
"tcu+", "tuc=");
|
||||
test_geometry<ls, poly>("LINESTRING(10 0,0 0,-1 1)", "POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
"tcc+", "tuu=");
|
||||
|
||||
// true hole
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 5,10 0,0 0)(2 2,10 5,2 8,2 2))",
|
||||
expected("tiu+")("tiu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 5,10 0,0 0)(2 2,10 5,2 8,2 2))",
|
||||
expected("mcu+")("ecc=")("tiu+")("mxc="));
|
||||
|
||||
// fake hole
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
|
||||
expected("tuu+")("tiu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(10 1,10 5,10 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 5,2 8,2 2,10 5,10 0,0 0))",
|
||||
expected("mcu+")("tuc=")("tcu+")("mxc="));
|
||||
|
||||
// true hole
|
||||
test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 2)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
expected("mcu+")("mic=")("tcu+")("txc="));
|
||||
test_geometry<ls, poly>("LINESTRING(10 1,10 5,2 8)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
expected("mcu+")("mic=")("tcc+")("txu="));
|
||||
|
||||
// SPIKE - NON-ENDPOINT - NON-OPPOSITE
|
||||
|
||||
// spike - neq eq
|
||||
test_geometry<ls, poly>("LINESTRING(2 2.0036594926050877,4 4,1 1.0022887548647630)",
|
||||
"POLYGON((0 0,4 4,6 3,6 0,0 0))",
|
||||
expected("mcc+")("txu=")("tcu=")("mxc="));
|
||||
// spike - eq eq
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,4 4,1 1.0022887548647630)",
|
||||
"POLYGON((0 0,4 4,6 3,6 0,0 0))",
|
||||
expected("tcc+")("txu=")("tcu=")("mxc="));
|
||||
// spike - eq neq
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,3 3.0031983963093536,1 1.0022887548647630)",
|
||||
"POLYGON((0 0,4 4,6 3,6 0,0 0))",
|
||||
expected("tcc+")("mxu=")("mcu=")("mxc="));
|
||||
// spike - neq neq
|
||||
test_geometry<ls, poly>("LINESTRING(1 1.0022887548647630,3 3.0031983963093536,2 2.0036594926050877)",
|
||||
"POLYGON((0 0,4 4,6 3,6 0,0 0))",
|
||||
expected("mcc+")("mxu=")("mcu=")("mxc="));
|
||||
// spike - out neq
|
||||
test_geometry<ls, poly>("LINESTRING(0 -0.0030515201230775146,3 3.0024370300767784,2 2.0021346673827409)",
|
||||
"POLYGON((1 1,4 4,6 3,6 0,1 1))",
|
||||
expected("mcc+")("mxu=")("mcu=")("mxc="));
|
||||
// spike - out eq
|
||||
test_geometry<ls, poly>("LINESTRING(0 -0.0030515201230775146,4 4,2 2.0021346673827409)",
|
||||
"POLYGON((1 1,4 4,6 3,6 0,1 1))",
|
||||
expected("mcc+")("txu=")("tcu=")("mxc="));
|
||||
// spike - out out/eq
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2.0036594926050877)",
|
||||
"POLYGON((1 0,4 4,6 3,1 0))",
|
||||
expected("tuu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2.0036594926050877)",
|
||||
"POLYGON((0 1,4 4,6 3,6 0,-1 -1,0 1))",
|
||||
expected("tiu+"));
|
||||
// spike - out out/neq
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,4 4,2 2.0036594926050877)",
|
||||
"POLYGON((4 0,4 5,6 3,4 0))",
|
||||
expected("muu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,4 4.0024308111527205,2 2.0048800944714089)",
|
||||
"POLYGON((0 4,5 4,6 3,6 0,-1 -1,0 4))",
|
||||
expected("miu+"));
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(0 1,1 1.0012195839797347,0 1)",
|
||||
"POLYGON((0 0,3 3,3 0,0 0))",
|
||||
expected("muu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(0 1,3 3,0 1)",
|
||||
"POLYGON((0 0,3 3,3 0,0 0))",
|
||||
expected("tuu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(0 1,0 0,0 1)",
|
||||
"POLYGON((0 0,3 3,3 0,0 0))",
|
||||
expected("tuu+"));
|
||||
|
||||
// SPIKE - NON-ENDPOINT - OPPOSITE
|
||||
|
||||
// opposite - eq eq
|
||||
test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
|
||||
"POLYGON((-1 -1,0 0,4 4,6 3,-1 -1))",
|
||||
expected("tcu+")("txc=")("tcc=")("mxu="));
|
||||
// opposite - neq eq
|
||||
test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
|
||||
"POLYGON((-1 -1,0 0,5 4.9931712414532354,6 3,-1 -1))",
|
||||
expected("mcu+")("txc=")("tcc=")("mxu="));
|
||||
// opposite - eq, neq
|
||||
test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
|
||||
"POLYGON((-2 -2,-1 -1.0022887548647628,4 4,6 3,-2 -2))",
|
||||
expected("tcu+")("mxc=")("mcc=")("mxu="));
|
||||
// opposite - neq neq
|
||||
test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
|
||||
"POLYGON((-2 -2,-1 -1.0022887548647628,3 3.0031983963093536,6 3,-2 -2))",
|
||||
expected("mcu+")("mxc=")("mcc=")("mxu="));
|
||||
// opposite - neq neq
|
||||
test_geometry<ls, poly>("LINESTRING(6 6,4 4,0 0,2 2.0036594926050877)",
|
||||
"POLYGON((-2 -2,-1 -1.0022887548647628,3 3.0031983963093536,5 4.9931712414532354,6 3,-2 -2))",
|
||||
expected("mcu+")("mxc=")("mcc=")("mxu="));
|
||||
|
||||
// spike vs internal
|
||||
test_geometry<ls, poly>("LINESTRING(0 1,1 1,0 1)", // --
|
||||
"POLYGON((1 0,1 1,2 1,1 0))",
|
||||
expected("tuu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(1 2,1 1,1 2)", // |
|
||||
"POLYGON((1 0,1 1,2 1,1 0))",
|
||||
expected("tuu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(0 2,1 1,0 2)", // \ (avoid multi-line comment)
|
||||
"POLYGON((1 0,1 1,2 1,1 0))",
|
||||
expected("tuu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(2 0,1 1,2 0)", // \ (avoid multi-line comment)
|
||||
"POLYGON((1 0,1 1,2 1,2 0,1 0))",
|
||||
expected("tiu+")("tiu+")("txu+")); // TODO: should spike point be duplicated?
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,1 1,0 0)", // /
|
||||
"POLYGON((1 0,1 1,2 1,1 0))",
|
||||
expected("tuu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(2 2,1 1,2 2)", // /
|
||||
"POLYGON((1 0,1 1,2 1,1 0))",
|
||||
expected("tuu+"));
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(2 1,1 1,2 1)", // --
|
||||
"POLYGON((1 0,1 1,2 1,1 0))",
|
||||
expected("tcu+")("txc=")("tcc=")("txu="));
|
||||
|
||||
// 21.01.2015
|
||||
test_geometry<ls, poly>("LINESTRING(1 2.9977189008308085,3 1.0004570537241195)",
|
||||
"POLYGON((0 0,0 4,4 4,4 0,2 2,0 0))",
|
||||
expected("mcu+")("mxc="));
|
||||
|
||||
// extended
|
||||
test_geometry<ls, poly>("LINESTRING(1 6.9651356719477091,4 4,7 1.0022887548647630)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("tcu+")("mxc="));
|
||||
test_geometry<ls, poly>("LINESTRING(1 6.9651356719477091,3 4.9931712414532363,7 1.0022887548647630)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcu+")("mxc="));
|
||||
test_geometry<ls, poly>("LINESTRING(1 6.9651356719477091,5 3.0031983963093536,7 1.0022887548647630)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcu+")("mxc="));
|
||||
test_geometry<ls, poly>("LINESTRING(4 4,7 1.0022887548647630)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("tcu+")("mxc="));
|
||||
test_geometry<ls, poly>("LINESTRING(5 3.0031983963093536,7 1.0022887548647630)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcu+")("mxc="));
|
||||
// reversed
|
||||
test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,4 4,1 6.9651356719477091)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcc+")("tiu="));
|
||||
test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,3 4.9931712414532363,1 6.9651356719477091)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcc+")("miu="));
|
||||
test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,5 3.0031983963093536,1 6.9651356719477091)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcc+")("ccc=")("miu="));
|
||||
test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,4 4)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcc+")("txu="));
|
||||
test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,5 3.0031983963093536)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcc+")("mxu="));
|
||||
test_geometry<ls, poly>("LINESTRING(7 1.0022887548647630,3 4.9931712414532363)",
|
||||
"POLYGON((0 0,0 8,8 8,8 0,4 4,0 0))",
|
||||
expected("mcc+")("miu="));
|
||||
|
||||
// 23.01.2015 - spikes
|
||||
test_geometry<ls, poly>("LINESTRING(3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 1.7773315888299086)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
expected("miu+")("miu+")("miu+")("mxu+"));
|
||||
test_geometry<ls, poly>("LINESTRING(7 8, 6 10.035925377760330, 11 -0.31552621163523403)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
expected("miu+")("iuu+"));
|
||||
|
||||
// 25.01.2015
|
||||
test_geometry<ls, poly>("LINESTRING(2 3, 4 5, 0 5.9782377228588262, 5 6.0009072995372446)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))",
|
||||
expected("miu+")("miu+")("mcu+")("mxc="));
|
||||
test_geometry<ls, poly>("LINESTRING(0 5.9782377228588262, 5 6.0009072995372446)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(4 4,6 4,6 6,4 6,4 4))",
|
||||
expected("miu+")("mcu+")("mxc="));
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<float>();
|
||||
test_all<double>();
|
||||
|
||||
//#if ! defined(_MSC_VER)
|
||||
// test_all<long double>();
|
||||
//#endif
|
||||
|
||||
//#if defined(HAVE_TTMATH)
|
||||
// test_all<ttmath_big>();
|
||||
//#endif
|
||||
return 0;
|
||||
}
|
439
test/algorithms/overlay/get_turns_linear_linear_sph.cpp
Normal file
439
test/algorithms/overlay/get_turns_linear_linear_sph.cpp
Normal file
@ -0,0 +1,439 @@
|
||||
// Boost.Geometry
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
|
||||
#include "test_get_turns.hpp"
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
|
||||
template <typename T>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::point<T, 2, bg::cs::spherical_equatorial<bg::degree> > pt;
|
||||
typedef bg::model::linestring<pt> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
// NOTE: currently for the first endpoint of the Linestring on collinear segment
|
||||
// is_collinear flags are set to FALSE!
|
||||
// E.g. in the first test tii++, NOT tii==
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0)", "LINESTRING(0 0,2 0)", "tii++", "txx==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0)", "LINESTRING(2 0,0 0)", "tix+=", "txi=+");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,1 1)", "LINESTRING(0 0,1 0,2 0)", "tuu++");
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,0 0)", "LINESTRING(0 0,1 0,2 0)", "txi=+", "tiu+=");
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,2 0)", "LINESTRING(0 0,1 0,2 0)", "tii++", "txx==");
|
||||
test_geometry<ls, ls>("LINESTRING(1 1,1 0)", "LINESTRING(0 0,1 0,2 0)", "txu++");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0)", "LINESTRING(0 0,1 0,2 0)", "tii++", "txu==");
|
||||
test_geometry<ls, ls>("LINESTRING(2 0,1 0)", "LINESTRING(0 0,1 0,2 0)", "txi=+", "tix+=");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,1 1)", "tuu++");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,0 0)", "tix+=", "tui=+");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 0,2 0)", "tii++", "txx==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(1 1,1 0)", "tux++");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(0 0,1 0)", "tii++", "tux==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 0)", "LINESTRING(2 0,1 0)", "tix+=", "txi=+");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 1,1 0,3 0,3 1)", "mii++", "ccc==", "muu==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(1 -1,1 0,3 0,3 -1)", "mii++", "ccc==", "muu==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 1,3 0,1 0,1 1)", "miu+=", "mui=+");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,4 0)", "LINESTRING(3 -1,3 0,1 0,1 -1)", "miu+=", "mui=+");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 1,2 0,4 0,4 1)", "tii++", "ccc==", "tuu==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(2 -1,2 0,4 0,4 -1)", "tii++", "ccc==", "tuu==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 1,4 0,2 0,2 1)", "tiu+=", "tui=+");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0,4 0,6 0)", "LINESTRING(4 -1,4 0,2 0,2 -1)", "tiu+=", "tui=+");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(1 0,2 1,3 5)", "tii++", "ecc==", "tux==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,1 0,2 1,3 5,4 0)", "LINESTRING(3 5,2 1,1 0)", "tix+=", "ecc==", "tui=+");
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,2 1,3 5)", "LINESTRING(0 0,1 0,2 1,3 5,4 0)", "txu==", "ecc==", "tii++");
|
||||
test_geometry<ls, ls>("LINESTRING(3 5,2 1,1 0)", "LINESTRING(0 0,1 0,2 1,3 5,4 0)", "tiu+=", "ecc==", "txi=+");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(-1 -1,1 0,10 0,20 -1)", "mii++", "txu==");
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,10 0)", "LINESTRING(20 -1,10 0,1 0,-1 -1)", "miu+=", "txi=+");
|
||||
test_geometry<ls, ls>("LINESTRING(-1 -1,1 0,10 0,20 -1)", "LINESTRING(0 0,10 0)", "mii++", "tux==");
|
||||
test_geometry<ls, ls>("LINESTRING(20 -1,10 0,1 0,-1 -1)", "LINESTRING(0 0,10 0)", "mui=+", "tix+=");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)",
|
||||
"LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)",
|
||||
expected("tii++")("ecc==")("muu==")("mii++")("muu==")("mii++")("mux=="));
|
||||
test_geometry<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)",
|
||||
"LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)",
|
||||
expected("tiu+=")("ecc==")("mui=+")("miu+=")("mui=+")("miu+=")("mui=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)",
|
||||
"LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)",
|
||||
expected("tui=+")("ecc==")("miu+=")("mui=+")("miu+=")("mui=+")("mix+="));
|
||||
test_geometry<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)",
|
||||
"LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)",
|
||||
expected("tuu==")("ecc==")("mii++")("muu==")("mii++")("muu==")("mii++"));
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(-1 0,1 0,2 1.0004570537241201524198894179384922,3 2)",
|
||||
"LINESTRING(4 5,3 2,1 0,0 0)",
|
||||
"mix+=", "txi=+", "ecc==");
|
||||
test_geometry<ls, ls>("LINESTRING(4 5,3 2,1 0,0 0)",
|
||||
"LINESTRING(-1 0,1 0,2 1.0004570537241201524198894179384922,3 2)",
|
||||
"mxi=+", "tix+=", "ecc==");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(30 0,20 0,1 1,-1 -1)", "LINESTRING(0 -1,0 0,1 -1,20 0,25 0)", "mix+=", "tui=+", "muu++");
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1,0 0,1 -1,20 0,25 0)", "LINESTRING(30 0,20 0,1 1,-1 -1)", "mxi=+", "tiu+=", "muu++");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,30 0)", "LINESTRING(4 0,4 1,20 1,5 0,1 0)", "muu++", "mui=+", "mix+=");
|
||||
test_geometry<ls, ls>("LINESTRING(4 0,4 1,20 1,5 0,1 0)", "LINESTRING(0 0,30 0)", "muu++", "miu+=", "mxi=+");
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(30 0,0 0)", "LINESTRING(1 0,5 0,20 1,4 1,4 0,5 0)",
|
||||
expected("mui=+")("miu+=")("mui=+")("mix+="));
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,5 0,20 1,4 1,4 0,5 0)", "LINESTRING(30 0,0 0)",
|
||||
expected("miu+=")("mui=+")("miu+=")("mxi=+"));
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,4 -1)",
|
||||
expected("mii++")("iuu++")("muu=="));
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,7 0,8 1)", "LINESTRING(0 0,10 0,10 10,5 0,4 1)",
|
||||
expected("mii++")("muu++")("muu=="));
|
||||
|
||||
// non-collinear
|
||||
test_geometry<ls, ls>("LINESTRING(0 1,0 0)", "LINESTRING(0 0,1 0,2 0)", "txu++");
|
||||
test_geometry<ls, ls>("LINESTRING(0 1,0 0,1 1)", "LINESTRING(0 0,1 0,2 0)", "tuu++");
|
||||
test_geometry<ls, ls>("LINESTRING(0 1,1 0,2 1)", "LINESTRING(0 0,1 0,2 0)", "tuu++");
|
||||
|
||||
// SPIKE - NON-ENDPOINT - NON-OPPOSITE
|
||||
|
||||
// spike - neq eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 2,0 4,0 1)", "LINESTRING(0 0,0 4,6 3)",
|
||||
expected("mii++")("txu==")("tiu==")("mxi=+"));
|
||||
// spike - eq eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 1)", "LINESTRING(0 0,0 4,6 3)",
|
||||
expected("tii++")("txu==")("tiu==")("mxi=+"));
|
||||
// spike - eq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 1)", "LINESTRING(0 0,0 4,6 3)",
|
||||
expected("tii++")("mxu==")("miu==")("mxi=+"));
|
||||
// spike - neq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 1,0 3,0 2)", "LINESTRING(0 0,0 4,6 3)",
|
||||
expected("mii++")("mxu==")("miu==")("mxi=+"));
|
||||
// spike - out neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 2)", "LINESTRING(0 1,0 4,6 3)",
|
||||
expected("mii++")("mxu==")("miu==")("mxi=+"));
|
||||
// spike - out eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(0 1,0 4,6 3)",
|
||||
expected("mii++")("txu==")("tiu==")("mxi=+"));
|
||||
// spike - out out/eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(1 0,0 4,6 3)",
|
||||
expected("tuu++"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(-1 0,0 4,6 3)",
|
||||
expected("tuu++"));
|
||||
// spike - out out/neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(-1 0,1 0,6 3)",
|
||||
expected("muu++"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(-1 0,1 0,6 3)",
|
||||
expected("muu++"));
|
||||
|
||||
// SPIKE - NON-ENDPOINT - OPPOSITE
|
||||
|
||||
// opposite - eq eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -1,0 0,0 4,6 3)",
|
||||
expected("tiu+=")("txi=+")("tii=+")("mxu=="));
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1,0 0,0 4,6 3)", "LINESTRING(0 6,0 4,0 0,0 2)",
|
||||
expected("tui=+")("tix+=")("tii+=")("mux=="));
|
||||
// opposite - neq eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -1,0 0,0 5,6 3)",
|
||||
expected("miu+=")("txi=+")("tii=+")("mxu=="));
|
||||
// opposite - eq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -2,0 -1,0 4,6 3)",
|
||||
expected("tiu+=")("mxi=+")("mii=+")("mxu=="));
|
||||
// opposite - neq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -2,0 -1,0 3,6 3)",
|
||||
expected("miu+=")("mxi=+")("mii=+")("mxu=="));
|
||||
// opposite - neq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 6,0 4,0 0,0 2)", "LINESTRING(0 -2,0 -1,0 3,0 5,6 3)",
|
||||
expected("miu+=")("mxi=+")("mii=+")("mxu=="));
|
||||
// opposite - neq eq
|
||||
test_geometry<ls, ls>("LINESTRING(6 3,0 3,0 0)", "LINESTRING(0 0,0 2,0 3,0 1)",
|
||||
expected("txi=+")("tix+=")("tii+=")("mux=="));
|
||||
|
||||
// SPIKE - ENDPOINT - NON-OPPOSITE
|
||||
|
||||
// spike - neq eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 2,0 4,0 1)", "LINESTRING(0 0,0 4)",
|
||||
expected("mii++")("txx==")("tix==")("mxi=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 2,0 4,0 1)", "LINESTRING(0 4,0 0)",
|
||||
expected("miu+=")("txi=+")("tii=+")("mxu=="));
|
||||
// spike - eq eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 1)", "LINESTRING(0 0,0 4)",
|
||||
expected("tii++")("txx==")("tix==")("mxi=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 1)", "LINESTRING(0 4,0 0)",
|
||||
expected("tix+=")("txi=+")("tii=+")("mxu=="));
|
||||
// spike - eq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 1)", "LINESTRING(0 0,0 4)",
|
||||
expected("tii++")("mxu==")("miu==")("mxi=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 1)", "LINESTRING(0 4,0 0)",
|
||||
expected("tix+=")("mxi=+")("mii=+")("mxu=="));
|
||||
// spike - neq neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 1,0 3,0 2)", "LINESTRING(0 0,0 4)",
|
||||
expected("mii++")("mxu==")("miu==")("mxi=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 1,0 3,0 2)", "LINESTRING(0 4,0 0)",
|
||||
expected("miu+=")("mxi=+")("mii=+")("mxu=="));
|
||||
// spike - out neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 2)", "LINESTRING(0 1,0 4)",
|
||||
expected("mii++")("mxu==")("miu==")("mxi=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 3,0 2)", "LINESTRING(0 4,0 1)",
|
||||
expected("mix+=")("mxi=+")("mii=+")("mxu=="));
|
||||
// spike - out eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(0 1,0 4)",
|
||||
expected("mii++")("txx==")("tix==")("mxi=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(0 4,0 1)",
|
||||
expected("mix+=")("txi=+")("tii=+")("mxu=="));
|
||||
// spike - out out/eq
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(1 0,0 4)",
|
||||
expected("tux++"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,0 4,0 2)", "LINESTRING(-1 0,0 4)",
|
||||
expected("tux++"));
|
||||
// spike - out out/neq
|
||||
test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(-1 0,1 0)",
|
||||
expected("muu++"));
|
||||
test_geometry<ls, ls>("LINESTRING(0 -2,0 0,0 -1)", "LINESTRING(1 0,-1 0)",
|
||||
expected("muu++"));
|
||||
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(3 0,0 0)",
|
||||
"LINESTRING(4 2,1 0,9 0)",
|
||||
expected("mui=+")("miu+="));
|
||||
|
||||
|
||||
// 01.02.2015
|
||||
test_geometry<ls, ls>("LINESTRING(6 0,0 0,5 0)",
|
||||
"LINESTRING(2 0,0 0,-10 0)",
|
||||
expected("mii++")("txu==")("tiu==")("mui=+"));
|
||||
// the reversal could be automatic...
|
||||
test_geometry<ls, ls>("LINESTRING(2 0,0 0,-10 0)",
|
||||
"LINESTRING(6 0,0 0,5 0)",
|
||||
expected("mii++")("tux==")("tui==")("miu+="));
|
||||
// sanity check
|
||||
test_geometry<ls, ls>("LINESTRING(6 0,0 0)",
|
||||
"LINESTRING(2 0,0 0,-10 0)",
|
||||
expected("mii++")("txu=="));
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,5 0)",
|
||||
"LINESTRING(2 0,0 0,-10 0)",
|
||||
expected("tiu+=")("mui=+"));
|
||||
|
||||
if ( BOOST_GEOMETRY_CONDITION((boost::is_same<T, double>::value)) )
|
||||
{
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
|
||||
"LINESTRING(12 10, 12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
|
||||
expected("mii++")("ccc==")("mux=="));
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
|
||||
"LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392, 12 10)",
|
||||
expected("miu+=")("mui=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
|
||||
"LINESTRING(12 10, 12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
|
||||
expected("mui=+")("mix+="));
|
||||
test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 0)",
|
||||
"LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392, 12 10)",
|
||||
expected("muu==")("ccc==")("mii++"));
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
|
||||
"LINESTRING(12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
|
||||
expected("mii++")("ccc==")("mux=="));
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
|
||||
"LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392)",
|
||||
expected("mix+=")("mui=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
|
||||
"LINESTRING(12.5 -0.50051443471392, 15 0, 17.5 0.50051443471392)",
|
||||
expected("mui=+")("mix+="));
|
||||
test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
|
||||
"LINESTRING(17.5 0.50051443471392, 15 0, 12.5 -0.50051443471392)",
|
||||
expected("mux==")("ccc==")("mii++"));
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
|
||||
"LINESTRING(12 10, 12.5 -0.50051443471392, 15 0)",
|
||||
expected("mii++")("mux=="));
|
||||
test_geometry<ls, ls>("LINESTRING(0 -1, 10 -1, 20 1)",
|
||||
"LINESTRING(15 0, 12.5 -0.50051443471392, 12 10)",
|
||||
expected("miu+=")("mui=+"));
|
||||
test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
|
||||
"LINESTRING(12 10, 12.5 -0.50051443471392, 15 0)",
|
||||
expected("mui=+")("mix+="));
|
||||
test_geometry<ls, ls>("LINESTRING(20 1, 10 -1, 0 -1)",
|
||||
"LINESTRING(15 0, 12.5 -0.50051443471392, 12 10)",
|
||||
expected("muu==")("mii++"));
|
||||
}
|
||||
|
||||
// TODO:
|
||||
//test_geometry<ls, ls>("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
|
||||
//test_geometry<ls, ls>("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");
|
||||
|
||||
//test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(3 0,3 3,3 1)", "0F1FF0102");
|
||||
//test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 3,2 1)", "0F1FF0102");
|
||||
//test_geometry<ls, ls>("LINESTRING(0 0,3 3,1 1)", "LINESTRING(2 0,2 2,2 1)", "0F1FF0102");
|
||||
|
||||
//test_geometry<ls, ls>("LINESTRING(0 0,2 2,3 3,4 4)", "LINESTRING(0 0,1 1,4 4)", "1FFF0FFF2");
|
||||
|
||||
|
||||
//if ( boost::is_same<T, double>::value )
|
||||
//{
|
||||
// to_svg<ls, ls>("LINESTRING(0 0,1 0,2 0,2.5 0,3 1)", "LINESTRING(0 0,2 0,2.5 0,3 1)", "test11.svg");
|
||||
// to_svg<ls, ls>("LINESTRING(0 0,1 0,2 0,2.5 0,3 1)", "LINESTRING(3 1,2.5 0,2 0,0 0)", "test12.svg");
|
||||
// to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,20 0,30 0,31 1)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test21.svg");
|
||||
// to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,20 0,30 0,31 1)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test22.svg");
|
||||
|
||||
// to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test31.svg");
|
||||
// to_svg<ls, ls>("LINESTRING(-1 1,0 0,1 0,4 0,5 5,10 5,15 0,31 0)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test32.svg");
|
||||
// to_svg<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)", "LINESTRING(-1 -1,0 0,1 0,2 0,2.5 1,3 0,30 0)", "test33.svg");
|
||||
// to_svg<ls, ls>("LINESTRING(31 0,15 0,10 5,5 5,4 0,1 0,0 0,-1 1)", "LINESTRING(30 0,3 0,2.5 1,2 0,1 0,0 0,-1 -1)", "test34.svg");
|
||||
//}
|
||||
|
||||
// duplicated
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0,30 0))",
|
||||
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0),(2 0,2 0),(3 0,3 0,3 0))",
|
||||
expected("mii++")("ccc==")("ccc==")("txx=="));
|
||||
|
||||
// spike
|
||||
test_geometry<ls, ls>("LINESTRING(2 2,5 -1,15 2,18 0,20 0)",
|
||||
"LINESTRING(30 0,19 0,18 0,0 0)",
|
||||
expected("iuu++")("iuu++")("tiu+=")("mxi=+"));
|
||||
// spike
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0,5 0))",
|
||||
"MULTILINESTRING((1 0,8 0,4 0))",
|
||||
expected("mii++")("mix+=")("mux==")("mui==")("mix+=")("mii+=")("mxu==")("mxi=+"));
|
||||
|
||||
/*test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0,5 0))",
|
||||
"MULTILINESTRING((1 0,8 0,4 0),(2 0,9 0,5 0))",
|
||||
expected("mii")("ccc")("ccc")("txx"));*/
|
||||
|
||||
// spike vs endpoint
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
|
||||
"MULTILINESTRING((-1 0,0 0,-2 0),(11 0,10 0,12 0))",
|
||||
expected("tuu++")("txu++"));
|
||||
// internal turning R vs spike
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
|
||||
"MULTILINESTRING((0 1,1 1,0 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
|
||||
"MULTILINESTRING((1 2,1 1,1 2))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 0,0 0))",
|
||||
"MULTILINESTRING((2 0,1 0,2 0))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
|
||||
"MULTILINESTRING((0 2,1 1,0 2))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
|
||||
"MULTILINESTRING((2 0,1 1,2 0))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,2 1))",
|
||||
"MULTILINESTRING((2 1,1 1,2 1))",
|
||||
expected("txi=+")("tix+=")("tii+=")("txx=="));
|
||||
// internal turning L vs spike
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
|
||||
"MULTILINESTRING((2 1,1 1,2 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
|
||||
"MULTILINESTRING((1 2,1 1,1 2))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
|
||||
"MULTILINESTRING((2 2,1 1,2 2))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
|
||||
"MULTILINESTRING((0 0,1 1,0 0))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 0,1 1,0 1))",
|
||||
"MULTILINESTRING((0 1,1 1,0 1))",
|
||||
expected("txi=+")("tix+=")("tii+=")("txx=="));
|
||||
// spike vs internal turning R
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 1,1 1,0 1))",
|
||||
"MULTILINESTRING((1 0,1 1,2 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 2,1 1,1 2))",
|
||||
"MULTILINESTRING((1 0,1 1,2 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((2 0,1 0,2 0))",
|
||||
"MULTILINESTRING((0 0,1 0,0 0))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 2,1 1,0 2))",
|
||||
"MULTILINESTRING((1 0,1 1,2 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((2 0,1 1,2 0))",
|
||||
"MULTILINESTRING((1 0,1 1,2 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((2 1,1 1,2 1))",
|
||||
"MULTILINESTRING((1 0,1 1,2 1))",
|
||||
expected("tix+=")("txi=+")("tii=+")("txx=="));
|
||||
// spike vs internal turning L
|
||||
test_geometry<mls, mls>("MULTILINESTRING((2 1,1 1,2 1))",
|
||||
"MULTILINESTRING((1 0,1 1,0 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((1 2,1 1,1 2))",
|
||||
"MULTILINESTRING((1 0,1 1,0 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((2 2,1 1,2 2))",
|
||||
"MULTILINESTRING((1 0,1 1,0 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((1 0,1 1,0 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 1,1 1,0 1))",
|
||||
"MULTILINESTRING((1 0,1 1,0 1))",
|
||||
expected("tix+=")("txi=+")("tii=+")("txx=="));
|
||||
// spike vs internal collinear
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 1,1 1,0 1))",
|
||||
"MULTILINESTRING((2 1,1 1,0 1))",
|
||||
expected("tix+=")("txi=+")("tii=+")("txx=="));
|
||||
// internal collinear vs spike
|
||||
test_geometry<mls, mls>("MULTILINESTRING((2 1,1 1,0 1))",
|
||||
"MULTILINESTRING((0 1,1 1,0 1))",
|
||||
expected("txi=+")("tix+=")("tii+=")("txx=="));
|
||||
// spike vs spike
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((2 2,1 1,2 2))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((2 0,1 1,2 0))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((2 1,1 1,2 1))",
|
||||
expected("tuu++"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((0 1,1 1,0 1))",
|
||||
expected("tuu++"));
|
||||
// collinear spikes
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((0 0,1 1,0 0))",
|
||||
expected("tii++")("tix+=")("txi=+")("txx==")
|
||||
("ecc=="));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,1 1,0 0))",
|
||||
"MULTILINESTRING((1 1,0 0,1 1))",
|
||||
expected("tix+=")("tii+=")("txx==")("txi==")
|
||||
("txi=+")("tii=+")("txx==")("tix=="));
|
||||
// non-spike similar
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
|
||||
"MULTILINESTRING((-1 0,0 0,2 0))",
|
||||
expected("tii++")("mux=="));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
|
||||
"MULTILINESTRING((-1 -1,0 0,2 0))",
|
||||
expected("tii++")("mux=="));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
|
||||
"MULTILINESTRING((2 0,0 0,-1 0))",
|
||||
expected("tiu+=")("mui=+"));
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,10 0))",
|
||||
"MULTILINESTRING((2 0,0 0,-1 -1))",
|
||||
expected("tiu+=")("mui=+"));
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<float>();
|
||||
test_all<double>();
|
||||
|
||||
#if ! defined(_MSC_VER)
|
||||
test_all<long double>();
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<ttmath_big>();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
@ -2,6 +2,11 @@
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -927,10 +932,32 @@ static std::string mysql_21965285_b[2] =
|
||||
"MULTIPOLYGON(((1 1, 3 0, 19 -8, -4 -3, 1 1)),((3 0, -2 7, -3 16, 1 19, 8 12, 3 0)))"
|
||||
};
|
||||
|
||||
static std::string mysql_1[2] =
|
||||
// formerly mysql_1
|
||||
static std::string mysql_23023665_7[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((4 5,12 11,-12 -3,4 5)))",
|
||||
"MULTIPOLYGON(((5 4,-14 0,1 0,5 4)),((1 6,13 0,10 12,1 6)))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_8[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((0 0,0 40,40 40,40 0,0 0),(10 10,30 10,30 30,10 30,10 10)))",
|
||||
"MULTIPOLYGON(((10 10,10 20,20 10,10 10)),((20 10,30 20,30 10,20 10)),((10 20,10 30,20 20,10 20)),((20 20,30 30,30 20,20 20)))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_9[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((0 0, 0 40, 40 40, 40 0, 0 0),(10 10, 30 10, 30 30, 10 30, 10 10)))",
|
||||
"MULTIPOLYGON(((15 10, 10 15, 10 17, 15 10)),((15 10, 10 20, 10 22, 15 10)),"
|
||||
"((15 10, 10 25, 10 27, 15 10)),((25 10, 30 17, 30 15, 25 10)),"
|
||||
"((25 10, 30 22, 30 20, 25 10)),((25 10, 30 27, 30 25, 25 10)),"
|
||||
"((18 10, 20 30, 19 10, 18 10)),((21 10, 20 30, 22 10, 21 10)))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_12[2] =
|
||||
{
|
||||
"MULTIPOLYGON(((6 7,18 14,-8 1,0 0,18 -8,6 7),(6 0,-4 3,5 3,6 0)))",
|
||||
"MULTIPOLYGON(((2 3,-3 5,-10 -1,2 3)))"
|
||||
};
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_MULTI_OVERLAY_CASES_HPP
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <boost/geometry/geometries/multi_polygon.hpp>
|
||||
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
//#include <boost/geometry/io/svg/write_svg.hpp>
|
||||
//#include <boost/geometry/io/svg/write.hpp>
|
||||
|
||||
|
||||
|
||||
|
@ -366,7 +366,7 @@ void test_overlay(std::string const& caseid,
|
||||
rescale_policy_type robust_policy
|
||||
= bg::get_rescale_policy<rescale_policy_type>(g1, g2);
|
||||
|
||||
typedef bg::strategy_intersection
|
||||
typedef bg::intersection_strategies
|
||||
<
|
||||
typename bg::cs_tag<Geometry>::type,
|
||||
Geometry,
|
||||
|
@ -3,10 +3,11 @@
|
||||
//
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2015.
|
||||
// Modifications copyright (c) 2015, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2015, 2016.
|
||||
// Modifications copyright (c) 2015-2016, 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
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -41,6 +42,17 @@ static std::string case_3[2] = {
|
||||
"POLYGON((1 2,2 4,4 3,3 1,1 2))",
|
||||
"POLYGON((1 1,1 4,4 4,4 1,1 1))" };
|
||||
|
||||
static std::string case_3_sph[2] = {
|
||||
"POLYGON((1 2,2 4.0012148518458881,4 3,3.0001521347633209 1.0003046174216719,1 2))",
|
||||
"POLYGON((1 1,1 4,4 4,4 1,1 1))" };
|
||||
|
||||
static std::string case_3_2[2] = {
|
||||
"POLYGON((1 1,1 2,1 4,2 4,4 4,4 3,4 1,3 1,1 1))",
|
||||
"POLYGON((1 1,1 4,4 4,4 1,1 1))" };
|
||||
|
||||
static std::string case_3_2_sph[2] = {
|
||||
"POLYGON((1 1,1 2,1 4,2 4.0012148518458881,4 4, 4 3,4 1,3.0001521347633209 1.0003046174216719,1 1))",
|
||||
"POLYGON((1 1,1 4,4 4,4 1,1 1))" };
|
||||
|
||||
static std::string case_4[2] = {
|
||||
"POLYGON((0 2,2 5,5 3,3 0,0 2))",
|
||||
@ -55,6 +67,10 @@ static std::string case_6[2] = {
|
||||
"POLYGON((0 1,2 5,5 2,0 1))",
|
||||
"POLYGON((1 3,2 5,5 2,1 3))" };
|
||||
|
||||
static std::string case_6_sph[2] = {
|
||||
"POLYGON((0 1,2 5,5 2,0 1))",
|
||||
"POLYGON((0.99816884334995659 3.0004544452169379,2 5,5 2,0.99816884334995659 3.0004544452169379))" };
|
||||
|
||||
static std::string case_7[2] = {
|
||||
"POLYGON((0 1,1 3,5 2,0 1))",
|
||||
"POLYGON((1 3,2 5,5 2,1 3))" };
|
||||
@ -63,10 +79,18 @@ static std::string case_8[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((1 3,4 4,3 1,1 3))" };
|
||||
|
||||
static std::string case_8_sph[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((1.0023984691325358 3.0008039480973441,4 4,3.0005710779764270 1.0017165445544389,1.0023984691325358 3.0008039480973441))" };
|
||||
|
||||
static std::string case_9[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((2 2,2 4,5 4,2 2))" };
|
||||
|
||||
static std::string case_9_sph[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((2.0021918671997510 2.0014662914956771,2 4,5 4,2.0021918671997510 2.0014662914956771))" };
|
||||
|
||||
static std::string ccw_case_9[2] = {
|
||||
"POLYGON((0 0,4 0,0 4,0 0))",
|
||||
"POLYGON((2 2,5 4,2 4,2 2))" };
|
||||
@ -79,10 +103,18 @@ static std::string case_10[2] = {
|
||||
"POLYGON((0 0,2 4,4 0,0 0))",
|
||||
"POLYGON((1 2,2 5,3 2,2 4,1 2))" };
|
||||
|
||||
static std::string case_10_sph[2] = {
|
||||
"POLYGON((0 0,2 4,4 0,0 0))",
|
||||
"POLYGON((1.0027234797707729 2.0081941097810105,2 5,2.9972765202292275 2.0081941097810105,2 4,1.0027234797707729 2.0081941097810105))" };
|
||||
|
||||
static std::string case_11[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((1 2,2 2,2 1,1 1))" };
|
||||
|
||||
static std::string case_11_sph[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((1 2,2 2.0036594926050890,2 1,1 1))" };
|
||||
|
||||
static std::string case_12[2] = {
|
||||
"POLYGON((0 1,1 4,2 2,3 4,4 1,0 1))",
|
||||
"POLYGON((0 3,2 4,4 3,0 3))" };
|
||||
@ -91,26 +123,50 @@ static std::string case_13[2] = {
|
||||
"POLYGON((0 1,1 2,3 0,0 1))",
|
||||
"POLYGON((0 3,2 3,2 1,0 3))" };
|
||||
|
||||
static std::string case_13_sph[2] = {
|
||||
"POLYGON((0 1,1 2,3 0,0 1))",
|
||||
"POLYGON((0 2.9977189008308094,2 3,2 1.0004570537241211,0 2.9977189008308094))" };
|
||||
|
||||
static std::string case_14[2] = {
|
||||
"POLYGON((0 0,0 4,2 2,4 0,0 0))",
|
||||
"POLYGON((1 3,4 4,3 1,1 3))" };
|
||||
|
||||
static std::string case_14_sph[2] = {
|
||||
"POLYGON((0 0,0 4,2 2.0036594926050877,4 0,0 0))",
|
||||
"POLYGON((1.0023984691325358 3.0008039480973441,4 4,3.0005710779764270 1.0017165445544389,1.0023984691325358 3.0008039480973441))" };
|
||||
|
||||
static std::string case_15[2] = {
|
||||
"POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))",
|
||||
"POLYGON((1 3,4 4,3 1,1 3))" };
|
||||
|
||||
static std::string case_15_sph[2] = {
|
||||
"POLYGON((0 0,0 4,1.5 2.5037147591481679,2.5 1.5031461368777814,4 0,0 0))",
|
||||
"POLYGON((1.0023984691325358 3.0008039480973441,4 4,3.0005710779764270 1.0017165445544389,1.0023984691325358 3.0008039480973441))" };
|
||||
|
||||
static std::string case_16[2] = {
|
||||
"POLYGON((1 2,3 4,2 1,1 2))",
|
||||
"POLYGON((1 0,1 2,2 1,3 4,2 3,3 5,4 0,1 0))" };
|
||||
|
||||
static std::string case_16_sph[2] = {
|
||||
"POLYGON((1 2,3 4,2 1,1 2))",
|
||||
"POLYGON((1 0,1 2,2 1,3 4,2.0013644968330810 3.0027358616998980,3 5,4 0,1 0))" };
|
||||
|
||||
static std::string case_17[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((1 1,1 3,3 1,1 1))" };
|
||||
|
||||
static std::string case_17_sph[2] = {
|
||||
"POLYGON((0 0,0 4,4 0,0 0))",
|
||||
"POLYGON((1 1,1 3.0031983963093531,3 1.0022887548647623,1 1))" };
|
||||
|
||||
static std::string case_18[2] = {
|
||||
"POLYGON((0 0,0 4,1.5 2.5,2.5 1.5,4 0,0 0))",
|
||||
"POLYGON((1 1,1 3,3 1,1 1))" };
|
||||
|
||||
static std::string case_18_sph[2] = {
|
||||
"POLYGON((0 0,0 4,1.5 2.5037147591481679,2.5 1.5031461368777814,4 0,0 0))",
|
||||
"POLYGON((1 1,1 3.0031983963093531,3 1.0022887548647623,1 1))" };
|
||||
|
||||
static std::string case_19[2] = {
|
||||
"POLYGON((2 0,1 3,5 2,2 0))",
|
||||
"POLYGON((1 3,2 5,5 2,1 3))" };
|
||||
@ -1031,5 +1087,58 @@ static std::string mysql_21965285_b_inv[2] =
|
||||
"POLYGON((-20 -20,-20 20,20 20,20 -20,-20 -20),(1 1, -4 -3, 19 -8, 3 0, 1 1),(3 0, 8 12, 1 19, -3 16, -2 7, 3 0))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_1[2] =
|
||||
{
|
||||
"POLYGON((7 3,0 10,0 -6,9 -5,7 7,7 3),(0 8,2 3,2 -2,0 8))",
|
||||
"POLYGON((0 8,-8 14,-11 18,-19 11,-3 1,0 8))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_2[2] =
|
||||
{
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(0 8,4 4,4 6,0 8))",
|
||||
"POLYGON((0 8,-8 8,-10 4,0 8))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_3[2] =
|
||||
{
|
||||
"POLYGON((5 0,15 18,-14 11,5 0),(0 3,-1 4,5 0,0 3))",
|
||||
"POLYGON((6 0,-5 0,-1 -12,6 0))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_4[2] =
|
||||
{
|
||||
"POLYGON((7 0,10 -3,7 1,7 0))",
|
||||
"POLYGON((7 4,-14 10,7 -17,7 4),(7 1,0 3,-2 4,7 1))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_5[2] =
|
||||
{
|
||||
"POLYGON((8 6,5 7,-1 4,-8 -7,0 -17,8 6),(3 6,5 5,0 -2,3 6))",
|
||||
"POLYGON((3 5,-17 11,-8 -3,3 5))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_6[2] =
|
||||
{
|
||||
"POLYGON((6 7,18 14, -8 1, 0 0, 18 -8, 6 7), (6 0, -4 3, 5 3, 6 0))",
|
||||
"POLYGON((2 3,-3 5,-10 -1,2 3))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_10[2] =
|
||||
{
|
||||
"POLYGON((0 5, -6 -17, 12 17, 0 5),(4 6, 5 5, 0 1, 4 6))",
|
||||
"POLYGON((3 9, -15 -5, 13 -11, 3 9))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_11[2] =
|
||||
{
|
||||
"POLYGON((5 6,-15 -13,1 -8,5 6))",
|
||||
"POLYGON((0 8,-19 6,18 -17,20 8,11 17,0 8),(3 2,3 -1,1 0,3 2),(1 3,4 4,0 -1,1 3))"
|
||||
};
|
||||
|
||||
static std::string mysql_23023665_13[2] =
|
||||
{
|
||||
"POLYGON((6 7,18 14,-8 1,0 0,18 -8,6 7),(6 0,-4 3,5 3,6 0))",
|
||||
"POLYGON((0 7,-5 6,11 -13,0 7))"
|
||||
};
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_OVERLAY_CASES_HPP
|
||||
|
@ -4,8 +4,8 @@
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014 Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2014, 2016.
|
||||
// Modifications copyright (c) 2014-2016 Oracle and/or its affiliates.
|
||||
|
||||
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
||||
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
||||
@ -33,12 +33,13 @@
|
||||
#include <boost/geometry/io/wkt/read.hpp>
|
||||
#include <boost/geometry/io/wkt/write.hpp>
|
||||
|
||||
template <int Version = 0>
|
||||
struct expected_pusher
|
||||
{
|
||||
static const int version = Version;
|
||||
void push_back(std::string const& ex)
|
||||
{
|
||||
vec.push_back(ex);
|
||||
}
|
||||
|
||||
void push_back(std::string const& ex) { vec.push_back(ex); }
|
||||
expected_pusher & operator()(std::string const& ex)
|
||||
{
|
||||
push_back(ex);
|
||||
@ -56,13 +57,12 @@ struct expected_pusher
|
||||
std::vector<std::string> vec;
|
||||
};
|
||||
|
||||
expected_pusher<1> expected(std::string const& ex)
|
||||
inline expected_pusher expected(std::string const& ex)
|
||||
{
|
||||
expected_pusher<1> res;
|
||||
expected_pusher res;
|
||||
return res(ex);
|
||||
}
|
||||
|
||||
template <int Version>
|
||||
struct equal_turn
|
||||
{
|
||||
equal_turn(std::string const& s) : turn_ptr(&s) {}
|
||||
@ -70,43 +70,45 @@ struct equal_turn
|
||||
template <typename T>
|
||||
bool operator()(T const& t) const
|
||||
{
|
||||
BOOST_ASSERT(turn_ptr && turn_ptr->size() == 3);
|
||||
return bg::method_char(t.method) == (*turn_ptr)[0]
|
||||
&& bg::operation_char(t.operations[0].operation) == (*turn_ptr)[1]
|
||||
&& bg::operation_char(t.operations[1].operation) == (*turn_ptr)[2];
|
||||
std::string const& s = (*turn_ptr);
|
||||
std::string::size_type const count = s.size();
|
||||
|
||||
return (count > 0
|
||||
? bg::method_char(t.method) == s[0]
|
||||
: true)
|
||||
&& (count > 1
|
||||
? bg::operation_char(t.operations[0].operation) == s[1]
|
||||
: true)
|
||||
&& (count > 2
|
||||
? bg::operation_char(t.operations[1].operation) == s[2]
|
||||
: true)
|
||||
&& equal_operations_ex(t.operations[0], t.operations[1], s);
|
||||
}
|
||||
|
||||
const std::string * turn_ptr;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct equal_turn<1>
|
||||
{
|
||||
equal_turn(std::string const& s) : turn_ptr(&s) {}
|
||||
|
||||
template <typename T>
|
||||
bool operator()(T const& t) const
|
||||
template <typename P, typename R>
|
||||
static bool equal_operations_ex(bg::detail::overlay::turn_operation<P, R> const& op0,
|
||||
bg::detail::overlay::turn_operation<P, R> const& op1,
|
||||
std::string const& s)
|
||||
{
|
||||
std::string::size_type count = turn_ptr->size();
|
||||
//BOOST_ASSERT(turn_ptr && count >= 1);
|
||||
return ( count > 0
|
||||
? bg::method_char(t.method) == (*turn_ptr)[0]
|
||||
: true )
|
||||
&& ( count > 1
|
||||
? bg::operation_char(t.operations[0].operation) == (*turn_ptr)[1]
|
||||
: true )
|
||||
&& ( count > 2
|
||||
? bg::operation_char(t.operations[1].operation) == (*turn_ptr)[2]
|
||||
: true )
|
||||
&& ( count > 3
|
||||
? is_colinear_char(t.operations[0].is_collinear) == (*turn_ptr)[3]
|
||||
: true )
|
||||
&& ( count > 4
|
||||
? is_colinear_char(t.operations[1].is_collinear) == (*turn_ptr)[4]
|
||||
: true );
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline char is_colinear_char(bool is_collinear)
|
||||
template <typename P, typename R>
|
||||
static bool equal_operations_ex(bg::detail::overlay::turn_operation_linear<P, R> const& op0,
|
||||
bg::detail::overlay::turn_operation_linear<P, R> const& op1,
|
||||
std::string const& s)
|
||||
{
|
||||
std::string::size_type const count = s.size();
|
||||
|
||||
return (count > 3
|
||||
? is_colinear_char(op0.is_collinear) == s[3]
|
||||
: true)
|
||||
&& (count > 4
|
||||
? is_colinear_char(op1.is_collinear) == s[4]
|
||||
: true);
|
||||
}
|
||||
|
||||
static char is_colinear_char(bool is_collinear)
|
||||
{
|
||||
return is_collinear ? '=' : '+';
|
||||
}
|
||||
@ -115,12 +117,11 @@ struct equal_turn<1>
|
||||
};
|
||||
|
||||
template <typename Geometry1, typename Geometry2, typename Expected>
|
||||
void check_geometry_range(
|
||||
Geometry1 const& g1,
|
||||
Geometry2 const& g2,
|
||||
std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
Expected const& expected)
|
||||
void check_geometry_range(Geometry1 const& g1,
|
||||
Geometry2 const& g2,
|
||||
std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
Expected const& expected)
|
||||
{
|
||||
typedef bg::detail::no_rescale_policy robust_policy_type;
|
||||
typedef typename bg::point_type<Geometry2>::type point_type;
|
||||
@ -168,7 +169,7 @@ void check_geometry_range(
|
||||
sit != boost::end(expected) ; ++sit)
|
||||
{
|
||||
typename std::vector<turn_info>::iterator
|
||||
it = std::find_if(turns.begin(), turns.end(), equal_turn<Expected::version>(*sit));
|
||||
it = std::find_if(turns.begin(), turns.end(), equal_turn(*sit));
|
||||
|
||||
if ( it != turns.end() )
|
||||
turns.erase(it);
|
||||
@ -245,9 +246,9 @@ void test_geometry(std::string const& wkt1, std::string const& wkt2,
|
||||
test_geometry_range<G1, G2>(wkt1, wkt2, expected(ex0)(ex1)(ex2));
|
||||
}
|
||||
|
||||
template <typename G1, typename G2, int Version>
|
||||
template <typename G1, typename G2>
|
||||
void test_geometry(std::string const& wkt1, std::string const& wkt2,
|
||||
expected_pusher<Version> const& expected)
|
||||
expected_pusher const& expected)
|
||||
{
|
||||
test_geometry_range<G1, G2>(wkt1, wkt2, expected);
|
||||
}
|
||||
|
16
test/algorithms/perimeter/Jamfile.v2
Normal file
16
test/algorithms/perimeter/Jamfile.v2
Normal file
@ -0,0 +1,16 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
#
|
||||
# Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
#
|
||||
# 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)
|
||||
|
||||
test-suite boost-geometry-algorithms-perimeter
|
||||
:
|
||||
[ run perimeter.cpp : : : : algorithms_perimeter ]
|
||||
[ run perimeter_geo.cpp : : : : algorithms_perimeter_geo ]
|
||||
[ run perimeter_sph.cpp : : : : algorithms_perimeter_sph ]
|
||||
;
|
66
test/algorithms/perimeter/perimeter.cpp
Normal file
66
test/algorithms/perimeter/perimeter.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include <algorithms/test_perimeter.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
// Simple
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,4 3,0 0))",
|
||||
5 + sqrt(2.0) + 5);
|
||||
// Non-simple
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,4 3,0 3,0 0))",
|
||||
5 + sqrt(2.0) + 4 + 3);
|
||||
// With holes
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,4 3,0 0),\
|
||||
(2 2,3 4,3 3,2 2))",
|
||||
5 + sqrt(2.0) + 5 +
|
||||
sqrt(5.0) + 1 + sqrt(2.0));
|
||||
// Repeated points
|
||||
test_geometry<bg::model::polygon<P> >("POLYGON((0 0,3 4,3 4,3 4,4 3,4 3,\
|
||||
4 3,4 3,4 3,4 3,0 3,0 0))",
|
||||
5 + sqrt(2.0) + 4 + 3);
|
||||
// Multipolygon
|
||||
test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
|
||||
(
|
||||
"MULTIPOLYGON(((0 0,3 4,4 3,0 0)), ((0 0,3 4,4 3,0 3,0 0)))",
|
||||
5 + sqrt(2.0) + 5 + 5 + sqrt(2.0) + 4 + 3
|
||||
);
|
||||
|
||||
// Geometries with perimeter zero
|
||||
test_geometry<P>("POINT(0 0)", 0);
|
||||
test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,3 4,4 3)", 0);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_empty_input()
|
||||
{
|
||||
test_empty_input(bg::model::polygon<P>());
|
||||
test_empty_input(bg::model::multi_polygon<bg::model::polygon<P> >());
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<int> >();
|
||||
test_all<bg::model::d2::point_xy<float> >();
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
// test_empty_input<bg::model::d2::point_xy<int> >();
|
||||
|
||||
return 0;
|
||||
}
|
114
test/algorithms/perimeter/perimeter_geo.cpp
Normal file
114
test/algorithms/perimeter/perimeter_geo.cpp
Normal file
@ -0,0 +1,114 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include <algorithms/test_perimeter.hpp>
|
||||
#include <algorithms/perimeter/perimeter_polygon_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
template <typename P>
|
||||
struct geo_strategies
|
||||
{
|
||||
// Set radius type, but for integer coordinates we want to have floating
|
||||
// point radius type
|
||||
typedef typename bg::promote_floating_point
|
||||
<
|
||||
typename bg::coordinate_type<P>::type
|
||||
>::type rtype;
|
||||
|
||||
typedef bg::srs::spheroid<rtype> stype;
|
||||
typedef bg::strategy::distance::andoyer<stype> andoyer_type;
|
||||
typedef bg::strategy::distance::thomas<stype> thomas_type;
|
||||
typedef bg::strategy::distance::vincenty<stype> vincenty_type;
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
void test_default() //this should use andoyer strategy
|
||||
{
|
||||
for (std::size_t i = 0; i <= 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::polygon<P> >(poly_data_geo[i],
|
||||
1116814.237 + 1116152.605);
|
||||
}
|
||||
|
||||
// Multipolygon
|
||||
test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
|
||||
(multipoly_data[0], 60078934.0425);
|
||||
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0);
|
||||
test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,0 1,1 1,1 0,0 0)",
|
||||
0);
|
||||
}
|
||||
|
||||
template <typename P, typename N, typename Strategy>
|
||||
void test_with_strategy(N exp_length, Strategy strategy)
|
||||
{
|
||||
for (std::size_t i = 0; i <= 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::polygon<P> >(poly_data_geo[i],
|
||||
exp_length,
|
||||
strategy);
|
||||
}
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0, strategy);
|
||||
test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,0 1,1 1,1 0,0 0)",
|
||||
0,
|
||||
strategy);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_andoyer()
|
||||
{
|
||||
typename geo_strategies<P>::andoyer_type andoyer;
|
||||
test_with_strategy<P>(1116814.237 + 1116152.605, andoyer);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_thomas()
|
||||
{
|
||||
typename geo_strategies<P>::thomas_type thomas;
|
||||
test_with_strategy<P>(1116825.795 + 1116158.7417, thomas);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_vincenty()
|
||||
{
|
||||
typename geo_strategies<P>::vincenty_type vincenty;
|
||||
test_with_strategy<P>(1116828.8624 + 1116161.625, vincenty);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_default<P>();
|
||||
test_andoyer<P>();
|
||||
test_thomas<P>();
|
||||
test_vincenty<P>();
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
// Works only for double(?!)
|
||||
//test_all<bg::model::d2::point_xy<int,
|
||||
// bg::cs::geographic<bg::degree> > >();
|
||||
//test_all<bg::model::d2::point_xy<float,
|
||||
// bg::cs::geographic<bg::degree> > >();
|
||||
test_all<bg::model::d2::point_xy<double,
|
||||
bg::cs::geographic<bg::degree> > >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
35
test/algorithms/perimeter/perimeter_polygon_cases.hpp
Normal file
35
test/algorithms/perimeter/perimeter_polygon_cases.hpp
Normal file
@ -0,0 +1,35 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
|
||||
// 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 PERIMETER_POLYGON_CASES_HPP
|
||||
#define PERIMETER_POLYGON_CASES_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
static std::string poly_data_geo[] = {
|
||||
"POLYGON((0 90,1 80,1 70))",
|
||||
"POLYGON((0 90,1 80,1 80,1 80,1 70,1 70))",
|
||||
"POLYGON((0 90,1 80,1 79,1 78,1 77,1 76,1 75,1 74,\
|
||||
1 73,1 72,1 71,1 70))"
|
||||
};
|
||||
|
||||
static std::string poly_data_sph[] = {
|
||||
"POLYGON((0 0,180 0,0 0))",
|
||||
"POLYGON((0 0,180 0,180 0,180 0,180 180,0 0))",
|
||||
"POLYGON((0 0,180 0,180 10,180 20,180 30,180 40,180 50,180 60,\
|
||||
180 70,180 80,180 90,180 100,180 110,180 120,180 130,\
|
||||
180 140,180 150,180 160,180 170,180 180,0 0))"
|
||||
};
|
||||
|
||||
static std::string multipoly_data[] = {
|
||||
"MULTIPOLYGON(((0 0,180 0,0 0)), ((0 0, 0 90, 90 90, 0 0)))"
|
||||
};
|
||||
|
||||
#endif // PERIMETER_POLYGON_CASES_HPP
|
88
test/algorithms/perimeter/perimeter_sph.cpp
Normal file
88
test/algorithms/perimeter/perimeter_sph.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include <algorithms/test_perimeter.hpp>
|
||||
#include <algorithms/perimeter/perimeter_polygon_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
|
||||
template <typename P>
|
||||
void test_all_default() //test the default strategy
|
||||
{
|
||||
double const pi = boost::math::constants::pi<double>();
|
||||
|
||||
for (std::size_t i = 0; i <= 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::polygon<P> >(poly_data_sph[i], 2 * pi);
|
||||
}
|
||||
|
||||
// Multipolygon
|
||||
test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
|
||||
(multipoly_data[0], 3 * pi);
|
||||
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0);
|
||||
test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,3 4,4 3)", 0);
|
||||
}
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all_haversine(double const mean_radius)
|
||||
{
|
||||
double const pi = boost::math::constants::pi<double>();
|
||||
bg::strategy::distance::haversine<double> haversine_strategy(mean_radius);
|
||||
|
||||
for (std::size_t i = 0; i <= 2; ++i)
|
||||
{
|
||||
test_geometry<bg::model::polygon<P> >(poly_data_sph[i],
|
||||
2 * pi * mean_radius,
|
||||
haversine_strategy);
|
||||
}
|
||||
|
||||
// Multipolygon
|
||||
test_geometry<bg::model::multi_polygon<bg::model::polygon<P> > >
|
||||
(multipoly_data[0],
|
||||
3 * pi * mean_radius,
|
||||
haversine_strategy);
|
||||
|
||||
// Geometries with length zero
|
||||
test_geometry<P>("POINT(0 0)", 0, haversine_strategy);
|
||||
test_geometry<bg::model::linestring<P> >("LINESTRING(0 0,3 4,4 3)",
|
||||
0,
|
||||
haversine_strategy);
|
||||
}
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
//Earth radius estimation in Km
|
||||
//(see https://en.wikipedia.org/wiki/Earth_radius)
|
||||
double const mean_radius = 6371.0;
|
||||
|
||||
test_all_default<bg::model::d2::point_xy<int,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
test_all_default<bg::model::d2::point_xy<float,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
test_all_default<bg::model::d2::point_xy<double,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
|
||||
test_all_haversine<bg::model::d2::point_xy<int,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
|
||||
test_all_haversine<bg::model::d2::point_xy<float,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
|
||||
test_all_haversine<bg::model::d2::point_xy<double,
|
||||
bg::cs::spherical_equatorial<bg::degree> > >(mean_radius);
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_all<bg::model::d2::point_xy<ttmath_big> >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
@ -14,18 +14,10 @@
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
test-suite boost-geometry-algorithms-relational
|
||||
:
|
||||
[ run covered_by.cpp : : : : algorithms_covered_by ]
|
||||
[ run covered_by_multi.cpp : : : : algorithms_covered_by_multi ]
|
||||
[ run covered_by_sph_geo.cpp : : : : algorithms_covered_by_sph_geo ]
|
||||
[ run crosses.cpp : : : : algorithms_crosses ]
|
||||
[ run equals.cpp : : : : algorithms_equals ]
|
||||
[ run equals_multi.cpp : : : : algorithms_equals_multi ]
|
||||
[ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ]
|
||||
;
|
||||
|
||||
build-project covered_by ;
|
||||
build-project crosses ;
|
||||
build-project disjoint ;
|
||||
build-project equals ;
|
||||
build-project intersects ;
|
||||
build-project overlaps ;
|
||||
build-project relate ;
|
||||
|
23
test/algorithms/relational_operations/covered_by/Jamfile.v2
Normal file
23
test/algorithms/relational_operations/covered_by/Jamfile.v2
Normal file
@ -0,0 +1,23 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
#
|
||||
# This file was modified by Oracle on 2014, 2015, 2016.
|
||||
# Modifications copyright (c) 2014-2016, 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
|
||||
#
|
||||
# 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)
|
||||
|
||||
test-suite boost-geometry-algorithms-covered_by
|
||||
:
|
||||
[ run covered_by.cpp : : : : algorithms_covered_by ]
|
||||
[ run covered_by_multi.cpp : : : : algorithms_covered_by_multi ]
|
||||
[ run covered_by_sph.cpp : : : : algorithms_covered_by_sph ]
|
||||
[ run covered_by_sph_geo.cpp : : : : algorithms_covered_by_sph_geo ]
|
||||
;
|
@ -0,0 +1,273 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include "test_covered_by.hpp"
|
||||
|
||||
#include <algorithms/overlay/overlay_cases.hpp>
|
||||
#include <algorithms/overlay/multi_overlay_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_polygon_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
test_geometry<ring, ring>(case_1[0], case_1[1],
|
||||
false);
|
||||
test_geometry<ring, poly>(case_1[0], case_1[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_1[0], case_1[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_2[0], case_2[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
|
||||
true);
|
||||
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
|
||||
true);
|
||||
test_geometry<poly, poly>(case_4[0], case_4[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_5[0], case_5[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_6_sph[1], case_6_sph[0],
|
||||
true);
|
||||
|
||||
test_geometry<poly, poly>(case_7[0], case_7[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_11_sph[1], case_11_sph[0],
|
||||
true);
|
||||
test_geometry<poly, poly>(case_12[0], case_12[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_17_sph[1], case_17_sph[0],
|
||||
true);
|
||||
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_18_sph[1], case_18_sph[0],
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_polygon_multi_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<ring, mpoly>(case_1[0], case_multi_2[0],
|
||||
false);
|
||||
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_polygon_multi_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::polygon<P> ring;
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
true);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
true);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_multi_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
|
||||
"MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
|
||||
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_multi_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
|
||||
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
|
||||
true);
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
|
||||
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
|
||||
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true);
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_multi_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
|
||||
"MULTILINESTRING((1 0,2 0),(1 1,2 1))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
|
||||
"MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_multi_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))",
|
||||
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_point_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/9162
|
||||
test_geometry<P, poly>("POINT(0 90)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly>("POINT(-120 21)",
|
||||
"POLYGON((30 0,30 30,90 30, 90 0, 30 0))",
|
||||
false);
|
||||
// extended
|
||||
test_geometry<P, poly>("POINT(0 -90)",
|
||||
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
|
||||
true);
|
||||
test_geometry<P, poly>("POINT(0 89)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
test_geometry<P, poly>("POINT(-180 89)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
true);
|
||||
}
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_polygon_polygon<P>();
|
||||
test_polygon_multi_polygon<P>();
|
||||
test_multi_polygon_multi_polygon<P>();
|
||||
|
||||
test_linestring_polygon<P>();
|
||||
test_linestring_multi_polygon<P>();
|
||||
test_multi_linestring_polygon<P>();
|
||||
test_multi_linestring_multi_polygon<P>();
|
||||
|
||||
test_linestring_linestring<P>();
|
||||
test_linestring_multi_linestring<P>();
|
||||
test_multi_linestring_multi_linestring<P>();
|
||||
|
||||
test_point_polygon<P>();
|
||||
}
|
||||
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
21
test/algorithms/relational_operations/crosses/Jamfile.v2
Normal file
21
test/algorithms/relational_operations/crosses/Jamfile.v2
Normal file
@ -0,0 +1,21 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
#
|
||||
# This file was modified by Oracle on 2014, 2015, 2016.
|
||||
# Modifications copyright (c) 2014-2016, 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
|
||||
#
|
||||
# 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)
|
||||
|
||||
test-suite boost-geometry-algorithms-crosses
|
||||
:
|
||||
[ run crosses.cpp : : : : algorithms_crosses ]
|
||||
[ run crosses_sph.cpp : : : : algorithms_crosses_sph ]
|
||||
;
|
119
test/algorithms/relational_operations/crosses/crosses_sph.cpp
Normal file
119
test/algorithms/relational_operations/crosses/crosses_sph.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include "test_crosses.hpp"
|
||||
|
||||
#include <algorithms/overlay/overlay_cases.hpp>
|
||||
#include <algorithms/overlay/multi_overlay_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::polygon<P> ring;
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_multi_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
|
||||
"MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
|
||||
true);
|
||||
|
||||
test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
|
||||
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
|
||||
true);
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_multi_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
|
||||
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
|
||||
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
|
||||
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_linestring_polygon<P>();
|
||||
test_linestring_multi_polygon<P>();
|
||||
test_multi_linestring_polygon<P>();
|
||||
test_multi_linestring_multi_polygon<P>();
|
||||
}
|
||||
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
@ -4,8 +4,8 @@
|
||||
# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
#
|
||||
# This file was modified by Oracle on 2014, 2015.
|
||||
# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates.
|
||||
# This file was modified by Oracle on 2014, 2015, 2016.
|
||||
# Modifications copyright (c) 2014-2016, 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
|
||||
@ -25,4 +25,5 @@ test-suite boost-geometry-algorithms-disjoint
|
||||
[ run disjoint_coverage_p_p.cpp : : : : algorithms_disjoint_coverage_p_p ]
|
||||
[ run disjoint_multi.cpp : : : : algorithms_disjoint_multi ]
|
||||
[ run disjoint_point_box_geometry.cpp : : : : algorithms_disjoint_point_box_geometry ]
|
||||
[ run disjoint_sph.cpp : : : : algorithms_disjoint_sph ]
|
||||
;
|
||||
|
271
test/algorithms/relational_operations/disjoint/disjoint_sph.cpp
Normal file
271
test/algorithms/relational_operations/disjoint/disjoint_sph.cpp
Normal file
@ -0,0 +1,271 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include "test_disjoint.hpp"
|
||||
|
||||
#include <algorithms/overlay/overlay_cases.hpp>
|
||||
#include <algorithms/overlay/multi_overlay_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_polygon_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
test_geometry<ring, ring>(case_1[0], case_1[1],
|
||||
false);
|
||||
test_geometry<ring, poly>(case_1[0], case_1[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_1[0], case_1[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_2[0], case_2[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_4[0], case_4[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_5[0], case_5[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_7[0], case_7[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_12[0], case_12[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_17_sph[1], case_17_sph[0],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_18_sph[1], case_18_sph[0],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_polygon_multi_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<ring, mpoly>(case_1[0], case_multi_2[0],
|
||||
false);
|
||||
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_polygon_multi_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::polygon<P> ring;
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls, ring>("LINESTRING(11 0,11 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 10)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(5 0,5 5,10 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(5 1,5 5,9 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", false);
|
||||
test_geometry<ls, poly>("LINESTRING(11 1,11 5)", "POLYGON((0 0,0 10,10 10,10 0,0 0))", true);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(9 1,10 5,9 9,1 9,1 1,9 1)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, poly>("LINESTRING(0 0,10 0,10 10,0 10,0 0)",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_multi_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<ls, mpoly>("LINESTRING(10 1,10 5,10 9)",
|
||||
"MULTIPOLYGON(((0 20,0 30,10 30,10 20,0 20)),((0 0,0 10,10 10,10 0,0 0),(10 5,2 8,2 2,10 5)))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, ring>("MULTILINESTRING((6 6,15 15),(0 0, 7 7))",
|
||||
"POLYGON((5 5,5 15,15 15,15 5,5 5))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((3 10.031432746397092, 1 5, 1 10.013467818052765, 3 4, 7 8, 6 10.035925377760330, 10 2))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_multi_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10,0 10,0 0),(2 2,5 5,2 8,2 2))",
|
||||
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0),(2 2,5 5,2 8,2 2)))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((0 0,10 0,10 10),(10 10,0 10,0 0),(20 20,50 50,20 80,20 20))",
|
||||
"MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)))",
|
||||
false);
|
||||
|
||||
test_geometry<mls, mpoly>("MULTILINESTRING((5 -2,4 -2,5 0),(5 -2,6 -2,5 0))",
|
||||
"MULTIPOLYGON(((5 0,0 5,10 5,5 0)),((5 0,10 -5,0 -5,5 0)))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", false);
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_multi_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
|
||||
"MULTILINESTRING((1 0,2 0),(1 1,2 1))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
|
||||
"MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_multi_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))",
|
||||
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_point_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
|
||||
// https://svn.boost.org/trac/boost/ticket/9162
|
||||
test_geometry<P, poly>("POINT(0 90)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
false);
|
||||
test_geometry<P, poly>("POINT(-120 21)",
|
||||
"POLYGON((30 0,30 30,90 30, 90 0, 30 0))",
|
||||
true);
|
||||
// extended
|
||||
test_geometry<P, poly>("POINT(0 -90)",
|
||||
"POLYGON((0 -80,90 -80, -180 -80, -90 -80, 0 -80))",
|
||||
false);
|
||||
test_geometry<P, poly>("POINT(0 89)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
false);
|
||||
test_geometry<P, poly>("POINT(-180 89)",
|
||||
"POLYGON((0 80,-90 80, -180 80, 90 80, 0 80))",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_polygon_polygon<P>();
|
||||
test_polygon_multi_polygon<P>();
|
||||
test_multi_polygon_multi_polygon<P>();
|
||||
|
||||
test_linestring_polygon<P>();
|
||||
test_linestring_multi_polygon<P>();
|
||||
test_multi_linestring_polygon<P>();
|
||||
test_multi_linestring_multi_polygon<P>();
|
||||
|
||||
test_linestring_linestring<P>();
|
||||
test_linestring_multi_linestring<P>();
|
||||
test_multi_linestring_multi_linestring<P>();
|
||||
|
||||
test_point_polygon<P>();
|
||||
}
|
||||
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
@ -27,21 +27,34 @@
|
||||
|
||||
template <typename G1, typename G2>
|
||||
void check_disjoint(std::string const& id,
|
||||
std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
G1 const& g1,
|
||||
G2 const& g2,
|
||||
bool expected)
|
||||
{
|
||||
bool detected = bg::disjoint(g1, g2);
|
||||
BOOST_CHECK_MESSAGE(detected == expected,
|
||||
"disjoint: " << id
|
||||
<< " -> Expected: " << expected
|
||||
<< " detected: " << detected);
|
||||
if (id.empty())
|
||||
{
|
||||
BOOST_CHECK_MESSAGE(detected == expected,
|
||||
"disjoint: " << wkt1 << " and " << wkt2
|
||||
<< " -> Expected: " << expected
|
||||
<< " detected: " << detected);
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_CHECK_MESSAGE(detected == expected,
|
||||
"disjoint: " << id
|
||||
<< " -> Expected: " << expected
|
||||
<< " detected: " << detected);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename G1, typename G2>
|
||||
void test_disjoint(std::string const& id,
|
||||
std::string const& wkt1,
|
||||
std::string const& wkt2, bool expected)
|
||||
std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
bool expected)
|
||||
{
|
||||
G1 g1;
|
||||
bg::read_wkt(wkt1, g1);
|
||||
@ -52,11 +65,18 @@ void test_disjoint(std::string const& id,
|
||||
boost::variant<G1> v1(g1);
|
||||
boost::variant<G2> v2(g2);
|
||||
|
||||
check_disjoint(id, g1, g2, expected);
|
||||
check_disjoint(id, v1, g2, expected);
|
||||
check_disjoint(id, g1, v2, expected);
|
||||
check_disjoint(id, v1, v2, expected);
|
||||
check_disjoint(id, wkt1, wkt2, g1, g2, expected);
|
||||
check_disjoint(id, wkt1, wkt2, v1, g2, expected);
|
||||
check_disjoint(id, wkt1, wkt2, g1, v2, expected);
|
||||
check_disjoint(id, wkt1, wkt2, v1, v2, expected);
|
||||
}
|
||||
|
||||
template <typename G1, typename G2>
|
||||
void test_geometry(std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
bool expected)
|
||||
{
|
||||
test_disjoint<G1, G2>("", wkt1, wkt2, expected);
|
||||
}
|
||||
|
||||
#endif // BOOST_GEOMETRY_TEST_DISJOINT_HPP
|
||||
|
22
test/algorithms/relational_operations/equals/Jamfile.v2
Normal file
22
test/algorithms/relational_operations/equals/Jamfile.v2
Normal file
@ -0,0 +1,22 @@
|
||||
# Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
#
|
||||
# Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
# Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
|
||||
# Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
|
||||
#
|
||||
# This file was modified by Oracle on 2014, 2015, 2016.
|
||||
# Modifications copyright (c) 2014-2016, 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
|
||||
#
|
||||
# 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)
|
||||
|
||||
test-suite boost-geometry-algorithms-equals
|
||||
:
|
||||
[ run equals.cpp : : : : algorithms_equals ]
|
||||
[ run equals_multi.cpp : : : : algorithms_equals_multi ]
|
||||
[ run equals_on_spheroid.cpp : : : : algorithms_equals_on_spheroid ]
|
||||
;
|
155
test/algorithms/relational_operations/equals/equals_sph.cpp
Normal file
155
test/algorithms/relational_operations/equals/equals_sph.cpp
Normal file
@ -0,0 +1,155 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
|
||||
#include "test_equals.hpp"
|
||||
|
||||
#include <algorithms/overlay/overlay_cases.hpp>
|
||||
#include <algorithms/overlay/multi_overlay_cases.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_polygon_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
test_geometry<poly, ring>(case_1[0], case_1[0],
|
||||
true);
|
||||
test_geometry<ring, ring>(case_1[0], case_1[1],
|
||||
false);
|
||||
test_geometry<ring, poly>(case_1[0], case_1[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_1[0], case_1[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_2[0], case_2[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_3_sph[0], case_3_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_3_2_sph[0], case_3_2_sph[1],
|
||||
true);
|
||||
test_geometry<poly, poly>(case_4[0], case_4[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_5[0], case_5[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_6_sph[0], case_6_sph[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_7[0], case_7[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_8_sph[0], case_8_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_9_sph[0], case_9_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_10_sph[0], case_10_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_11_sph[0], case_11_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_12[0], case_12[1],
|
||||
false);
|
||||
|
||||
test_geometry<poly, poly>(case_13_sph[0], case_13_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_14_sph[0], case_14_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_15_sph[0], case_15_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_16_sph[0], case_16_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_17_sph[0], case_17_sph[1],
|
||||
false);
|
||||
test_geometry<poly, poly>(case_18_sph[0], case_18_sph[1],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_polygon_multi_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<ring, mpoly>(case_1[0], case_multi_2[0],
|
||||
false);
|
||||
test_geometry<poly, mpoly>(case_2[0], case_multi_2[0],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_polygon_multi_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
|
||||
test_geometry<mpoly, mpoly>(case_multi_2[0], case_multi_2[1],
|
||||
false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0, 2 2, 3 2)", "LINESTRING(0 0, 2 2, 3 2)", true);
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,2 2,2 3)", "LINESTRING(0 0, 2 2, 3 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_linestring_multi_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,10 0)",
|
||||
"MULTILINESTRING((1 0,2 0),(1 1,2 1))",
|
||||
false);
|
||||
|
||||
test_geometry<ls, mls>("LINESTRING(0 0,5 0,5 5,0 5,0 0)",
|
||||
"MULTILINESTRING((5 5,0 5,0 0),(0 0,5 0,5 5))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_multi_linestring_multi_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<mls, mls>("MULTILINESTRING((0 0,0 0,18 0,18 0,19 0,19 0,19 0,30 0,30 0))",
|
||||
"MULTILINESTRING((0 10,5 0,20 0,20 0,30 0))",
|
||||
false);
|
||||
}
|
||||
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_polygon_polygon<P>();
|
||||
test_polygon_multi_polygon<P>();
|
||||
test_multi_polygon_multi_polygon<P>();
|
||||
|
||||
test_linestring_linestring<P>();
|
||||
test_linestring_multi_linestring<P>();
|
||||
test_multi_linestring_multi_linestring<P>();
|
||||
}
|
||||
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::point<double, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
|
||||
#if defined(HAVE_TTMATH)
|
||||
test_cs<bg::model::point<ttmath_big, 2, bg::cs::spherical_equatorial<bg::degree> > >();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
@ -4,6 +4,10 @@
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2016.
|
||||
// Modifications copyright (c) 2016 Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// 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)
|
||||
@ -66,4 +70,12 @@ void test_geometry(std::string const& caseid,
|
||||
check_geometry(boost::variant<Geometry1>(geometry1), boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected);
|
||||
}
|
||||
|
||||
template <typename Geometry1, typename Geometry2>
|
||||
void test_geometry(std::string const& wkt1,
|
||||
std::string const& wkt2,
|
||||
bool expected)
|
||||
{
|
||||
test_geometry<Geometry1, Geometry2>("", wkt1, wkt2, expected);
|
||||
}
|
||||
|
||||
#endif
|
@ -14,12 +14,13 @@
|
||||
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
# http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
test-suite boost-geometry-algorithms-relational-intersects
|
||||
test-suite boost-geometry-algorithms-intersects
|
||||
:
|
||||
[ run intersects.cpp : : : : algorithms_intersects ]
|
||||
[ run intersects_box_geometry.cpp : : : : algorithms_intersects_box_geometry ]
|
||||
[ run intersects_multi.cpp : : : : algorithms_intersects_multi ]
|
||||
[ run intersects_self.cpp : : : : algorithms_intersects_self ]
|
||||
[ run intersects_sph_geo.cpp : : : : algorithms_intersects_sph_geo ]
|
||||
[ run intersects_sph.cpp : : : : algorithms_intersects_sph ]
|
||||
;
|
||||
|
||||
|
@ -3,8 +3,9 @@
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013, 2015.
|
||||
// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2013, 2015, 2016.
|
||||
// Modifications copyright (c) 2013-2016, Oracle and/or its affiliates.
|
||||
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -18,20 +19,21 @@
|
||||
|
||||
#include <boost/geometry/util/rational.hpp>
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_polygon_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P, false, false> poly_ccw_o;
|
||||
test_geometry<poly_ccw_o, poly_ccw_o>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
|
||||
test_geometry<poly_ccw_o, poly_ccw_o>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
|
||||
test_geometry<poly_ccw_o, poly_ccw_o>("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
|
||||
typedef bg::model::polygon<P1, false, false> poly_ccw_o1;
|
||||
typedef bg::model::polygon<P2, false, false> poly_ccw_o2;
|
||||
test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
|
||||
test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
|
||||
test_geometry<poly_ccw_o1, poly_ccw_o2>("POLYGON((7 7, 9 7, 9 9, 7 9))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_linestring_segment()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::segment<P> seg;
|
||||
typedef bg::model::linestring<P1> ls;
|
||||
typedef bg::model::segment<P2> seg;
|
||||
|
||||
test_geometry<ls, seg>("LINESTRING(1 1, 3 3, 2 5)", "SEGMENT(2 0, 2 6)", true);
|
||||
test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(1 0, 1 1)", true);
|
||||
@ -39,28 +41,29 @@ void test_intersects_linestring_segment()
|
||||
test_geometry<ls, seg>("LINESTRING(1 1, 3 3)", "SEGMENT(3 0, 4 1)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_linestring_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::linestring<P1> ls1;
|
||||
typedef bg::model::linestring<P2> ls2;
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(0 0,1 1,2 2)", true);
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(2 2,1 1,0 0)", true);
|
||||
test_geometry<ls, ls>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(0 0,1 1,2 2)", true);
|
||||
test_geometry<ls, ls>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(2 2,1 1,0 0)", true);
|
||||
test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(0 0,1 1,2 2)", true);
|
||||
test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(2 2,1 1,0 0)", true);
|
||||
test_geometry<ls1, ls2>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(0 0,1 1,2 2)", true);
|
||||
test_geometry<ls1, ls2>("LINESTRING(3 0,2 0,0 0)", "LINESTRING(2 2,1 1,0 0)", true);
|
||||
|
||||
test_geometry<ls, ls>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(1 0,4 0,5 0)", true);
|
||||
test_geometry<ls, ls>("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", true);
|
||||
test_geometry<ls1, ls2>("LINESTRING(0 0,2 0,3 0)", "LINESTRING(1 0,4 0,5 0)", true);
|
||||
test_geometry<ls1, ls2>("LINESTRING(1 0,2 0)", "LINESTRING(1 0,0 0)", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::linestring<P1> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
typedef bg::model::polygon<P> poly_cw_c;
|
||||
typedef bg::model::polygon<P, false> poly_ccw_c;
|
||||
typedef bg::model::polygon<P, false, false> poly_ccw_o;
|
||||
typedef bg::model::polygon<P2> poly_cw_c;
|
||||
typedef bg::model::polygon<P2, false> poly_ccw_c;
|
||||
typedef bg::model::polygon<P2, false, false> poly_ccw_o;
|
||||
typedef bg::model::multi_polygon<poly_ccw_c> mpoly_ccw_c;
|
||||
|
||||
test_geometry<ls, poly_ccw_c>("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
|
||||
@ -81,12 +84,12 @@ void test_intersects_linestring_polygon()
|
||||
test_geometry<mls, mpoly_ccw_c>("MULTILINESTRING((1 1,2 2))", "MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0)))", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_linestring_ring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::linestring<P1> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
typedef bg::model::ring<P, false> ring_ccw_c;
|
||||
typedef bg::model::ring<P2, false> ring_ccw_c;
|
||||
|
||||
test_geometry<ls, ring_ccw_c>("LINESTRING(1 1,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
|
||||
test_geometry<ls, ring_ccw_c>("LINESTRING(1 0,2 2)", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
|
||||
@ -96,11 +99,11 @@ void test_intersects_linestring_ring()
|
||||
test_geometry<mls, ring_ccw_c>("MULTILINESTRING((1 1,2 2))", "POLYGON((0 0,10 0,10 10,0 10,0 0))", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_ring_polygon()
|
||||
{
|
||||
typedef bg::model::ring<P, false, false> ring_ccw_o;
|
||||
typedef bg::model::polygon<P, false, false> poly_ccw_o;
|
||||
typedef bg::model::ring<P1, false, false> ring_ccw_o;
|
||||
typedef bg::model::polygon<P2, false, false> poly_ccw_o;
|
||||
|
||||
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((1 1, 3 3, 2 5))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", true);
|
||||
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((6 6, 7 6, 7 7, 6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
|
||||
@ -109,36 +112,36 @@ void test_intersects_ring_polygon()
|
||||
test_geometry<ring_ccw_o, poly_ccw_o>("POLYGON((6 6,7 6,7 7,6 7))", "POLYGON((0 0, 9 0, 9 9, 0 9),(5 5,5 8,8 8,8 5))", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_point_linestring()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::linestring<P2> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
|
||||
test_geometry<P, ls>("POINT(0 0)", "LINESTRING(0 0,2 2,4 0)", true);
|
||||
test_geometry<P, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,4 0)", true);
|
||||
test_geometry<P, ls>("POINT(1 0)", "LINESTRING(0 0,2 2,4 0)", false);
|
||||
test_geometry<P1, ls>("POINT(0 0)", "LINESTRING(0 0,2 2,4 0)", true);
|
||||
test_geometry<P1, ls>("POINT(1 1)", "LINESTRING(0 0,2 2,4 0)", true);
|
||||
test_geometry<P1, ls>("POINT(1 0)", "LINESTRING(0 0,2 2,4 0)", false);
|
||||
|
||||
// MULTI
|
||||
test_geometry<P, mls>("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true);
|
||||
test_geometry<P1, mls>("POINT(0 0)", "MULTILINESTRING((0 0,2 2,4 0))", true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_intersects_point_segment()
|
||||
{
|
||||
typedef bg::model::segment<P> seg;
|
||||
typedef bg::model::segment<P2> 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);
|
||||
test_geometry<P1, seg>("POINT(0 0)", "LINESTRING(0 0,2 2)", true);
|
||||
test_geometry<P1, seg>("POINT(1 1)", "LINESTRING(0 0,2 2)", true);
|
||||
test_geometry<P1, seg>("POINT(1 0)", "LINESTRING(0 0,2 2)", false);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_multi_linestring_polygon()
|
||||
{
|
||||
typedef bg::model::linestring<P> ls;
|
||||
typedef bg::model::linestring<P1> ls;
|
||||
typedef bg::model::multi_linestring<ls> mls;
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::polygon<P2> poly;
|
||||
|
||||
test_geometry<mls, poly>("MULTILINESTRING((11 11, 20 20),(5 7, 4 1))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
|
||||
@ -148,56 +151,69 @@ void test_multi_linestring_polygon()
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_multi_polygon_polygon()
|
||||
{
|
||||
typedef bg::model::polygon<P> poly;
|
||||
typedef bg::model::multi_polygon<poly> mpoly;
|
||||
typedef bg::model::polygon<P1> poly1;
|
||||
typedef bg::model::multi_polygon<poly1> mpoly;
|
||||
typedef bg::model::polygon<P2> poly2;
|
||||
|
||||
test_geometry<mpoly, poly>("MULTIPOLYGON(((11 11,11 20,20 20,20 11,11 11)),((5 5,5 6,6 6,6 5,5 5)))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
|
||||
true);
|
||||
test_geometry<mpoly, poly2>("MULTIPOLYGON(((11 11,11 20,20 20,20 11,11 11)),((5 5,5 6,6 6,6 5,5 5)))",
|
||||
"POLYGON((0 0,0 10,10 10,10 0,0 0),(2 2,4 2,4 4,2 4,2 2))",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
void test_point_polygon()
|
||||
{
|
||||
typedef bg::model::ring<P2> ring;
|
||||
typedef bg::model::polygon<P2> poly;
|
||||
|
||||
test_geometry<P1, ring>(
|
||||
"POINT(0 0)",
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
true);
|
||||
test_geometry<P1, poly>(
|
||||
"POINT(0 0)",
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
true);
|
||||
|
||||
test_geometry<ring, P1>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
"POINT(0 0)",
|
||||
true);
|
||||
test_geometry<poly, P1>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
"POINT(0 0)",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P1, typename P2>
|
||||
void test_all()
|
||||
{
|
||||
test_intersects_point_segment<P1, P2>();
|
||||
test_intersects_point_linestring<P1, P2>();
|
||||
test_intersects_polygon_polygon<P1, P2>();
|
||||
test_intersects_linestring_polygon<P1, P2>();
|
||||
test_intersects_linestring_ring<P1, P2>();
|
||||
test_intersects_linestring_segment<P1, P2>();
|
||||
test_intersects_linestring_linestring<P1, P2>();
|
||||
test_intersects_ring_polygon<P1, P2>();
|
||||
test_multi_linestring_polygon<P1, P2>();
|
||||
test_multi_polygon_polygon<P1, P2>();
|
||||
test_point_polygon<P1, P2>();
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
|
||||
test_intersects_point_segment<P>();
|
||||
test_intersects_point_linestring<P>();
|
||||
test_intersects_polygon_polygon<P>();
|
||||
test_intersects_linestring_polygon<P>();
|
||||
test_intersects_linestring_ring<P>();
|
||||
test_intersects_linestring_segment<P>();
|
||||
test_intersects_linestring_linestring<P>();
|
||||
test_intersects_ring_polygon<P>();
|
||||
test_multi_linestring_polygon<P>();
|
||||
test_multi_polygon_polygon<P>();
|
||||
|
||||
test_geometry<P, ring>(
|
||||
"POINT(0 0)",
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
true);
|
||||
test_geometry<P, polygon>(
|
||||
"POINT(0 0)",
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
true);
|
||||
|
||||
test_geometry<ring, P>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
"POINT(0 0)",
|
||||
true);
|
||||
test_geometry<polygon, P>(
|
||||
"POLYGON((0 0,3 3,3 3,4 1))",
|
||||
"POINT(0 0)",
|
||||
true);
|
||||
test_all<P, P>();
|
||||
}
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
test_all<bg::model::d2::point_xy<double>, bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
|
||||
#if ! defined(BOOST_GEOMETRY_RESCALE_TO_ROBUST)
|
||||
test_all<bg::model::d2::point_xy<boost::rational<int> > >();
|
||||
|
@ -3,8 +3,8 @@
|
||||
// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
|
||||
|
||||
// This file was modified by Oracle on 2013, 2015.
|
||||
// Modifications copyright (c) 2013-2015, Oracle and/or its affiliates.
|
||||
// This file was modified by Oracle on 2013, 2015, 2016.
|
||||
// Modifications copyright (c) 2013-2016, Oracle and/or its affiliates.
|
||||
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -19,35 +19,41 @@
|
||||
#include <boost/geometry/util/rational.hpp>
|
||||
|
||||
|
||||
template <typename P>
|
||||
template <typename P1, typename P2>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::model::polygon<P> polygon;
|
||||
typedef bg::model::ring<P> ring;
|
||||
typedef bg::model::polygon<P1> polygon;
|
||||
typedef bg::model::ring<P1> ring;
|
||||
|
||||
// intersect <=> ! disjoint (in most cases)
|
||||
// so most tests are done in disjoint test.
|
||||
// We only test compilation of a few cases.
|
||||
test_geometry<P, bg::model::box<P> >("POINT(1 1)", "BOX(0 0,2 2)", true);
|
||||
test_geometry<P1, bg::model::box<P2> >("POINT(1 1)", "BOX(0 0,2 2)", true);
|
||||
|
||||
test_geometry<polygon, bg::model::box<P> >(
|
||||
test_geometry<polygon, bg::model::box<P2> >(
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<ring, bg::model::box<P> >(
|
||||
test_geometry<ring, bg::model::box<P2> >(
|
||||
"POLYGON((1992 3240,1992 1440,3792 1800,3792 3240,1992 3240))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<polygon, bg::model::box<P> >(
|
||||
test_geometry<polygon, bg::model::box<P2> >(
|
||||
"POLYGON((1941 2066,2055 2066,2055 2166,1941 2166))",
|
||||
"BOX(1941 2066, 2055 2166)", true);
|
||||
|
||||
test_geometry<P, bg::model::box<P> >(
|
||||
test_geometry<P1, bg::model::box<P2> >(
|
||||
"POINT(0 0)",
|
||||
"BOX(0 0,4 4)",
|
||||
true);
|
||||
}
|
||||
|
||||
template <typename P>
|
||||
void test_all()
|
||||
{
|
||||
test_all<P, P>();
|
||||
}
|
||||
|
||||
// Those tests won't pass for rational<> because numeric_limits<> isn't specialized for this type
|
||||
template <typename P>
|
||||
void test_additional()
|
||||
@ -150,6 +156,7 @@ void test_additional()
|
||||
|
||||
int test_main( int , char* [] )
|
||||
{
|
||||
test_all<bg::model::d2::point_xy<float>, bg::model::point<double, 2, bg::cs::cartesian> >();
|
||||
test_all<bg::model::d2::point_xy<double> >();
|
||||
test_additional<bg::model::d2::point_xy<double> >();
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user