mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-09 11:12:21 +00:00
Merge branch 'develop' of github.com:boostorg/geometry into develop
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -19,6 +24,7 @@
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp>
|
||||
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
@@ -39,7 +45,9 @@ void test_andoyer(double lon1, double lat1, double lon2, double lat2, double exp
|
||||
typename bg::coordinate_type<P1>::type
|
||||
>::type rtype;
|
||||
|
||||
typedef bg::strategy::distance::andoyer<rtype> andoyer_type;
|
||||
typedef bg::srs::spheroid<rtype> stype;
|
||||
|
||||
typedef bg::strategy::distance::andoyer<stype> andoyer_type;
|
||||
|
||||
BOOST_CONCEPT_ASSERT
|
||||
(
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -19,6 +24,7 @@
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp>
|
||||
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
@@ -39,7 +45,9 @@ void test_vincenty(double lon1, double lat1, double lon2, double lat2, double ex
|
||||
typename bg::coordinate_type<P1>::type
|
||||
>::type rtype;
|
||||
|
||||
typedef bg::strategy::distance::vincenty<rtype> vincenty_type;
|
||||
typedef bg::srs::spheroid<rtype> stype;
|
||||
|
||||
typedef bg::strategy::distance::vincenty<stype> vincenty_type;
|
||||
|
||||
BOOST_CONCEPT_ASSERT(
|
||||
(
|
||||
|
||||
@@ -81,7 +81,7 @@ struct access<custom_circle, 1>
|
||||
};
|
||||
|
||||
template<>
|
||||
struct radius_access<custom_circle, int, 0>
|
||||
struct radius_access<custom_circle, 0>
|
||||
{
|
||||
static inline int get(custom_circle const& c)
|
||||
{
|
||||
|
||||
69
include/boost/geometry/algorithms/detail/flattening.hpp
Normal file
69
include/boost/geometry/algorithms/detail/flattening.hpp
Normal file
@@ -0,0 +1,69 @@
|
||||
// Boost.Geometry
|
||||
|
||||
// Copyright (c) 2014 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_ALGORITHMS_DETAIL_FLATTENING_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_FLATTENING_HPP
|
||||
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/not_implemented.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace detail_dispatch
|
||||
{
|
||||
|
||||
template <typename ResultType, typename Geometry, typename Tag = typename tag<Geometry>::type>
|
||||
struct flattening
|
||||
: not_implemented<Tag>
|
||||
{};
|
||||
|
||||
template <typename ResultType, typename Geometry>
|
||||
struct flattening<ResultType, Geometry, srs_sphere_tag>
|
||||
{
|
||||
static inline ResultType apply(Geometry const& geometry)
|
||||
{
|
||||
return ResultType(0);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename ResultType, typename Geometry>
|
||||
struct flattening<ResultType, Geometry, srs_spheroid_tag>
|
||||
{
|
||||
static inline ResultType apply(Geometry const& geometry)
|
||||
{
|
||||
return ResultType(get_radius<0>(geometry) - get_radius<2>(geometry))
|
||||
/ ResultType(get_radius<0>(geometry));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail_dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename ResultType, typename Geometry>
|
||||
ResultType flattening(Geometry const& geometry)
|
||||
{
|
||||
return detail_dispatch::flattening<ResultType, Geometry>::apply(geometry);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_FLATTENING_HPP
|
||||
250
include/boost/geometry/core/radius.hpp
Normal file
250
include/boost/geometry/core/radius.hpp
Normal file
@@ -0,0 +1,250 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// 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.
|
||||
|
||||
// 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_CORE_RADIUS_HPP
|
||||
#define BOOST_GEOMETRY_CORE_RADIUS_HPP
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/util/bare_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace traits
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Traits class to get/set radius of a circle/sphere/(ellipse)
|
||||
\details the radius access meta-functions give read/write access to the radius of a circle or a sphere,
|
||||
or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid.
|
||||
|
||||
It should be specialized per geometry, in namespace core_dispatch. Those specializations should
|
||||
forward the call via traits to the geometry class, which could be specified by the user.
|
||||
|
||||
There is a corresponding generic radius_get and radius_set function
|
||||
\par Geometries:
|
||||
- n-sphere (circle,sphere)
|
||||
- upcoming ellipse
|
||||
\par Specializations should provide:
|
||||
- inline static T get(Geometry const& geometry)
|
||||
- inline static void set(Geometry& geometry, T const& radius)
|
||||
\ingroup traits
|
||||
*/
|
||||
template <typename Geometry, std::size_t Dimension>
|
||||
struct radius_access {};
|
||||
|
||||
|
||||
/*!
|
||||
\brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere
|
||||
\par Geometries:
|
||||
- n-sphere (circle,sphere)
|
||||
- upcoming ellipse
|
||||
\par Specializations should provide:
|
||||
- typedef T type (double,float,int,etc)
|
||||
\ingroup traits
|
||||
*/
|
||||
template <typename Geometry>
|
||||
struct radius_type {};
|
||||
|
||||
} // namespace traits
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace core_dispatch
|
||||
{
|
||||
|
||||
template <typename Tag, typename Geometry>
|
||||
struct radius_type
|
||||
{
|
||||
//typedef core_dispatch_specialization_required type;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief radius access meta-functions, used by concept n-sphere and upcoming ellipse.
|
||||
*/
|
||||
template <typename Tag,
|
||||
typename Geometry,
|
||||
std::size_t Dimension,
|
||||
typename IsPointer>
|
||||
struct radius_access
|
||||
{
|
||||
//static inline CoordinateType get(Geometry const& ) {}
|
||||
//static inline void set(Geometry& g, CoordinateType const& value) {}
|
||||
};
|
||||
|
||||
} // namespace core_dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
/*!
|
||||
\brief Metafunction to get the type of radius of a circle / sphere / ellipse / etc.
|
||||
\ingroup access
|
||||
\tparam Geometry the type of geometry
|
||||
*/
|
||||
template <typename Geometry>
|
||||
struct radius_type
|
||||
{
|
||||
typedef typename core_dispatch::radius_type
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
typename util::bare_type<Geometry>::type
|
||||
>::type type;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Function to get radius of a circle / sphere / ellipse / etc.
|
||||
\return radius The radius for a given axis
|
||||
\ingroup access
|
||||
\param geometry the geometry to get the radius from
|
||||
\tparam I index of the axis
|
||||
*/
|
||||
template <std::size_t I, typename Geometry>
|
||||
inline typename radius_type<Geometry>::type get_radius(Geometry const& geometry)
|
||||
{
|
||||
return core_dispatch::radius_access
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
typename util::bare_type<Geometry>::type,
|
||||
I,
|
||||
typename boost::is_pointer<Geometry>::type
|
||||
>::get(geometry);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Function to set the radius of a circle / sphere / ellipse / etc.
|
||||
\ingroup access
|
||||
\tparam I index of the axis
|
||||
\param geometry the geometry to change
|
||||
\param radius the radius to set
|
||||
*/
|
||||
template <std::size_t I, typename Geometry>
|
||||
inline void set_radius(Geometry& geometry,
|
||||
typename radius_type<Geometry>::type const& radius)
|
||||
{
|
||||
core_dispatch::radius_access
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
typename util::bare_type<Geometry>::type,
|
||||
I,
|
||||
typename boost::is_pointer<Geometry>::type
|
||||
>::set(geometry, radius);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template <typename Tag, typename Geometry, std::size_t Dimension>
|
||||
struct radius_access
|
||||
{
|
||||
static inline typename radius_type<Geometry>::type get(Geometry const& geometry)
|
||||
{
|
||||
return traits::radius_access<Geometry, Dimension>::get(geometry);
|
||||
}
|
||||
static inline void set(Geometry& geometry,
|
||||
typename radius_type<Geometry>::type const& value)
|
||||
{
|
||||
traits::radius_access<Geometry, Dimension>::set(geometry, value);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace core_dispatch
|
||||
{
|
||||
|
||||
template <typename Tag,
|
||||
typename Geometry,
|
||||
std::size_t Dimension>
|
||||
struct radius_access<Tag, Geometry, Dimension, boost::true_type>
|
||||
{
|
||||
typedef typename geometry::radius_type<Geometry>::type radius_type;
|
||||
|
||||
static inline radius_type get(const Geometry * geometry)
|
||||
{
|
||||
return radius_access
|
||||
<
|
||||
Tag,
|
||||
Geometry,
|
||||
Dimension,
|
||||
typename boost::is_pointer<Geometry>::type
|
||||
>::get(*geometry);
|
||||
}
|
||||
|
||||
static inline void set(Geometry * geometry, radius_type const& value)
|
||||
{
|
||||
return radius_access
|
||||
<
|
||||
Tag,
|
||||
Geometry,
|
||||
Dimension,
|
||||
typename boost::is_pointer<Geometry>::type
|
||||
>::set(*geometry, value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry>
|
||||
struct radius_type<srs_sphere_tag, Geometry>
|
||||
{
|
||||
typedef typename traits::radius_type<Geometry>::type type;
|
||||
};
|
||||
|
||||
template <typename Geometry, std::size_t Dimension>
|
||||
struct radius_access<srs_sphere_tag, Geometry, Dimension, boost::false_type>
|
||||
: detail::radius_access<srs_sphere_tag, Geometry, Dimension>
|
||||
{
|
||||
BOOST_STATIC_ASSERT(Dimension == 0);
|
||||
//BOOST_STATIC_ASSERT(Dimension < 3);
|
||||
};
|
||||
|
||||
template <typename Geometry>
|
||||
struct radius_type<srs_spheroid_tag, Geometry>
|
||||
{
|
||||
typedef typename traits::radius_type<Geometry>::type type;
|
||||
};
|
||||
|
||||
template <typename Geometry, std::size_t Dimension>
|
||||
struct radius_access<srs_spheroid_tag, Geometry, Dimension, boost::false_type>
|
||||
: detail::radius_access<srs_spheroid_tag, Geometry, Dimension>
|
||||
{
|
||||
BOOST_STATIC_ASSERT(Dimension == 0 || Dimension == 2);
|
||||
//BOOST_STATIC_ASSERT(Dimension < 3);
|
||||
};
|
||||
|
||||
} // namespace core_dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_CORE_RADIUS_HPP
|
||||
195
include/boost/geometry/core/srs.hpp
Normal file
195
include/boost/geometry/core/srs.hpp
Normal file
@@ -0,0 +1,195 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// 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.
|
||||
|
||||
// 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_CORE_SRS_HPP
|
||||
#define BOOST_GEOMETRY_CORE_SRS_HPP
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace srs
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Defines spheroid radius values for use in geographical CS calculations
|
||||
\note See http://en.wikipedia.org/wiki/Figure_of_the_Earth
|
||||
and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
|
||||
*/
|
||||
template <typename RadiusType>
|
||||
class spheroid
|
||||
{
|
||||
public:
|
||||
spheroid(RadiusType const& a, RadiusType const& b)
|
||||
: m_a(a)
|
||||
, m_b(b)
|
||||
{}
|
||||
|
||||
spheroid()
|
||||
: m_a(RadiusType(6378137.0))
|
||||
, m_b(RadiusType(6356752.314245))
|
||||
{}
|
||||
|
||||
template <std::size_t I>
|
||||
RadiusType get_radius() const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(I < 3);
|
||||
|
||||
return I < 2 ? m_a : m_b;
|
||||
}
|
||||
|
||||
template <std::size_t I>
|
||||
void set_radius(RadiusType const& radius)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(I < 3);
|
||||
|
||||
(I < 2 ? m_a : m_b) = radius;
|
||||
}
|
||||
|
||||
private:
|
||||
RadiusType m_a, m_b; // equatorial radius, polar radius
|
||||
};
|
||||
|
||||
} // namespace srs
|
||||
|
||||
// Traits specializations for spheroid
|
||||
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
namespace traits
|
||||
{
|
||||
|
||||
template <typename RadiusType>
|
||||
struct tag< srs::spheroid<RadiusType> >
|
||||
{
|
||||
typedef srs_spheroid_tag type;
|
||||
};
|
||||
|
||||
template <typename RadiusType>
|
||||
struct radius_type< srs::spheroid<RadiusType> >
|
||||
{
|
||||
typedef RadiusType type;
|
||||
};
|
||||
|
||||
template <typename RadiusType, std::size_t Dimension>
|
||||
struct radius_access<srs::spheroid<RadiusType>, Dimension>
|
||||
{
|
||||
typedef srs::spheroid<RadiusType> spheroid_type;
|
||||
|
||||
static inline RadiusType get(spheroid_type const& s)
|
||||
{
|
||||
return s.template get_radius<Dimension>();
|
||||
}
|
||||
|
||||
static inline void set(spheroid_type& s, RadiusType const& value)
|
||||
{
|
||||
s.template set_radius<Dimension>(value);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace traits
|
||||
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
|
||||
namespace srs
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Defines sphere radius value for use in spherical CS calculations
|
||||
*/
|
||||
template <typename RadiusType>
|
||||
class sphere
|
||||
{
|
||||
public:
|
||||
explicit sphere(RadiusType const& r)
|
||||
: m_r(r)
|
||||
{}
|
||||
sphere()
|
||||
: m_r(RadiusType((2.0 * 6378137.0 + 6356752.314245) / 3.0))
|
||||
{}
|
||||
|
||||
template <std::size_t I>
|
||||
RadiusType get_radius() const
|
||||
{
|
||||
BOOST_STATIC_ASSERT(I < 3);
|
||||
|
||||
return m_r;
|
||||
}
|
||||
|
||||
template <std::size_t I>
|
||||
void set_radius(RadiusType const& radius)
|
||||
{
|
||||
BOOST_STATIC_ASSERT(I < 3);
|
||||
|
||||
m_r = radius;
|
||||
}
|
||||
|
||||
private:
|
||||
RadiusType m_r; // radius
|
||||
};
|
||||
|
||||
} // namespace srs
|
||||
|
||||
// Traits specializations for sphere
|
||||
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
namespace traits
|
||||
{
|
||||
|
||||
template <typename RadiusType>
|
||||
struct tag< srs::sphere<RadiusType> >
|
||||
{
|
||||
typedef srs_sphere_tag type;
|
||||
};
|
||||
|
||||
template <typename RadiusType>
|
||||
struct radius_type< srs::sphere<RadiusType> >
|
||||
{
|
||||
typedef RadiusType type;
|
||||
};
|
||||
|
||||
template <typename RadiusType, std::size_t Dimension>
|
||||
struct radius_access<srs::sphere<RadiusType>, Dimension>
|
||||
{
|
||||
typedef srs::sphere<RadiusType> sphere_type;
|
||||
|
||||
static inline RadiusType get(sphere_type const& s)
|
||||
{
|
||||
return s.template get_radius<Dimension>();
|
||||
}
|
||||
|
||||
static inline void set(sphere_type& s, RadiusType const& value)
|
||||
{
|
||||
s.template set_radius<Dimension>(value);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace traits
|
||||
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_CORE_SRS_HPP
|
||||
@@ -4,6 +4,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -37,6 +42,14 @@ struct spherical_equatorial_tag : spherical_tag {};
|
||||
struct geographic_tag : spherical_tag {};
|
||||
|
||||
|
||||
// Tags defining coordinate systems reference models
|
||||
|
||||
/// For reference spheroid defining parameters of geographical coordinate system
|
||||
struct srs_spheroid_tag {};
|
||||
|
||||
/// For reference sphere defining parameters of spherical coordinate system
|
||||
struct srs_sphere_tag : srs_spheroid_tag {};
|
||||
|
||||
|
||||
// Tags defining tag hierarchy
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
||||
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
||||
|
||||
// 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_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace detail
|
||||
{
|
||||
|
||||
|
||||
/*!
|
||||
\brief Defines ellipsoid values for use in distance calculations
|
||||
\details They have a constructor with the earth radius
|
||||
\note Will be moved / merged with projections
|
||||
\todo Optionally specify earth model, defaulting to WGS84
|
||||
- See http://en.wikipedia.org/wiki/Figure_of_the_Earth
|
||||
- and http://en.wikipedia.org/wiki/World_Geodetic_System#A_new_World_Geodetic_System:_WGS84
|
||||
\note
|
||||
*/
|
||||
template <typename T>
|
||||
class ellipsoid
|
||||
{
|
||||
public :
|
||||
ellipsoid(T const& a, T const& b)
|
||||
: m_a(a)
|
||||
, m_b(b)
|
||||
, m_f((a - b) / a)
|
||||
{}
|
||||
ellipsoid()
|
||||
: m_a(T(6378137.0))
|
||||
, m_b(T(6356752.314245))
|
||||
, m_f((m_a - m_b) / m_a)
|
||||
{}
|
||||
|
||||
T a() const { return m_a; }
|
||||
T b() const { return m_b; }
|
||||
T f() const { return m_f; }
|
||||
|
||||
private :
|
||||
T m_a, m_b, m_f; // equatorial radius, polar radius, flattening
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
}}} // namespace boost::geometry::detail
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_DETAIL_ELLIPSOID_HPP
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014 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)
|
||||
@@ -10,14 +15,18 @@
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_ANDOYER_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp>
|
||||
#include <boost/geometry/algorithms/detail/flattening.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -44,7 +53,7 @@ are about the same as Vincenty. In my (Barend's) testcases the results didn't di
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename RadiusType,
|
||||
typename Spheroid,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class andoyer
|
||||
@@ -63,14 +72,14 @@ public :
|
||||
>
|
||||
{};
|
||||
|
||||
typedef RadiusType radius_type;
|
||||
typedef Spheroid model_type;
|
||||
|
||||
inline andoyer()
|
||||
: m_ellipsoid()
|
||||
: m_spheroid()
|
||||
{}
|
||||
|
||||
explicit inline andoyer(geometry::detail::ellipsoid<RadiusType> const& e)
|
||||
: m_ellipsoid(e)
|
||||
explicit inline andoyer(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
|
||||
@@ -85,20 +94,12 @@ public :
|
||||
);
|
||||
}
|
||||
|
||||
inline geometry::detail::ellipsoid<RadiusType> ellipsoid() const
|
||||
inline Spheroid const& model() const
|
||||
{
|
||||
return m_ellipsoid;
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
inline RadiusType radius() const
|
||||
{
|
||||
return m_ellipsoid.a();
|
||||
}
|
||||
|
||||
|
||||
private :
|
||||
geometry::detail::ellipsoid<RadiusType> m_ellipsoid;
|
||||
|
||||
template <typename CT, typename T>
|
||||
inline CT calc(T const& lon1,
|
||||
T const& lat1,
|
||||
@@ -136,15 +137,19 @@ private :
|
||||
return c0;
|
||||
}
|
||||
|
||||
CT const radius_a = CT(get_radius<0>(m_spheroid));
|
||||
CT const flattening = geometry::detail::flattening<CT>(m_spheroid);
|
||||
|
||||
CT const omega = atan(math::sqrt(S / C));
|
||||
CT const r3 = c3 * math::sqrt(S * C) / omega; // not sure if this is r or greek nu
|
||||
CT const D = c2 * omega * m_ellipsoid.a();
|
||||
CT const D = c2 * omega * radius_a;
|
||||
CT const H1 = (r3 - c1) / (c2 * C);
|
||||
CT const H2 = (r3 + c1) / (c2 * S);
|
||||
CT const f = m_ellipsoid.f();
|
||||
|
||||
return D * (c1 + f * H1 * sinF2 * cosG2 - f * H2 * cosF2 * sinG2);
|
||||
return D * (c1 + flattening * (H1 * sinF2 * cosG2 - H2 * cosF2 * sinG2) );
|
||||
}
|
||||
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
|
||||
@@ -152,41 +157,41 @@ private :
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename RadiusType, typename CalculationType>
|
||||
struct tag<andoyer<RadiusType, CalculationType> >
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct tag<andoyer<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template <typename RadiusType, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<andoyer<RadiusType, CalculationType>, P1, P2>
|
||||
: andoyer<RadiusType, CalculationType>::template calculation_type<P1, P2>
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<andoyer<Spheroid, CalculationType>, P1, P2>
|
||||
: andoyer<Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename RadiusType, typename CalculationType>
|
||||
struct comparable_type<andoyer<RadiusType, CalculationType> >
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<andoyer<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef andoyer<RadiusType, CalculationType> type;
|
||||
typedef andoyer<Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename RadiusType, typename CalculationType>
|
||||
struct get_comparable<andoyer<RadiusType, CalculationType> >
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<andoyer<Spheroid, CalculationType> >
|
||||
{
|
||||
static inline andoyer<RadiusType, CalculationType> apply(andoyer<RadiusType, CalculationType> const& input)
|
||||
static inline andoyer<Spheroid, CalculationType> apply(andoyer<Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename RadiusType, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<andoyer<RadiusType, CalculationType>, P1, P2>
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<andoyer<Spheroid, CalculationType>, P1, P2>
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<andoyer<RadiusType, CalculationType>, P1, P2>::type
|
||||
apply(andoyer<RadiusType, CalculationType> const& , T const& value)
|
||||
static inline typename return_type<andoyer<Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(andoyer<Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@@ -196,7 +201,13 @@ struct result_from_distance<andoyer<RadiusType, CalculationType>, P1, P2>
|
||||
template <typename Point1, typename Point2>
|
||||
struct default_strategy<point_tag, point_tag, Point1, Point2, geographic_tag, geographic_tag>
|
||||
{
|
||||
typedef strategy::distance::andoyer<typename select_coordinate_type<Point1, Point2>::type> type;
|
||||
typedef strategy::distance::andoyer
|
||||
<
|
||||
srs::spheroid
|
||||
<
|
||||
typename select_coordinate_type<Point1, Point2>::type
|
||||
>
|
||||
> type;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
|
||||
// This file was modified by Oracle on 2014.
|
||||
// Modifications copyright (c) 2014 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)
|
||||
@@ -9,19 +14,20 @@
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_STRATEGIES_VINCENTY_HPP
|
||||
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/detail/flattening.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/distance.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/coordinate_type.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
|
||||
#include <boost/geometry/util/math.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/detail/ellipsoid.hpp>
|
||||
|
||||
|
||||
#include <boost/geometry/util/promote_floating_point.hpp>
|
||||
#include <boost/geometry/util/select_calculation_type.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
@@ -45,7 +51,7 @@ namespace strategy { namespace distance
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename RadiusType,
|
||||
typename Spheroid,
|
||||
typename CalculationType = void
|
||||
>
|
||||
class vincenty
|
||||
@@ -64,13 +70,14 @@ public :
|
||||
>
|
||||
{};
|
||||
|
||||
typedef RadiusType radius_type;
|
||||
typedef Spheroid model_type;
|
||||
|
||||
inline vincenty()
|
||||
: m_spheroid()
|
||||
{}
|
||||
|
||||
explicit inline vincenty(geometry::detail::ellipsoid<RadiusType> const& e)
|
||||
: m_ellipsoid(e)
|
||||
explicit inline vincenty(Spheroid const& spheroid)
|
||||
: m_spheroid(spheroid)
|
||||
{}
|
||||
|
||||
template <typename Point1, typename Point2>
|
||||
@@ -84,25 +91,17 @@ public :
|
||||
);
|
||||
}
|
||||
|
||||
inline geometry::detail::ellipsoid<RadiusType> ellipsoid() const
|
||||
inline Spheroid const& model() const
|
||||
{
|
||||
return m_ellipsoid;
|
||||
}
|
||||
|
||||
inline RadiusType radius() const
|
||||
{
|
||||
// For now return the major axis. It is used in distance_cross_track, from point-to-line
|
||||
return m_ellipsoid.a();
|
||||
return m_spheroid;
|
||||
}
|
||||
|
||||
private :
|
||||
geometry::detail::ellipsoid<RadiusType> m_ellipsoid;
|
||||
|
||||
template <typename CT, typename T>
|
||||
inline CT calculate(T const& lon1,
|
||||
T const& lat1,
|
||||
T const& lon2,
|
||||
T const& lat2) const
|
||||
T const& lat1,
|
||||
T const& lon2,
|
||||
T const& lat2) const
|
||||
{
|
||||
CT const c2 = 2;
|
||||
CT const pi = geometry::math::pi<CT>();
|
||||
@@ -120,9 +119,13 @@ private :
|
||||
return CT(0);
|
||||
}
|
||||
|
||||
CT const radius_a = CT(get_radius<0>(m_spheroid));
|
||||
CT const radius_b = CT(get_radius<2>(m_spheroid));
|
||||
CT const flattening = geometry::detail::flattening<CT>(m_spheroid);
|
||||
|
||||
// U: reduced latitude, defined by tan U = (1-f) tan phi
|
||||
CT const c1 = 1;
|
||||
CT const one_min_f = c1 - m_ellipsoid.f();
|
||||
CT const one_min_f = c1 - flattening;
|
||||
|
||||
CT const U1 = atan(one_min_f * tan(lat1)); // above (1)
|
||||
CT const U2 = atan(one_min_f * tan(lat2)); // above (1)
|
||||
@@ -150,7 +153,7 @@ private :
|
||||
CT const c6 = 6;
|
||||
CT const c16 = 16;
|
||||
|
||||
CT const c_e_12 = 1e-12;
|
||||
CT const c_e_12 = CT(1e-12);
|
||||
|
||||
do
|
||||
{
|
||||
@@ -163,15 +166,15 @@ private :
|
||||
cos2_alpha = c1 - math::sqr(sin_alpha);
|
||||
cos2_sigma_m = math::equals(cos2_alpha, 0) ? 0 : cos_sigma - c2 * sin_U1 * sin_U2 / cos2_alpha; // (18)
|
||||
|
||||
CT C = m_ellipsoid.f()/c16 * cos2_alpha * (c4 + m_ellipsoid.f() * (c4 - c3 * cos2_alpha)); // (10)
|
||||
CT C = flattening/c16 * cos2_alpha * (c4 + flattening * (c4 - c3 * cos2_alpha)); // (10)
|
||||
sigma = atan2(sin_sigma, cos_sigma); // (16)
|
||||
lambda = L + (c1 - C) * m_ellipsoid.f() * sin_alpha *
|
||||
lambda = L + (c1 - C) * flattening * sin_alpha *
|
||||
(sigma + C * sin_sigma * ( cos2_sigma_m + C * cos_sigma * (-c1 + c2 * math::sqr(cos2_sigma_m)))); // (11)
|
||||
|
||||
} while (geometry::math::abs(previous_lambda - lambda) > c_e_12
|
||||
&& geometry::math::abs(lambda) < pi);
|
||||
|
||||
CT sqr_u = cos2_alpha * (math::sqr(m_ellipsoid.a()) - math::sqr(m_ellipsoid.b())) / math::sqr(m_ellipsoid.b()); // above (1)
|
||||
CT sqr_u = cos2_alpha * (math::sqr(radius_a) - math::sqr(radius_b)) / math::sqr(radius_b); // above (1)
|
||||
|
||||
// Oops getting hard here
|
||||
// (again, problem is that ttmath cannot divide by doubles, which is OK)
|
||||
@@ -191,49 +194,51 @@ private :
|
||||
CT delta_sigma = B * sin_sigma * ( cos2_sigma_m + (B/c4) * (cos(sigma)* (-c1 + c2 * cos2_sigma_m)
|
||||
- (B/c6) * cos2_sigma_m * (-c3 + c4 * math::sqr(sin_sigma)) * (-c3 + c4 * cos2_sigma_m))); // (6)
|
||||
|
||||
return m_ellipsoid.b() * A * (sigma - delta_sigma); // (19)
|
||||
return radius_b * A * (sigma - delta_sigma); // (19)
|
||||
}
|
||||
|
||||
Spheroid m_spheroid;
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
|
||||
namespace services
|
||||
{
|
||||
|
||||
template <typename RadiusType, typename CalculationType>
|
||||
struct tag<vincenty<RadiusType, CalculationType> >
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct tag<vincenty<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef strategy_tag_distance_point_point type;
|
||||
};
|
||||
|
||||
|
||||
template <typename RadiusType, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<vincenty<RadiusType, CalculationType>, P1, P2>
|
||||
: vincenty<RadiusType, CalculationType>::template calculation_type<P1, P2>
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct return_type<vincenty<Spheroid, CalculationType>, P1, P2>
|
||||
: vincenty<Spheroid, CalculationType>::template calculation_type<P1, P2>
|
||||
{};
|
||||
|
||||
|
||||
template <typename RadiusType, typename CalculationType>
|
||||
struct comparable_type<vincenty<RadiusType, CalculationType> >
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct comparable_type<vincenty<Spheroid, CalculationType> >
|
||||
{
|
||||
typedef vincenty<RadiusType, CalculationType> type;
|
||||
typedef vincenty<Spheroid, CalculationType> type;
|
||||
};
|
||||
|
||||
|
||||
template <typename RadiusType, typename CalculationType>
|
||||
struct get_comparable<vincenty<RadiusType, CalculationType> >
|
||||
template <typename Spheroid, typename CalculationType>
|
||||
struct get_comparable<vincenty<Spheroid, CalculationType> >
|
||||
{
|
||||
static inline vincenty<RadiusType, CalculationType> apply(vincenty<RadiusType, CalculationType> const& input)
|
||||
static inline vincenty<Spheroid, CalculationType> apply(vincenty<Spheroid, CalculationType> const& input)
|
||||
{
|
||||
return input;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename RadiusType, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<vincenty<RadiusType, CalculationType>, P1, P2 >
|
||||
template <typename Spheroid, typename CalculationType, typename P1, typename P2>
|
||||
struct result_from_distance<vincenty<Spheroid, CalculationType>, P1, P2 >
|
||||
{
|
||||
template <typename T>
|
||||
static inline typename return_type<vincenty<RadiusType, CalculationType>, P1, P2>::type
|
||||
apply(vincenty<RadiusType, CalculationType> const& , T const& value)
|
||||
static inline typename return_type<vincenty<Spheroid, CalculationType>, P1, P2>::type
|
||||
apply(vincenty<Spheroid, CalculationType> const& , T const& value)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -19,9 +24,7 @@
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
#include <boost/type_traits/remove_const.hpp>
|
||||
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/nsphere/core/tags.hpp>
|
||||
|
||||
@@ -29,129 +32,28 @@
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace traits
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Traits class to get/set radius of a circle/sphere/(ellipse)
|
||||
\details the radius access meta-functions give read/write access to the radius of a circle or a sphere,
|
||||
or to the major/minor axis or an ellipse, or to one of the 3 equatorial radii of an ellipsoid.
|
||||
|
||||
It should be specialized per geometry, in namespace core_dispatch. Those specializations should
|
||||
forward the call via traits to the geometry class, which could be specified by the user.
|
||||
|
||||
There is a corresponding generic radius_get and radius_set function
|
||||
\par Geometries:
|
||||
- n-sphere (circle,sphere)
|
||||
- upcoming ellipse
|
||||
\par Specializations should provide:
|
||||
- inline static T get(G const& geometry)
|
||||
- inline static void set(G& geometry, T const& radius)
|
||||
\ingroup traits
|
||||
*/
|
||||
template <typename G, typename T, std::size_t D>
|
||||
struct radius_access {};
|
||||
|
||||
|
||||
/*!
|
||||
\brief Traits class indicating the type (double,float,...) of the radius of a circle or a sphere
|
||||
\par Geometries:
|
||||
- n-sphere (circle,sphere)
|
||||
- upcoming ellipse
|
||||
\par Specializations should provide:
|
||||
- typedef T type (double,float,int,etc)
|
||||
\ingroup traits
|
||||
*/
|
||||
template <typename G>
|
||||
struct radius_type {};
|
||||
|
||||
} // namespace traits
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace core_dispatch
|
||||
{
|
||||
|
||||
template <typename Tag, typename G>
|
||||
struct radius_type
|
||||
{
|
||||
//typedef core_dispatch_specialization_required type;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief radius access meta-functions, used by concept n-sphere and upcoming ellipse.
|
||||
*/
|
||||
template <typename Tag, typename G, typename T, std::size_t D>
|
||||
struct radius_access
|
||||
{
|
||||
//static inline T get(G const& ) {}
|
||||
//static inline void set(G& g, T const& value) {}
|
||||
};
|
||||
|
||||
template <typename S>
|
||||
struct radius_type<nsphere_tag, S>
|
||||
{
|
||||
typedef typename traits::radius_type<S>::type type;
|
||||
};
|
||||
|
||||
template <typename S, typename T, std::size_t D>
|
||||
struct radius_access<nsphere_tag, S, T, D>
|
||||
template <typename S, std::size_t D>
|
||||
struct radius_access<nsphere_tag, S, D, boost::false_type>
|
||||
: detail::radius_access<nsphere_tag, S, D>
|
||||
{
|
||||
BOOST_STATIC_ASSERT((D == 0));
|
||||
static inline T get(S const& s)
|
||||
{
|
||||
return traits::radius_access<S, T, D>::get(s);
|
||||
}
|
||||
static inline void set(S& s, T const& radius)
|
||||
{
|
||||
traits::radius_access<S, T, D>::set(s, radius);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace core_dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
template <typename G>
|
||||
struct radius_type
|
||||
{
|
||||
typedef typename boost::remove_const<G>::type rconst;
|
||||
typedef typename core_dispatch::radius_type<typename tag<G>::type, rconst>::type type;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Function to get radius
|
||||
\return radius of a circle / sphere / ellipse
|
||||
\ingroup access
|
||||
\param geometry the geometry to get the radius from
|
||||
\tparam I index, for circle/sphere always zero, for ellipse major/minor axis,
|
||||
for ellipsoid one of the 3 equatorial radii
|
||||
*/
|
||||
template <std::size_t I, typename G>
|
||||
inline typename radius_type<G>::type get_radius(G const& geometry)
|
||||
{
|
||||
typedef typename boost::remove_const<G>::type rconst;
|
||||
|
||||
return core_dispatch::radius_access<typename tag<G>::type, rconst,
|
||||
typename radius_type<G>::type, I>::get(geometry);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Function to set the radius of a circle / sphere / (ellipse)
|
||||
\ingroup access
|
||||
\tparam I index, for circle/sphere always zero, for ellipse major/minor axis,
|
||||
for ellipsoid one of the 3 equatorial radii
|
||||
\param geometry the geometry to change
|
||||
\param radius the radius to set
|
||||
*/
|
||||
template <std::size_t I, typename G>
|
||||
inline void set_radius(G& geometry, typename radius_type<G>::type const& radius)
|
||||
{
|
||||
core_dispatch::radius_access<typename tag<G>::type, G,
|
||||
typename radius_type<G>::type, I>::set(geometry, radius);
|
||||
}
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ struct access<model::nsphere<Point, CoordinateType>, Dimension>
|
||||
};
|
||||
|
||||
template <typename Point, typename RadiusType>
|
||||
struct radius_access<model::nsphere<Point, RadiusType>, RadiusType, 0>
|
||||
struct radius_access<model::nsphere<Point, RadiusType>, 0>
|
||||
{
|
||||
typedef model::nsphere<Point, RadiusType> nsphere_type;
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -25,6 +30,7 @@
|
||||
#include <boost/geometry/core/point_order.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
#include <boost/geometry/core/tag.hpp>
|
||||
#include <boost/geometry/core/tag_cast.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
@@ -34,9 +40,9 @@
|
||||
#include <boost/geometry/core/exterior_ring.hpp>
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/topological_dimension.hpp>
|
||||
|
||||
|
||||
#include <boost/geometry/arithmetic/arithmetic.hpp>
|
||||
#include <boost/geometry/arithmetic/dot_product.hpp>
|
||||
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -29,6 +34,7 @@
|
||||
#include <boost/geometry/algorithms/assign.hpp>
|
||||
#include <boost/geometry/algorithms/append.hpp>
|
||||
#include <boost/geometry/algorithms/clear.hpp>
|
||||
#include <boost/geometry/algorithms/detail/equals/point_point.hpp>
|
||||
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/coordinate_dimension.hpp>
|
||||
@@ -38,6 +44,7 @@
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/mutable_range.hpp>
|
||||
#include <boost/geometry/core/point_type.hpp>
|
||||
#include <boost/geometry/core/tag_cast.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
@@ -98,7 +105,9 @@ namespace detail { namespace wkt
|
||||
|
||||
typedef boost::tokenizer<boost::char_separator<char> > tokenizer;
|
||||
|
||||
template <typename Point, std::size_t Dimension, std::size_t DimensionCount>
|
||||
template <typename Point,
|
||||
std::size_t Dimension = 0,
|
||||
std::size_t DimensionCount = geometry::dimension<Point>::value>
|
||||
struct parsing_assigner
|
||||
{
|
||||
static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
|
||||
@@ -208,12 +217,7 @@ struct container_inserter
|
||||
|
||||
while (it != end && *it != ")")
|
||||
{
|
||||
parsing_assigner
|
||||
<
|
||||
Point,
|
||||
0,
|
||||
dimension<Point>::value
|
||||
>::apply(it, end, point, wkt);
|
||||
parsing_assigner<Point>::apply(it, end, point, wkt);
|
||||
out = point;
|
||||
++out;
|
||||
if (it != end && *it == ",")
|
||||
@@ -227,35 +231,94 @@ struct container_inserter
|
||||
};
|
||||
|
||||
|
||||
template <typename Geometry,
|
||||
closure_selector Closure = closure<Geometry>::value>
|
||||
struct stateful_range_appender
|
||||
{
|
||||
typedef typename geometry::point_type<Geometry>::type point_type;
|
||||
|
||||
// NOTE: Geometry is a reference
|
||||
inline void append(Geometry geom, point_type const& point, bool)
|
||||
{
|
||||
geometry::append(geom, point);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geometry>
|
||||
struct stateful_range_appender<Geometry, open>
|
||||
{
|
||||
typedef typename geometry::point_type<Geometry>::type point_type;
|
||||
typedef typename boost::range_size
|
||||
<
|
||||
typename util::bare_type<Geometry>::type
|
||||
>::type size_type;
|
||||
|
||||
BOOST_STATIC_ASSERT(( boost::is_same
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
ring_tag
|
||||
>::value ));
|
||||
|
||||
inline stateful_range_appender()
|
||||
: pt_index(0)
|
||||
{}
|
||||
|
||||
// NOTE: Geometry is a reference
|
||||
inline void append(Geometry geom, point_type const& point, bool is_next_expected)
|
||||
{
|
||||
bool should_append = true;
|
||||
|
||||
if ( pt_index == 0 )
|
||||
{
|
||||
first_point = point;
|
||||
//should_append = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// NOTE: if there is not enough Points, they're always appended
|
||||
should_append
|
||||
= is_next_expected
|
||||
|| pt_index < core_detail::closure::minimum_ring_size<open>::value
|
||||
|| !detail::equals::equals_point_point(point, first_point);
|
||||
}
|
||||
++pt_index;
|
||||
|
||||
if ( should_append )
|
||||
{
|
||||
geometry::append(geom, point);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
size_type pt_index;
|
||||
point_type first_point;
|
||||
};
|
||||
|
||||
// Geometry is a value-type or reference-type
|
||||
template <typename Geometry>
|
||||
struct container_appender
|
||||
{
|
||||
typedef typename geometry::point_type
|
||||
<
|
||||
typename boost::remove_reference<Geometry>::type
|
||||
>::type point_type;
|
||||
typedef typename geometry::point_type<Geometry>::type point_type;
|
||||
|
||||
static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
|
||||
std::string const& wkt, Geometry out)
|
||||
std::string const& wkt, Geometry out)
|
||||
{
|
||||
handle_open_parenthesis(it, end, wkt);
|
||||
|
||||
point_type point;
|
||||
stateful_range_appender<Geometry> appender;
|
||||
|
||||
// Parse points until closing parenthesis
|
||||
|
||||
while (it != end && *it != ")")
|
||||
{
|
||||
parsing_assigner
|
||||
<
|
||||
point_type,
|
||||
0,
|
||||
dimension<point_type>::value
|
||||
>::apply(it, end, point, wkt);
|
||||
point_type point;
|
||||
|
||||
geometry::append(out, point);
|
||||
if (it != end && *it == ",")
|
||||
parsing_assigner<point_type>::apply(it, end, point, wkt);
|
||||
|
||||
bool const is_next_expected = it != end && *it == ",";
|
||||
|
||||
appender.append(out, point, is_next_expected);
|
||||
|
||||
if ( is_next_expected )
|
||||
{
|
||||
++it;
|
||||
}
|
||||
@@ -276,7 +339,7 @@ struct point_parser
|
||||
std::string const& wkt, P& point)
|
||||
{
|
||||
handle_open_parenthesis(it, end, wkt);
|
||||
parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt);
|
||||
parsing_assigner<P>::apply(it, end, point, wkt);
|
||||
handle_close_parenthesis(it, end, wkt);
|
||||
}
|
||||
};
|
||||
@@ -512,7 +575,7 @@ struct noparenthesis_point_parser
|
||||
static inline void apply(tokenizer::iterator& it, tokenizer::iterator end,
|
||||
std::string const& wkt, P& point)
|
||||
{
|
||||
parsing_assigner<P, 0, dimension<P>::value>::apply(it, end, point, wkt);
|
||||
parsing_assigner<P>::apply(it, end, point, wkt);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -174,9 +174,13 @@ struct visitor<Value, Parameters, Box, Allocators, node_throwing_static_tag, IsV
|
||||
// allocators
|
||||
|
||||
template <typename Allocator, typename Value, typename Parameters, typename Box>
|
||||
struct allocators<Allocator, Value, Parameters, Box, node_throwing_static_tag>
|
||||
class allocators<Allocator, Value, Parameters, Box, node_throwing_static_tag>
|
||||
: public Allocator::template rebind<
|
||||
typename node<Value, Parameters, Box, allocators<Allocator, Value, Parameters, Box, node_throwing_static_tag>, node_throwing_static_tag>::type
|
||||
typename node<
|
||||
Value, Parameters, Box,
|
||||
allocators<Allocator, Value, Parameters, Box, node_throwing_static_tag>,
|
||||
node_throwing_static_tag
|
||||
>::type
|
||||
>::other
|
||||
{
|
||||
typedef typename Allocator::template rebind<
|
||||
|
||||
@@ -280,7 +280,7 @@ void test_open_rings()
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,0 0,0 0))"), false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 0))"), false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,0 0))"), false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 1,0 0))"),
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 1,0 0,0 0))"),
|
||||
AllowDuplicates);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 0,1 1))"),
|
||||
AllowDuplicates);
|
||||
@@ -426,7 +426,7 @@ void test_open_polygons()
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,0 0,0 0))"), false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 0))"), false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,0 0))"), false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 1,0 0))"), AllowDuplicates);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 1,0 0,0 0))"), AllowDuplicates);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 0,1 1))"), AllowDuplicates);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,1 0,1 0,1 1,0 0))"),
|
||||
AllowDuplicates);
|
||||
@@ -438,7 +438,7 @@ void test_open_polygons()
|
||||
false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 1,1 1))"),
|
||||
false);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 2,2 1,1 1))"),
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 2,2 1,1 1,1 1))"),
|
||||
AllowDuplicates);
|
||||
test::apply(from_wkt<OG>("POLYGON((0 0,10 0,10 10,0 10),(1 1,2 2,2 2,2 1))"),
|
||||
AllowDuplicates);
|
||||
|
||||
@@ -86,11 +86,11 @@ int test_main(int, char* [])
|
||||
|
||||
// test open geometries
|
||||
test_num_points<open_ring>("POLYGON((0 0,1 1,0 1))", 3u, 4u);
|
||||
test_num_points<open_ring>("POLYGON((0 0,1 1,0 1,0 0))", 4u, 5u);
|
||||
test_num_points<open_ring>("POLYGON((0 0,1 1,0 1,0 0))", 3u, 4u);
|
||||
test_num_points<open_polygon>("POLYGON((0 0,10 10,0 10))", 3u, 4u);
|
||||
test_num_points<open_polygon>("POLYGON((0 0,10 10,0 10,0 0))", 4u, 5u);
|
||||
test_num_points<open_polygon>("POLYGON((0 0,10 10,0 10,0 0))", 3u, 4u);
|
||||
test_num_points<open_multi_polygon>("MULTIPOLYGON(((0 0,0 10,10 10,10 0)),((0 10,1 10,1 9)))", 7u, 9u);
|
||||
test_num_points<open_multi_polygon>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 9u, 11u);
|
||||
test_num_points<open_multi_polygon>("MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),((0 10,1 10,1 9,0 10)))", 7u, 9u);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -88,10 +88,6 @@ void test_ordered_ring(std::string const& wkt_point,
|
||||
{
|
||||
std::reverse(boost::begin(ring), boost::end(ring));
|
||||
}
|
||||
if (! Closed)
|
||||
{
|
||||
ring.resize(ring.size() - 1);
|
||||
}
|
||||
|
||||
bg::read_wkt(wkt_point, point);
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ test-suite boost-geometry-core
|
||||
[ run geometry_id.cpp ]
|
||||
[ run point_type.cpp ]
|
||||
[ run radian_access.cpp ]
|
||||
[ run radius.cpp ]
|
||||
# [ run reverse_dispatch.cpp ]
|
||||
[ run ring.cpp ]
|
||||
[ run tag.cpp ]
|
||||
|
||||
62
test/core/radius.cpp
Normal file
62
test/core/radius.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
// Unit Test
|
||||
|
||||
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
||||
// 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.
|
||||
|
||||
// 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)
|
||||
|
||||
|
||||
#include <geometry_test_common.hpp>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/core/radius.hpp>
|
||||
#include <boost/geometry/core/srs.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/make.hpp>
|
||||
|
||||
|
||||
template <std::size_t I, typename G>
|
||||
void test_get_set()
|
||||
{
|
||||
typedef typename bg::radius_type<G>::type radius_type;
|
||||
|
||||
G g;
|
||||
bg::set_radius<I>(g, radius_type(5));
|
||||
|
||||
radius_type x = bg::get_radius<I>(g);
|
||||
|
||||
BOOST_CHECK_CLOSE(double(x), 5.0, 0.0001);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void test_all()
|
||||
{
|
||||
typedef bg::srs::spheroid<T> Sd;
|
||||
test_get_set<0, Sd>();
|
||||
test_get_set<2, Sd>();
|
||||
|
||||
typedef bg::srs::sphere<T> Se;
|
||||
test_get_set<0, Se>();
|
||||
}
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<int>();
|
||||
test_all<float>();
|
||||
test_all<double>();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -5,6 +5,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -45,6 +50,33 @@ void test_all();
|
||||
#define GEOMETRY_TEST_MULTI
|
||||
#include "io/wkt/wkt.cpp"
|
||||
|
||||
template <typename T>
|
||||
void test_order_closure()
|
||||
{
|
||||
using namespace boost::geometry;
|
||||
typedef bg::model::point<T, 2, bg::cs::cartesian> Pt;
|
||||
typedef bg::model::polygon<Pt, true, true> PCWC;
|
||||
typedef bg::model::polygon<Pt, true, false> PCWO;
|
||||
typedef bg::model::polygon<Pt, false, true> PCCWC;
|
||||
typedef bg::model::polygon<Pt, false, false> PCCWO;
|
||||
typedef bg::model::multi_polygon<PCWC> MPCWC;
|
||||
typedef bg::model::multi_polygon<PCWO> MPCWO;
|
||||
typedef bg::model::multi_polygon<PCCWC> MPCCWC;
|
||||
typedef bg::model::multi_polygon<PCCWO> MPCCWO;
|
||||
|
||||
std::string wkt_cwc = "MULTIPOLYGON(((0 0,0 2,2 2,2 0,0 0)),((0 0,0 -3,-3 -3,-3 0,0 0),(-1 -1,-2 -1,-2 -2,-1 -2,-1 -1)))";
|
||||
std::string wkt_cwo = "MULTIPOLYGON(((0 0,0 2,2 2,2 0)),((0 0,0 -3,-3 -3,-3 0),(-1 -1,-2 -1,-2 -2,-1 -2)))";
|
||||
std::string wkt_ccwc = "MULTIPOLYGON(((0 0,2 0,2 2,0 2,0 0)),((0 0,-3 0,-3 -3,0 -3,0 0),(-1 -1,-1 -2,-2 -2,-2 -1,-1 -1)))";
|
||||
std::string wkt_ccwo = "MULTIPOLYGON(((0 0,2 0,2 2,0 2)),((0 0,-3 0,-3 -3,0 -3),(-1 -1,-1 -2,-2 -2,-2 -1)))";
|
||||
|
||||
test_wkt<MPCWC>(wkt_cwc, wkt_cwc, 15, 0, 12, 24);
|
||||
test_wkt<MPCWO>(wkt_cwc, wkt_cwc, 12, 0, 12, 24);
|
||||
test_wkt<MPCWO>(wkt_cwo, wkt_cwc, 12, 0, 12, 24);
|
||||
test_wkt<MPCCWC>(wkt_ccwc, wkt_ccwc, 15, 0, 12, 24);
|
||||
test_wkt<MPCCWO>(wkt_ccwc, wkt_ccwc, 12, 0, 12, 24);
|
||||
test_wkt<MPCCWO>(wkt_ccwo, wkt_ccwc, 12, 0, 12, 24);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void test_all()
|
||||
{
|
||||
@@ -79,6 +111,8 @@ void test_all()
|
||||
test_wrong_wkt<bg::model::multi_point<P> >(
|
||||
"MULTIPOINT(16 17), (18 19)",
|
||||
"too much tokens at ',' in 'multipoint(16 17), (18 19)'");
|
||||
|
||||
test_order_closure<T>();
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
// 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.
|
||||
|
||||
// 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.
|
||||
|
||||
@@ -42,8 +47,8 @@ void check_wkt(G const& geometry, std::string const& expected)
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
void test_wkt(std::string const& wkt, std::size_t n, double len = 0,
|
||||
double ar = 0, double peri = 0)
|
||||
void test_wkt(std::string const& wkt, std::string const& expected,
|
||||
std::size_t n, double len = 0, double ar = 0, double peri = 0)
|
||||
{
|
||||
G geometry;
|
||||
|
||||
@@ -67,8 +72,15 @@ void test_wkt(std::string const& wkt, std::size_t n, double len = 0,
|
||||
BOOST_CHECK_CLOSE(double(bg::perimeter(geometry)), peri, 0.0001);
|
||||
}
|
||||
|
||||
check_wkt(geometry, wkt);
|
||||
check_wkt(boost::variant<G>(geometry), wkt);
|
||||
check_wkt(geometry, expected);
|
||||
check_wkt(boost::variant<G>(geometry), expected);
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
void test_wkt(std::string const& wkt,
|
||||
std::size_t n, double len = 0, double ar = 0, double peri = 0)
|
||||
{
|
||||
test_wkt<G>(wkt, wkt, n, len, ar, peri);
|
||||
}
|
||||
|
||||
template <typename G>
|
||||
@@ -135,6 +147,44 @@ void test_wkt_output_iterator(std::string const& wkt)
|
||||
|
||||
|
||||
#ifndef GEOMETRY_TEST_MULTI
|
||||
template <typename T>
|
||||
void test_order_closure()
|
||||
{
|
||||
using namespace boost::geometry;
|
||||
typedef bg::model::point<T, 2, bg::cs::cartesian> Pt;
|
||||
typedef bg::model::polygon<Pt, true, true> PCWC;
|
||||
typedef bg::model::polygon<Pt, true, false> PCWO;
|
||||
typedef bg::model::polygon<Pt, false, true> PCCWC;
|
||||
typedef bg::model::polygon<Pt, false, false> PCCWO;
|
||||
|
||||
{
|
||||
std::string wkt_cwc = "POLYGON((0 0,0 2,2 2,2 0,0 0))";
|
||||
std::string wkt_cwo = "POLYGON((0 0,0 2,2 2,2 0))";
|
||||
std::string wkt_ccwc = "POLYGON((0 0,2 0,2 2,0 2,0 0))";
|
||||
std::string wkt_ccwo = "POLYGON((0 0,2 0,2 2,0 2))";
|
||||
|
||||
test_wkt<PCWC>(wkt_cwc, 5, 0, 4, 8);
|
||||
test_wkt<PCWO>(wkt_cwc, 4, 0, 4, 8);
|
||||
test_wkt<PCWO>(wkt_cwo, wkt_cwc, 4, 0, 4, 8);
|
||||
test_wkt<PCCWC>(wkt_ccwc, 5, 0, 4, 8);
|
||||
test_wkt<PCCWO>(wkt_ccwc, 4, 0, 4, 8);
|
||||
test_wkt<PCCWO>(wkt_ccwo, wkt_ccwc, 4, 0, 4, 8);
|
||||
}
|
||||
{
|
||||
std::string wkt_cwc = "POLYGON((0 0,0 3,3 3,3 0,0 0),(1 1,2 1,2 2,1 2,1 1))";
|
||||
std::string wkt_cwo = "POLYGON((0 0,0 3,3 3,3 0),(1 1,2 1,2 2,1 2))";
|
||||
std::string wkt_ccwc = "POLYGON((0 0,3 0,3 3,0 3,0 0),(1 1,1 2,2 2,2 1,1 1))";
|
||||
std::string wkt_ccwo = "POLYGON((0 0,3 0,3 3,0 3),(1 1,1 2,2 2,2 1,1 1))";
|
||||
|
||||
test_wkt<PCWC>(wkt_cwc, 10, 0, 8, 16);
|
||||
test_wkt<PCWO>(wkt_cwc, 8, 0, 8, 16);
|
||||
test_wkt<PCWO>(wkt_cwo, wkt_cwc, 8, 0, 8, 16);
|
||||
test_wkt<PCCWC>(wkt_ccwc, 10, 0, 8, 16);
|
||||
test_wkt<PCCWO>(wkt_ccwc, 8, 0, 8, 16);
|
||||
test_wkt<PCCWO>(wkt_ccwo, wkt_ccwc, 8, 0, 8, 16);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void test_all()
|
||||
{
|
||||
@@ -201,10 +251,11 @@ void test_all()
|
||||
// Deprecated:
|
||||
// test_wkt_output_iterator<bg::model::linestring<P> >("LINESTRING(1 1,2 2,3 3)");
|
||||
// test_wkt_output_iterator<bg::model::ring<P> >("POLYGON((1 1,2 2,3 3))");
|
||||
|
||||
test_order_closure<T>();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int test_main(int, char* [])
|
||||
{
|
||||
test_all<double>();
|
||||
|
||||
Reference in New Issue
Block a user