From ae08aac3a5bb1581e2e64d6137956f3fed33be2c Mon Sep 17 00:00:00 2001 From: Menelaos Karavelas Date: Wed, 29 Apr 2015 16:10:27 +0300 Subject: [PATCH] [algorithms][envelope][spherical] move existing implementation of envelope(box, mbr) to separate file and add implementation for envelope(box, mbr) for boxes in the spherical equatorial and geographic coordinate systems --- .../algorithms/detail/envelope/box.hpp | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 include/boost/geometry/algorithms/detail/envelope/box.hpp diff --git a/include/boost/geometry/algorithms/detail/envelope/box.hpp b/include/boost/geometry/algorithms/detail/envelope/box.hpp new file mode 100644 index 000000000..0edb21632 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/envelope/box.hpp @@ -0,0 +1,128 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2008-2015 Bruno Lalande, Paris, France. +// Copyright (c) 2009-2015 Mateusz Loskot, London, UK. + +// This file was modified by Oracle on 2015. +// Modifications copyright (c) 2015, Oracle and/or its affiliates. + +// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle + +// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library +// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP + +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace envelope +{ + + +struct envelope_box_on_spheroid +{ + template + static inline bool is_band(Box const& box) + { + typedef typename coordinate_type::type coordinate_type; + coordinate_type const period = math::detail::constants_on_spheroid + < + coordinate_type, + typename coordinate_system::type::units + >::period(); + + coordinate_type longitude_diff = geometry::get(box) + - geometry::get(box); + + return ! math::smaller(math::abs(longitude_diff), period); + } + + template + static inline void apply(BoxIn const& box_in, BoxOut& mbr) + { + typedef typename coordinate_type::type box_out_coordinate_type; + typedef typename coordinate_system::type::units mbr_units_type; + + bool const band = is_band(box_in); + + mbr = math::convert_box(box_in); + box_out_coordinate_type lon1 = geometry::get(mbr); + box_out_coordinate_type lat1 = geometry::get(mbr); + box_out_coordinate_type lon2 = geometry::get(mbr); + box_out_coordinate_type lat2 = geometry::get(mbr); + + math::normalize_spheroidal_box_coordinates + < + mbr_units_type + >(lon1, lat1, lon2, lat2, band); + + assign_values(mbr, lon1, lat1, lon2, lat2); + } +}; + + +template +struct envelope_box +{ + template + static inline void apply(BoxIn const& box_in, BoxOut& mbr) + { + geometry::convert(box_in, mbr); + } +}; + +template <> +struct envelope_box + : envelope_box_on_spheroid +{}; + +template <> +struct envelope_box + : envelope_box_on_spheroid +{}; + + +}} // namespace detail::envelope +#endif // DOXYGEN_NO_DETAIL + +#ifndef DOXYGEN_NO_DISPATCH +namespace dispatch +{ + + +template +struct envelope + : detail::envelope::envelope_box::type> +{}; + + +} // namespace dispatch +#endif + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP