From bda35568f0c837465d719464cd3f8b3b3c76af2a Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Mar 2015 16:40:12 +0200 Subject: [PATCH 001/104] [algorithms][overlay] implement intersection and difference for pointlike/linear geometries --- .../detail/overlay/intersection_insert.hpp | 80 +++- .../detail/overlay/pointlike_linear.hpp | 344 ++++++++++++++++++ .../detail/overlay/pointlike_pointlike.hpp | 4 +- 3 files changed, 423 insertions(+), 5 deletions(-) create mode 100644 include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp index 3101de8c3..491a540c1 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/intersection_insert.hpp @@ -1,9 +1,9 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// 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, 2015. +// Modifications copyright (c) 2014-2015 Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -42,6 +42,7 @@ #include #include +#include #if defined(BOOST_GEOMETRY_DEBUG_FOLLOW) #include @@ -700,6 +701,79 @@ struct intersection_insert {}; +// dispatch for difference/intersection of pointlike-linear geometries +template +< + typename Point, typename Linear, typename PointOut, + overlay_type OverlayType, + bool Reverse1, bool Reverse2, bool ReverseOut, + typename Tag +> +struct intersection_insert + < + Point, Linear, PointOut, OverlayType, + Reverse1, Reverse2, ReverseOut, + point_tag, Tag, point_tag, + false, false, false + > : detail_dispatch::overlay::pointlike_linear_point + < + Point, Linear, PointOut, OverlayType, + point_tag, typename tag_cast::type + > +{}; + + +template +< + typename MultiPoint, typename Linear, typename PointOut, + overlay_type OverlayType, + bool Reverse1, bool Reverse2, bool ReverseOut, + typename Tag +> +struct intersection_insert + < + MultiPoint, Linear, PointOut, OverlayType, + Reverse1, Reverse2, ReverseOut, + multi_point_tag, Tag, point_tag, + false, false, false + > : detail_dispatch::overlay::pointlike_linear_point + < + MultiPoint, Linear, PointOut, OverlayType, + multi_point_tag, + typename tag_cast::type + > +{}; + + +template +< + typename Linestring, typename MultiPoint, typename PointOut, + bool Reverse1, bool Reverse2, bool ReverseOut +> +struct intersection_insert + < + Linestring, MultiPoint, PointOut, overlay_intersection, + Reverse1, Reverse2, ReverseOut, + linestring_tag, multi_point_tag, point_tag, + false, false, false + > +{ + template + static inline OutputIterator apply(Linestring const& linestring, + MultiPoint const& multipoint, + RobustPolicy const& robust_policy, + OutputIterator out, + Strategy const& strategy) + { + return detail_dispatch::overlay::pointlike_linear_point + < + MultiPoint, Linestring, PointOut, overlay_intersection, + multi_point_tag, linear_tag + >::apply(multipoint, linestring, robust_policy, out, strategy); + } +}; + + } // namespace dispatch #endif // DOXYGEN_NO_DISPATCH diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp new file mode 100644 index 000000000..ad8756473 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp @@ -0,0 +1,344 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_POINTLIKE_LINEAR_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_POINTLIKE_LINEAR_HPP + +#include +#include + +#include +#include + +#include + +#include + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace overlay +{ + + +// action struct for pointlike-linear difference/intersection +// it works the same as its pointlike-pointlike counterpart, hence the +// derivation +template +struct action_selector_pl_l + : action_selector_pl_pl +{}; + +// difference/intersection of point-linear +template +< + typename Point, + typename Linear, + typename PointOut, + overlay_type OverlayType, + typename Policy +> +struct point_linear_point +{ + template + static inline OutputIterator apply(Point const& point, + Linear const& linear, + RobustPolicy const&, + OutputIterator oit, + Strategy const&) + { + action_selector_pl_l + < + PointOut, OverlayType + >::apply(point, Policy::apply(point, linear), oit); + return oit; + } +}; + +// difference/intersection of multipoint-segment +template +< + typename MultiPoint, + typename Segment, + typename PointOut, + overlay_type OverlayType, + typename Policy +> +struct multipoint_segment_point +{ + template + static inline OutputIterator apply(MultiPoint const& multipoint, + Segment const& segment, + RobustPolicy const&, + OutputIterator oit, + Strategy const&) + { + for (typename boost::range_iterator::type + it = boost::begin(multipoint); + it != boost::end(multipoint); + ++it) + { + action_selector_pl_l + < + PointOut, OverlayType + >::apply(*it, Policy::apply(*it, segment), oit); + } + + return oit; + } +}; + + +// difference/intersection of multipoint-linear +template +< + typename MultiPoint, + typename Linear, + typename PointOut, + overlay_type OverlayType, + typename Policy +> +class multipoint_linear_point +{ +private: + // structs for partition -- start + struct expand_box + { + template + static inline void apply(Box& total, Geometry const& geometry) + { + geometry::expand(total, geometry::return_envelope(geometry)); + } + + }; + + struct overlaps_box + { + template + static inline bool apply(Box const& box, Geometry const& geometry) + { + return ! geometry::disjoint(geometry, box); + } + }; + + template + class item_visitor_type + { + public: + item_visitor_type(OutputIterator& oit) : m_oit(oit) {} + + template + inline void apply(Item1 const& item1, Item2 const& item2) + { + action_selector_pl_l + < + PointOut, overlay_intersection + >::apply(item1, Policy::apply(item1, item2), m_oit); + } + + private: + OutputIterator& m_oit; + }; + // structs for partition -- end + + class segment_range + { + public: + typedef geometry::segment_iterator const_iterator; + typedef const_iterator iterator; + + segment_range(Linear const& linear) + : m_linear(linear) + {} + + const_iterator begin() const + { + return geometry::segments_begin(m_linear); + } + + const_iterator end() const + { + return geometry::segments_end(m_linear); + } + + private: + Linear const& m_linear; + }; + + template + static inline OutputIterator get_common_points(MultiPoint const& multipoint, + Linear const& linear, + OutputIterator oit) + { + item_visitor_type item_visitor(oit); + + segment_range rng(linear); + + geometry::partition + < + geometry::model::box + < + typename boost::range_value::type + >, + expand_box, + overlaps_box + >::apply(multipoint, rng, item_visitor); + + return oit; + } + +public: + template + static inline OutputIterator apply(MultiPoint const& multipoint, + Linear const& linear, + RobustPolicy const& robust_policy, + OutputIterator oit, + Strategy const& strategy) + { + typedef std::vector + < + typename boost::range_value::type + > point_vector_type; + + point_vector_type common_points; + + // compute the common points + get_common_points(multipoint, linear, + std::back_inserter(common_points)); + + return multipoint_multipoint_point + < + MultiPoint, point_vector_type, PointOut, OverlayType + >::apply(multipoint, common_points, robust_policy, oit, strategy); + } +}; + + +}} // namespace detail::overlay +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace detail_dispatch { namespace overlay +{ + +// dispatch struct for pointlike-linear difference/intersection computation +template +< + typename PointLike, + typename Linear, + typename PointOut, + overlay_type OverlayType, + typename Tag1, + typename Tag2 +> +struct pointlike_linear_point + : not_implemented +{}; + + +template +< + typename Point, + typename Linear, + typename PointOut, + overlay_type OverlayType +> +struct pointlike_linear_point + < + Point, Linear, PointOut, OverlayType, point_tag, linear_tag + > : detail::overlay::point_linear_point + < + Point, Linear, PointOut, OverlayType, + detail::not_ + > +{}; + + +template +< + typename Point, + typename Segment, + typename PointOut, + overlay_type OverlayType +> +struct pointlike_linear_point + < + Point, Segment, PointOut, OverlayType, point_tag, segment_tag + > : detail::overlay::point_linear_point + < + Point, Segment, PointOut, OverlayType, + detail::not_ + > +{}; + + +template +< + typename MultiPoint, + typename Linear, + typename PointOut, + overlay_type OverlayType +> +struct pointlike_linear_point + < + MultiPoint, Linear, PointOut, OverlayType, multi_point_tag, linear_tag + > : detail::overlay::multipoint_linear_point + < + MultiPoint, Linear, PointOut, OverlayType, + detail::not_ + > +{}; + + +template +< + typename MultiPoint, + typename Segment, + typename PointOut, + overlay_type OverlayType +> +struct pointlike_linear_point + < + MultiPoint, Segment, PointOut, OverlayType, multi_point_tag, segment_tag + > : detail::overlay::multipoint_segment_point + < + MultiPoint, Segment, PointOut, OverlayType, + detail::not_ + > +{}; + + +}} // namespace detail_dispatch::overlay +#endif // DOXYGEN_NO_DISPATCH + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_POINTLIKE_LINEAR_HPP diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp index 0af062d27..3e0641329 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -264,7 +264,7 @@ struct multipoint_multipoint_point >::apply(multipoint2, multipoint1, robust_policy, oit, strategy); } - std::vector::type> + std::vector::type> points2(boost::begin(multipoint2), boost::end(multipoint2)); std::sort(points2.begin(), points2.end(), detail::relate::less()); From a4b062583ce6a28dcf91306023043f63b4d59e91 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Mar 2015 16:46:28 +0200 Subject: [PATCH 002/104] [test][algorithms][set operations] add unit tests for intersection and difference for pointlike/linear geometries --- .../difference/difference_pl_l.cpp | 674 +++++++++++++++++ .../intersection/intersection_pl_l.cpp | 702 ++++++++++++++++++ 2 files changed, 1376 insertions(+) create mode 100644 test/algorithms/set_operations/difference/difference_pl_l.cpp create mode 100644 test/algorithms/set_operations/intersection/intersection_pl_l.cpp diff --git a/test/algorithms/set_operations/difference/difference_pl_l.cpp b/test/algorithms/set_operations/difference/difference_pl_l.cpp new file mode 100644 index 000000000..9592ec56d --- /dev/null +++ b/test/algorithms/set_operations/difference/difference_pl_l.cpp @@ -0,0 +1,674 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_difference_pointlike_linear +#endif + +#include +#include + +#include + +#include "../test_set_ops_pointlike.hpp" + +#include +#include +#include +#include +#include + +typedef bg::model::point point_type; +typedef bg::model::segment segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_point multi_point_type; +typedef bg::model::multi_linestring multi_linestring_type; + + +//=========================================================================== +//=========================================================================== +//=========================================================================== + + +BOOST_AUTO_TEST_CASE( test_difference_point_segment ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << "size of std::size_t: " << sizeof(std::size_t) << std::endl; + std::cout << "size of range_iterator: " + << sizeof(boost::range_iterator::type) + << std::endl; + std::cout << "size of range_iterator: " + << sizeof(boost::range_iterator::type) + << std::endl; + std::cout << "size of point_iterator: " + << sizeof(bg::point_iterator) << std::endl; + std::cout << "size of point_iterator: " + << sizeof(bg::point_iterator) << std::endl; + std::cout << "size of point_iterator: " + << sizeof(bg::point_iterator) << std::endl; + std::cout << "size of segment_iterator: " + << sizeof(bg::segment_iterator) << std::endl; + std::cout << "size of segment_iterator: " + << sizeof(bg::segment_iterator) << std::endl; + + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** POINT / SEGMENT DIFFERENCE ***" << std::endl; + std::cout << std::endl; +#endif + + typedef point_type P; + typedef segment_type S; + typedef multi_point_type MP; + + typedef test_set_op_of_pointlike_geometries + < + P, S, MP, bg::overlay_difference + > tester; + + tester::apply + ("psdf01", + from_wkt

("POINT(0 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("psdf02", + from_wkt

("POINT(0 0)"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("psdf03", + from_wkt

("POINT(1 1)"), + from_wkt("SEGMENT(0 0,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("psdf04", + from_wkt

("POINT(3 3)"), + from_wkt("SEGMENT(0 0,2 2)"), + from_wkt("MULTIPOINT(3 3)") + ); +} + + +BOOST_AUTO_TEST_CASE( test_difference_point_linestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** POINT / LINESTRING DIFFERENCE ***" << std::endl; + std::cout << std::endl; +#endif + + typedef point_type P; + typedef linestring_type L; + typedef multi_point_type MP; + + typedef test_set_op_of_pointlike_geometries + < + P, L, MP, bg::overlay_difference + > tester; + + tester::apply + ("pldf01", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pldf02", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pldf03", + from_wkt

("POINT(1 1)"), + from_wkt("LINESTRING(0 0,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pldf04", + from_wkt

("POINT(3 3)"), + from_wkt("LINESTRING(0 0,2 2)"), + from_wkt("MULTIPOINT(3 3)") + ); + + // linestrings with more than two points + tester::apply + ("pldf05", + from_wkt

("POINT(1 1)"), + from_wkt("LINESTRING(0 0,1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pldf06", + from_wkt

("POINT(2 2)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pldf07", + from_wkt

("POINT(10 10)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT(10 10)") + ); + + tester::apply + ("pldf08", + from_wkt

("POINT(0 1)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT(0 1)") + ); + + tester::apply + ("pldf09", + from_wkt

("POINT(4 4)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pldf10", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT()") + ); +} + + +BOOST_AUTO_TEST_CASE( test_difference_point_multilinestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** POINT / MULTILINESTRING DIFFERENCE ***" << std::endl; + std::cout << std::endl; +#endif + + typedef point_type P; + typedef multi_linestring_type ML; + typedef multi_point_type MP; + + typedef test_set_op_of_pointlike_geometries + < + P, ML, MP, bg::overlay_difference + > tester; + + tester::apply + ("pmldf01", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pmldf02", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((0 0,1 1))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf03", + from_wkt

("POINT(1 1)"), + from_wkt("MULTILINESTRING((0 0,2 2))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf04", + from_wkt

("POINT(3 3)"), + from_wkt("MULTILINESTRING((0 0,2 2))"), + from_wkt("MULTIPOINT(3 3)") + ); + + // linestrings with more than two points + tester::apply + ("pmldf05", + from_wkt

("POINT(1 1)"), + from_wkt("MULTILINESTRING((0 0,1 1,2 2))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf06", + from_wkt

("POINT(2 2)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf07", + from_wkt

("POINT(10 10)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(10 10)") + ); + + tester::apply + ("pmldf08", + from_wkt

("POINT(0 1)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(0 1)") + ); + + tester::apply + ("pmldf09", + from_wkt

("POINT(4 4)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf10", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + // multilinestrings with more than one linestring + tester::apply + ("pmldf11", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((-10,-10),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf12", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((-10 0,0 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf13", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmldf14", + from_wkt

("POINT(-20 0)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(-20 0)") + ); + + tester::apply + ("pmldf15", + from_wkt

("POINT(0 1)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(0 1)") + ); +} + + +BOOST_AUTO_TEST_CASE( test_difference_multipoint_segment ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** MULTIPOINT / SEGMENT DIFFERENCE ***" << std::endl; + std::cout << std::endl; +#endif + + typedef multi_point_type MP; + typedef segment_type S; + + typedef test_set_op_of_pointlike_geometries + < + MP, S, MP, bg::overlay_difference + > tester; + + tester::apply + ("mpsdf01", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mpsdf02", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsdf03", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsdf04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsdf05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0,0 0,1 0)") + ); + + tester::apply + ("mpsf06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("SEGMENT(1 0,2 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsdf07", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(0 0,1 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpsdf08", + from_wkt("MULTIPOINT()"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsdf09", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(-1 0,1 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpsdf10", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(1 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsdf11", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(-1 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsdf12", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,2 0)") + ); + + tester::apply + ("mpsdf12a", + from_wkt("MULTIPOINT(0 0,2 0,0 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,2 0)") + ); + + tester::apply + ("mpsdf12b", + from_wkt("MULTIPOINT(0 0,2 0,0 0,2 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,2 0,2 0)") + ); + + tester::apply + ("mpsdf12c", + from_wkt("MULTIPOINT(0 0,2 0,0 0,2 0,0 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,0 0,2 0,2 0)") + ); + + tester::apply + ("mpsdf13", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsdf14", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(0 0,0 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpsdf15", + from_wkt("MULTIPOINT()"), + from_wkt("SEGMENT(0 0,1 0)"), + from_wkt("MULTIPOINT()") + ); +} + + +BOOST_AUTO_TEST_CASE( test_difference_multipoint_linestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** MULTIPOINT / LINESTRING DIFFERENCE ***" << std::endl; + std::cout << std::endl; +#endif + + typedef multi_point_type MP; + typedef linestring_type L; + + typedef test_set_op_of_pointlike_geometries + < + MP, L, MP, bg::overlay_difference + > tester; + + tester::apply + ("mpldf01", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("LINESTRING(1 1,2 2,3 3,4 4,5 5)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mpldf02", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpldf03", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpldf04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpldf05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + from_wkt("MULTIPOINT(0 0,0 0,1 0)") + ); + + tester::apply + ("mplf06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("LINESTRING(1 0,2 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpldf07", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(0 0,1 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpldf08", + from_wkt("MULTIPOINT()"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpldf09", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(-1 0,1 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpldf10", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpldf11", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(-1 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpldf12", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(3 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,2 0)") + ); + + tester::apply + ("mpldf13", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(2 0,2 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpldf14", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(0 0,0 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpldf15", + from_wkt("MULTIPOINT()"), + from_wkt("LINESTRING(0 0,1 0,2 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpldf16", + from_wkt("MULTIPOINT()"), + from_wkt("LINESTRING()"), + from_wkt("MULTIPOINT()") + ); +} + + +BOOST_AUTO_TEST_CASE( test_difference_multipoint_multilinestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** MULTIPOINT / MULTILINESTRING DIFFERENCE ***" << std::endl; + std::cout << std::endl; +#endif + + typedef multi_point_type MP; + typedef multi_linestring_type ML; + + typedef test_set_op_of_pointlike_geometries + < + MP, ML, MP, bg::overlay_difference + > tester; + + tester::apply + ("mpmldf01", + from_wkt("MULTIPOINT(0 0,1 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,1 1,1 1,4 4))"), + from_wkt("MULTIPOINT(0 0,2 0)") + ); + + tester::apply + ("mpmldf02", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + from_wkt("MULTILINESTRING((1 0,1 1,1 1,4 4))"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpmldf03", + from_wkt("MULTIPOINT(5 5,3 3,0 0,0 0,5 5,1 1,1 1,1 0,1 0)"), + from_wkt("MULTILINESTRING((1 0,1 1,1 1,4 4))"), + from_wkt("MULTIPOINT(5 5,5 5,0 0,0 0)") + ); + + tester::apply + ("mpmldf04", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTILINESTRING((1 0,0 0,1 1,0 0))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmldf05", + from_wkt("MULTIPOINT(0 0,1 0,2 0,5 0)"), + from_wkt("MULTILINESTRING((0 1,0 0,1 2,1 0),\ + (0 1,2 0,0 10,2 0,2 10,5 10,5 0,5 10))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmldf05a", + from_wkt("MULTIPOINT(0 0,1 0,6 0,7 0,2 0,5 0,7 0,8 0)"), + from_wkt("MULTILINESTRING((0 1,0 0,1 2,1 0),\ + (0 1,2 0,0 10,2 0,2 10,5 10,5 0,5 10))"), + from_wkt("MULTIPOINT(7 0,7 0,8 0,6 0)") + ); + + tester::apply + ("mpmldf06", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTILINESTRING(())"), + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)") + ); + + tester::apply + ("mpmldf07", + from_wkt("MULTIPOINT()"), + from_wkt("MULTILINESTRING(())"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmldf08", + from_wkt("MULTIPOINT()"), + from_wkt("MULTILINESTRING((0 0,1 0),(9 0,10 0))"), + from_wkt("MULTIPOINT()") + ); +} diff --git a/test/algorithms/set_operations/intersection/intersection_pl_l.cpp b/test/algorithms/set_operations/intersection/intersection_pl_l.cpp new file mode 100644 index 000000000..fd4575f0b --- /dev/null +++ b/test/algorithms/set_operations/intersection/intersection_pl_l.cpp @@ -0,0 +1,702 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_intersection_pointlike_linear +#endif + +#include +#include + +#include + +#include "../test_set_ops_pointlike.hpp" + +#include +#include +#include +#include +#include + +typedef bg::model::point point_type; +typedef bg::model::segment segment_type; +typedef bg::model::linestring linestring_type; +typedef bg::model::multi_point multi_point_type; +typedef bg::model::multi_linestring multi_linestring_type; + + +//=========================================================================== +//=========================================================================== +//=========================================================================== + + +BOOST_AUTO_TEST_CASE( test_intersection_point_segment ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** POINT / SEGMENT INTERSECTION ***" << std::endl; + std::cout << std::endl; +#endif + + typedef point_type P; + typedef segment_type S; + typedef multi_point_type MP; + + typedef test_set_op_of_pointlike_geometries + < + P, S, MP, bg::overlay_intersection + > tester; + + tester::apply + ("psi01", + from_wkt

("POINT(0 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("psi02", + from_wkt

("POINT(0 0)"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("psi03", + from_wkt

("POINT(1 1)"), + from_wkt("SEGMENT(0 0,2 2)"), + from_wkt("MULTIPOINT(1 1)") + ); + + tester::apply + ("psi04", + from_wkt

("POINT(3 3)"), + from_wkt("SEGMENT(0 0,2 2)"), + from_wkt("MULTIPOINT()") + ); +} + + +BOOST_AUTO_TEST_CASE( test_intersection_point_linestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** POINT / LINESTRING INTERSECTION ***" << std::endl; + std::cout << std::endl; +#endif + + typedef point_type P; + typedef linestring_type L; + typedef multi_point_type MP; + + typedef test_set_op_of_pointlike_geometries + < + P, L, MP, bg::overlay_intersection + > tester; + + tester::apply + ("pli01", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pli02", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pli03", + from_wkt

("POINT(1 1)"), + from_wkt("LINESTRING(0 0,2 2)"), + from_wkt("MULTIPOINT(1 1)") + ); + + tester::apply + ("pli04", + from_wkt

("POINT(3 3)"), + from_wkt("LINESTRING(0 0,2 2)"), + from_wkt("MULTIPOINT()") + ); + + // linestrings with more than two points + tester::apply + ("pli05", + from_wkt

("POINT(1 1)"), + from_wkt("LINESTRING(0 0,1 1,2 2)"), + from_wkt("MULTIPOINT(1 1)") + ); + + tester::apply + ("pli06", + from_wkt

("POINT(2 2)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT(2 2)") + ); + + tester::apply + ("pli07", + from_wkt

("POINT(10 10)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pli08", + from_wkt

("POINT(0 1)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pli09", + from_wkt

("POINT(4 4)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT(4 4)") + ); + + tester::apply + ("pli10", + from_wkt

("POINT(0 0)"), + from_wkt("LINESTRING(0 0,1 1,4 4)"), + from_wkt("MULTIPOINT(0 0)") + ); +} + + +BOOST_AUTO_TEST_CASE( test_intersection_point_multilinestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** POINT / MULTILINESTRING INTERSECTION ***" << std::endl; + std::cout << std::endl; +#endif + + typedef point_type P; + typedef multi_linestring_type ML; + typedef multi_point_type MP; + + typedef test_set_op_of_pointlike_geometries + < + P, ML, MP, bg::overlay_intersection + > tester; + + tester::apply + ("pmli01", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((1 1,2 2))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmli02", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((0 0,1 1))"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pmli03", + from_wkt

("POINT(1 1)"), + from_wkt("MULTILINESTRING((0 0,2 2))"), + from_wkt("MULTIPOINT(1 1)") + ); + + tester::apply + ("pmli04", + from_wkt

("POINT(3 3)"), + from_wkt("MULTILINESTRING((0 0,2 2))"), + from_wkt("MULTIPOINT()") + ); + + // linestrings with more than two points + tester::apply + ("pmli05", + from_wkt

("POINT(1 1)"), + from_wkt("MULTILINESTRING((0 0,1 1,2 2))"), + from_wkt("MULTIPOINT(1 1)") + ); + + tester::apply + ("pmli06", + from_wkt

("POINT(2 2)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(2 2)") + ); + + tester::apply + ("pmli07", + from_wkt

("POINT(10 10)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmli08", + from_wkt

("POINT(0 1)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmli09", + from_wkt

("POINT(4 4)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(4 4)") + ); + + tester::apply + ("pmli10", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(0 0)") + ); + + // multilinestrings with more than one linestring + tester::apply + ("pmli11", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((-10,-10),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pmli12", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((-10 0,0 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pmli13", + from_wkt

("POINT(0 0)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("pmli14", + from_wkt

("POINT(-20 0)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmli15", + from_wkt

("POINT(0 1)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 0,1 1,4 4))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("pmli16", + from_wkt

("POINT(1 0)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(-1 0,2 0,20 0))"), + from_wkt("MULTIPOINT(1 0)") + ); + + tester::apply + ("pmli17", + from_wkt

("POINT(1 0)"), + from_wkt("MULTILINESTRING((-10 0,10 0),(0 -1,0 2,0 4))"), + from_wkt("MULTIPOINT(1 0)") + ); +} + + +BOOST_AUTO_TEST_CASE( test_intersection_multipoint_segment ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** MULTIPOINT / SEGMENT INTERSECTION ***" << std::endl; + std::cout << std::endl; +#endif + + typedef multi_point_type MP; + typedef segment_type S; + + typedef test_set_op_of_pointlike_geometries + < + MP, S, MP, bg::overlay_intersection + > tester; + + tester::apply + ("mpsi01", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi02", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mpsi03", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsi05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("SEGMENT(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsf06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("SEGMENT(1 0,2 0)"), + from_wkt("MULTIPOINT(1 0)") + ); + + tester::apply + ("mpsi07", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(0 0,1 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsi07a", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(0 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,2 0)") + ); + + tester::apply + ("mpsi08", + from_wkt("MULTIPOINT()"), + from_wkt("SEGMENT(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi09", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(-1 0,1 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsi10", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(1 0,3 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpsi11", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(-1 0,3 0)"), + from_wkt("MULTIPOINT(0 0,0 0,2 0)") + ); + + tester::apply + ("mpsi12", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi12a", + from_wkt("MULTIPOINT(0 0,2 0,0 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi12b", + from_wkt("MULTIPOINT(0 0,2 0,0 0,2 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi12c", + from_wkt("MULTIPOINT(0 0,2 0,0 0,2 0,0 0)"), + from_wkt("SEGMENT(3 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi13", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(2 0,2 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpsi14", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("SEGMENT(0 0,0 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpsi15", + from_wkt("MULTIPOINT()"), + from_wkt("SEGMENT(0 0,1 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpsi16", + from_wkt("MULTIPOINT(0 0,2 0,0 0,2 0,0 0)"), + from_wkt("SEGMENT(-1 0,10 0)"), + from_wkt("MULTIPOINT(0 0,0 0,0 0,2 0,2 0)") + ); +} + + +BOOST_AUTO_TEST_CASE( test_intersection_multipoint_linestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** MULTIPOINT / LINESTRING INTERSECTION ***" << std::endl; + std::cout << std::endl; +#endif + + typedef multi_point_type MP; + typedef linestring_type L; + + typedef test_set_op_of_pointlike_geometries + < + MP, L, MP, bg::overlay_intersection + > tester; + + tester::apply + ("mpli01", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("LINESTRING(1 1,2 2,3 3,4 4,5 5)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpli02", + from_wkt("MULTIPOINT(0 0)"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT(0 0)") + ); + + tester::apply + ("mpli03", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpli04", + from_wkt("MULTIPOINT(0 0,0 0)"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpli05", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("LINESTRING(1 1,2 2)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpli06", + from_wkt("MULTIPOINT(0 0,0 0,1 0)"), + from_wkt("LINESTRING(1 0,2 0)"), + from_wkt("MULTIPOINT(1 0)") + ); + + tester::apply + ("mpli07", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(0 0,1 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpli08", + from_wkt("MULTIPOINT()"), + from_wkt("LINESTRING(0 0,1 1)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpli09", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(-1 0,1 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpli10", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpli10a", + from_wkt("MULTIPOINT(2 0,0 0,2 0,0 0,2 0)"), + from_wkt("LINESTRING(1 0,3 0)"), + from_wkt("MULTIPOINT(2 0,2 0,2 0)") + ); + + tester::apply + ("mpli11", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(-1 0,3 0)"), + from_wkt("MULTIPOINT(2 0,0 0,0 0)") + ); + + tester::apply + ("mpli12", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(3 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpli13", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(2 0,2 0)"), + from_wkt("MULTIPOINT(2 0)") + ); + + tester::apply + ("mpli14", + from_wkt("MULTIPOINT(0 0,0 0,2 0)"), + from_wkt("LINESTRING(0 0,0 0)"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); + + tester::apply + ("mpli15", + from_wkt("MULTIPOINT()"), + from_wkt("LINESTRING(0 0,1 0,2 0,3 0)"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpli16", + from_wkt("MULTIPOINT()"), + from_wkt("LINESTRING()"), + from_wkt("MULTIPOINT()") + ); +} + + +BOOST_AUTO_TEST_CASE( test_intersection_multipoint_multilinestring ) +{ +#ifdef BOOST_GEOMETRY_TEST_DEBUG + std::cout << std::endl << std::endl << std::endl; + std::cout << "*** MULTIPOINT / MULTILINESTRING INTERSECTION ***" + << std::endl; + std::cout << std::endl; +#endif + + typedef multi_point_type MP; + typedef multi_linestring_type ML; + + typedef test_set_op_of_pointlike_geometries + < + MP, ML, MP, bg::overlay_intersection + > tester; + + tester::apply + ("mpmli01", + from_wkt("MULTIPOINT(0 0,1 0,2 0)"), + from_wkt("MULTILINESTRING((1 0,1 1,1 1,4 4))"), + from_wkt("MULTIPOINT(1 0)") + ); + + tester::apply + ("mpmli02", + from_wkt("MULTIPOINT(2 2,3 3,0 0,0 0,2 2,1 1,1 1,1 0,1 0)"), + from_wkt("MULTILINESTRING((1 0,1 1,1 1,4 4))"), + from_wkt("MULTIPOINT(2 2,2 2,3 3,1 1,1 1,1 0,1 0)") + ); + + tester::apply + ("mpmli03", + from_wkt("MULTIPOINT(5 5,3 3,0 0,0 0,5 5,1 1,1 1,1 0,1 0)"), + from_wkt("MULTILINESTRING((1 0,1 1,1 1,4 4))"), + from_wkt("MULTIPOINT(1 0,1 0,3 3,1 1,1 1)") + ); + + tester::apply + ("mpmli04", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTILINESTRING((1 0,0 0,1 1,0 0))"), + from_wkt("MULTIPOINT(1 0,0 0,1 1,1 1)") + ); + + tester::apply + ("mpmli05", + from_wkt("MULTIPOINT(0 0,1 0,2 0,5 0)"), + from_wkt("MULTILINESTRING((0 1,0 0,1 2,1 0),\ + (0 1,2 0,0 10,2 0,2 10,5 10,5 0,5 10))"), + from_wkt("MULTIPOINT(0 0,1 0,2 0,5 0)") + ); + + tester::apply + ("mpmli06", + from_wkt("MULTIPOINT(0 0,1 1,1 0,1 1)"), + from_wkt("MULTILINESTRING(())"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmli07", + from_wkt("MULTIPOINT()"), + from_wkt("MULTILINESTRING(())"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmli08", + from_wkt("MULTIPOINT()"), + from_wkt("MULTILINESTRING((0 0,1 0),(9 0,10 0))"), + from_wkt("MULTIPOINT()") + ); + + tester::apply + ("mpmli09", + from_wkt("MULTIPOINT(0 0,1 1,0 0,0 0,0 0,0 0,0 0,0 0,\ + 0 0,0 0,0 0,0 0,0 0)"), + from_wkt("MULTILINESTRING((0 0,0 1),(0 0,2 0),(0 0,0 3),\ + (0 0,4 0),(0 0,0 5),(0 0,6 0),(0 0,7 0),(0 0,8 0))"), + from_wkt("MULTIPOINT(0 0,0 0,0 0,0 0,0 0,0 0,0 0,\ + 0 0,0 0,0 0,0 0,0 0)") + ); + + tester::apply + ("mpmli09a", + from_wkt("MULTIPOINT(0 0,1 1,0 0)"), + from_wkt("MULTILINESTRING((0 0,0 1),(0 0,2 0),(0 0,0 3),\ + (0 0,4 0),(0 0,0 5),(0 0,6 0),(0 0,7 0),(0 0,8 0))"), + from_wkt("MULTIPOINT(0 0,0 0)") + ); +} From 9c860772fff0275bb5836fe937500003d595c40e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 10 Mar 2015 16:52:14 +0200 Subject: [PATCH 003/104] [test][algorithms][set operations] update Jamfiles with the new unit tests --- test/algorithms/set_operations/difference/Jamfile.v2 | 11 ++++++----- .../algorithms/set_operations/intersection/Jamfile.v2 | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/test/algorithms/set_operations/difference/Jamfile.v2 b/test/algorithms/set_operations/difference/Jamfile.v2 index 2903d9cc5..bead4559e 100644 --- a/test/algorithms/set_operations/difference/Jamfile.v2 +++ b/test/algorithms/set_operations/difference/Jamfile.v2 @@ -1,11 +1,11 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. -# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +# Copyright (c) 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. -# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -18,6 +18,7 @@ test-suite boost-geometry-algorithms-difference : [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run difference_linear_linear.cpp ] + [ run difference_pl_l.cpp ] [ run difference_pl_pl.cpp ] [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] diff --git a/test/algorithms/set_operations/intersection/Jamfile.v2 b/test/algorithms/set_operations/intersection/Jamfile.v2 index c039b1664..e66bfb166 100644 --- a/test/algorithms/set_operations/intersection/Jamfile.v2 +++ b/test/algorithms/set_operations/intersection/Jamfile.v2 @@ -1,11 +1,11 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. -# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +# Copyright (c) 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. -# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -18,6 +18,7 @@ test-suite boost-geometry-algorithms-intersection : [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] [ run intersection_linear_linear.cpp ] + [ run intersection_pl_l.cpp ] [ run intersection_pl_pl.cpp ] [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] ; From e6275f7178f14413e6802e9814ca52af00f7800e Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 14 Mar 2015 01:20:38 +0200 Subject: [PATCH 004/104] [algorithms][disjoint][spheroid] implement disjoint(point, point) for points on a spheroid (applicable to spherical equatorial and geographic coordinate systems) --- .../detail/disjoint/point_point.hpp | 147 ++++++++++++++++-- 1 file changed, 138 insertions(+), 9 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp b/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp index b1d32bf95..56fe9b4ce 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp @@ -1,12 +1,12 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2008-2014 Bruno Lalande, Paris, France. -// Copyright (c) 2009-2014 Mateusz Loskot, London, UK. -// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland +// 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. +// Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland -// This file was modified by Oracle on 2013-2014. -// Modifications copyright (c) 2013-2014, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014, 2015. +// Modifications copyright (c) 2013-2015, 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 @@ -23,11 +23,19 @@ #include +#include + #include -#include +#include +#include +#include +#include #include +#include #include +#include +#include #include @@ -40,12 +48,131 @@ namespace boost { namespace geometry namespace detail { namespace disjoint { + +class point_point_on_spheroid +{ +private: + template + static inline bool is_north_pole(CoordinateType const& latitude) + { + static CoordinateType const max_latitude + = math::max_latitude(); + + return math::equals(latitude, max_latitude); + } + + template + static inline bool is_south_pole(CoordinateType const& latitude) + { + static CoordinateType const min_latitude + = math::min_latitude(); + + return math::equals(latitude, min_latitude); + } + + template + < + typename Units, + typename CoordinateType1, + typename CoordinateType2 + > + static inline bool apply_same_units(CoordinateType1& lon1, + CoordinateType1& lat1, + CoordinateType2& lon2, + CoordinateType2& lat2) + { + math::normalize_spheroidal_coordinates(lon1, lat1); + math::normalize_spheroidal_coordinates(lon2, lat2); + + if (is_north_pole(lat1)) + { + return ! is_north_pole(lat2); + } + + if (is_south_pole(lat1)) + { + return ! is_south_pole(lat2); + } + + return ! math::equals(lat1, lat2) || ! math::equals(lon1, lon2); + } + +public: + template + static inline bool apply(Point1 const& p1, Point2 const& p2) + { + typedef typename coordinate_type::type coordinate_type1; + typedef typename coordinate_type::type coordinate_type2; + + typedef typename coordinate_system::type::units units1; + typedef typename coordinate_system::type::units units2; + + if (BOOST_GEOMETRY_CONDITION((boost::is_same::value))) + { + coordinate_type1 lon1 = geometry::get<0>(p1); + coordinate_type1 lat1 = geometry::get<1>(p1); + coordinate_type2 lon2 = geometry::get<0>(p2); + coordinate_type2 lat2 = geometry::get<1>(p2); + + return apply_same_units(lon1, lat1, lon2, lat2); + } + + typedef typename geometry::select_most_precise + < + typename fp_coordinate_type::type, + typename fp_coordinate_type::type + >::type calculation_type; + + calculation_type lon1 = get_as_radian<0>(p1); + calculation_type lat1 = get_as_radian<1>(p1); + + calculation_type lon2 = get_as_radian<0>(p2); + calculation_type lat2 = get_as_radian<1>(p2); + + return apply_same_units(lon1, lat1, lon2, lat2); + } +}; + + +template +< + typename Point1, typename Point2, + std::size_t Dimension, std::size_t DimensionCount, + typename CSTag1 = typename cs_tag::type, + typename CSTag2 = CSTag1 +> +struct point_point + : point_point +{}; + template < typename Point1, typename Point2, std::size_t Dimension, std::size_t DimensionCount > struct point_point + < + Point1, Point2, Dimension, DimensionCount, spherical_equatorial_tag + > : point_point_on_spheroid +{}; + +template +< + typename Point1, typename Point2, + std::size_t Dimension, std::size_t DimensionCount +> +struct point_point + < + Point1, Point2, Dimension, DimensionCount, geographic_tag + > : point_point_on_spheroid +{}; + +template +< + typename Point1, typename Point2, + std::size_t Dimension, std::size_t DimensionCount +> +struct point_point { static inline bool apply(Point1 const& p1, Point2 const& p2) { @@ -61,9 +188,11 @@ struct point_point } }; - template -struct point_point +struct point_point + < + Point1, Point2, DimensionCount, DimensionCount, cartesian_tag + > { static inline bool apply(Point1 const& , Point2 const& ) { From ac3dd837444ac8d1c38890b1889b4cfffb41a2af Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 14 Mar 2015 01:22:23 +0200 Subject: [PATCH 005/104] [util][math] function to normalize coordinates on a spheroid: * the normalized longitude lies in the interval (-180, 180] (in degrees) * the normalized latitude lies in the interval [-90, 90] (in degrees) --- .../util/normalize_spheroidal_coordinates.hpp | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 include/boost/geometry/util/normalize_spheroidal_coordinates.hpp diff --git a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp new file mode 100644 index 000000000..e6d325698 --- /dev/null +++ b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp @@ -0,0 +1,246 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +#ifndef BOOST_GEOMETRY_UTIL_NORMALIZE_SPHEROIDAL_COORDINATES_HPP +#define BOOST_GEOMETRY_UTIL_NORMALIZE_SPHEROIDAL_COORDINATES_HPP + +#include + +#include +#include + + +namespace boost { namespace geometry +{ + +namespace math +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail +{ + + +template +struct constants_on_spheroid +{ + static inline CoordinateType period() + { + static CoordinateType const two_pi + = math::pi() * CoordinateType(2.0); + return two_pi; + } + + static inline CoordinateType half_period() + { + return math::pi(); + } + + static inline CoordinateType min_longitude() + { + static CoordinateType const minus_pi = -math::pi(); + return minus_pi; + } + + static inline CoordinateType max_longitude() + { + return math::pi(); + } + + static inline CoordinateType min_latitude() + { + static CoordinateType const minus_half_pi + = math::pi() / CoordinateType(-2.0); + return minus_half_pi; + } + + static inline CoordinateType max_latitude() + { + static CoordinateType const half_pi + = math::pi() / CoordinateType(2.0); + return half_pi; + } +}; + +template +struct constants_on_spheroid +{ + static inline CoordinateType period() + { + return CoordinateType(360.0); + } + + static inline CoordinateType half_period() + { + return CoordinateType(180.0); + } + + static inline CoordinateType min_longitude() + { + return CoordinateType(-180.0); + } + + static inline CoordinateType max_longitude() + { + return CoordinateType(180.0); + } + + static inline CoordinateType min_latitude() + { + return CoordinateType(-90.0); + } + + static inline CoordinateType max_latitude() + { + return CoordinateType(90.0); + } +}; + + +template +class normalize_spheroidal_coordinates +{ + typedef constants_on_spheroid constants; + +protected: + static inline CoordinateType normalize_up(CoordinateType const& value) + { + return + math::fmod(value + constants::half_period(), constants::period()) + - constants::half_period(); + } + + static inline CoordinateType normalize_down(CoordinateType const& value) + { + return + math::fmod(value - constants::half_period(), constants::period()) + + constants::half_period(); + } + +public: + static inline void apply(CoordinateType& longitude, + CoordinateType& latitude) + { + + // first normalize latitude + if (math::larger(latitude, constants::half_period())) + { + latitude = normalize_up(latitude); + } + else if (math::smaller(latitude, -constants::half_period())) + { + latitude = normalize_down(latitude); + } + + // fix latitude range + if (latitude < constants::min_latitude()) + { + latitude = -constants::half_period() - latitude; + longitude -= constants::half_period(); + } + else if (latitude > constants::max_latitude()) + { + latitude = constants::half_period() - latitude; + longitude -= constants::half_period(); + } + + // now normalize longitude + if (math::equals(longitude, -constants::half_period()) + || math::equals(longitude, constants::half_period())) + { + longitude = constants::half_period(); + } + else if (longitude > constants::half_period()) + { + longitude = normalize_up(longitude); + if (math::equals(longitude, -constants::half_period())) + { + longitude = constants::half_period(); + } + } + else if (longitude < -constants::half_period()) + { + longitude = normalize_down(longitude); + } + + BOOST_ASSERT(!math::larger(constants::min_latitude(), latitude)); + BOOST_ASSERT(!math::larger(latitude, constants::max_latitude())); + + BOOST_ASSERT(math::smaller(constants::min_longitude(), longitude)); + BOOST_ASSERT(!math::larger(longitude, constants::max_longitude())); + } +}; + + +} // namespace detail +#endif // DOXYGEN_NO_DETAIL + + +template +inline CoordinateType min_longitude() +{ + return detail::constants_on_spheroid + < + CoordinateType, Units + >::min_longitude(); +} + +template +inline CoordinateType max_longitude() +{ + return detail::constants_on_spheroid + < + CoordinateType, Units + >::max_longitude(); +} + +template +inline CoordinateType min_latitude() +{ + return detail::constants_on_spheroid + < + CoordinateType, Units + >::min_latitude(); +} + +template +inline CoordinateType max_latitude() +{ + return detail::constants_on_spheroid + < + CoordinateType, Units + >::max_latitude(); +} + + +/*! +\brief Short utility to normalize the coordinates on a spheroid +\tparam Units The units of the coordindate system in the spheroid +\tparam CoordinateType The type of the coordinates +\param longitude Longitude +\param latitude Latitude +\ingroup utility +*/ +template +inline void normalize_spheroidal_coordinates(CoordinateType& longitude, + CoordinateType& latitude) +{ + detail::normalize_spheroidal_coordinates + < + Units, CoordinateType + >::apply(longitude, latitude); +} + + +} // namespace math + + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_UTIL_NORMALIZE_SPHEROIDAL_COORDINATES_HPP From 042e907fcbbba06a0f090d537ee03f34431f3b8f Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 14 Mar 2015 01:25:03 +0200 Subject: [PATCH 006/104] [test][algorithms][equals] add unit test for testing equality of points and segments on a spheroid (also tests disjoint(point, point) for points on a spheroid) --- .../equals_on_spheroid.cpp | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 test/algorithms/relational_operations/equals_on_spheroid.cpp diff --git a/test/algorithms/relational_operations/equals_on_spheroid.cpp b/test/algorithms/relational_operations/equals_on_spheroid.cpp new file mode 100644 index 000000000..80c8593e8 --- /dev/null +++ b/test/algorithms/relational_operations/equals_on_spheroid.cpp @@ -0,0 +1,183 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit test + +// Copyright (c) 2015, Oracle and/or its affiliates. + +// Licensed under the Boost Software License version 1.0. +// http://www.boost.org/users/license.html + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +#ifndef BOOST_TEST_MODULE +#define BOOST_TEST_MODULE test_equals_on_spheroid +#endif + +#include + +#include + +#include "test_equals.hpp" + +#include + +#include + +namespace bgm = bg::model; + +template +struct test_point_point +{ + static inline void apply(std::string const& header) + { + std::string const str = header + "-"; + + test_geometry(str + "pp_01", "POINT(0 0)", "POINT(0 0)", true); + test_geometry(str + "pp_02", "POINT(0 0)", "POINT(10 0)", false); + + // points whose longitudes differ by 360 degrees + test_geometry(str + "pp_03", "POINT(0 0)", "POINT(360 0)", true); + test_geometry(str + "pp_04", "POINT(10 0)", "POINT(370 0)", true); + test_geometry(str + "pp_05", "POINT(10 0)", "POINT(-350 0)", true); + test_geometry(str + "pp_06", "POINT(180 10)", "POINT(-180 10)", true); + test_geometry(str + "pp_06a", "POINT(540 10)", "POINT(-540 10)", true); + test_geometry(str + "pp_06b", "POINT(540 370)", "POINT(-540 -350)", true); + test_geometry(str + "pp_06c", "POINT(1260 370)", "POINT(-1260 -350)", true); + test_geometry(str + "pp_06d", "POINT(2340 370)", "POINT(-2340 -350)", true); + test_geometry(str + "pp_06e", "POINT(-180 10)", "POINT(-540 10)", true); + test_geometry(str + "pp_06f", "POINT(180 10)", "POINT(-540 10)", true); + + // north & south pole + test_geometry(str + "pp_07", "POINT(0 90)", "POINT(0 90)", true); + test_geometry(str + "pp_07a", "POINT(0 450)", "POINT(10 -270)", true); + test_geometry(str + "pp_07b", "POINT(0 270)", "POINT(10 90)", false); + test_geometry(str + "pp_07c", "POINT(0 -450)", "POINT(10 90)", false); + test_geometry(str + "pp_08", "POINT(0 90)", "POINT(10 90)", true); + test_geometry(str + "pp_09", "POINT(0 90)", "POINT(0 -90)", false); + test_geometry(str + "pp_10", "POINT(0 -90)", "POINT(0 -90)", true); + test_geometry(str + "pp_11", "POINT(0 -90)", "POINT(10 -90)", true); + test_geometry(str + "pp_11a", "POINT(0 -90)", "POINT(10 90)", false); + test_geometry(str + "pp_12", "POINT(0 -90)", "POINT(0 -85)", false); + test_geometry(str + "pp_13", "POINT(0 90)", "POINT(0 85)", false); + test_geometry(str + "pp_14", "POINT(0 90)", "POINT(10 85)", false); + + // symmetric wrt prime meridian + test_geometry(str + "pp_15", "POINT(-10 45)", "POINT(10 45)", false); + test_geometry(str + "pp_16", "POINT(-170 45)", "POINT(170 45)", false); + + // other points + test_geometry(str + "pp_17", "POINT(-10 45)", "POINT(10 -45)", false); + test_geometry(str + "pp_18", "POINT(-10 -45)", "POINT(10 45)", false); + test_geometry(str + "pp_19", "POINT(10 -135)", "POINT(10 45)", false); + test_geometry(str + "pp_20", "POINT(190 135)", "POINT(10 45)", true); + test_geometry(str + "pp_21", "POINT(190 150)", "POINT(10 30)", true); + test_geometry(str + "pp_21a", "POINT(-170 150)", "POINT(10 30)", true); + test_geometry(str + "pp_22", "POINT(190 -135)", "POINT(10 -45)", true); + test_geometry(str + "pp_23", "POINT(190 -150)", "POINT(10 -30)", true); + test_geometry(str + "pp_23a", "POINT(-170 -150)", "POINT(10 -30)", true); + } +}; + + +template +void test_segment_segment(std::string const& header) +{ + typedef bgm::segment

seg; + + std::string const str = header + "-"; + + test_geometry(str + "ss_01", + "SEGMENT(10 0,180 0)", + "SEGMENT(10 0,-180 0)", + true); + test_geometry(str + "ss_02", + "SEGMENT(0 90,180 0)", + "SEGMENT(10 90,-180 0)", + true); + test_geometry(str + "ss_03", + "SEGMENT(0 90,0 -90)", + "SEGMENT(10 90,20 -90)", + true); + test_geometry(str + "ss_04", + "SEGMENT(10 80,10 -80)", + "SEGMENT(10 80,20 -80)", + false); + test_geometry(str + "ss_05", + "SEGMENT(170 10,-170 10)", + "SEGMENT(170 10,350 10)", + false); +} + + +BOOST_AUTO_TEST_CASE( equals_point_point_se ) +{ + typedef bg::cs::spherical_equatorial cs_type; + + test_point_point >::apply("se"); + test_point_point >::apply("se"); + test_point_point >::apply("se"); + + // mixed point types + test_point_point + < + bgm::point, bgm::point + >::apply("se"); + + test_point_point + < + bgm::point, bgm::point + >::apply("se"); + +#if defined(HAVE_TTMATH) + test_point_point >::apply("se"); +#endif +} + +BOOST_AUTO_TEST_CASE( equals_point_point_geo ) +{ + typedef bg::cs::geographic cs_type; + + test_point_point >::apply("geo"); + test_point_point >::apply("geo"); + test_point_point >::apply("geo"); + + // mixed point types + test_point_point + < + bgm::point, bgm::point + >::apply("se"); + + test_point_point + < + bgm::point, bgm::point + >::apply("se"); + +#if defined(HAVE_TTMATH) + test_point_point >::apply("geo"); +#endif +} + +BOOST_AUTO_TEST_CASE( equals_segment_segment_se ) +{ + typedef bg::cs::spherical_equatorial cs_type; + + test_segment_segment >("se"); + test_segment_segment >("se"); + test_segment_segment >("se"); + +#if defined(HAVE_TTMATH) + test_segment_segment >("se"); +#endif +} + +BOOST_AUTO_TEST_CASE( equals_segment_segment_geo ) +{ + typedef bg::cs::geographic cs_type; + + test_segment_segment >("geo"); + test_segment_segment >("geo"); + test_segment_segment >("geo"); + +#if defined(HAVE_TTMATH) + test_segment_segment >("geo"); +#endif +} From 0570471cf81ee11a009081da945ca60655ba08ba Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Sat, 14 Mar 2015 01:28:23 +0200 Subject: [PATCH 007/104] [test][algorithms][equals][spheroid] add unit test to Jamfile --- test/algorithms/relational_operations/Jamfile.v2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index 5b432e2e9..f4e3808c2 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -1,11 +1,11 @@ # Boost.Geometry (aka GGL, Generic Geometry Library) # -# Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -# Copyright (c) 2008-2014 Bruno Lalande, Paris, France. -# Copyright (c) 2009-2014 Mateusz Loskot, London, UK. +# Copyright (c) 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. -# Modifications copyright (c) 2014, Oracle and/or its affiliates. +# This file was modified by Oracle on 2014, 2015. +# Modifications copyright (c) 2014-2015, Oracle and/or its affiliates. # # Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle # Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -19,6 +19,7 @@ test-suite boost-geometry-algorithms-relational [ run covered_by.cpp : : : msvc:/bigobj ] [ run crosses.cpp : : : msvc:/bigobj ] [ run equals.cpp : : : msvc:/bigobj ] + [ run equals_on_spheroid.cpp : : : msvc:/bigobj ] [ run intersects.cpp : : : msvc:/bigobj ] [ run multi_covered_by.cpp : : : msvc:/bigobj ] [ run multi_equals.cpp : : : msvc:/bigobj ] From 449e381fdab9daee470af976039f20e7ac73ee93 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 16 Mar 2015 11:55:47 +0200 Subject: [PATCH 008/104] [util][math][spheroid] replace calls to math::fmod() by calls to math::mod() --- .../boost/geometry/util/normalize_spheroidal_coordinates.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp index e6d325698..a1203ef83 100644 --- a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp +++ b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp @@ -112,14 +112,14 @@ protected: static inline CoordinateType normalize_up(CoordinateType const& value) { return - math::fmod(value + constants::half_period(), constants::period()) + math::mod(value + constants::half_period(), constants::period()) - constants::half_period(); } static inline CoordinateType normalize_down(CoordinateType const& value) { return - math::fmod(value - constants::half_period(), constants::period()) + math::mod(value - constants::half_period(), constants::period()) + constants::half_period(); } From c2a74a23471b5083dc3064148213bb2fa51558f0 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 21 Mar 2015 13:03:42 +0100 Subject: [PATCH 009/104] [test] Remove bigobj flag from Jamfiles now that it is defined in the upper level --- test/algorithms/Jamfile.v2 | 22 +++++++++---------- test/algorithms/buffer/Jamfile.v2 | 16 +++++++------- test/algorithms/distance/Jamfile.v2 | 6 ++--- test/algorithms/overlay/Jamfile.v2 | 2 +- .../relational_operations/Jamfile.v2 | 20 ++++++++--------- .../relational_operations/disjoint/Jamfile.v2 | 6 ++--- .../relational_operations/relate/Jamfile.v2 | 8 +++---- .../relational_operations/within/Jamfile.v2 | 12 +++++----- .../set_operations/difference/Jamfile.v2 | 6 ++--- .../set_operations/intersection/Jamfile.v2 | 4 ++-- .../set_operations/union/Jamfile.v2 | 4 ++-- 11 files changed, 53 insertions(+), 53 deletions(-) diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index e6bd3512f..5fd0e3c04 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -16,21 +16,21 @@ test-suite boost-geometry-algorithms : - [ run append.cpp : : : msvc:/bigobj ] - [ run area.cpp : : : msvc:/bigobj ] + [ run append.cpp ] + [ run area.cpp ] [ run assign.cpp ] [ run buffer.cpp ] - [ run centroid.cpp : : : msvc:/bigobj ] - [ run comparable_distance.cpp : : : msvc:/bigobj ] - [ run convex_hull.cpp : : : msvc:/bigobj ] - [ run correct.cpp : : : msvc:/bigobj ] - [ run convert.cpp : : : msvc:/bigobj ] - [ run envelope.cpp : : : msvc:/bigobj ] + [ run centroid.cpp ] + [ run comparable_distance.cpp ] + [ run convex_hull.cpp ] + [ run correct.cpp ] + [ run convert.cpp ] + [ run envelope.cpp ] [ run expand.cpp ] [ run for_each.cpp ] - [ run is_simple.cpp : : : msvc:/bigobj ] - [ run is_valid.cpp : : : msvc:/bigobj ] - [ run is_valid_failure.cpp : : : msvc:/bigobj ] + [ run is_simple.cpp ] + [ run is_valid.cpp ] + [ run is_valid_failure.cpp ] [ run length.cpp ] [ run make.cpp ] [ run multi_area.cpp ] diff --git a/test/algorithms/buffer/Jamfile.v2 b/test/algorithms/buffer/Jamfile.v2 index 125c600db..c7a37a646 100644 --- a/test/algorithms/buffer/Jamfile.v2 +++ b/test/algorithms/buffer/Jamfile.v2 @@ -14,13 +14,13 @@ project boost-geometry-algorithms-buffer test-suite boost-geometry-algorithms-buffer : - [ run point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run aimes_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] -# [ run country_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] # Uncomment if you want to test this manually; requires access to data/ folder + [ run point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_point_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_polygon_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run aimes_linestring_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] +# [ run country_buffer.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] # Uncomment if you want to test this manually; requires access to data/ folder ; diff --git a/test/algorithms/distance/Jamfile.v2 b/test/algorithms/distance/Jamfile.v2 index 1eb679dd7..bb76a8622 100644 --- a/test/algorithms/distance/Jamfile.v2 +++ b/test/algorithms/distance/Jamfile.v2 @@ -16,9 +16,9 @@ test-suite boost-geometry-algorithms-distance : - [ run distance.cpp : : : msvc:/bigobj ] - [ run distance_areal_areal.cpp : : : msvc:/bigobj ] - [ run distance_linear_areal.cpp : : : msvc:/bigobj ] + [ run distance.cpp ] + [ run distance_areal_areal.cpp ] + [ run distance_linear_areal.cpp ] [ run distance_linear_linear.cpp ] [ run distance_pointlike_areal.cpp ] [ run distance_pointlike_linear.cpp ] diff --git a/test/algorithms/overlay/Jamfile.v2 b/test/algorithms/overlay/Jamfile.v2 index c1758d155..fc27dbf59 100644 --- a/test/algorithms/overlay/Jamfile.v2 +++ b/test/algorithms/overlay/Jamfile.v2 @@ -16,7 +16,7 @@ test-suite boost-geometry-algorithms-overlay : [ run assemble.cpp ] - [ run ccw_traverse.cpp : : : msvc:/bigobj ] + [ run ccw_traverse.cpp ] [ run get_turn_info.cpp ] [ run get_turns.cpp ] [ run get_turns_areal_areal.cpp ] diff --git a/test/algorithms/relational_operations/Jamfile.v2 b/test/algorithms/relational_operations/Jamfile.v2 index 5b432e2e9..2c0c34c9e 100644 --- a/test/algorithms/relational_operations/Jamfile.v2 +++ b/test/algorithms/relational_operations/Jamfile.v2 @@ -16,16 +16,16 @@ test-suite boost-geometry-algorithms-relational : - [ run covered_by.cpp : : : msvc:/bigobj ] - [ run crosses.cpp : : : msvc:/bigobj ] - [ run equals.cpp : : : msvc:/bigobj ] - [ run intersects.cpp : : : msvc:/bigobj ] - [ run multi_covered_by.cpp : : : msvc:/bigobj ] - [ run multi_equals.cpp : : : msvc:/bigobj ] - [ run multi_intersects.cpp : : : msvc:/bigobj ] - [ run multi_touches.cpp : : : msvc:/bigobj ] - [ run overlaps.cpp : : : msvc:/bigobj ] - [ run touches.cpp : : : msvc:/bigobj ] + [ run covered_by.cpp ] + [ run crosses.cpp ] + [ run equals.cpp ] + [ run intersects.cpp ] + [ run multi_covered_by.cpp ] + [ run multi_equals.cpp ] + [ run multi_intersects.cpp ] + [ run multi_touches.cpp ] + [ run overlaps.cpp ] + [ run touches.cpp ] ; build-project disjoint ; diff --git a/test/algorithms/relational_operations/disjoint/Jamfile.v2 b/test/algorithms/relational_operations/disjoint/Jamfile.v2 index a2423a745..8586e9a2c 100644 --- a/test/algorithms/relational_operations/disjoint/Jamfile.v2 +++ b/test/algorithms/relational_operations/disjoint/Jamfile.v2 @@ -16,7 +16,7 @@ test-suite boost-geometry-algorithms-disjoint : - [ run disjoint.cpp : : : msvc:/bigobj ] - [ run disjoint_coverage.cpp : : : msvc:/bigobj ] - [ run multi_disjoint.cpp : : : msvc:/bigobj ] + [ run disjoint.cpp ] + [ run disjoint_coverage.cpp ] + [ run multi_disjoint.cpp ] ; diff --git a/test/algorithms/relational_operations/relate/Jamfile.v2 b/test/algorithms/relational_operations/relate/Jamfile.v2 index 871b8eb17..7e6bb61c9 100644 --- a/test/algorithms/relational_operations/relate/Jamfile.v2 +++ b/test/algorithms/relational_operations/relate/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-relate : - [ run relate_areal_areal.cpp : : : msvc:/bigobj ] - [ run relate_linear_areal.cpp : : : msvc:/bigobj ] - [ run relate_linear_linear.cpp : : : msvc:/bigobj ] - [ run relate_pointlike_xxx.cpp : : : msvc:/bigobj ] + [ run relate_areal_areal.cpp ] + [ run relate_linear_areal.cpp ] + [ run relate_linear_linear.cpp ] + [ run relate_pointlike_xxx.cpp ] ; diff --git a/test/algorithms/relational_operations/within/Jamfile.v2 b/test/algorithms/relational_operations/within/Jamfile.v2 index d2a679571..dc33b40cc 100644 --- a/test/algorithms/relational_operations/within/Jamfile.v2 +++ b/test/algorithms/relational_operations/within/Jamfile.v2 @@ -16,10 +16,10 @@ test-suite boost-geometry-algorithms-within : - [ run multi_within.cpp : : : msvc:/bigobj ] - [ run within.cpp : : : msvc:/bigobj ] - [ run within_areal_areal.cpp : : : msvc:/bigobj ] - [ run within_linear_areal.cpp : : : msvc:/bigobj ] - [ run within_linear_linear.cpp : : : msvc:/bigobj ] - [ run within_pointlike_xxx.cpp : : : msvc:/bigobj ] + [ run multi_within.cpp ] + [ run within.cpp ] + [ run within_areal_areal.cpp ] + [ run within_linear_areal.cpp ] + [ run within_linear_linear.cpp ] + [ run within_pointlike_xxx.cpp ] ; diff --git a/test/algorithms/set_operations/difference/Jamfile.v2 b/test/algorithms/set_operations/difference/Jamfile.v2 index 2903d9cc5..8bbbbbdc6 100644 --- a/test/algorithms/set_operations/difference/Jamfile.v2 +++ b/test/algorithms/set_operations/difference/Jamfile.v2 @@ -16,9 +16,9 @@ test-suite boost-geometry-algorithms-difference : - [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run difference_linear_linear.cpp ] [ run difference_pl_pl.cpp ] - [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_difference.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run multi_difference_spike.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] ; diff --git a/test/algorithms/set_operations/intersection/Jamfile.v2 b/test/algorithms/set_operations/intersection/Jamfile.v2 index c039b1664..b21302819 100644 --- a/test/algorithms/set_operations/intersection/Jamfile.v2 +++ b/test/algorithms/set_operations/intersection/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-intersection : - [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run intersection_linear_linear.cpp ] [ run intersection_pl_pl.cpp ] - [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_intersection.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] ; diff --git a/test/algorithms/set_operations/union/Jamfile.v2 b/test/algorithms/set_operations/union/Jamfile.v2 index d4df3ea5c..1f6b4f17e 100644 --- a/test/algorithms/set_operations/union/Jamfile.v2 +++ b/test/algorithms/set_operations/union/Jamfile.v2 @@ -16,8 +16,8 @@ test-suite boost-geometry-algorithms-union : - [ run multi_union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] - [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE msvc:/bigobj ] + [ run multi_union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] + [ run union.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE ] [ run union_linear_linear.cpp ] [ run union_pl_pl.cpp ] ; From 9eec41f53d1d4dd88ea568f6570ae6f2cdf90826 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 31 Mar 2015 13:20:34 +0300 Subject: [PATCH 010/104] [util][math] normalize the spherical coordinates for the north and south poles by setting the longitude to zero; this way equality of points on the sphere/spheroid amounts to equality of their normalized coordinates (for all points on the sphere/spheroid, including the poles) --- .../util/normalize_spheroidal_coordinates.hpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp index a1203ef83..2b782db9c 100644 --- a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp +++ b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp @@ -125,7 +125,8 @@ protected: public: static inline void apply(CoordinateType& longitude, - CoordinateType& latitude) + CoordinateType& latitude, + bool normalize_poles = true) { // first normalize latitude @@ -169,6 +170,17 @@ public: longitude = normalize_down(longitude); } + // finally normalize poles + if (normalize_poles) + { + if (math::equals(math::abs(latitude), constants::max_latitude())) + { + // for the north and south pole we set the longitude to 0 + // (works for both radians and degrees) + longitude = CoordinateType(0); + } + } + BOOST_ASSERT(!math::larger(constants::min_latitude(), latitude)); BOOST_ASSERT(!math::larger(latitude, constants::max_latitude())); From ca743293454abb17ddbd383bedd84a27d287c712 Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 31 Mar 2015 13:22:58 +0300 Subject: [PATCH 011/104] [algorithms][disjoint] do not treat poles in a special way: normalization of spherical coordinates takes care of that --- .../detail/disjoint/point_point.hpp | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp b/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp index 56fe9b4ce..2261efd3a 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/point_point.hpp @@ -52,24 +52,6 @@ namespace detail { namespace disjoint class point_point_on_spheroid { private: - template - static inline bool is_north_pole(CoordinateType const& latitude) - { - static CoordinateType const max_latitude - = math::max_latitude(); - - return math::equals(latitude, max_latitude); - } - - template - static inline bool is_south_pole(CoordinateType const& latitude) - { - static CoordinateType const min_latitude - = math::min_latitude(); - - return math::equals(latitude, min_latitude); - } - template < typename Units, @@ -84,16 +66,6 @@ private: math::normalize_spheroidal_coordinates(lon1, lat1); math::normalize_spheroidal_coordinates(lon2, lat2); - if (is_north_pole(lat1)) - { - return ! is_north_pole(lat2); - } - - if (is_south_pole(lat1)) - { - return ! is_south_pole(lat2); - } - return ! math::equals(lat1, lat2) || ! math::equals(lon1, lon2); } From 0db855fc6b36faddf041ea35cf019a81483b6cbb Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 1 Apr 2015 22:20:12 +0200 Subject: [PATCH 012/104] [test][buffer] Update ticket #11162 expectations, which will be fixed if pending changes are committed (side_of_intersection) --- test/algorithms/buffer/linestring_buffer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/test/algorithms/buffer/linestring_buffer.cpp b/test/algorithms/buffer/linestring_buffer.cpp index 5179eff9b..1348bdd24 100644 --- a/test/algorithms/buffer/linestring_buffer.cpp +++ b/test/algorithms/buffer/linestring_buffer.cpp @@ -203,10 +203,9 @@ void test_all() double const d15 = 1.5; test_one("mysql_report_2015_03_02c_asym1", mysql_report_2015_03_02c, join_round(7), end_round(7), 39.714, d10, d15); test_one("mysql_report_2015_03_02c_asym2", mysql_report_2015_03_02c, join_round(7), end_round(7), 46.116, d15, d10); -#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) + double const d100 = 10; - test_one("mysql_report_2015_04_01", mysql_report_2015_04_01, join_round(32), end_round(32), 1.0/*NON ZERO*/, d100); -#endif + test_one("mysql_report_2015_04_01", mysql_report_2015_04_01, join_round(32), end_round(32), 632.234, d100); } From 0722e4ba13214e23c65859b3067c72d3d72d8012 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 8 Apr 2015 12:15:20 +0200 Subject: [PATCH 013/104] [buffer][is_convex] add (non-complete) is_convex algorithm, and convex property for buffered pieces Including unit test. --- .../buffer/buffered_piece_collection.hpp | 4 + .../boost/geometry/algorithms/is_convex.hpp | 160 ++++++++++++++++++ test/algorithms/Jamfile.v2 | 1 + test/algorithms/is_convex.cpp | 61 +++++++ 4 files changed, 226 insertions(+) create mode 100644 include/boost/geometry/algorithms/is_convex.hpp create mode 100644 test/algorithms/is_convex.cpp diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index a501e3f19..233b202c0 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -21,6 +21,7 @@ #include #include +#include #include @@ -191,6 +192,7 @@ struct buffered_piece_collection std::vector helper_points; // 4 points for side, 3 points for join - 0 points for flat-end #endif + bool is_convex; bool is_monotonic_increasing[2]; // 0=x, 1=y bool is_monotonic_decreasing[2]; // 0=x, 1=y @@ -607,6 +609,8 @@ struct buffered_piece_collection pc.is_monotonic_decreasing[0] = true; pc.is_monotonic_decreasing[1] = true; + pc.is_convex = geometry::is_convex(pc.robust_ring); + if (pc.offsetted_count < 2) { return; diff --git a/include/boost/geometry/algorithms/is_convex.hpp b/include/boost/geometry/algorithms/is_convex.hpp new file mode 100644 index 000000000..8feb48db6 --- /dev/null +++ b/include/boost/geometry/algorithms/is_convex.hpp @@ -0,0 +1,160 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_IS_CONVEX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_IS_CONVEX_HPP + + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace boost { namespace geometry +{ + + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace is_convex +{ + +struct ring_is_convex +{ + template + static inline bool apply(Ring const& ring) + { + typedef typename geometry::point_type::type point_type; + typedef typename strategy::side::services::default_strategy + < + typename cs_tag::type + >::type side_strategy_type; + + std::size_t n = boost::size(ring); + if (boost::size(ring) < core_detail::closure::minimum_ring_size + < + geometry::closure::value + >::value) + { + // (Too) small rings are considered as non-concave, is convex + return true; + } + + // Walk in clockwise direction, consider ring as closed + // (though closure is not important in this algorithm - any dupped + // point is skipped) + typedef detail::normalized_view view_type; + view_type view(ring); + + typedef geometry::ever_circling_range_iterator it_type; + it_type previous(view); + it_type current(view); + current++; + + std::size_t index = 1; + while (equals::equals_point_point(*current, *previous) && index < n) + { + current++; + index++; + } + + if (index == n) + { + // All points are apparently equal + return true; + } + + it_type next = current; + next++; + while (equals::equals_point_point(*current, *next)) + { + next++; + } + + // We have now three different points on the ring + // Walk through all points, use a counter because of the ever-circling + // iterator + for (std::size_t i = 0; i < n; i++) + { + int const side = side_strategy_type::apply(*previous, *current, *next); + if (side == 1) + { + // Next is on the left side of clockwise ring: + // the piece is not convex + return false; + } + + previous = current; + current = next; + + // Advance next to next different point + // (because there are non-equal points, this loop is not infinite) + next++; + while (equals::equals_point_point(*current, *next)) + { + next++; + } + } + return true; + } +}; + + +}} // namespace detail::is_convex +#endif // DOXYGEN_NO_DETAIL + + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + +template +< + typename Geometry, + typename Tag = typename tag::type +> +struct is_convex : not_implemented +{}; + +template +struct is_convex +{ + static inline bool apply(Box const& ) + { + // Any box is convex (TODO: consider spherical boxes) + return true; + } +}; + +template +struct is_convex : detail::is_convex::ring_is_convex +{}; + + +} // namespace dispatch +#endif // DOXYGEN_NO_DISPATCH + +// TODO: variants + +// TODO: documentation / qbk +template +inline bool is_convex(Geometry const& geometry) +{ + return dispatch::is_convex::apply(geometry); +} + + +}} // namespace boost::geometry + + +#endif // BOOST_GEOMETRY_ALGORITHMS_IS_CONVEX_HPP diff --git a/test/algorithms/Jamfile.v2 b/test/algorithms/Jamfile.v2 index 5fd0e3c04..5233e3f61 100644 --- a/test/algorithms/Jamfile.v2 +++ b/test/algorithms/Jamfile.v2 @@ -28,6 +28,7 @@ test-suite boost-geometry-algorithms [ run envelope.cpp ] [ run expand.cpp ] [ run for_each.cpp ] + [ run is_convex.cpp ] [ run is_simple.cpp ] [ run is_valid.cpp ] [ run is_valid_failure.cpp ] diff --git a/test/algorithms/is_convex.cpp b/test/algorithms/is_convex.cpp new file mode 100644 index 000000000..7fcc8a913 --- /dev/null +++ b/test/algorithms/is_convex.cpp @@ -0,0 +1,61 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include + +#include + +#include + +#include +#include +#include +#include +#include + + +template +void test_one(std::string const& case_id, std::string const& wkt, bool expected) +{ + Geometry geometry; + bg::read_wkt(wkt, geometry); + bg::correct(geometry); + + bool detected = bg::is_convex(geometry); + BOOST_CHECK_MESSAGE(detected == expected, + "Not as expected, case: " << case_id + << " / expected: " << expected + << " / detected: " << detected); +} + + +template +void test_all() +{ + // rectangular, with concavity + std::string const concave1 = "polygon((1 1, 1 4, 3 4, 3 3, 4 3, 4 4, 5 4, 5 1, 1 1))"; + std::string const triangle = "polygon((1 1, 1 4, 5 1, 1 1))"; + + test_one >("triangle", triangle, true); + test_one >("concave1", concave1, false); + test_one >("triangle", triangle, true); + test_one >("concave1", concave1, false); + + test_one >("box", "box(0 0,2 2)", true); +} + + +int test_main(int, char* []) +{ + test_all >(); + test_all >(); + + return 0; +} From b1168415c7c2fc1742b240a6a799195980687ecc Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 8 Apr 2015 17:25:53 +0200 Subject: [PATCH 014/104] [buffer] add side_of_intersection (still with conditional) --- .../detail/buffer/buffer_policies.hpp | 8 + .../buffer/buffered_piece_collection.hpp | 4 + .../detail/buffer/get_piece_turns.hpp | 30 ++++ .../detail/buffer/turn_in_piece_visitor.hpp | 153 +++++++++++++++++- test/algorithms/buffer/linestring_buffer.cpp | 2 + test/algorithms/buffer/multi_point_buffer.cpp | 4 + .../buffer/multi_polygon_buffer.cpp | 6 +- test/algorithms/buffer/test_buffer.hpp | 2 + 8 files changed, 203 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp index c5bb8acc0..58b1cf5a9 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_policies.hpp @@ -122,6 +122,10 @@ struct buffer_turn_info intersection_location_type location; +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + robust_point_type rob_pi, rob_pj, rob_qi, rob_qj; +#endif + int count_within; bool within_original; @@ -130,7 +134,9 @@ struct buffer_turn_info int count_on_offsetted; int count_on_helper; +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) int count_within_near_offsetted; +#endif bool remove_on_multi; @@ -147,7 +153,9 @@ struct buffer_turn_info , count_in_original(0) , count_on_offsetted(0) , count_on_helper(0) +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) , count_within_near_offsetted(0) +#endif , remove_on_multi(false) , count_on_occupied(0) , count_on_multi(0) diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index 233b202c0..c04cddf66 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -446,6 +446,7 @@ struct buffered_piece_collection { it->location = inside_buffer; } +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) if (it->count_within_near_offsetted > 0) { // Within can have in rare cases a rounding issue. We don't discard this @@ -453,6 +454,7 @@ struct buffered_piece_collection // will never start a new ring from this type of points. it->selectable_start = false; } +#endif } } @@ -546,6 +548,7 @@ struct buffered_piece_collection } } +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) // Insert all rescaled turn-points into these rings, to form a // reliable integer-based ring. All turns can be compared (inside) to this // rings to see if they are inside. @@ -585,6 +588,7 @@ struct buffered_piece_collection } BOOST_ASSERT(assert_indices_in_robust_rings()); +#endif } template diff --git a/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp b/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp index 6a3daa282..76980074c 100644 --- a/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/get_piece_turns.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace boost { namespace geometry @@ -28,6 +29,31 @@ namespace detail { namespace buffer { +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) +struct buffer_assign_turn +{ + static bool const include_no_turn = false; + static bool const include_degenerate = false; + static bool const include_opposite = false; + + template + < + typename Info, + typename Point1, + typename Point2, + typename IntersectionInfo + > + static inline void apply(Info& info, Point1 const& p1, Point2 const& p2, IntersectionInfo const& iinfo) + { + info.rob_pi = iinfo.rpi(); + info.rob_pj = iinfo.rpj(); + info.rob_qi = iinfo.rqi(); + info.rob_qj = iinfo.rqj(); + } + +}; +#endif + template < typename Pieces, @@ -204,7 +230,11 @@ class piece_turn_visitor // and iterating in sync with them... typedef detail::overlay::get_turn_info < +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + buffer_assign_turn +#else detail::overlay::assign_null_policy +#endif > turn_policy; turn_policy::apply(*prev1, *it1, *next1, diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp index 8803efdec..405213bb2 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_piece_visitor.hpp @@ -25,6 +25,10 @@ #include #include #include +#include +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) +#include +#endif namespace boost { namespace geometry @@ -89,8 +93,10 @@ enum analyse_result analyse_disjoint, analyse_within, analyse_on_original_boundary, - analyse_on_offsetted, - analyse_near_offsetted + analyse_on_offsetted +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + , analyse_near_offsetted +#endif }; template @@ -112,6 +118,31 @@ inline analyse_result check_segment(Point const& previous, Point const& current, Turn const& turn, bool from_monotonic) { + +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + typedef geometry::model::referring_segment segment_type; + segment_type const p(turn.rob_pi, turn.rob_pj); + segment_type const q(turn.rob_qi, turn.rob_qj); + segment_type const r(previous, current); + int const side = strategy::side::side_of_intersection::apply(p, q, r, + turn.robust_point); + + if (side == 0) + { + return analyse_on_offsetted; + } + if (side == -1 && from_monotonic) + { + return analyse_within; + } + if (side == 1 && from_monotonic) + { + return analyse_disjoint; + } + return analyse_continue; + +#else + typedef typename strategy::side::services::default_strategy < typename cs_tag::type @@ -156,6 +187,7 @@ inline analyse_result check_segment(Point const& previous, // Not monotonic, on left or right side: continue analysing return analyse_continue; +#endif } @@ -228,6 +260,48 @@ class analyse_turn_wrt_piece bool is_original, Point const& offsetted) { +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + typedef geometry::model::referring_segment segment_type; + segment_type const p(turn.rob_pi, turn.rob_pj); + segment_type const q(turn.rob_qi, turn.rob_qj); + segment_type const r(s1, s2); + int const side = strategy::side::side_of_intersection::apply(p, q, r, + turn.robust_point); + + if (side == 1) + { + // left of segment + return analyse_disjoint; + } + else if (side == 0) + { + // If is collinear, either on segment or before/after + typedef geometry::model::box box_type; + + box_type box; + geometry::assign_inverse(box); + geometry::expand(box, s1); + geometry::expand(box, s2); + + if (geometry::covered_by(turn.robust_point, box)) + { + // Points on helper-segments are considered as within + // Points on original boundary are processed differently + return is_original + ? analyse_on_original_boundary + : analyse_within; + } + + // It is collinear but not on the segment. Because these + // segments are convex, it is outside + // Unless the offsetted ring is collinear or concave w.r.t. + // helper-segment but that scenario is not yet supported + return analyse_disjoint; + } + + // right of segment + return analyse_continue; +#else typedef typename strategy::side::services::default_strategy < typename cs_tag::type @@ -276,6 +350,7 @@ class analyse_turn_wrt_piece // right of segment return analyse_continue; +#endif } template @@ -492,6 +567,60 @@ class turn_in_piece_visitor return false; } +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + template + static inline int turn_in_convex_piece(Turn const& turn, + Piece const& piece) + { + typedef typename Turn::robust_point_type point_type; + typedef typename Piece::piece_robust_ring_type ring_type; + typedef geometry::model::referring_segment segment; + + segment const p(turn.rob_pi, turn.rob_pj); + segment const q(turn.rob_qi, turn.rob_qj); + + typedef typename boost::range_iterator::type iterator_type; + iterator_type it = boost::begin(piece.robust_ring); + iterator_type end = boost::end(piece.robust_ring); + + // A robust ring is always closed, and always clockwise + for (iterator_type previous = it++; it != end; ++previous, ++it) + { + geometry::equal_to comparator; + if (comparator(*previous, *it)) + { + // Points are the same + continue; + } + + segment r(*previous, *it); + + int const side = strategy::side::side_of_intersection::apply(p, q, r, + turn.robust_point); + + if (side == 1) + { + // IP is left of segment, so it is outside + return -1; // outside + } + else if (side == 0) + { + // IP is collinear with segment. TODO: we should analyze this further + // For now we use the fallback point + if (in_box(*previous, *it, turn.robust_point)) + { + return 0; + } + else + { + return -1; // outside + } + } + } + return 1; // inside + } +#endif + public: @@ -549,16 +678,32 @@ public: case analyse_within : mutable_turn.count_within++; return; +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) case analyse_near_offsetted : mutable_turn.count_within_near_offsetted++; return; +#endif default : break; } - // TODO: this point_in_geometry is a performance-bottleneck here and - // will be replaced completely by extending analyse_piece functionality +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + // We don't know (yet) + int geometry_code = 0; + if (piece.is_convex) + { + geometry_code = turn_in_convex_piece(turn, piece); + } + else + { + + // TODO: this point_in_geometry is a performance-bottleneck here and + // will be replaced completely by extending analyse_piece functionality + geometry_code = detail::within::point_in_geometry(turn.robust_point, piece.robust_ring); + } +#else int geometry_code = detail::within::point_in_geometry(turn.robust_point, piece.robust_ring); +#endif if (geometry_code == 1) { diff --git a/test/algorithms/buffer/linestring_buffer.cpp b/test/algorithms/buffer/linestring_buffer.cpp index 1348bdd24..1ce527420 100644 --- a/test/algorithms/buffer/linestring_buffer.cpp +++ b/test/algorithms/buffer/linestring_buffer.cpp @@ -204,8 +204,10 @@ void test_all() test_one("mysql_report_2015_03_02c_asym1", mysql_report_2015_03_02c, join_round(7), end_round(7), 39.714, d10, d15); test_one("mysql_report_2015_03_02c_asym2", mysql_report_2015_03_02c, join_round(7), end_round(7), 46.116, d15, d10); +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) double const d100 = 10; test_one("mysql_report_2015_04_01", mysql_report_2015_04_01, join_round(32), end_round(32), 632.234, d100); +#endif } diff --git a/test/algorithms/buffer/multi_point_buffer.cpp b/test/algorithms/buffer/multi_point_buffer.cpp index 5c4cbd6a7..f4b1ad5d9 100644 --- a/test/algorithms/buffer/multi_point_buffer.cpp +++ b/test/algorithms/buffer/multi_point_buffer.cpp @@ -84,6 +84,10 @@ void test_all() template void test_many_points_per_circle() { +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + // These tests still fail for the new approach + return; +#endif // Tests for large distances / many points in circles. // Before Boost 1.58, this would (seem to) hang. It is solved by using monotonic sections in get_turns for buffer // This is more time consuming, only calculate this for counter clockwise diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index 4b526a8e6..c88083022 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -415,7 +415,9 @@ void test_all() test_one("rt_p22", rt_p22, join_miter, end_flat, 26.5711, 1.0); test_one("rt_q1", rt_q1, join_miter, end_flat, 27, 1.0); +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) test_one("rt_q2", rt_q2, join_miter, end_flat, 26.4853, 1.0); +#endif test_one("rt_q2", rt_q2, join_miter, end_flat, 0.9697, -0.25); test_one("rt_r", rt_r, join_miter, end_flat, 21.0761, 1.0); @@ -451,8 +453,8 @@ void test_all() test_one("rt_u11_50", rt_u11, join_miter, end_flat, 0.04289, -0.50); test_one("rt_u11_25", rt_u11, join_miter, end_flat, 10.1449, -0.25); -#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) - test_one("rt_u12", rt_u12, join_miter, end_flat, 999, 1.0); +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) + test_one("rt_u12", rt_u12, join_miter, end_flat, 142.1348, 1.0); test_one("rt_u13", rt_u13, join_miter, end_flat, 115.4853, 1.0); #endif diff --git a/test/algorithms/buffer/test_buffer.hpp b/test/algorithms/buffer/test_buffer.hpp index 6b0d91105..9f7e454c7 100644 --- a/test/algorithms/buffer/test_buffer.hpp +++ b/test/algorithms/buffer/test_buffer.hpp @@ -211,7 +211,9 @@ struct svg_visitor << "/" << bg::operation_char(it->operations[1].operation); out << " " << (it->count_on_offsetted > 0 ? "b" : "") // b: offsetted border +#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) << (it->count_within_near_offsetted > 0 ? "n" : "") +#endif << (it->count_within > 0 ? "w" : "") << (it->count_on_helper > 0 ? "h" : "") << (it->count_on_multi > 0 ? "m" : "") From f6d6869b14484ca2e3675b82f891e7b70b6bfaf6 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 8 Apr 2015 17:26:16 +0200 Subject: [PATCH 015/104] [less] add missing includes --- include/boost/geometry/algorithms/detail/relate/less.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/geometry/algorithms/detail/relate/less.hpp b/include/boost/geometry/algorithms/detail/relate/less.hpp index 3f11d4e87..462fcc35f 100644 --- a/include/boost/geometry/algorithms/detail/relate/less.hpp +++ b/include/boost/geometry/algorithms/detail/relate/less.hpp @@ -14,6 +14,10 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_LESS_HPP +#include +#include +#include + namespace boost { namespace geometry { From 9e69537ede0b8982b996a8af18d4b165b684d8c3 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 8 Apr 2015 17:28:50 +0200 Subject: [PATCH 016/104] [side] update side of intersection with fallback point, and use multi_precision point to avoid large multiplications and overflow --- .../cartesian/side_of_intersection.hpp | 126 ++++++++++++++++-- test/strategies/side_of_intersection.cpp | 74 +++++++--- 2 files changed, 174 insertions(+), 26 deletions(-) diff --git a/include/boost/geometry/strategies/cartesian/side_of_intersection.hpp b/include/boost/geometry/strategies/cartesian/side_of_intersection.hpp index 39487676c..d95510223 100644 --- a/include/boost/geometry/strategies/cartesian/side_of_intersection.hpp +++ b/include/boost/geometry/strategies/cartesian/side_of_intersection.hpp @@ -13,8 +13,13 @@ #include #include #include +#include +#include #include +#include +#include +#include namespace boost { namespace geometry { @@ -29,15 +34,74 @@ namespace strategy { namespace side // It can be used for either integer (rescaled) points, and also for FP class side_of_intersection { +private : + template + static inline + int sign_of_product(T const& a, U const& b) + { + return a == 0 || b == 0 ? 0 + : a > 0 && b > 0 ? 1 + : a < 0 && b < 0 ? 1 + : -1; + } + + template + static inline + int sign_of_compare(T const& a, T const& b, T const& c, T const& d) + { + // Both a*b and c*d are positive + // We have to judge if a*b > c*d + + using namespace boost::multiprecision; + cpp_int const lab = cpp_int(a) * cpp_int(b); + cpp_int const lcd = cpp_int(c) * cpp_int(d); + + return lab > lcd ? 1 + : lab < lcd ? -1 + : 0 + ; + } + + template + static inline + int sign_of_addition_of_two_products(T const& a, T const& b, T const& c, T const& d) + { + // sign of a*b+c*d, 1 if positive, -1 if negative, else 0 + int const ab = sign_of_product(a, b); + int const cd = sign_of_product(c, d); + if (ab == 0) + { + return cd; + } + if (cd == 0) + { + return ab; + } + + if (ab == cd) + { + // Both positive or both negative + return ab; + } + + // One is positive, one is negative, both are non zero + // If ab is positive, we have to judge if a*b > -c*d (then 1 because sum is positive) + // If ab is negative, we have to judge if c*d > -a*b (idem) + return ab == 1 + ? sign_of_compare(a, b, -c, d) + : sign_of_compare(c, d, -a, b); + } + + public : // Calculates the side of the intersection-point (if any) of // of segment a//b w.r.t. segment c // This is calculated without (re)calculating the IP itself again and fully // based on integer mathematics - template + template static inline T side_value(Segment const& a, Segment const& b, - Segment const& c) + Segment const& c, Point const& fallback_point) { // The first point of the three segments is reused several times T const ax = get<0, 0>(a); @@ -67,9 +131,15 @@ public : if (d == zero) { // There is no IP of a//b, they are collinear or parallel - // We don't have to divide but we can already conclude the side-value - // is meaningless and the resulting determinant will be 0 - return zero; + // Assuming they intersect (this method should be called for + // segments known to intersect), they are collinear and overlap. + // They have one or two intersection points - we don't know and + // have to rely on the fallback intersection point + + Point c1, c2; + geometry::detail::assign_point_from_index<0>(c, c1); + geometry::detail::assign_point_from_index<1>(c, c2); + return side_by_triangle<>::apply(c1, c2, fallback_point); } // Cramer's rule: da (see cart_intersect.hpp) @@ -82,7 +152,9 @@ public : // IP is at (ax + (da/d) * dx_a, ay + (da/d) * dy_a) // Side of IP is w.r.t. c is: determinant(dx_c, dy_c, ipx-cx, ipy-cy) // We replace ipx by expression above and multiply each term by d - T const result = geometry::detail::determinant + +#ifdef BOOST_GEOMETRY_SIDE_OF_INTERSECTION_DEBUG + T const result1 = geometry::detail::determinant ( dx_c * d, dy_c * d, d * (ax - cx) + dx_a * da, d * (ay - cy) + dy_a * da @@ -93,15 +165,51 @@ public : // Therefore, the sign is always the same as that result, and the // resulting side (left,right,collinear) is the same + // The first row we divide again by d because of determinant multiply rule + T const result2 = d * geometry::detail::determinant + ( + dx_c, dy_c, + d * (ax - cx) + dx_a * da, d * (ay - cy) + dy_a * da + ); + // Write out: + T const result3 = d * (dx_c * (d * (ay - cy) + dy_a * da) + - dy_c * (d * (ax - cx) + dx_a * da)); + // Write out in braces: + T const result4 = d * (dx_c * d * (ay - cy) + dx_c * dy_a * da + - dy_c * d * (ax - cx) - dy_c * dx_a * da); + // Write in terms of d * XX + da * YY + T const result5 = d * (d * (dx_c * (ay - cy) - dy_c * (ax - cx)) + + da * (dx_c * dy_a - dy_c * dx_a)); + + //return result; +#endif + + // We consider the results separately + // (in the end we only have to return the side-value 1,0 or -1) + + // To avoid multiplications we judge the product (easy, avoids *d) + // and the sign of p*q+r*s (more elaborate) + T const result = sign_of_product + ( + d, + sign_of_addition_of_two_products + ( + d, dx_c * (ay - cy) - dy_c * (ax - cx), + da, dx_c * dy_a - dy_c * dx_a + ) + ); return result; + } - template - static inline int apply(Segment const& a, Segment const& b, Segment const& c) + template + static inline int apply(Segment const& a, Segment const& b, + Segment const& c, + Point const& fallback_point) { typedef typename geometry::coordinate_type::type coordinate_type; - coordinate_type const s = side_value(a, b, c); + coordinate_type const s = side_value(a, b, c, fallback_point); coordinate_type const zero = coordinate_type(); return math::equals(s, zero) ? 0 : s > zero ? 1 diff --git a/test/strategies/side_of_intersection.cpp b/test/strategies/side_of_intersection.cpp index c5de7e0ea..761faa94f 100644 --- a/test/strategies/side_of_intersection.cpp +++ b/test/strategies/side_of_intersection.cpp @@ -19,9 +19,13 @@ namespace bg = boost::geometry; int test_main(int, char* []) { - typedef bg::model::d2::point_xy point; + typedef bg::model::d2::point_xy point; typedef bg::model::segment segment; + typedef bg::strategy::side::side_of_intersection side; + + point no_fb(-99, -99); + segment a(point(20, 10), point(10, 20)); segment b1(point(11, 16), point(20, 14)); // IP with a: (14.857, 15.143) @@ -31,27 +35,63 @@ int test_main(int, char* []) segment c2(point(15, 16), point(14, 8)); segment c3(point(15, 16), point(15, 8)); - typedef bg::strategy::side::side_of_intersection side; - BOOST_CHECK_EQUAL( 1, side::apply(a, b1, c1)); - BOOST_CHECK_EQUAL(-1, side::apply(a, b1, c2)); - BOOST_CHECK_EQUAL(-1, side::apply(a, b1, c3)); + BOOST_CHECK_EQUAL( 1, side::apply(a, b1, c1, no_fb)); + BOOST_CHECK_EQUAL(-1, side::apply(a, b1, c2, no_fb)); + BOOST_CHECK_EQUAL(-1, side::apply(a, b1, c3, no_fb)); - BOOST_CHECK_EQUAL( 1, side::apply(a, b2, c1)); - BOOST_CHECK_EQUAL( 1, side::apply(a, b2, c2)); - BOOST_CHECK_EQUAL( 0, side::apply(a, b2, c3)); + BOOST_CHECK_EQUAL( 1, side::apply(a, b2, c1, no_fb)); + BOOST_CHECK_EQUAL( 1, side::apply(a, b2, c2, no_fb)); + BOOST_CHECK_EQUAL( 0, side::apply(a, b2, c3, no_fb)); - // Check internal calculation-method: - BOOST_CHECK_EQUAL(-1400, side::side_value(a, b1, c2)); - BOOST_CHECK_EQUAL( 2800, side::side_value(a, b1, c1)); + // Collinear cases + // 1: segments intersecting are collinear (with a fallback point): + { + point fb(5, 5); + segment col1(point(0, 5), point(5, 5)); + segment col2(point(5, 5), point(10, 5)); // One IP with col1 at (5,5) + segment col3(point(5, 0), point(5, 5)); + BOOST_CHECK_EQUAL( 0, side::apply(col1, col2, col3, fb)); + } + // 2: segment of side calculation collinear with one of the segments + { + point fb(5, 5); + segment col1(point(0, 5), point(10, 5)); + segment col2(point(5, 5), point(5, 12)); // IP with col1 at (5,5) + segment col3(point(5, 1), point(5, 5)); // collinear with col2 + BOOST_CHECK_EQUAL( 0, side::apply(col1, col2, col3, fb)); + } + { + point fb(5, 5); + segment col1(point(10, 5), point(0, 5)); + segment col2(point(5, 5), point(5, 12)); // IP with col1 at (5,5) + segment col3(point(5, 1), point(5, 5)); // collinear with col2 + BOOST_CHECK_EQUAL( 0, side::apply(col1, col2, col3, fb)); + } + { + point fb(5, 5); + segment col1(point(0, 5), point(10, 5)); + segment col2(point(5, 12), point(5, 5)); // IP with col1 at (5,5) + segment col3(point(5, 1), point(5, 5)); // collinear with col2 + BOOST_CHECK_EQUAL( 0, side::apply(col1, col2, col3, fb)); + } + + { + point fb(517248, -517236); + segment col1(point(-172408, -517236), point(862076, -517236)); + segment col2(point(517248, -862064), point(517248, -172408)); + segment col3(point(517248, -172408), point(517248, -517236)); + BOOST_CHECK_EQUAL( 0, side::apply(col1, col2, col3, fb)); + } + { + point fb(-221647, -830336); + segment col1(point(-153817, -837972), point(-222457, -830244)); + segment col2(point(-221139, -833615), point(-290654, -384388)); + segment col3(point(-255266, -814663), point(-264389, -811197)); + BOOST_CHECK_EQUAL(1, side::apply(col1, col2, col3, fb)); // Left of segment... + } - BOOST_CHECK_EQUAL (2800, side::side_value(a, b1, c1)); - BOOST_CHECK_EQUAL(-1400, side::side_value(a, b1, c2)); - BOOST_CHECK_EQUAL(-5600, side::side_value(a, b1, c3)); - BOOST_CHECK_EQUAL(12800, side::side_value(a, b2, c1)); - BOOST_CHECK_EQUAL( 6400, side::side_value(a, b2, c2)); - BOOST_CHECK_EQUAL( 0, side::side_value(a, b2, c3)); // TODO: we might add a check calculating the IP, determining the side // with the normal side strategy, and verify the results are equal From ca36bc77859865cf83948568f0e81047c9baa846 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 12 Apr 2015 17:37:00 +0200 Subject: [PATCH 017/104] [buffer][test] enable two tests which are now OK for SIDE_OF_INTERSECTION approach --- test/algorithms/buffer/multi_point_buffer.cpp | 5 ++--- test/algorithms/buffer/multi_polygon_buffer.cpp | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/test/algorithms/buffer/multi_point_buffer.cpp b/test/algorithms/buffer/multi_point_buffer.cpp index 0b2f60729..e28f0145d 100644 --- a/test/algorithms/buffer/multi_point_buffer.cpp +++ b/test/algorithms/buffer/multi_point_buffer.cpp @@ -60,15 +60,14 @@ void test_all() { bg::strategy::buffer::point_square point_strategy; - test_with_custom_strategies("grid_a50", grid_a, join_miter, end_flat, distance_strategy(0.5), side_strategy, point_strategy, 7.0); -#if defined(BOOST_GEOMETRY_BUFFER_INCLUDE_FAILING_TESTS) +#if defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) test_with_custom_strategies("grid_a54", grid_a, join_miter, end_flat, - distance_strategy(0.54), side_strategy, point_strategy, 99); + distance_strategy(0.54), side_strategy, point_strategy, 7.819); #endif } diff --git a/test/algorithms/buffer/multi_polygon_buffer.cpp b/test/algorithms/buffer/multi_polygon_buffer.cpp index 17ffeae76..0b937bb9f 100644 --- a/test/algorithms/buffer/multi_polygon_buffer.cpp +++ b/test/algorithms/buffer/multi_polygon_buffer.cpp @@ -413,9 +413,7 @@ void test_all() test_one("rt_p22", rt_p22, join_miter, end_flat, 26.5711, 1.0); test_one("rt_q1", rt_q1, join_miter, end_flat, 27, 1.0); -#if ! defined(BOOST_GEOMETRY_BUFFER_USE_SIDE_OF_INTERSECTION) test_one("rt_q2", rt_q2, join_miter, end_flat, 26.4853, 1.0); -#endif test_one("rt_q2", rt_q2, join_miter, end_flat, 0.9697, -0.25); test_one("rt_r", rt_r, join_miter, end_flat, 21.0761, 1.0); From 07b96a8f9e6a605e9cfe9d6e89a620e87dcf6e4b Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Thu, 23 Apr 2015 10:15:24 +0300 Subject: [PATCH 018/104] [algorithms][overlay P/L] replace detail::disjoint::disjoint_point_segment by detail::disjoint::reverse_covered_by --- .../geometry/algorithms/detail/overlay/pointlike_linear.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp index ad8756473..bb42b4232 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_linear.hpp @@ -293,7 +293,7 @@ struct pointlike_linear_point > : detail::overlay::point_linear_point < Point, Segment, PointOut, OverlayType, - detail::not_ + detail::not_ > {}; @@ -311,7 +311,7 @@ struct pointlike_linear_point > : detail::overlay::multipoint_linear_point < MultiPoint, Linear, PointOut, OverlayType, - detail::not_ + detail::not_ > {}; @@ -329,7 +329,7 @@ struct pointlike_linear_point > : detail::overlay::multipoint_segment_point < MultiPoint, Segment, PointOut, OverlayType, - detail::not_ + detail::not_ > {}; From 33447669102a1d1d287e925afce422312f9a5fe8 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 25 Apr 2015 19:39:42 +0200 Subject: [PATCH 019/104] [projections] remove redundant return statements --- .../geometry/extensions/gis/projections/proj/aitoff.hpp | 6 ------ .../geometry/extensions/gis/projections/proj/gn_sinu.hpp | 1 - .../geometry/extensions/gis/projections/proj/krovak.hpp | 8 -------- .../geometry/extensions/gis/projections/proj/ortho.hpp | 4 ---- .../geometry/extensions/gis/projections/proj/qsc.hpp | 2 -- 5 files changed, 21 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp index 966c0e6f4..b7f15787e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp @@ -90,9 +90,7 @@ namespace boost { namespace geometry { namespace projections xy_x = (xy_x + lp_lon * this->m_proj_parm.cosphi1) * 0.5; xy_y = (xy_y + lp_lat) * 0.5; } - return; } - /*********************************************************************************** * * Inverse functions added by Drazen Tutic and Lovro Gradiser based on paper: @@ -114,7 +112,6 @@ namespace boost { namespace geometry { namespace projections * ************************************************************************************/ - inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { int iter, MAXITER = 10, round = 0, MAXROUND = 20; @@ -171,10 +168,7 @@ namespace boost { namespace geometry { namespace projections } while (((fabs(xy_x-x) > EPSILON) || (fabs(xy_y-y) > EPSILON)) && (round++ < MAXROUND)); if (iter == MAXITER && round == MAXROUND) fprintf(stderr, "Warning: Accuracy of 1e-12 not reached. Last increments: dlat=%e and dlon=%e\n", dp, dl); - - return; } - }; template diff --git a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp index bd2bc33f9..f1a827c58 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp @@ -95,7 +95,6 @@ namespace boost { namespace geometry { namespace projections } else if ((s - EPS10) < HALFPI) lp_lon = 0.; else throw proj_exception();; - return; } /* General spherical sinusoidals */ }; diff --git a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp index 49bd7d885..537981757 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp @@ -161,13 +161,8 @@ namespace boost { namespace geometry { namespace projections xy_y *= -1.0; xy_x *= -1.0; } - - return; } - - - inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { /* calculate lat/lon from xy */ @@ -247,10 +242,7 @@ namespace boost { namespace geometry { namespace projections while (ok==0); lp_lon -= this->m_par.lam0; - - return; } - }; // Krovak diff --git a/include/boost/geometry/extensions/gis/projections/proj/ortho.hpp b/include/boost/geometry/extensions/gis/projections/proj/ortho.hpp index 44f5b0d7e..399126f7b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/ortho.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/ortho.hpp @@ -101,10 +101,8 @@ namespace boost { namespace geometry { namespace projections break; } xy_x = cosphi * sin(lp_lon); - return; } - inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double rh, cosc, sinc; @@ -146,9 +144,7 @@ namespace boost { namespace geometry { namespace projections ? (xy_x == 0. ? 0. : xy_x < 0. ? -HALFPI : HALFPI) : atan2(xy_x, xy_y); } - return; } - }; // Orthographic diff --git a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp index a9f6bf0db..529e8e4b9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp @@ -238,9 +238,7 @@ namespace boost { namespace geometry { namespace projections xy_x = t * cos(mu); xy_y = t * sin(mu); boost::ignore_unused(nu); - return; } - /* Inverse projection, ellipsoid */ inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const From 24f070a0379d2253ade7c4a29c6aab2b5a849bbc Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sat, 25 Apr 2015 20:58:02 +0200 Subject: [PATCH 020/104] [projections][imw_p] changes in conversion (staying more close to original) --- .../extensions/gis/projections/proj/imw_p.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp index db9b88850..8f6d9d310 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp @@ -53,7 +53,7 @@ namespace boost { namespace geometry { namespace projections static const double TOL = 1e-10; static const double EPS = 1e-10; - struct PXY { double x, y; }; // x/y projection specific + struct XY { double x, y; }; // specific for IMW_P struct par_imw_p { @@ -80,9 +80,9 @@ namespace boost { namespace geometry { namespace projections return err; } template - inline PXY - loc_for(double const& lp_lam, double const& lp_phi, const Parameters& par, par_imw_p const& proj_parm, double *yc) { - PXY xy; + inline XY + loc_for(double const& lp_lam, double const& lp_phi, Parameters& par, par_imw_p& proj_parm, double *yc) { + XY xy; if (! lp_phi) { xy.x = lp_lam; @@ -159,13 +159,13 @@ namespace boost { namespace geometry { namespace projections inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { double yc = 0; - PXY xy = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc); + XY xy = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc); xy_x = xy.x; xy_y = xy.y; } inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { - PXY t; + XY t; double yc = 0; lp_lat = this->m_proj_parm.phi_2; From e15b685a8d5745d69cef442d3c2c006720149d81 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 10:49:14 +0200 Subject: [PATCH 021/104] [projections] ONLY changes in empty lines (in generation) --- .../geometry/extensions/gis/projections/proj/aea.hpp | 5 ----- .../geometry/extensions/gis/projections/proj/aeqd.hpp | 5 ----- .../geometry/extensions/gis/projections/proj/airy.hpp | 4 ---- .../geometry/extensions/gis/projections/proj/aitoff.hpp | 5 ----- .../geometry/extensions/gis/projections/proj/geocent.hpp | 4 ---- .../geometry/extensions/gis/projections/proj/geos.hpp | 2 -- .../geometry/extensions/gis/projections/proj/gstmerc.hpp | 1 - .../geometry/extensions/gis/projections/proj/krovak.hpp | 8 -------- .../geometry/extensions/gis/projections/proj/latlong.hpp | 2 -- .../geometry/extensions/gis/projections/proj/lcca.hpp | 2 -- .../geometry/extensions/gis/projections/proj/mod_ster.hpp | 1 - .../geometry/extensions/gis/projections/proj/nzmg.hpp | 4 ---- .../geometry/extensions/gis/projections/proj/omerc.hpp | 2 -- .../geometry/extensions/gis/projections/proj/qsc.hpp | 2 -- .../geometry/extensions/gis/projections/proj/robin.hpp | 2 -- .../geometry/extensions/gis/projections/proj/sterea.hpp | 3 --- 16 files changed, 52 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp index 6aa65ccd2..27be1a781 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp @@ -75,11 +75,6 @@ namespace boost { namespace geometry { namespace projections double en[EN_SIZE]; int ellips; }; - - - - - /* determine latitude angle phi-1 */ inline double phi1_(double qs, double Te, double Tone_es) { diff --git a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp index c8cbeb067..b9bdf23ea 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp @@ -72,11 +72,6 @@ namespace boost { namespace geometry { namespace projections int mode; }; - - - - - // template class, using CRTP to implement forward/inverse template struct base_aeqd_ellipsoid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/airy.hpp b/include/boost/geometry/extensions/gis/projections/proj/airy.hpp index c8c383599..61f03f90a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/airy.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/airy.hpp @@ -65,10 +65,6 @@ namespace boost { namespace geometry { namespace projections int no_cut; /* do not cut at hemisphere limit */ }; - - - - // template class, using CRTP to implement forward/inverse template struct base_airy_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp index b7f15787e..267c770b1 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp @@ -57,11 +57,6 @@ namespace boost { namespace geometry { namespace projections int mode; }; - - - - - // template class, using CRTP to implement forward/inverse template struct base_aitoff_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp b/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp index 4df4b4d2f..65b9cc09f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp @@ -51,10 +51,6 @@ namespace boost { namespace geometry { namespace projections namespace detail { namespace geocent{ - - - - // template class, using CRTP to implement forward/inverse template struct base_geocent_other : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/geos.hpp b/include/boost/geometry/extensions/gis/projections/proj/geos.hpp index e2fe57c44..13fe1f6ed 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/geos.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/geos.hpp @@ -63,8 +63,6 @@ namespace boost { namespace geometry { namespace projections int flip_axis; }; - - // template class, using CRTP to implement forward/inverse template struct base_geos_ellipsoid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp index ccff62891..2caf55a9c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp @@ -63,7 +63,6 @@ namespace boost { namespace geometry { namespace projections double YS; }; - // template class, using CRTP to implement forward/inverse template struct base_gstmerc_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp index 537981757..89b32d26f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp @@ -54,11 +54,6 @@ namespace boost { namespace geometry { namespace projections { double C_x; }; - - - - - /** NOTES: According to EPSG the full Krovak projection method should have the following parameters. Within PROJ.4 the azimuth, and pseudo @@ -82,9 +77,6 @@ namespace boost { namespace geometry { namespace projections **/ - - - // template class, using CRTP to implement forward/inverse template struct base_krovak_ellipsoid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp b/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp index 75e6ab90f..1a552c01f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp @@ -52,10 +52,8 @@ namespace boost { namespace geometry { namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace latlong{ - /* very loosely based upon DMA code by Bradford W. Drew */ - // template class, using CRTP to implement forward/inverse template struct base_latlong_other : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index 37737793b..c5a7b61ab 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -59,8 +59,6 @@ namespace boost { namespace geometry { namespace projections double r0, l, M0; double C; }; - - inline double /* func to compute dr */ fS(double S, double C) { return(S * ( 1. + S * S * C)); diff --git a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp index f772392e0..98d6c1a37 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp @@ -61,7 +61,6 @@ namespace boost { namespace geometry { namespace projections }; /* based upon Snyder and Linck, USGS-NMD */ - // template class, using CRTP to implement forward/inverse template struct base_mod_ster_ellipsoid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp b/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp index 9da524997..a0a83886b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp @@ -56,10 +56,6 @@ namespace boost { namespace geometry { namespace projections static const int Ntpsi = 9; static const int Ntphi = 8; - - - - static COMPLEX bf[] = { {.7557853228, 0.0}, diff --git a/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp index 37d37eeb1..bf9fd2e6f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp @@ -65,8 +65,6 @@ namespace boost { namespace geometry { namespace projections int no_rot; }; - - // template class, using CRTP to implement forward/inverse template struct base_omerc_ellipsoid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp index 529e8e4b9..2e1f0f0af 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp @@ -70,8 +70,6 @@ namespace boost { namespace geometry { namespace projections double one_minus_f; double one_minus_f_squared; }; - - /* The six cube faces. */ /* The four areas on a cube face. AREA_0 is the area of definition, diff --git a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp index fae3416a0..3d8c2933b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp @@ -58,8 +58,6 @@ namespace boost { namespace geometry { namespace projections static const double ONEEPS = 1.000001; static const double EPS = 1e-8; - - struct COEFS { double c0, c1, c2, c3; }; diff --git a/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp b/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp index 96e89dded..00284c045 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sterea.hpp @@ -63,9 +63,6 @@ namespace boost { namespace geometry { namespace projections gauss::GAUSS en; }; - - - // template class, using CRTP to implement forward/inverse template struct base_sterea_ellipsoid : public base_t_fi, From 9f9d59a515bee898fb9162179e52abfb70aef984 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 10:56:15 +0200 Subject: [PATCH 022/104] [projections] add const (was accidentally removed in one function two commits away) --- .../geometry/extensions/gis/projections/proj/imw_p.hpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp index 8f6d9d310..995a7193c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp @@ -81,7 +81,7 @@ namespace boost { namespace geometry { namespace projections } template inline XY - loc_for(double const& lp_lam, double const& lp_phi, Parameters& par, par_imw_p& proj_parm, double *yc) { + loc_for(double const& lp_lam, double const& lp_phi, Parameters const& par, par_imw_p const& proj_parm, double *yc) { XY xy; if (! lp_phi) { @@ -127,10 +127,9 @@ namespace boost { namespace geometry { namespace projections } return (xy); } - template - inline void - xy(Parameters& par, par_imw_p& proj_parm, double phi, double *x, double *y, double *sp, double *R) { + inline void + xy(Parameters const& par, par_imw_p const& proj_parm, double phi, double *x, double *y, double *sp, double *R) { double F; *sp = sin(phi); @@ -140,7 +139,6 @@ namespace boost { namespace geometry { namespace projections *x = *R * sin(F); } - // template class, using CRTP to implement forward/inverse template struct base_imw_p_ellipsoid : public base_t_fi, From 5607fa25b3e93509aef235eedb41976118a068b8 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 12:36:59 +0200 Subject: [PATCH 023/104] [projections] changes in generation (enfn) result is closer to original --- .../geometry/extensions/gis/projections/impl/pj_mlfn.hpp | 3 ++- .../boost/geometry/extensions/gis/projections/proj/aea.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/aeqd.hpp | 4 ++-- .../boost/geometry/extensions/gis/projections/proj/cass.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/eqdc.hpp | 4 ++-- .../geometry/extensions/gis/projections/proj/gn_sinu.hpp | 4 ++-- .../boost/geometry/extensions/gis/projections/proj/imw_p.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/lcca.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/poly.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/tmerc.hpp | 4 ++-- 10 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp b/include/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp index b5db34988..c4bbf266e 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp @@ -65,7 +65,7 @@ static const double EPS = 1e-11; static const int MAX_ITER = 10; static const int EN_SIZE = 5; -inline void pj_enfn(double es, double* en) +inline bool pj_enfn(double es, double* en) { double t; //, *en; @@ -78,6 +78,7 @@ inline void pj_enfn(double es, double* en) en[4] = t * es * C88; } // return en; + return true; } inline double pj_mlfn(double phi, double sphi, double cphi, const double *en) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp index 27be1a781..085ab350a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp @@ -163,7 +163,7 @@ namespace boost { namespace geometry { namespace projections secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10; if( (proj_parm.ellips = (par.es > 0.))) { double ml1, m1; - pj_enfn(par.es, proj_parm.en); + if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); m1 = pj_msfn(sinphi, cosphi, par.es); ml1 = pj_qsfn(sinphi, par.e, par.one_es); if (secant) { /* secant cone */ diff --git a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp index b9bdf23ea..66faf7076 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp @@ -45,8 +45,8 @@ #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { @@ -317,7 +317,7 @@ namespace boost { namespace geometry { namespace projections // par.inv = s_inverse; // par.fwd = s_forward; } else { - pj_enfn(par.es, proj_parm.en); + if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); if (pj_param(par.params, "bguam").i) { proj_parm.M1 = pj_mlfn(par.phi0, proj_parm.sinph0, proj_parm.cosph0, proj_parm.en); // par.inv = e_guam_inv; diff --git a/include/boost/geometry/extensions/gis/projections/proj/cass.hpp b/include/boost/geometry/extensions/gis/projections/proj/cass.hpp index 037476abf..d6432a284 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/cass.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/cass.hpp @@ -155,7 +155,7 @@ namespace boost { namespace geometry { namespace projections void setup_cass(Parameters& par, par_cass& proj_parm) { if (par.es) { - pj_enfn(par.es, proj_parm.en); + if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); proj_parm.m0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); // par.inv = e_inverse; // par.fwd = e_forward; diff --git a/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp b/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp index 70dec1580..dad1024d8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp @@ -130,8 +130,8 @@ namespace boost { namespace geometry { namespace projections proj_parm.phi1 = pj_param(par.params, "rlat_1").f; proj_parm.phi2 = pj_param(par.params, "rlat_2").f; if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21); - pj_enfn(par.es, proj_parm.en); - + if (!pj_enfn(par.es, proj_parm.en)) + throw proj_exception(0); proj_parm.n = sinphi = sin(proj_parm.phi1); cosphi = cos(proj_parm.phi1); secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10; diff --git a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp index f1a827c58..5f9fb2be2 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp @@ -173,8 +173,8 @@ namespace boost { namespace geometry { namespace projections template void setup_sinu(Parameters& par, par_gn_sinu& proj_parm) { - pj_enfn(par.es, proj_parm.en); - + if (!pj_enfn(par.es, proj_parm.en)) + throw proj_exception(0); if (par.es) { // par.inv = e_inverse; // par.fwd = e_forward; diff --git a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp index 995a7193c..059f3a692 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp @@ -182,7 +182,7 @@ namespace boost { namespace geometry { namespace projections { double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2; int i; - pj_enfn(par.es, proj_parm.en); + if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); if( (i = phi12(par, proj_parm, &del, &sig)) != 0) throw proj_exception(i); if (proj_parm.phi_2 < proj_parm.phi_1) { /* make sure proj_parm.phi_1 most southerly */ diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index c5a7b61ab..62c119514 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -120,7 +120,7 @@ namespace boost { namespace geometry { namespace projections { double s2p0, N0, R0, tan0, tan20; boost::ignore_unused(tan20); - pj_enfn(par.es, proj_parm.en); + if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50); if (par.phi0 == 0.) throw proj_exception(51); proj_parm.l = sin(par.phi0); diff --git a/include/boost/geometry/extensions/gis/projections/proj/poly.hpp b/include/boost/geometry/extensions/gis/projections/proj/poly.hpp index f9b560ec5..8c21a5962 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/poly.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/poly.hpp @@ -178,7 +178,7 @@ namespace boost { namespace geometry { namespace projections void setup_poly(Parameters& par, par_poly& proj_parm) { if (par.es) { - pj_enfn(par.es, proj_parm.en); + if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); proj_parm.ml0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); // par.inv = e_inverse; // par.fwd = e_forward; diff --git a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp index e45cb1d7b..f0420a1c6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp @@ -222,8 +222,8 @@ namespace boost { namespace geometry { namespace projections boost::ignore_unused(par); boost::ignore_unused(proj_parm); if (par.es) { - pj_enfn(par.es, proj_parm.en); - + if (!pj_enfn(par.es, proj_parm.en)) + throw proj_exception(0); proj_parm.ml0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en); proj_parm.esp = par.es / (1. - par.es); // par.inv = e_inverse; From 866aae97e0d792ddd300711150f06cab6342cbfd Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 14:27:19 +0200 Subject: [PATCH 024/104] [projections] changes in authset, conform enfn --- .../boost/geometry/extensions/gis/projections/impl/pj_auth.hpp | 3 ++- include/boost/geometry/extensions/gis/projections/proj/cea.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp b/include/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp index f198cc51a..adcd3a16b 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/pj_auth.hpp @@ -53,7 +53,7 @@ static const double P20 = .01641501294219154443; static const int APA_SIZE = 3; /* determine latitude from authalic latitude */ -inline void pj_authset(double es, double* APA) +inline bool pj_authset(double es, double* APA) { BOOST_ASSERT(0 != APA); @@ -70,6 +70,7 @@ inline void pj_authset(double es, double* APA) APA[1] += t * P11; APA[2] = t * P20; } + return true; } inline double pj_authlat(double beta, const double* APA) diff --git a/include/boost/geometry/extensions/gis/projections/proj/cea.hpp b/include/boost/geometry/extensions/gis/projections/proj/cea.hpp index 741ad4426..4a4ed0d25 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/cea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/cea.hpp @@ -134,7 +134,7 @@ namespace boost { namespace geometry { namespace projections t = sin(t); par.k0 /= sqrt(1. - par.es * t * t); par.e = sqrt(par.es); - pj_authset(par.es, proj_parm.apa); + if (!pj_authset(par.es, proj_parm.apa)) throw proj_exception(0); proj_parm.qp = pj_qsfn(1., par.e, par.one_es); // par.inv = e_inverse; // par.fwd = e_forward; From 9f992895512c480820bac8ea2e60dc818098e9de Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 14:30:15 +0200 Subject: [PATCH 025/104] [projections] changes in mdist conform enfn/authset --- .../geometry/extensions/gis/projections/impl/proj_mdist.hpp | 3 ++- .../boost/geometry/extensions/gis/projections/proj/aeqd.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/rouss.hpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp b/include/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp index 562e513ce..9069b47b4 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp @@ -53,7 +53,7 @@ namespace detail double b[MDIST_MAX_ITER]; }; - inline void proj_mdist_ini(double es, MDIST& b) + inline bool proj_mdist_ini(double es, MDIST& b) { double numf, numfi, twon1, denf, denfi, ens, T, twon; double den, El, Es; @@ -97,6 +97,7 @@ namespace detail numfi += 2.; denfi += 2.; } + return true; } inline double proj_mdist(double phi, double sphi, double cphi, const MDIST& b) { diff --git a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp index 66faf7076..8220f14bd 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp @@ -45,7 +45,6 @@ #include #include #include -#include #include namespace boost { namespace geometry { namespace projections diff --git a/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp b/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp index 1429c76e9..4382ae462 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp @@ -115,8 +115,8 @@ namespace boost { namespace geometry { namespace projections void setup_rouss(Parameters& par, par_rouss& proj_parm) { double N0, es2, t, t2, R_R0_2, R_R0_4; - proj_mdist_ini(par.es, proj_parm.en); - + if (!proj_mdist_ini(par.es, proj_parm.en)) + throw proj_exception(0); es2 = sin(par.phi0); proj_parm.s0 = proj_mdist(par.phi0, es2, cos(par.phi0), proj_parm.en); t = 1. - (es2 = par.es * es2 * es2); From 121f8b39c1ba88888150eedc8271eeb3cb9ae567 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 14:47:22 +0200 Subject: [PATCH 026/104] [projections] changes in includes, especially hypot, only necessary in a few cases, and changes in order --- .../boost/geometry/extensions/gis/projections/proj/aea.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/airy.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/aitoff.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/august.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/bacon.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/boggs.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/cass.hpp | 2 -- include/boost/geometry/extensions/gis/projections/proj/cc.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/cea.hpp | 4 +--- .../boost/geometry/extensions/gis/projections/proj/chamb.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/collg.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/crast.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/denoy.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/eck1.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/eck2.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/eck3.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/eck4.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/eck5.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/eqc.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/eqdc.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/fahey.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/fouc_s.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/gall.hpp | 2 -- .../geometry/extensions/gis/projections/proj/geocent.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/gins8.hpp | 2 -- .../geometry/extensions/gis/projections/proj/gn_sinu.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/goode.hpp | 4 +--- .../geometry/extensions/gis/projections/proj/gstmerc.hpp | 4 +--- .../boost/geometry/extensions/gis/projections/proj/hammer.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/hatano.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/imw_p.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/krovak.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/labrd.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/laea.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/lagrng.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/larr.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/lask.hpp | 2 -- .../geometry/extensions/gis/projections/proj/latlong.hpp | 4 ---- .../boost/geometry/extensions/gis/projections/proj/lcc.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/lcca.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/loxim.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/lsat.hpp | 3 +-- .../geometry/extensions/gis/projections/proj/mbt_fps.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/merc.hpp | 4 +--- .../boost/geometry/extensions/gis/projections/proj/mill.hpp | 2 -- .../geometry/extensions/gis/projections/proj/mod_ster.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/moll.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/nell.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/nell_h.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/nocol.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/nzmg.hpp | 3 +-- .../geometry/extensions/gis/projections/proj/ob_tran.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/ocea.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/oea.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/omerc.hpp | 4 +--- .../boost/geometry/extensions/gis/projections/proj/poly.hpp | 4 +--- .../boost/geometry/extensions/gis/projections/proj/putp2.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/putp3.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/putp4p.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/putp5.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/putp6.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/qsc.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/robin.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/rouss.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/rpoly.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/somerc.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/sts.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/tcc.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/tcea.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/tmerc.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/tpeqd.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/urm5.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/urmfps.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/vandg.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/vandg2.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/vandg4.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/wag2.hpp | 3 +-- .../boost/geometry/extensions/gis/projections/proj/wag3.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/wag7.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/wink1.hpp | 2 -- .../boost/geometry/extensions/gis/projections/proj/wink2.hpp | 2 -- 83 files changed, 29 insertions(+), 163 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp index 085ab350a..066c28128 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp @@ -45,9 +45,9 @@ #include #include #include +#include #include #include -#include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/airy.hpp b/include/boost/geometry/extensions/gis/projections/proj/airy.hpp index 61f03f90a..8efc490bc 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/airy.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/airy.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp index 267c770b1..89826ad3e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/august.hpp b/include/boost/geometry/extensions/gis/projections/proj/august.hpp index 6a88a2e3f..c4e6815b7 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/august.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/august.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/bacon.hpp b/include/boost/geometry/extensions/gis/projections/proj/bacon.hpp index 402a22796..95b86ec60 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/bacon.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/bacon.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp b/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp index 8ba33ab21..e00ed04e3 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/cass.hpp b/include/boost/geometry/extensions/gis/projections/proj/cass.hpp index d6432a284..7a4e7275b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/cass.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/cass.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/cc.hpp b/include/boost/geometry/extensions/gis/projections/proj/cc.hpp index 0b491abe2..12d59f36e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/cc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/cc.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/cea.hpp b/include/boost/geometry/extensions/gis/projections/proj/cea.hpp index 4a4ed0d25..eb36cb103 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/cea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/cea.hpp @@ -38,14 +38,12 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp b/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp index 5f7949637..bc41c512b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp @@ -40,8 +40,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/collg.hpp b/include/boost/geometry/extensions/gis/projections/proj/collg.hpp index 0358e0648..63895e781 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/collg.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/collg.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/crast.hpp b/include/boost/geometry/extensions/gis/projections/proj/crast.hpp index ba1a581f8..213f14091 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/crast.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/crast.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp b/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp index 11c1d97a3..91a3f0b38 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp index 1acb1e6d5..516562b1a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp index 22f56a403..5f17ebdb0 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp index e9d9caf0e..dbff39220 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp index f118e3347..371dca9ed 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp index e9b12f7bc..dccb96fa4 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/eqc.hpp b/include/boost/geometry/extensions/gis/projections/proj/eqc.hpp index f7c831468..fb30d0c26 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eqc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eqc.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp b/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp index dad1024d8..ef6b00094 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp @@ -44,8 +44,8 @@ #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp b/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp index ac444c8ef..ca72efa7c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp b/include/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp index da057e0f0..12953fb16 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/fouc_s.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/gall.hpp b/include/boost/geometry/extensions/gis/projections/proj/gall.hpp index 21ba02354..eb6dd605a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gall.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gall.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp b/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp index 65b9cc09f..e0adacd33 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp b/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp index 4fe4d33f2..14cce3172 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp index 5f9fb2be2..52988993c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp @@ -39,12 +39,11 @@ #include -#include - #include #include #include #include +#include #include namespace boost { namespace geometry { namespace projections diff --git a/include/boost/geometry/extensions/gis/projections/proj/goode.hpp b/include/boost/geometry/extensions/gis/projections/proj/goode.hpp index 2873f93fd..0f87f8962 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/goode.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/goode.hpp @@ -38,14 +38,12 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp index 2caf55a9c..8ee79f340 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gstmerc.hpp @@ -38,14 +38,12 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/hammer.hpp b/include/boost/geometry/extensions/gis/projections/proj/hammer.hpp index 42755171e..2895b25b1 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/hammer.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/hammer.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp index bf8c06a8d..79a113e18 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp index 059f3a692..14e0048b5 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp index 89b32d26f..2db34983e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/labrd.hpp b/include/boost/geometry/extensions/gis/projections/proj/labrd.hpp index 3a46dd486..19681be81 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/labrd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/labrd.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/laea.hpp b/include/boost/geometry/extensions/gis/projections/proj/laea.hpp index e07b4af4d..fcf6740b0 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/laea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/laea.hpp @@ -44,8 +44,8 @@ #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/lagrng.hpp b/include/boost/geometry/extensions/gis/projections/proj/lagrng.hpp index 71c2a4016..ee84a8a6c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lagrng.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lagrng.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/larr.hpp b/include/boost/geometry/extensions/gis/projections/proj/larr.hpp index 45cff26f8..42d3384ca 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/larr.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/larr.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/lask.hpp b/include/boost/geometry/extensions/gis/projections/proj/lask.hpp index 2111b5791..77aa5c064 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lask.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lask.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp b/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp index 1a552c01f..d689463a2 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/latlong.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include @@ -70,14 +68,12 @@ namespace boost { namespace geometry { namespace projections inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { - xy_x = lp_lon / this->m_par.a; xy_y = lp_lat / this->m_par.a; } inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { - lp_lat = xy_y * this->m_par.a; lp_lon = xy_x * this->m_par.a; } diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcc.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcc.hpp index 088a0cbe5..bd67bbc90 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcc.hpp @@ -45,8 +45,8 @@ #include #include #include -#include #include +#include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index 62c119514..346da454f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/loxim.hpp b/include/boost/geometry/extensions/gis/projections/proj/loxim.hpp index 7eba713b0..10f4dd17f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/loxim.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/loxim.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp b/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp index 2061750ca..39cef0733 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp index 0abb4ee4f..764429aa6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp index b552f82aa..5dd9631ca 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp index 66544aa5b..084974276 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/merc.hpp b/include/boost/geometry/extensions/gis/projections/proj/merc.hpp index 8b6c29daf..a2a48c967 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/merc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/merc.hpp @@ -38,15 +38,13 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/mill.hpp b/include/boost/geometry/extensions/gis/projections/proj/mill.hpp index be21405ca..e9128a75a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mill.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mill.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp index 98d6c1a37..80d923cb9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp @@ -45,6 +45,7 @@ #include #include #include +#include #include namespace boost { namespace geometry { namespace projections diff --git a/include/boost/geometry/extensions/gis/projections/proj/moll.hpp b/include/boost/geometry/extensions/gis/projections/proj/moll.hpp index 0afb9bd4e..1e7ef64a4 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/moll.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/moll.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/nell.hpp b/include/boost/geometry/extensions/gis/projections/proj/nell.hpp index 125f66313..59ce067ba 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nell.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nell.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp b/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp index a9d0ec33d..85df442da 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp b/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp index 4276b02fc..dd52aa8cc 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp b/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp index a0a83886b..7c26398ff 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp b/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp index f38ae8a0e..05210bc19 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp @@ -39,12 +39,12 @@ #include -#include #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/ocea.hpp b/include/boost/geometry/extensions/gis/projections/proj/ocea.hpp index 41e206ccc..ad0f8c6d1 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/ocea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/ocea.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/oea.hpp b/include/boost/geometry/extensions/gis/projections/proj/oea.hpp index f1a043317..6ecd2488b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/oea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/oea.hpp @@ -44,6 +44,7 @@ #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp index bf9fd2e6f..96c71eb91 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp @@ -38,14 +38,12 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/poly.hpp b/include/boost/geometry/extensions/gis/projections/proj/poly.hpp index 8c21a5962..4090a2259 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/poly.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/poly.hpp @@ -38,14 +38,12 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp index 1e05e1099..fcf2a7271 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp index 5722dd08e..d34741466 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp index 42204f98c..9ca25d629 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp @@ -39,12 +39,11 @@ #include -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp index ce3ef9db8..0ae6d21a8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp index 6f8def3a9..44da56a6c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp @@ -39,12 +39,11 @@ #include -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp index 2e1f0f0af..b7dde8038 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp index 3d8c2933b..701190e3d 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/robin.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/robin.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp b/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp index 4382ae462..cad652fa8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/rouss.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/rpoly.hpp b/include/boost/geometry/extensions/gis/projections/proj/rpoly.hpp index 7783e5080..95cee093f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/rpoly.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/rpoly.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/somerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/somerc.hpp index e5377abeb..edd7ea059 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/somerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/somerc.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/sts.hpp b/include/boost/geometry/extensions/gis/projections/proj/sts.hpp index 1d84cf64f..338fabb48 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sts.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sts.hpp @@ -39,12 +39,11 @@ #include -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/tcc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tcc.hpp index e7a375d27..3f53180b9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tcc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tcc.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/tcea.hpp b/include/boost/geometry/extensions/gis/projections/proj/tcea.hpp index 57d90cf4f..7113614c0 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tcea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tcea.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp index f0420a1c6..1fca2a5e1 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp @@ -39,8 +39,6 @@ #include -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp b/include/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp index bc11a1d13..3020fc5d4 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tpeqd.hpp @@ -44,6 +44,7 @@ #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp b/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp index ce6a125b3..5547835a6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/urm5.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp b/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp index 3a9d14d46..427b49e45 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp @@ -39,12 +39,11 @@ #include -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp b/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp index 32e5e9d98..9adad8179 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/vandg2.hpp b/include/boost/geometry/extensions/gis/projections/proj/vandg2.hpp index 2bb33d513..f060f6664 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/vandg2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/vandg2.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp b/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp index 798f3a0a7..f45815322 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp b/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp index 09a743f70..c03e1d2ca 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp @@ -38,12 +38,11 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include #include +#include namespace boost { namespace geometry { namespace projections { diff --git a/include/boost/geometry/extensions/gis/projections/proj/wag3.hpp b/include/boost/geometry/extensions/gis/projections/proj/wag3.hpp index b34d39a94..af5a5f4cf 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wag3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wag3.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp b/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp index 565c8f022..0f553e316 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/wink1.hpp b/include/boost/geometry/extensions/gis/projections/proj/wink1.hpp index 731c5e0ea..280467f3f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wink1.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wink1.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/wink2.hpp b/include/boost/geometry/extensions/gis/projections/proj/wink2.hpp index cfad21270..97b3d51b1 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wink2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wink2.hpp @@ -38,8 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include - #include #include #include From 0e06548aa60680dd2af1618a52e7f29c14bdc43b Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 15:44:16 +0200 Subject: [PATCH 027/104] [projections] small changes in generation (chamb/lcca) --- .../geometry/extensions/gis/projections/proj/chamb.hpp | 7 ++++--- .../geometry/extensions/gis/projections/proj/lcca.hpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp b/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp index bc41c512b..737902717 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp @@ -53,8 +53,9 @@ namespace boost { namespace geometry { namespace projections static const double THIRD = 0.333333333333333333; static const double TOL = 1e-9; + // specific for 'chamb' struct VECT { double r, Az; }; - struct CXY { double x, y; }; // x/y for chamb + struct XY { double x, y; }; struct par_chamb { @@ -62,10 +63,10 @@ namespace boost { namespace geometry { namespace projections double phi, lam; double cosphi, sinphi; VECT v; - CXY p; + XY p; double Az; } c[3]; - CXY p; + XY p; double beta_0, beta_1, beta_2; }; inline VECT /* distance and azimuth from point 1 to point 2 */ diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index 346da454f..878170f40 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -117,7 +117,6 @@ namespace boost { namespace geometry { namespace projections void setup_lcca(Parameters& par, par_lcca& proj_parm) { double s2p0, N0, R0, tan0, tan20; - boost::ignore_unused(tan20); if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); if (!pj_param(par.params, "tlat_0").i) throw proj_exception(50); if (par.phi0 == 0.) throw proj_exception(51); @@ -133,6 +132,7 @@ namespace boost { namespace geometry { namespace projections proj_parm.C = 1. / (6. * R0 * N0); // par.inv = e_inverse; // par.fwd = e_forward; + boost::ignore_unused(tan20); } }} // namespace detail::lcca From eec5d4efd089e2caeb63bb3e0da77f43b44b8793 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 18:02:35 +0200 Subject: [PATCH 028/104] [projections] ob_tran, changes in generation --- .../extensions/gis/projections/proj/ob_tran.hpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp b/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp index 05210bc19..a00e69aef 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/ob_tran.hpp @@ -83,7 +83,6 @@ namespace boost { namespace geometry { namespace projections double coslam, sinphi, cosphi; - coslam = cos(lp_lon); sinphi = sin(lp_lat); cosphi = cos(lp_lat); @@ -129,7 +128,6 @@ namespace boost { namespace geometry { namespace projections double cosphi, coslam; - cosphi = cos(lp_lat); coslam = cos(lp_lon); lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), sin(lp_lat)) + this->m_proj_parm.lamp); @@ -155,11 +153,10 @@ namespace boost { namespace geometry { namespace projections template double setup_ob_tran(Parameters& par, par_ob_tran& proj_parm, bool create = true) { - int i; double phip; - - Parameters pj; + /* get name of projection to be translated */ + pj.name = pj_param(par.params, "so_proj").s; /* copy existing header into new */ par.es = 0.; /* force to spherical */ @@ -177,11 +174,10 @@ namespace boost { namespace geometry { namespace projections /* force spherical earth */ pj.one_es = pj.rone_es = 1.; pj.es = pj.e = 0.; - pj.name = pj_param(par.params, "so_proj").s; - factory fac; if (create) { + factory fac; proj_parm.link.reset(fac.create_new(pj)); if (! proj_parm.link.get()) throw proj_exception(-26); } @@ -227,7 +223,6 @@ namespace boost { namespace geometry { namespace projections // par.fwd = t_forward; // par.inv = pj.inv ? t_inverse : 0; } - boost::ignore_unused(i); // return phip to choose model return phip; } From 01b20f50da7cf5c5857074dc9c8e7be3727c9e53 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Sun, 26 Apr 2015 23:18:15 +0200 Subject: [PATCH 029/104] [projections] fixes in ignore_unused Now checked by scanning if really (un)used --- include/boost/geometry/extensions/gis/projections/proj/aea.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/aitoff.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/eck3.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/lcca.hpp | 2 ++ .../geometry/extensions/gis/projections/proj/mod_ster.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/moll.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/nsper.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/putp3.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/putp4p.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/putp5.hpp | 2 +- .../boost/geometry/extensions/gis/projections/proj/putp6.hpp | 2 +- include/boost/geometry/extensions/gis/projections/proj/qsc.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/sconics.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/stere.hpp | 3 --- include/boost/geometry/extensions/gis/projections/proj/sts.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/tmerc.hpp | 3 --- .../boost/geometry/extensions/gis/projections/proj/urmfps.hpp | 3 --- 18 files changed, 9 insertions(+), 36 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp index 066c28128..b33fbb17b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include @@ -153,8 +152,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_aea& proj_parm) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); double cosphi, sinphi; int secant; if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21); diff --git a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp index 89826ad3e..4fedccf05 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aitoff.hpp @@ -39,6 +39,7 @@ #include + #include #include #include @@ -167,7 +168,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_aitoff& proj_parm) { - boost::ignore_unused(par); boost::ignore_unused(proj_parm); // par.inv = s_inverse; // par.fwd = s_forward; diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp index dbff39220..036bea324 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck3.hpp @@ -39,6 +39,7 @@ #include + #include #include #include @@ -85,7 +86,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_eck3& proj_parm) { - boost::ignore_unused(par); boost::ignore_unused(proj_parm); par.es = 0.; // par.inv = s_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp index 52988993c..329a89776 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include #include @@ -147,8 +146,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_gn_sinu& proj_parm) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); par.es = 0; proj_parm.C_x = (proj_parm.C_y = sqrt((proj_parm.m + 1.) / proj_parm.n))/(proj_parm.m + 1.); // par.inv = s_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index 878170f40..cca6571eb 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -38,6 +38,8 @@ // DEALINGS IN THE SOFTWARE. +#include + #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp index 80d923cb9..7d5828589 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include @@ -150,8 +149,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_mod_ster& proj_parm) /* general initialization */ { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); double esphi, chio; if (par.es) { esphi = par.e * sin(par.phi0); diff --git a/include/boost/geometry/extensions/gis/projections/proj/moll.hpp b/include/boost/geometry/extensions/gis/projections/proj/moll.hpp index 1e7ef64a4..a3e1dcb6d 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/moll.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/moll.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include #include @@ -104,8 +103,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_moll& proj_parm, double p) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); double r, sp, p2 = p + p; par.es = 0; sp = sin(p); diff --git a/include/boost/geometry/extensions/gis/projections/proj/nsper.hpp b/include/boost/geometry/extensions/gis/projections/proj/nsper.hpp index 66dcf71bc..a099ecedd 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nsper.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nsper.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include @@ -185,8 +184,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_nsper& proj_parm) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); if ((proj_parm.height = pj_param(par.params, "dh").f) <= 0.) throw proj_exception(-30); if (fabs(fabs(par.phi0) - HALFPI) < EPS10) proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp index d34741466..d1a6d3a54 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp3.hpp @@ -39,6 +39,7 @@ #include + #include #include #include @@ -87,7 +88,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_putp3& proj_parm) { - boost::ignore_unused(par); boost::ignore_unused(proj_parm); par.es = 0.; // par.inv = s_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp index 9ca25d629..7611f9c89 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp4p.hpp @@ -39,6 +39,7 @@ #include + #include #include #include @@ -91,7 +92,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_putp4p& proj_parm) { - boost::ignore_unused(par); boost::ignore_unused(proj_parm); par.es = 0.; // par.inv = s_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp index 0ae6d21a8..35a6960b0 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp5.hpp @@ -39,6 +39,7 @@ #include + #include #include #include @@ -87,7 +88,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_putp5& proj_parm) { - boost::ignore_unused(par); boost::ignore_unused(proj_parm); par.es = 0.; // par.inv = s_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp index 44da56a6c..b044a985e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp6.hpp @@ -39,6 +39,7 @@ #include + #include #include #include @@ -107,7 +108,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_putp6& proj_parm) { - boost::ignore_unused(par); boost::ignore_unused(proj_parm); par.es = 0.; // par.inv = s_inverse; diff --git a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp index b7dde8038..6560317fb 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp @@ -39,6 +39,7 @@ #include + #include #include #include diff --git a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp index 0206c4918..a8e9a42b9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include @@ -151,8 +150,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_sconics& proj_parm) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); double del, cs; int i; if( (i = phi12(par, proj_parm, &del)) ) diff --git a/include/boost/geometry/extensions/gis/projections/proj/stere.hpp b/include/boost/geometry/extensions/gis/projections/proj/stere.hpp index d976ec521..a6418574f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/stere.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/stere.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include @@ -256,8 +255,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_stere& proj_parm) /* general initialization */ { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); double t; if (fabs((t = fabs(par.phi0)) - HALFPI) < EPS10) proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE; diff --git a/include/boost/geometry/extensions/gis/projections/proj/sts.hpp b/include/boost/geometry/extensions/gis/projections/proj/sts.hpp index 338fabb48..e273e918e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sts.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sts.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include #include @@ -106,8 +105,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_sts& proj_parm, double p, double q, int mode) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); par.es = 0.; // par.inv = s_inverse; // par.fwd = s_forward; diff --git a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp index 1fca2a5e1..384059f12 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include #include @@ -217,8 +216,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_tmerc& proj_parm) /* general initialization */ { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); if (par.es) { if (!pj_enfn(par.es, proj_parm.en)) throw proj_exception(0); diff --git a/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp b/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp index 427b49e45..07416fe00 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/urmfps.hpp @@ -38,7 +38,6 @@ // DEALINGS IN THE SOFTWARE. -#include #include #include #include @@ -90,8 +89,6 @@ namespace boost { namespace geometry { namespace projections template void setup(Parameters& par, par_urmfps& proj_parm) { - boost::ignore_unused(par); - boost::ignore_unused(proj_parm); proj_parm.C_y = Cy / proj_parm.n; par.es = 0.; // par.inv = s_inverse; From 9c50c6f02cd3767e5fda6f1210e7e5f57ac6c8ea Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Mon, 27 Apr 2015 12:58:35 +0300 Subject: [PATCH 030/104] [util][math] use math::two_pi<>() and math::half_pi<>() instead of computing them from math::pi<>() --- .../geometry/util/normalize_spheroidal_coordinates.hpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp index 2b782db9c..8a2c43a92 100644 --- a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp +++ b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp @@ -32,9 +32,7 @@ struct constants_on_spheroid { static inline CoordinateType period() { - static CoordinateType const two_pi - = math::pi() * CoordinateType(2.0); - return two_pi; + return math::two_pi(); } static inline CoordinateType half_period() @@ -56,15 +54,13 @@ struct constants_on_spheroid static inline CoordinateType min_latitude() { static CoordinateType const minus_half_pi - = math::pi() / CoordinateType(-2.0); + = -math::half_pi(); return minus_half_pi; } static inline CoordinateType max_latitude() { - static CoordinateType const half_pi - = math::pi() / CoordinateType(2.0); - return half_pi; + return math::half_pi(); } }; From a8282b538380a16b61756ea1b1b10f53daa418d2 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Mon, 27 Apr 2015 15:49:50 +0200 Subject: [PATCH 031/104] [projections] fix missing inline calls --- .../boost/geometry/extensions/gis/projections/impl/pj_init.hpp | 2 +- .../boost/geometry/extensions/gis/projections/impl/pj_inv.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/pj_init.hpp b/include/boost/geometry/extensions/gis/projections/impl/pj_init.hpp index 54e4b6c46..9234a6efa 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/pj_init.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/pj_init.hpp @@ -71,7 +71,7 @@ namespace detail /* large enough to hold projection specific parameters. */ /************************************************************************/ template -parameters pj_init(R const& arguments, bool use_defaults = true) +inline parameters pj_init(R const& arguments, bool use_defaults = true) { parameters pin; for (std::vector::const_iterator it = boost::begin(arguments); diff --git a/include/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp b/include/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp index 2b4f0c147..d59bc2121 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/pj_inv.hpp @@ -56,7 +56,7 @@ namespace inv /* inverse projection entry */ template -void pj_inv(PRJ const& prj, PAR const& par, XY const& xy, LL& ll) +inline void pj_inv(PRJ const& prj, PAR const& par, XY const& xy, LL& ll) { /* can't do as much preliminary checking as with forward */ /* descale and de-offset */ From 6d3fb0f11bad57bfcf943736f4403e46d1706bfc Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Mon, 27 Apr 2015 15:50:18 +0200 Subject: [PATCH 032/104] [projections] remove old variable warning protections --- .../extensions/gis/projections/impl/base_dynamic.hpp | 12 ++---------- .../extensions/gis/projections/impl/projects.hpp | 4 ++-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp b/include/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp index ff7eb5263..7a1f1cf26 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp @@ -11,7 +11,6 @@ #include -#include #include @@ -47,20 +46,13 @@ public: m_proj.fwd(lp_lon, lp_lat, xy_x, xy_y); } - virtual bool inverse(XY const& xy, LL& ll) const + virtual bool inverse(XY const& , LL& ) const { - boost::ignore_unused_variable_warning(xy); - boost::ignore_unused_variable_warning(ll); - // exception? return false; } - virtual void inv(XY_T& xy_x, XY_T& xy_y, LL_T& lp_lon, LL_T& lp_lat) const + virtual void inv(XY_T& , XY_T& , LL_T& , LL_T& ) const { - boost::ignore_unused_variable_warning(xy_x); - boost::ignore_unused_variable_warning(xy_y); - boost::ignore_unused_variable_warning(lp_lon); - boost::ignore_unused_variable_warning(lp_lat); // exception? } diff --git a/include/boost/geometry/extensions/gis/projections/impl/projects.hpp b/include/boost/geometry/extensions/gis/projections/impl/projects.hpp index eab7eba94..89240c222 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/projects.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/projects.hpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include namespace boost { namespace geometry { namespace projections @@ -177,7 +177,7 @@ public: proj_exception(int code = 0) { - boost::ignore_unused_variable_warning(code); + boost::ignore_unused(code); } }; From a9eb7c648bd9f60c9d492685a514dbd54afe116b Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Tue, 28 Apr 2015 21:32:53 +0300 Subject: [PATCH 033/104] [util][math][spherical] apply coding rules (put space after !) --- .../geometry/util/normalize_spheroidal_coordinates.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp index 8a2c43a92..2379b2d22 100644 --- a/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp +++ b/include/boost/geometry/util/normalize_spheroidal_coordinates.hpp @@ -177,11 +177,11 @@ public: } } - BOOST_ASSERT(!math::larger(constants::min_latitude(), latitude)); - BOOST_ASSERT(!math::larger(latitude, constants::max_latitude())); + BOOST_ASSERT(! math::larger(constants::min_latitude(), latitude)); + BOOST_ASSERT(! math::larger(latitude, constants::max_latitude())); BOOST_ASSERT(math::smaller(constants::min_longitude(), longitude)); - BOOST_ASSERT(!math::larger(longitude, constants::max_longitude())); + BOOST_ASSERT(! math::larger(longitude, constants::max_longitude())); } }; From ca9fa7260d33afa1b8567f23e7943ddef829dd28 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 10:51:42 +0200 Subject: [PATCH 034/104] [projections] added spheroid models skipped earlier --- .../gis/projections/proj/gn_sinu.hpp | 64 +++++++++++++++++++ .../extensions/gis/projections/proj/stere.hpp | 23 +++++++ 2 files changed, 87 insertions(+) diff --git a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp index 329a89776..aae623eca 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp @@ -202,6 +202,28 @@ namespace boost { namespace geometry { namespace projections }} // namespace detail::gn_sinu #endif // doxygen + /*! + \brief General Sinusoidal Series projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Pseudocylindrical + - Spheroid + - m= n= + \par Example + \image html ex_gn_sinu.gif + */ + template + struct gn_sinu_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid + { + inline gn_sinu_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid(par) + { + detail::gn_sinu::setup_gn_sinu(this->m_par, this->m_proj_parm); + } + }; + /*! \brief Sinusoidal (Sanson-Flamsteed) projection \ingroup projections @@ -224,6 +246,48 @@ namespace boost { namespace geometry { namespace projections } }; + /*! + \brief Eckert VI projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Pseudocylindrical + - Spheroid + \par Example + \image html ex_eck6.gif + */ + template + struct eck6_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid + { + inline eck6_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid(par) + { + detail::gn_sinu::setup_eck6(this->m_par, this->m_proj_parm); + } + }; + + /*! + \brief McBryde-Thomas Flat-Polar Sinusoidal projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Pseudocylindrical + - Spheroid + \par Example + \image html ex_mbtfps.gif + */ + template + struct mbtfps_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid + { + inline mbtfps_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid(par) + { + detail::gn_sinu::setup_mbtfps(this->m_par, this->m_proj_parm); + } + }; + /*! \brief General Sinusoidal Series projection \ingroup projections diff --git a/include/boost/geometry/extensions/gis/projections/proj/stere.hpp b/include/boost/geometry/extensions/gis/projections/proj/stere.hpp index a6418574f..c057db69a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/stere.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/stere.hpp @@ -407,6 +407,29 @@ namespace boost { namespace geometry { namespace projections } }; + /*! + \brief Universal Polar Stereographic projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Azimuthal + - Spheroid + - Ellipsoid + - south + \par Example + \image html ex_ups.gif + */ + template + struct ups_spheroid : public detail::stere::base_stere_spheroid + { + inline ups_spheroid(const Parameters& par) : detail::stere::base_stere_spheroid(par) + { + detail::stere::setup_ups(this->m_par, this->m_proj_parm); + } + }; + #ifndef DOXYGEN_NO_DETAIL namespace detail { From cc5f891b1a6e2c0fff44b998f8fc152d86fb03fc Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 11:07:59 +0200 Subject: [PATCH 035/104] [projections] enable sphere for utm, which can be done if the throw at non par.es is skipped --- .../extensions/gis/projections/proj/tmerc.hpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp index 384059f12..6816a7fdb 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/tmerc.hpp @@ -244,7 +244,6 @@ namespace boost { namespace geometry { namespace projections void setup_utm(Parameters& par, par_tmerc& proj_parm) { int zone; - if (!par.es) throw proj_exception(-34); par.y0 = pj_param(par.params, "bsouth").i ? 10000000. : 0.; par.x0 = 500000.; if (pj_param(par.params, "tzone").i) /* zone input ? */ @@ -332,6 +331,28 @@ namespace boost { namespace geometry { namespace projections } }; + /*! + \brief Universal Transverse Mercator (UTM) projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Cylindrical + - Spheroid + - zone= south + \par Example + \image html ex_utm.gif + */ + template + struct utm_spheroid : public detail::tmerc::base_tmerc_spheroid + { + inline utm_spheroid(const Parameters& par) : detail::tmerc::base_tmerc_spheroid(par) + { + detail::tmerc::setup_utm(this->m_par, this->m_proj_parm); + } + }; + #ifndef DOXYGEN_NO_DETAIL namespace detail { From 2d3d4780cce78bc54c85764cbe74caa037ff6a9f Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 11:44:20 +0200 Subject: [PATCH 036/104] [projections] natearth, regeneration --- .../gis/projections/proj/natearth.hpp | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp b/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp index 8acfe6a98..99efd0116 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp @@ -4,7 +4,7 @@ // Boost.Geometry - extensions-gis-projections (based on PROJ4) // This file is automatically generated. DO NOT EDIT. -// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -15,6 +15,8 @@ // PROJ4 is maintained by Frank Warmerdam // PROJ4 is converted to Boost.Geometry by Barend Gehrels +// Last updated version of proj: 4.9.1 + // Original copyright notice: // Permission is hereby granted, free of charge, to any person obtaining a @@ -35,7 +37,6 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -#include #include #include @@ -45,7 +46,7 @@ namespace boost { namespace geometry { namespace projections { #ifndef DOXYGEN_NO_DETAIL - namespace detail { namespace natearth{ + namespace detail { namespace natearth{ static const double A0 = 0.8707; static const double A1 = -0.131979; static const double A2 = -0.013791; @@ -64,8 +65,6 @@ namespace boost { namespace geometry { namespace projections static const double EPS = 1e-11; static const double MAX_Y = (0.8707 * 0.52 * PI); - - // template class, using CRTP to implement forward/inverse template @@ -84,7 +83,7 @@ namespace boost { namespace geometry { namespace projections inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const { double phi2, phi4; - + phi2 = lp_lat * lp_lat; phi4 = phi2 * phi2; xy_x = lp_lon * (A0 + phi2 * (A1 + phi2 * (A2 + phi4 * phi2 * (A3 + phi2 * A4)))); @@ -94,14 +93,14 @@ namespace boost { namespace geometry { namespace projections inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const { double yc, tol, y2, y4, f, fder; - + /* make sure y is inside valid range */ if (xy_y > MAX_Y) { xy_y = MAX_Y; } else if (xy_y < -MAX_Y) { xy_y = -MAX_Y; } - + /* latitude */ yc = xy_y; for (;;) { /* Newton-Raphson */ @@ -115,11 +114,10 @@ namespace boost { namespace geometry { namespace projections } } lp_lat = yc; - + /* longitude */ y2 = yc * yc; lp_lon = xy_x / (A0 + y2 * (A1 + y2 * (A2 + y2 * y2 * y2 * (A3 + y2 * A4)))); - } }; @@ -133,7 +131,7 @@ namespace boost { namespace geometry { namespace projections } }} // namespace detail::natearth - #endif // doxygen + #endif // doxygen /*! \brief Natural Earth projection @@ -177,7 +175,7 @@ namespace boost { namespace geometry { namespace projections factory.add_to_factory("natearth", new natearth_entry); } - } // namespace detail + } // namespace detail #endif // doxygen }}} // namespace boost::geometry::projections From 3937486a0fb7fef1b16bcd57c64d634c67c40359 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 12:59:37 +0200 Subject: [PATCH 037/104] [projections] changes in white lines --- include/boost/geometry/extensions/gis/projections/proj/aea.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/august.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/boggs.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/chamb.hpp | 1 + include/boost/geometry/extensions/gis/projections/proj/collg.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/crast.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/denoy.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/eck1.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/eck2.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/eck4.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/eck5.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/fahey.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/gall.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/geocent.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/gins8.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/hatano.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/krovak.hpp | 1 + include/boost/geometry/extensions/gis/projections/proj/larr.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/lask.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/lcca.hpp | 1 + include/boost/geometry/extensions/gis/projections/proj/lsat.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/merc.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/mill.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/mod_ster.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/natearth.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/nell.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/nell_h.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/nocol.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/putp2.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/qsc.hpp | 1 + .../boost/geometry/extensions/gis/projections/proj/sconics.hpp | 1 + include/boost/geometry/extensions/gis/projections/proj/stere.hpp | 1 + include/boost/geometry/extensions/gis/projections/proj/vandg.hpp | 1 - .../boost/geometry/extensions/gis/projections/proj/vandg4.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/wag2.hpp | 1 - include/boost/geometry/extensions/gis/projections/proj/wag7.hpp | 1 - 41 files changed, 11 insertions(+), 30 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp index b33fbb17b..c4f29d29c 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/aea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/aea.hpp @@ -74,6 +74,7 @@ namespace boost { namespace geometry { namespace projections double en[EN_SIZE]; int ellips; }; + /* determine latitude angle phi-1 */ inline double phi1_(double qs, double Te, double Tone_es) { diff --git a/include/boost/geometry/extensions/gis/projections/proj/august.hpp b/include/boost/geometry/extensions/gis/projections/proj/august.hpp index c4e6815b7..46c14821f 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/august.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/august.hpp @@ -49,7 +49,6 @@ namespace boost { namespace geometry { namespace projections namespace detail { namespace august{ static const double M = 1.333333333333333; - // template class, using CRTP to implement forward/inverse template struct base_august_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp b/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp index e00ed04e3..90e72c9bf 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/boggs.hpp @@ -55,7 +55,6 @@ namespace boost { namespace geometry { namespace projections static const double FYC = 0.49931; static const double FYC2 = 1.41421356237309504880; - // template class, using CRTP to implement forward/inverse template struct base_boggs_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp b/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp index 737902717..c170581bf 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/chamb.hpp @@ -69,6 +69,7 @@ namespace boost { namespace geometry { namespace projections XY p; double beta_0, beta_1, beta_2; }; + inline VECT /* distance and azimuth from point 1 to point 2 */ vect(double dphi, double c1, double s1, double c2, double s2, double dlam) { VECT v; diff --git a/include/boost/geometry/extensions/gis/projections/proj/collg.hpp b/include/boost/geometry/extensions/gis/projections/proj/collg.hpp index 63895e781..153b288e7 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/collg.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/collg.hpp @@ -51,7 +51,6 @@ namespace boost { namespace geometry { namespace projections static const double FYC = 1.77245385090551602729; static const double ONEEPS = 1.0000001; - // template class, using CRTP to implement forward/inverse template struct base_collg_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/crast.hpp b/include/boost/geometry/extensions/gis/projections/proj/crast.hpp index 213f14091..049f1f303 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/crast.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/crast.hpp @@ -53,7 +53,6 @@ namespace boost { namespace geometry { namespace projections static const double RYM = 0.32573500793527994772; static const double THIRD = 0.333333333333333333; - // template class, using CRTP to implement forward/inverse template struct base_crast_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp b/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp index 91a3f0b38..0739ea9d2 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/denoy.hpp @@ -53,7 +53,6 @@ namespace boost { namespace geometry { namespace projections static const double D1 = 0.9; static const double D5 = 0.03; - // template class, using CRTP to implement forward/inverse template struct base_denoy_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp index 516562b1a..618d45c1d 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck1.hpp @@ -50,7 +50,6 @@ namespace boost { namespace geometry { namespace projections static const double FC = .92131773192356127802; static const double RP = .31830988618379067154; - // template class, using CRTP to implement forward/inverse template struct base_eck1_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp index 5f17ebdb0..b8f9166f8 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck2.hpp @@ -52,7 +52,6 @@ namespace boost { namespace geometry { namespace projections static const double C13 = 0.33333333333333333333; static const double ONEEPS = 1.0000001; - // template class, using CRTP to implement forward/inverse template struct base_eck2_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp index 371dca9ed..1b14b83c7 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck4.hpp @@ -56,7 +56,6 @@ namespace boost { namespace geometry { namespace projections static const double EPS = 1e-7; static const int NITER = 6; - // template class, using CRTP to implement forward/inverse template struct base_eck4_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp b/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp index dccb96fa4..9dbc39b89 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/eck5.hpp @@ -52,7 +52,6 @@ namespace boost { namespace geometry { namespace projections static const double YF = 0.88202554344910296438; static const double RYF = 1.13375401361911319568; - // template class, using CRTP to implement forward/inverse template struct base_eck5_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp b/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp index ca72efa7c..721e6f0ba 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/fahey.hpp @@ -49,7 +49,6 @@ namespace boost { namespace geometry { namespace projections namespace detail { namespace fahey{ static const double TOL = 1e-6; - // template class, using CRTP to implement forward/inverse template struct base_fahey_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/gall.hpp b/include/boost/geometry/extensions/gis/projections/proj/gall.hpp index eb6dd605a..835788520 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gall.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gall.hpp @@ -52,7 +52,6 @@ namespace boost { namespace geometry { namespace projections static const double RYF = 0.58578643762690495119; static const double RXF = 1.41421356237309504880; - // template class, using CRTP to implement forward/inverse template struct base_gall_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp b/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp index e0adacd33..beb2069fb 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/geocent.hpp @@ -48,7 +48,6 @@ namespace boost { namespace geometry { namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace geocent{ - // template class, using CRTP to implement forward/inverse template struct base_geocent_other : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp b/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp index 14cce3172..9fa9bf435 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gins8.hpp @@ -51,7 +51,6 @@ namespace boost { namespace geometry { namespace projections static const double Cp = 0.162388; static const double C12 = 0.08333333333333333; - // template class, using CRTP to implement forward/inverse template struct base_gins8_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp index aae623eca..5bb5094cd 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp @@ -58,6 +58,7 @@ namespace boost { namespace geometry { namespace projections double en[EN_SIZE]; double m, n, C_x, C_y; }; + /* Ellipsoidal Sinusoidal only */ // template class, using CRTP to implement forward/inverse diff --git a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp index 79a113e18..b272f29c3 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/hatano.hpp @@ -61,7 +61,6 @@ namespace boost { namespace geometry { namespace projections static const double FXC = 0.85; static const double RXC = 1.17647058823529411764; - // template class, using CRTP to implement forward/inverse template struct base_hatano_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp index 14e0048b5..5797caf91 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp @@ -60,6 +60,7 @@ namespace boost { namespace geometry { namespace projections double en[EN_SIZE]; int mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */ }; + template inline int phi12(Parameters& par, par_imw_p& proj_parm, double *del, double *sig) { diff --git a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp index 2db34983e..7f2a7efb6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/krovak.hpp @@ -52,6 +52,7 @@ namespace boost { namespace geometry { namespace projections { double C_x; }; + /** NOTES: According to EPSG the full Krovak projection method should have the following parameters. Within PROJ.4 the azimuth, and pseudo diff --git a/include/boost/geometry/extensions/gis/projections/proj/larr.hpp b/include/boost/geometry/extensions/gis/projections/proj/larr.hpp index 42d3384ca..d24486ac7 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/larr.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/larr.hpp @@ -49,7 +49,6 @@ namespace boost { namespace geometry { namespace projections namespace detail { namespace larr{ static const double SIXTH = .16666666666666666; - // template class, using CRTP to implement forward/inverse template struct base_larr_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/lask.hpp b/include/boost/geometry/extensions/gis/projections/proj/lask.hpp index 77aa5c064..1ab51f1ac 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lask.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lask.hpp @@ -58,7 +58,6 @@ namespace boost { namespace geometry { namespace projections static const double b23 = -0.0285500; static const double b05 = -0.0491032; - // template class, using CRTP to implement forward/inverse template struct base_lask_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp index cca6571eb..3e1cb025b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lcca.hpp @@ -59,6 +59,7 @@ namespace boost { namespace geometry { namespace projections double r0, l, M0; double C; }; + inline double /* func to compute dr */ fS(double S, double C) { return(S * ( 1. + S * S * C)); diff --git a/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp b/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp index 39cef0733..ddd5c9525 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/lsat.hpp @@ -57,6 +57,7 @@ namespace boost { namespace geometry { namespace projections double a2, a4, b, c1, c3; double q, t, u, w, p22, sa, ca, xj, rlm, rlm2; }; + /* based upon Snyder and Linck, USGS-NMD */ template inline void diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp index 764429aa6..9f1497ab0 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp @@ -57,7 +57,6 @@ namespace boost { namespace geometry { namespace projections static const double C_y = 1.44492; static const double C1_2 = 0.33333333333333333333333333; - // template class, using CRTP to implement forward/inverse template struct base_mbt_fps_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp index 5dd9631ca..58bb5e440 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp @@ -54,7 +54,6 @@ namespace boost { namespace geometry { namespace projections static const double C13 = .33333333333333333333; static const double ONEEPS = 1.0000001; - // template class, using CRTP to implement forward/inverse template struct base_mbtfpp_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp b/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp index 084974276..df35b8b55 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp @@ -57,7 +57,6 @@ namespace boost { namespace geometry { namespace projections static const double FXC = 0.31245971410378249250; static const double RXC = 3.20041258076506210122; - // template class, using CRTP to implement forward/inverse template struct base_mbtfpq_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/merc.hpp b/include/boost/geometry/extensions/gis/projections/proj/merc.hpp index a2a48c967..bb0f5a290 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/merc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/merc.hpp @@ -52,7 +52,6 @@ namespace boost { namespace geometry { namespace projections namespace detail { namespace merc{ static const double EPS10 = 1.e-10; - // template class, using CRTP to implement forward/inverse template struct base_merc_ellipsoid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/mill.hpp b/include/boost/geometry/extensions/gis/projections/proj/mill.hpp index e9128a75a..586896910 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mill.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mill.hpp @@ -48,7 +48,6 @@ namespace boost { namespace geometry { namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace mill{ - // template class, using CRTP to implement forward/inverse template struct base_mill_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp index 7d5828589..53393537e 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/mod_ster.hpp @@ -59,6 +59,7 @@ namespace boost { namespace geometry { namespace projections double cchio, schio; int n; }; + /* based upon Snyder and Linck, USGS-NMD */ // template class, using CRTP to implement forward/inverse diff --git a/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp b/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp index 99efd0116..1bef3f59b 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/natearth.hpp @@ -65,7 +65,6 @@ namespace boost { namespace geometry { namespace projections static const double EPS = 1e-11; static const double MAX_Y = (0.8707 * 0.52 * PI); - // template class, using CRTP to implement forward/inverse template struct base_natearth_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/nell.hpp b/include/boost/geometry/extensions/gis/projections/proj/nell.hpp index 59ce067ba..493e32a86 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nell.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nell.hpp @@ -51,7 +51,6 @@ namespace boost { namespace geometry { namespace projections static const int MAX_ITER = 10; static const double LOOP_TOL = 1e-7; - // template class, using CRTP to implement forward/inverse template struct base_nell_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp b/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp index 85df442da..08bcb0c5a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nell_h.hpp @@ -50,7 +50,6 @@ namespace boost { namespace geometry { namespace projections static const int NITER = 9; static const double EPS = 1e-7; - // template class, using CRTP to implement forward/inverse template struct base_nell_h_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp b/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp index dd52aa8cc..af9f50498 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/nocol.hpp @@ -49,7 +49,6 @@ namespace boost { namespace geometry { namespace projections namespace detail { namespace nocol{ static const double EPS = 1e-10; - // template class, using CRTP to implement forward/inverse template struct base_nocol_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp b/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp index fcf2a7271..ed593989a 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/putp2.hpp @@ -55,7 +55,6 @@ namespace boost { namespace geometry { namespace projections static const int NITER = 10; static const double PI_DIV_3 = 1.0471975511965977; - // template class, using CRTP to implement forward/inverse template struct base_putp2_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp index 6560317fb..d38a2a9f9 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/qsc.hpp @@ -69,6 +69,7 @@ namespace boost { namespace geometry { namespace projections double one_minus_f; double one_minus_f_squared; }; + /* The six cube faces. */ /* The four areas on a cube face. AREA_0 is the area of definition, diff --git a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp index a8e9a42b9..792e5a477 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/sconics.hpp @@ -68,6 +68,7 @@ namespace boost { namespace geometry { namespace projections double c1, c2; int type; }; + /* get common factors for simple conics */ template inline int diff --git a/include/boost/geometry/extensions/gis/projections/proj/stere.hpp b/include/boost/geometry/extensions/gis/projections/proj/stere.hpp index c057db69a..70da21f17 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/stere.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/stere.hpp @@ -67,6 +67,7 @@ namespace boost { namespace geometry { namespace projections double akm1; int mode; }; + inline double ssfn_(double phit, double sinphi, double eccen) { sinphi *= eccen; diff --git a/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp b/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp index 9adad8179..75a1a9ea4 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/vandg.hpp @@ -56,7 +56,6 @@ namespace boost { namespace geometry { namespace projections static const double TPISQ = 19.73920880217871723738; static const double HPISQ = 4.93480220054467930934; - // template class, using CRTP to implement forward/inverse template struct base_vandg_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp b/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp index f45815322..bc993a6d6 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/vandg4.hpp @@ -50,7 +50,6 @@ namespace boost { namespace geometry { namespace projections static const double TOL = 1e-10; static const double TWORPI = 0.63661977236758134308; - // template class, using CRTP to implement forward/inverse template struct base_vandg4_spheroid : public base_t_f, diff --git a/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp b/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp index c03e1d2ca..04a133742 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wag2.hpp @@ -53,7 +53,6 @@ namespace boost { namespace geometry { namespace projections static const double C_p1 = 0.88022; static const double C_p2 = 0.88550; - // template class, using CRTP to implement forward/inverse template struct base_wag2_spheroid : public base_t_fi, diff --git a/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp b/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp index 0f553e316..a98a14984 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/wag7.hpp @@ -48,7 +48,6 @@ namespace boost { namespace geometry { namespace projections #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace wag7{ - // template class, using CRTP to implement forward/inverse template struct base_wag7_spheroid : public base_t_f, From c5c4c90c874e1dec51f4dc4c56c77f80166e3314 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 13:00:06 +0200 Subject: [PATCH 038/104] [projections] omerc, remove now unused inlined function --- .../boost/geometry/extensions/gis/projections/proj/omerc.hpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp b/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp index 96c71eb91..b05f48906 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/omerc.hpp @@ -52,10 +52,6 @@ namespace boost { namespace geometry { namespace projections static const double TOL = 1.e-7; static const double EPS = 1.e-10; - inline double TSFN0(double x) - {return tan(.5 * (HALFPI - (x))); } - - struct par_omerc { double A, B, E, AB, ArB, BrA, rB, singam, cosgam, sinrot, cosrot; From c81255cf5ee539b4004a1b666db2a499f8c78e15 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 13:35:14 +0200 Subject: [PATCH 039/104] [projections] add new projection isa include entry in unit test (tested with proj4.9.1) --- .../test/gis/projections/projections.cpp | 1 + .../extensions/gis/projections/factory.hpp | 2 + .../extensions/gis/projections/proj/isea.hpp | 1150 +++++++++++++++++ 3 files changed, 1153 insertions(+) create mode 100644 include/boost/geometry/extensions/gis/projections/proj/isea.hpp diff --git a/extensions/test/gis/projections/projections.cpp b/extensions/test/gis/projections/projections.cpp index 180acc3eb..75ed46bfc 100644 --- a/extensions/test/gis/projections/projections.cpp +++ b/extensions/test/gis/projections/projections.cpp @@ -149,6 +149,7 @@ void test_all() test_forward

("hammer", 4.897000, 52.371000, 370843.923425, 5630047.232233, "+proj=hammer +ellps=WGS84 +units=m"); test_forward

("hatano", 4.897000, 52.371000, 383644.128560, 6290117.704632, "+proj=hatano +ellps=WGS84 +units=m"); test_forward

("imw_p", 4.897000, 52.371000, 318784.808056, 3594184.939568, "+proj=imw_p +ellps=WGS84 +units=m +lat_1=20n +lat_2=60n +lon_1=5"); + test_forward

("isea", 4.897000, 52.371000, -413613.639976, 9218173.701546, "+proj=isea +ellps=WGS84 +units=m"); test_forward

("kav5", 4.897000, 52.371000, 383646.088858, 5997047.888175, "+proj=kav5 +ellps=WGS84 +units=m"); test_forward

("kav7", 4.897000, 52.371000, 407769.043907, 5829913.052335, "+proj=kav7 +ellps=WGS84 +units=m"); test_forward

("krovak", 14.416667, 50.083333, -743286.779768, -1043498.912060, "+proj=krovak +ellps=WGS84 +units=m"); diff --git a/include/boost/geometry/extensions/gis/projections/factory.hpp b/include/boost/geometry/extensions/gis/projections/factory.hpp index b95aed82f..0acb12eb7 100644 --- a/include/boost/geometry/extensions/gis/projections/factory.hpp +++ b/include/boost/geometry/extensions/gis/projections/factory.hpp @@ -53,6 +53,7 @@ #include #include #include // xy functions after inverse +#include #include #include #include @@ -175,6 +176,7 @@ public: detail::hatano_init(*this); detail::krovak_init(*this); detail::imw_p_init(*this); + detail::isea_init(*this); detail::labrd_init(*this); detail::laea_init(*this); detail::lagrng_init(*this); diff --git a/include/boost/geometry/extensions/gis/projections/proj/isea.hpp b/include/boost/geometry/extensions/gis/projections/proj/isea.hpp new file mode 100644 index 000000000..d82e4d174 --- /dev/null +++ b/include/boost/geometry/extensions/gis/projections/proj/isea.hpp @@ -0,0 +1,1150 @@ +#ifndef BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP +#define BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP + +// Boost.Geometry - extensions-gis-projections (based on PROJ4) +// This file is automatically generated. DO NOT EDIT. + +// Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// This file is converted from PROJ4, http://trac.osgeo.org/proj +// PROJ4 is originally written by Gerald Evenden (then of the USGS) +// PROJ4 is maintained by Frank Warmerdam +// PROJ4 is converted to Boost.Geometry by Barend Gehrels + +// Last updated version of proj: 4.9.1 + +// Original copyright notice: + +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the "Software"), +// to deal in the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: + +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. + +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + + +#include +#include +#include +#include + +namespace boost { namespace geometry { namespace projections +{ + #ifndef DOXYGEN_NO_DETAIL + namespace detail { namespace isea{ + static const double E = 52.62263186; + static const double F = 10.81231696; + static const double DEG60 = 1.04719755119659774614; + static const double DEG120 = 2.09439510239319549229; + static const double DEG72 = 1.25663706143591729537; + static const double DEG90 = 1.57079632679489661922; + static const double DEG144 = 2.51327412287183459075; + static const double DEG36 = 0.62831853071795864768; + static const double DEG108 = 1.88495559215387594306; + static const double DEG180 = M_PI; + static const double ISEA_SCALE = 0.8301572857837594396028083; + static const double V_LAT = 0.46364760899944494524; + static const double RAD2DEG = (180.0/M_PI); + static const double DEG2RAD = (M_PI/180.0); + static const double E_RAD = 0.91843818702186776133; + static const double F_RAD = 0.18871053072122403508; + static const double TABLE_G = 0.6615845383; + static const double TABLE_H = 0.1909830056; + static const double RPRIME = 0.91038328153090290025; + static const double PRECISION = 0.0000000000005; + static const double ISEA_STD_LAT = 1.01722196792335072101; + static const double ISEA_STD_LON = .19634954084936207740; + + #define DOWNTRI(tri) (((tri - 1) / 5) % 2 == 1) + + + + struct hex { + int iso; + int x, y, z; + }; + + /* y *must* be positive down as the xy /iso conversion assumes this */ + static + int hex_xy(struct hex *h) { + if (!h->iso) return 1; + if (h->x >= 0) { + h->y = -h->y - (h->x+1)/2; + } else { + /* need to round toward -inf, not toward zero, so x-1 */ + h->y = -h->y - h->x/2; + } + h->iso = 0; + + return 1; + } + + static + int hex_iso(struct hex *h) { + if (h->iso) return 1; + + if (h->x >= 0) { + h->y = (-h->y - (h->x+1)/2); + } else { + /* need to round toward -inf, not toward zero, so x-1 */ + h->y = (-h->y - (h->x)/2); + } + + h->z = -h->x - h->y; + h->iso = 1; + return 1; + } + + static + int hexbin2(int horizontal, double width, double x, double y, + int *i, int *j) { + double z, rx, ry, rz; + double abs_dx, abs_dy, abs_dz; + int ix, iy, iz, s; + struct hex h; + + x = x / cos(30 * M_PI / 180.0); /* rotated X coord */ + y = y - x / 2.0; /* adjustment for rotated X */ + + /* adjust for actual hexwidth */ + x /= width; + y /= width; + + z = -x - y; + + ix = rx = floor(x + 0.5); + iy = ry = floor(y + 0.5); + iz = rz = floor(z + 0.5); + + s = ix + iy + iz; + + if (s) { + abs_dx = fabs(rx - x); + abs_dy = fabs(ry - y); + abs_dz = fabs(rz - z); + + if (abs_dx >= abs_dy && abs_dx >= abs_dz) { + ix -= s; + } else if (abs_dy >= abs_dx && abs_dy >= abs_dz) { + iy -= s; + } else { + iz -= s; + } + } + h.x = ix; + h.y = iy; + h.z = iz; + h.iso = 1; + + hex_xy(&h); + *i = h.x; + *j = h.y; + return ix * 100 + iy; + } + + enum isea_poly { ISEA_NONE, ISEA_ICOSAHEDRON = 20 }; + enum isea_topology { ISEA_HEXAGON=6, ISEA_TRIANGLE=3, ISEA_DIAMOND=4 }; + enum isea_address_form { ISEA_GEO, ISEA_Q2DI, ISEA_SEQNUM, ISEA_INTERLEAVE, + ISEA_PLANE, ISEA_Q2DD, ISEA_PROJTRI, ISEA_VERTEX2DD, ISEA_HEX + }; + + struct isea_dgg { + int polyhedron; /* ignored, icosahedron */ + double o_lat, o_lon, o_az; /* orientation, radians */ + int pole; /* true if standard snyder */ + int topology; /* ignored, hexagon */ + int aperture; /* valid values depend on partitioning method */ + int resolution; + double radius; /* radius of the earth in meters, ignored 1.0 */ + int output; /* an isea_address_form */ + int triangle; /* triangle of last transformed point */ + int quad; /* quad of last transformed point */ + unsigned long serial; + }; + + struct isea_pt { + double x, y; + }; + + struct isea_geo { + double lon, lat; + }; + + struct isea_address { + int type; /* enum isea_address_form */ + int number; + double x,y; /* or i,j or lon,lat depending on type */ + }; + + /* ENDINC */ + + enum snyder_polyhedron { + SNYDER_POLY_HEXAGON, SNYDER_POLY_PENTAGON, + SNYDER_POLY_TETRAHEDRON, SNYDER_POLY_CUBE, + SNYDER_POLY_OCTAHEDRON, SNYDER_POLY_DODECAHEDRON, + SNYDER_POLY_ICOSAHEDRON + }; + + struct snyder_constants { + double g, G, theta, ea_w, ea_a, ea_b, g_w, g_a, g_b; + }; + + /* TODO put these in radians to avoid a later conversion */ + static + struct snyder_constants constants[] = { + {23.80018260, 62.15458023, 60.0, 3.75, 1.033, 0.968, 5.09, 1.195, 1.0}, + {20.07675127, 55.69063953, 54.0, 2.65, 1.030, 0.983, 3.59, 1.141, 1.027}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {37.37736814, 36.0, 30.0, 17.27, 1.163, 0.860, 13.14, 1.584, 1.0}, + }; + + + /* sqrt(5)/M_PI */ + + /* 26.565051177 degrees */ + + + static + struct isea_geo vertex[] = { + {0.0, DEG90}, + {DEG180, V_LAT}, + {-DEG108, V_LAT}, + {-DEG36, V_LAT}, + {DEG36, V_LAT}, + {DEG108, V_LAT}, + {-DEG144, -V_LAT}, + {-DEG72, -V_LAT}, + {0.0, -V_LAT}, + {DEG72, -V_LAT}, + {DEG144, -V_LAT}, + {0.0, -DEG90} + }; + + /* TODO make an isea_pt array of the vertices as well */ + + static int tri_v1[] = {0, 0, 0, 0, 0, 0, 6, 7, 8, 9, 10, 2, 3, 4, 5, 1, 11, 11, 11, 11, 11}; + + /* 52.62263186 */ + + /* 10.81231696 */ + + /* triangle Centers */ + struct isea_geo icostriangles[] = { + {0.0, 0.0}, + {-DEG144, E_RAD}, + {-DEG72, E_RAD}, + {0.0, E_RAD}, + {DEG72, E_RAD}, + {DEG144, E_RAD}, + {-DEG144, F_RAD}, + {-DEG72, F_RAD}, + {0.0, F_RAD}, + {DEG72, F_RAD}, + {DEG144, F_RAD}, + {-DEG108, -F_RAD}, + {-DEG36, -F_RAD}, + {DEG36, -F_RAD}, + {DEG108, -F_RAD}, + {DEG180, -F_RAD}, + {-DEG108, -E_RAD}, + {-DEG36, -E_RAD}, + {DEG36, -E_RAD}, + {DEG108, -E_RAD}, + {DEG180, -E_RAD}, + }; + + static double + az_adjustment(int triangle) + { + double adj; + + struct isea_geo v; + struct isea_geo c; + + v = vertex[tri_v1[triangle]]; + c = icostriangles[triangle]; + + /* TODO looks like the adjustment is always either 0 or 180 */ + /* at least if you pick your vertex carefully */ + adj = atan2(cos(v.lat) * sin(v.lon - c.lon), + cos(c.lat) * sin(v.lat) + - sin(c.lat) * cos(v.lat) * cos(v.lon - c.lon)); + return adj; + } + + /* R tan(g) sin(60) */ + + /* H = 0.25 R tan g = */ + + + static + struct isea_pt + isea_triangle_xy(int triangle) + { + struct isea_pt c; + double Rprime = 0.91038328153090290025; + + triangle = (triangle - 1) % 20; + + c.x = TABLE_G * ((triangle % 5) - 2) * 2.0; + if (triangle > 9) { + c.x += TABLE_G; + } + switch (triangle / 5) { + case 0: + c.y = 5.0 * TABLE_H; + break; + case 1: + c.y = TABLE_H; + break; + case 2: + c.y = -TABLE_H; + break; + case 3: + c.y = -5.0 * TABLE_H; + break; + default: + /* should be impossible */ + exit(EXIT_FAILURE); + }; + c.x *= Rprime; + c.y *= Rprime; + + return c; + } + + /* snyder eq 14 */ + static double + sph_azimuth(double f_lon, double f_lat, double t_lon, double t_lat) + { + double az; + + az = atan2(cos(t_lat) * sin(t_lon - f_lon), + cos(f_lat) * sin(t_lat) + - sin(f_lat) * cos(t_lat) * cos(t_lon - f_lon) + ); + return az; + } + + /* coord needs to be in radians */ + static + int + isea_snyder_forward(struct isea_geo * ll, struct isea_pt * out) + { + int i; + + double g; + + double G; + + double theta; + + /* additional variables from snyder */ + double q, Rprime, H, Ag, Azprime, Az, dprime, f, rho, + x, y; + + /* variables used to store intermediate results */ + double cot_theta, tan_g, az_offset; + + /* how many multiples of 60 degrees we adjust the azimuth */ + int Az_adjust_multiples; + + struct snyder_constants c; + + + /* TODO put these constants in as radians to begin with */ + c = constants[SNYDER_POLY_ICOSAHEDRON]; + theta = c.theta * DEG2RAD; + g = c.g * DEG2RAD; + G = c.G * DEG2RAD; + + for (i = 1; i <= 20; i++) { + double z; + struct isea_geo center; + + center = icostriangles[i]; + + /* step 1 */ + #if 0 + z = sph_distance(center.lon, center.lat, ll->lon, ll->lat); + #else + z = acos(sin(center.lat) * sin(ll->lat) + + cos(center.lat) * cos(ll->lat) * cos(ll->lon - center.lon)); + #endif + + /* not on this triangle */ + if (z > g + 0.000005) { /* TODO DBL_EPSILON */ + continue; + } + Az = sph_azimuth(ll->lon, ll->lat, center.lon, center.lat); + + Az = atan2(cos(ll->lat) * sin(ll->lon - center.lon), + cos(center.lat) * sin(ll->lat) + - sin(center.lat) * cos(ll->lat) * cos(ll->lon - center.lon) + ); + + /* step 2 */ + + /* This calculates "some" vertex coordinate */ + az_offset = az_adjustment(i); + + Az -= az_offset; + + /* TODO I don't know why we do this. It's not in snyder */ + /* maybe because we should have picked a better vertex */ + if (Az < 0.0) { + Az += 2.0 * M_PI; + } + + Az_adjust_multiples = 0; + while (Az < 0.0) { + Az += DEG120; + Az_adjust_multiples--; + } + while (Az > DEG120 + DBL_EPSILON) { + Az -= DEG120; + Az_adjust_multiples++; + } + + /* step 3 */ + cot_theta = 1.0 / tan(theta); + tan_g = tan(g); /* TODO this is a constant */ + + /* Calculate q from eq 9. */ + /* TODO cot_theta is cot(30) */ + q = atan2(tan_g, cos(Az) + sin(Az) * cot_theta); + + /* not in this triangle */ + if (z > q + 0.000005) { + continue; + } + /* step 4 */ + + /* Apply equations 5-8 and 10-12 in order */ + + /* eq 5 */ + /* Rprime = 0.9449322893 * R; */ + /* R' in the paper is for the truncated */ + Rprime = 0.91038328153090290025; + + /* eq 6 */ + H = acos(sin(Az) * sin(G) * cos(g) - cos(Az) * cos(G)); + + /* eq 7 */ + /* Ag = (Az + G + H - DEG180) * M_PI * R * R / DEG180; */ + Ag = Az + G + H - DEG180; + + /* eq 8 */ + Azprime = atan2(2.0 * Ag, Rprime * Rprime * tan_g * tan_g - 2.0 * Ag * cot_theta); + + /* eq 10 */ + /* cot(theta) = 1.73205080756887729355 */ + dprime = Rprime * tan_g / (cos(Azprime) + sin(Azprime) * cot_theta); + + /* eq 11 */ + f = dprime / (2.0 * Rprime * sin(q / 2.0)); + + /* eq 12 */ + rho = 2.0 * Rprime * f * sin(z / 2.0); + + + Azprime += DEG120 * Az_adjust_multiples; + + /* calculate rectangular coordinates */ + + x = rho * sin(Azprime); + y = rho * cos(Azprime); + + + out->x = x; + out->y = y; + + return i; + } + + + fprintf(stderr, "impossible transform: %f %f is not on any triangle\n", + ll->lon * RAD2DEG, ll->lat * RAD2DEG); + + exit(EXIT_FAILURE); + + /* not reached */ + return 0; /* supresses a warning */ + } + + + + /* formula from Snyder, Map Projections: A working manual, p31 */ + static + struct isea_geo + snyder_ctran(struct isea_geo * np, struct isea_geo * pt) + { + struct isea_geo npt; + double alpha, phi, lambda, lambda0, beta, lambdap, phip; + double sin_phip; + double lp_b; /* lambda prime minus beta */ + double cos_p, sin_a; + + phi = pt->lat; + lambda = pt->lon; + alpha = np->lat; + beta = np->lon; + lambda0 = beta; + + cos_p = cos(phi); + sin_a = sin(alpha); + + /* mpawm 5-7 */ + sin_phip = sin_a * sin(phi) - cos(alpha) * cos_p * cos(lambda - lambda0); + + /* mpawm 5-8b */ + + /* use the two argument form so we end up in the right quadrant */ + lp_b = atan2(cos_p * sin(lambda - lambda0), + (sin_a * cos_p * cos(lambda - lambda0) + cos(alpha) * sin(phi))); + + lambdap = lp_b + beta; + + /* normalize longitude */ + /* TODO can we just do a modulus ? */ + lambdap = fmod(lambdap, 2 * M_PI); + while (lambdap > M_PI) + lambdap -= 2 * M_PI; + while (lambdap < -M_PI) + lambdap += 2 * M_PI; + + phip = asin(sin_phip); + + npt.lat = phip; + npt.lon = lambdap; + + return npt; + } + + static + struct isea_geo + isea_ctran(struct isea_geo * np, struct isea_geo * pt, double lon0) + { + struct isea_geo npt; + + np->lon += M_PI; + npt = snyder_ctran(np, pt); + np->lon -= M_PI; + + npt.lon -= (M_PI - lon0 + np->lon); + + npt.lon += M_PI; + /* normalize longitude */ + npt.lon = fmod(npt.lon, 2 * M_PI); + while (npt.lon > M_PI) + npt.lon -= 2 * M_PI; + while (npt.lon < -M_PI) + npt.lon += 2 * M_PI; + + return npt; + } + + /* in radians */ + + /* fuller's at 5.2454 west, 2.3009 N, adjacent at 7.46658 deg */ + + static + int + isea_grid_init(struct isea_dgg * g) + { + if (!g) + return 0; + + g->polyhedron = 20; + g->o_lat = ISEA_STD_LAT; + g->o_lon = ISEA_STD_LON; + g->o_az = 0.0; + g->aperture = 4; + g->resolution = 6; + g->radius = 1.0; + g->topology = 6; + + return 1; + } + + static + int + isea_orient_isea(struct isea_dgg * g) + { + if (!g) + return 0; + g->o_lat = ISEA_STD_LAT; + g->o_lon = ISEA_STD_LON; + g->o_az = 0.0; + return 1; + } + + static + int + isea_orient_pole(struct isea_dgg * g) + { + if (!g) + return 0; + g->o_lat = M_PI / 2.0; + g->o_lon = 0.0; + g->o_az = 0; + return 1; + } + + static + int + isea_transform(struct isea_dgg * g, struct isea_geo * in, + struct isea_pt * out) + { + struct isea_geo i, pole; + int tri; + + pole.lat = g->o_lat; + pole.lon = g->o_lon; + + i = isea_ctran(&pole, in, g->o_az); + + tri = isea_snyder_forward(&i, out); + out->x *= g->radius; + out->y *= g->radius; + g->triangle = tri; + + return tri; + } + + + static + void + isea_rotate(struct isea_pt * pt, double degrees) + { + double rad; + + double x, y; + + rad = -degrees * M_PI / 180.0; + while (rad >= 2.0 * M_PI) rad -= 2.0 * M_PI; + while (rad <= -2.0 * M_PI) rad += 2.0 * M_PI; + + x = pt->x * cos(rad) + pt->y * sin(rad); + y = -pt->x * sin(rad) + pt->y * cos(rad); + + pt->x = x; + pt->y = y; + } + + static + int isea_tri_plane(int tri, struct isea_pt *pt, double radius) { + struct isea_pt tc; /* center of triangle */ + + if (DOWNTRI(tri)) { + isea_rotate(pt, 180.0); + } + tc = isea_triangle_xy(tri); + tc.x *= radius; + tc.y *= radius; + pt->x += tc.x; + pt->y += tc.y; + + return tri; + } + + /* convert projected triangle coords to quad xy coords, return quad number */ + static + int + isea_ptdd(int tri, struct isea_pt *pt) { + int downtri, quad; + + downtri = (((tri - 1) / 5) % 2 == 1); + quad = ((tri - 1) % 5) + ((tri - 1) / 10) * 5 + 1; + + isea_rotate(pt, downtri ? 240.0 : 60.0); + if (downtri) { + pt->x += 0.5; + /* pt->y += cos(30.0 * M_PI / 180.0); */ + pt->y += .86602540378443864672; + } + return quad; + } + + static + int + isea_dddi_ap3odd(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di) + { + struct isea_pt v; + double hexwidth; + double sidelength; /* in hexes */ + int d, i; + int maxcoord; + struct hex h; + + /* This is the number of hexes from apex to base of a triangle */ + sidelength = (pow(2.0, g->resolution) + 1.0) / 2.0; + + /* apex to base is cos(30deg) */ + hexwidth = cos(M_PI / 6.0) / sidelength; + + /* TODO I think sidelength is always x.5, so + * (int)sidelength * 2 + 1 might be just as good + */ + maxcoord = (int) (sidelength * 2.0 + 0.5); + + v = *pt; + hexbin2(0, hexwidth, v.x, v.y, &h.x, &h.y); + h.iso = 0; + hex_iso(&h); + + d = h.x - h.z; + i = h.x + h.y + h.y; + + if (quad <= 5) { + if (d == 0 && i == maxcoord) { + /* north pole */ + quad = 0; + d = 0; + i = 0; + } else if (i == maxcoord) { + /* upper right in next quad */ + quad += 1; + if (quad == 6) + quad = 1; + i = maxcoord - d; + d = 0; + } else if (d == maxcoord) { + /* lower right in quad to lower right */ + quad += 5; + d = 0; + } + } else if (quad >= 6) { + if (i == 0 && d == maxcoord) { + /* south pole */ + quad = 11; + d = 0; + i = 0; + } else if (d == maxcoord) { + /* lower right in next quad */ + quad += 1; + if (quad == 11) + quad = 6; + d = maxcoord - i; + i = 0; + } else if (i == maxcoord) { + /* upper right in quad to upper right */ + quad = (quad - 4) % 5; + i = 0; + } + } + + di->x = d; + di->y = i; + + g->quad = quad; + return quad; + } + + static + int + isea_dddi(struct isea_dgg *g, int quad, struct isea_pt *pt, struct isea_pt *di) { + struct isea_pt v; + double hexwidth; + int sidelength; /* in hexes */ + struct hex h; + + if (g->aperture == 3 && g->resolution % 2 != 0) { + return isea_dddi_ap3odd(g, quad, pt, di); + } + /* todo might want to do this as an iterated loop */ + if (g->aperture >0) { + sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5); + } else { + sidelength = g->resolution; + } + + hexwidth = 1.0 / sidelength; + + v = *pt; + isea_rotate(&v, -30.0); + hexbin2(0, hexwidth, v.x, v.y, &h.x, &h.y); + h.iso = 0; + hex_iso(&h); + + /* we may actually be on another quad */ + if (quad <= 5) { + if (h.x == 0 && h.z == -sidelength) { + /* north pole */ + quad = 0; + h.z = 0; + h.y = 0; + h.x = 0; + } else if (h.z == -sidelength) { + quad = quad + 1; + if (quad == 6) + quad = 1; + h.y = sidelength - h.x; + h.z = h.x - sidelength; + h.x = 0; + } else if (h.x == sidelength) { + quad += 5; + h.y = -h.z; + h.x = 0; + } + } else if (quad >= 6) { + if (h.z == 0 && h.x == sidelength) { + /* south pole */ + quad = 11; + h.x = 0; + h.y = 0; + h.z = 0; + } else if (h.x == sidelength) { + quad = quad + 1; + if (quad == 11) + quad = 6; + h.x = h.y + sidelength; + h.y = 0; + h.z = -h.x; + } else if (h.y == -sidelength) { + quad -= 4; + h.y = 0; + h.z = -h.x; + } + } + di->x = h.x; + di->y = -h.z; + + g->quad = quad; + return quad; + } + + static + int isea_ptdi(struct isea_dgg *g, int tri, struct isea_pt *pt, + struct isea_pt *di) { + struct isea_pt v; + int quad; + + v = *pt; + quad = isea_ptdd(tri, &v); + quad = isea_dddi(g, quad, &v, di); + return quad; + } + + /* q2di to seqnum */ + static + int isea_disn(struct isea_dgg *g, int quad, struct isea_pt *di) { + int sidelength; + int sn, height; + int hexes; + + if (quad == 0) { + g->serial = 1; + return g->serial; + } + /* hexes in a quad */ + hexes = (int) (pow(g->aperture, g->resolution) + 0.5); + if (quad == 11) { + g->serial = 1 + 10 * hexes + 1; + return g->serial; + } + if (g->aperture == 3 && g->resolution % 2 == 1) { + height = (int) (pow(g->aperture, (g->resolution - 1) / 2.0)); + sn = ((int) di->x) * height; + sn += ((int) di->y) / height; + sn += (quad - 1) * hexes; + sn += 2; + } else { + sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5); + sn = (quad - 1) * hexes + sidelength * di->x + di->y + 2; + } + + g->serial = sn; + return sn; + } + + /* TODO just encode the quad in the d or i coordinate + * quad is 0-11, which can be four bits. + * d' = d << 4 + q, d = d' >> 4, q = d' & 0xf + */ + /* convert a q2di to global hex coord */ + static + int isea_hex(struct isea_dgg *g, int tri, + struct isea_pt *pt, struct isea_pt *hex) { + struct isea_pt v; + int sidelength; + int d, i, x, y, quad; + + quad = isea_ptdi(g, tri, pt, &v); + + hex->x = ((int)v.x << 4) + quad; + hex->y = v.y; + + return 1; + + d = v.x; + i = v.y; + + /* Aperture 3 odd resolutions */ + if (g->aperture == 3 && g->resolution % 2 != 0) { + int offset = (int)(pow(3.0, g->resolution - 1) + 0.5); + + d += offset * ((g->quad-1) % 5); + i += offset * ((g->quad-1) % 5); + + if (quad == 0) { + d = 0; + i = offset; + } else if (quad == 11) { + d = 2 * offset; + i = 0; + } else if (quad > 5) { + d += offset; + } + + x = (2*d - i) /3; + y = (2*i - d) /3; + + hex->x = x + offset / 3; + hex->y = y + 2 * offset / 3; + return 1; + } + + /* aperture 3 even resolutions and aperture 4 */ + sidelength = (int) (pow(g->aperture, g->resolution / 2.0) + 0.5); + if (g->quad == 0) { + hex->x = 0; + hex->y = sidelength; + } else if (g->quad == 11) { + hex->x = sidelength * 2; + hex->y = 0; + } else { + hex->x = d + sidelength * ((g->quad-1) % 5); + if (g->quad > 5) hex->x += sidelength; + hex->y = i + sidelength * ((g->quad-1) % 5); + } + + return 1; + } + + static + struct isea_pt + isea_forward(struct isea_dgg *g, struct isea_geo *in) + { + int tri, downtri; + struct isea_pt out, coord; + + tri = isea_transform(g, in, &out); + + downtri = (((tri - 1) / 5) % 2 == 1); + + if (g->output == ISEA_PLANE) { + isea_tri_plane(tri, &out, g->radius); + return out; + } + + /* convert to isea standard triangle size */ + out.x = out.x / g->radius * ISEA_SCALE; + out.y = out.y / g->radius * ISEA_SCALE; + out.x += 0.5; + out.y += 2.0 * .14433756729740644112; + + switch (g->output) { + case ISEA_PROJTRI: + /* nothing to do, already in projected triangle */ + break; + case ISEA_VERTEX2DD: + g->quad = isea_ptdd(tri, &out); + break; + case ISEA_Q2DD: + /* Same as above, we just don't print as much */ + g->quad = isea_ptdd(tri, &out); + break; + case ISEA_Q2DI: + g->quad = isea_ptdi(g, tri, &out, &coord); + return coord; + break; + case ISEA_SEQNUM: + isea_ptdi(g, tri, &out, &coord); + /* disn will set g->serial */ + isea_disn(g, g->quad, &coord); + return coord; + break; + case ISEA_HEX: + isea_hex(g, tri, &out, &coord); + return coord; + break; + } + + return out; + } + + struct par_isea + { + struct isea_dgg dgg; + }; + + // template class, using CRTP to implement forward/inverse + template + struct base_isea_spheroid : public base_t_f, + Geographic, Cartesian, Parameters> + { + + typedef double geographic_type; + typedef double cartesian_type; + + par_isea m_proj_parm; + + inline base_isea_spheroid(const Parameters& par) + : base_t_f, + Geographic, Cartesian, Parameters>(*this, par) {} + + inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const + { + struct isea_pt out; + struct isea_geo in; + + in.lon = lp_lon; + in.lat = lp_lat; + + isea_dgg copy = this->m_proj_parm.dgg; + out = isea_forward(©, &in); + + xy_x = out.x; + xy_y = out.y; + } + }; + + // Icosahedral Snyder Equal Area + template + void setup_isea(Parameters& par, par_isea& proj_parm) + { + std::string opt; + // par.fwd = s_forward; + isea_grid_init(&proj_parm.dgg); + proj_parm.dgg.output = ISEA_PLANE; + /* proj_parm.dgg.radius = par.a; + / * otherwise defaults to 1 */ + /* calling library will scale, I think */ + opt = pj_param(par.params, "sorient").s; + if (! opt.empty()) { + if (opt == std::string("isea")) { + isea_orient_isea(&proj_parm.dgg); + } else if (opt == std::string("pole")) { + isea_orient_pole(&proj_parm.dgg); + } else { + throw proj_exception(-34); + } + } + if (pj_param(par.params, "tazi").i) { + proj_parm.dgg.o_az = pj_param(par.params, "razi").f; + } + if (pj_param(par.params, "tlon_0").i) { + proj_parm.dgg.o_lon = pj_param(par.params, "rlon_0").f; + } + if (pj_param(par.params, "tlat_0").i) { + proj_parm.dgg.o_lat = pj_param(par.params, "rlat_0").f; + } + if (pj_param(par.params, "taperture").i) { + proj_parm.dgg.aperture = pj_param(par.params, "iaperture").i; + } + if (pj_param(par.params, "tresolution").i) { + proj_parm.dgg.resolution = pj_param(par.params, "iresolution").i; + } + opt = pj_param(par.params, "smode").s; + if (! opt.empty()) { + if (opt == std::string("plane")) { + proj_parm.dgg.output = ISEA_PLANE; + } else if (opt == std::string("di")) { + proj_parm.dgg.output = ISEA_Q2DI; + } + else if (opt == std::string("dd")) { + proj_parm.dgg.output = ISEA_Q2DD; + } + else if (opt == std::string("hex")) { + proj_parm.dgg.output = ISEA_HEX; + } + else { + /* TODO verify error code. Possibly eliminate magic */ + throw proj_exception(-34); + } + } + if (pj_param(par.params, "trescale").i) { + proj_parm.dgg.radius = ISEA_SCALE; + } + if (pj_param(par.params, "tresolution").i) { + proj_parm.dgg.resolution = pj_param(par.params, "iresolution").i; + } else { + proj_parm.dgg.resolution = 4; + } + if (pj_param(par.params, "taperture").i) { + proj_parm.dgg.aperture = pj_param(par.params, "iaperture").i; + } else { + proj_parm.dgg.aperture = 3; + } + } + + }} // namespace detail::isea + #endif // doxygen + + /*! + \brief Icosahedral Snyder Equal Area projection + \ingroup projections + \tparam Geographic latlong point type + \tparam Cartesian xy point type + \tparam Parameters parameter type + \par Projection characteristics + - Spheroid + \par Example + \image html ex_isea.gif + */ + template + struct isea_spheroid : public detail::isea::base_isea_spheroid + { + inline isea_spheroid(const Parameters& par) : detail::isea::base_isea_spheroid(par) + { + detail::isea::setup_isea(this->m_par, this->m_proj_parm); + } + }; + + #ifndef DOXYGEN_NO_DETAIL + namespace detail + { + + // Factory entry(s) + template + class isea_entry : public detail::factory_entry + { + public : + virtual projection* create_new(const Parameters& par) const + { + return new base_v_f, Geographic, Cartesian, Parameters>(par); + } + }; + + template + inline void isea_init(detail::base_factory& factory) + { + factory.add_to_factory("isea", new isea_entry); + } + + } // namespace detail + #endif // doxygen + +}}} // namespace boost::geometry::projections + +#endif // BOOST_GEOMETRY_PROJECTIONS_ISEA_HPP + From 2ad12a62f358436e2079d23bb39d2403f55f0dc1 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 13:40:54 +0200 Subject: [PATCH 040/104] [projection] replace exit with throw --- .../boost/geometry/extensions/gis/projections/proj/isea.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/proj/isea.hpp b/include/boost/geometry/extensions/gis/projections/proj/isea.hpp index d82e4d174..f946023e7 100644 --- a/include/boost/geometry/extensions/gis/projections/proj/isea.hpp +++ b/include/boost/geometry/extensions/gis/projections/proj/isea.hpp @@ -323,7 +323,7 @@ namespace boost { namespace geometry { namespace projections break; default: /* should be impossible */ - exit(EXIT_FAILURE); + throw proj_exception(); }; c.x *= Rprime; c.y *= Rprime; @@ -484,7 +484,7 @@ namespace boost { namespace geometry { namespace projections fprintf(stderr, "impossible transform: %f %f is not on any triangle\n", ll->lon * RAD2DEG, ll->lat * RAD2DEG); - exit(EXIT_FAILURE); + throw proj_exception(); /* not reached */ return 0; /* supresses a warning */ From c6eb7748eb19d9859eeff8a12d66c4fea2aece5b Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 13:46:26 +0200 Subject: [PATCH 041/104] [projection] replace redundant comments --- .../boost/geometry/extensions/gis/projections/factory.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/factory.hpp b/include/boost/geometry/extensions/gis/projections/factory.hpp index 0acb12eb7..5847cc5fe 100644 --- a/include/boost/geometry/extensions/gis/projections/factory.hpp +++ b/include/boost/geometry/extensions/gis/projections/factory.hpp @@ -28,7 +28,7 @@ #include #include #include -#include // control points XY +#include #include #include #include @@ -47,12 +47,12 @@ #include #include #include -#include // includes two other projections +#include #include #include #include #include -#include // xy functions after inverse +#include #include #include #include @@ -77,7 +77,7 @@ #include #include #include -#include // includes other projection +#include #include #include #include From 68eac273d3eb710cca72c8af06514d6dac90bcb4 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 14:56:48 +0200 Subject: [PATCH 042/104] [projections] expose error code --- .../geometry/extensions/gis/projections/impl/projects.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/geometry/extensions/gis/projections/impl/projects.hpp b/include/boost/geometry/extensions/gis/projections/impl/projects.hpp index 89240c222..053594d1b 100644 --- a/include/boost/geometry/extensions/gis/projections/impl/projects.hpp +++ b/include/boost/geometry/extensions/gis/projections/impl/projects.hpp @@ -39,7 +39,6 @@ #include #include -#include #include namespace boost { namespace geometry { namespace projections @@ -176,9 +175,12 @@ class proj_exception public: proj_exception(int code = 0) + : m_code(code) { - boost::ignore_unused(code); } + int code() const { return m_code; } +private : + int m_code; }; }}} // namespace boost::geometry::projections From 4edcc4042e585d947f34738d5b5b9fc2ccd1140e Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Wed, 29 Apr 2015 14:57:27 +0200 Subject: [PATCH 043/104] [projections][test] add unit test for static projections (forward) including different models (spheroid/ellipsoid) --- extensions/test/gis/projections/Jamfile.v2 | 1 + .../gis/projections/projections_static.cpp | 385 ++++++++++++++++++ 2 files changed, 386 insertions(+) create mode 100644 extensions/test/gis/projections/projections_static.cpp diff --git a/extensions/test/gis/projections/Jamfile.v2 b/extensions/test/gis/projections/Jamfile.v2 index b57c8ebf5..232aef2b2 100644 --- a/extensions/test/gis/projections/Jamfile.v2 +++ b/extensions/test/gis/projections/Jamfile.v2 @@ -12,5 +12,6 @@ test-suite boost-geometry-extensions-gis-projections : [ run projection.cpp ] [ run projections.cpp ] + [ run projections_static.cpp ] [ run projection_epsg.cpp ] ; diff --git a/extensions/test/gis/projections/projections_static.cpp b/extensions/test/gis/projections/projections_static.cpp new file mode 100644 index 000000000..2599cb534 --- /dev/null +++ b/extensions/test/gis/projections/projections_static.cpp @@ -0,0 +1,385 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) +// Unit Test + +// Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + + +#if defined(_MSC_VER) +#pragma warning( disable : 4305 ) // truncation double -> float +#endif // defined(_MSC_VER) + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +//#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include +#include + +#include +#include +#include +#include + + +template