mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-12 12:12:10 +00:00
Added extensions
[SVN r59779]
This commit is contained in:
136
include/boost/geometry/extensions/algorithms/midpoints.hpp
Normal file
136
include/boost/geometry/extensions/algorithms/midpoints.hpp
Normal file
@@ -0,0 +1,136 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MIDPOINTS_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MIDPOINTS_HPP
|
||||
|
||||
// Renamed from "intermediate" to "midpoints"
|
||||
|
||||
#include <cstddef>
|
||||
#include <iterator>
|
||||
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
/*!
|
||||
\defgroup midpoints midpoints calculation
|
||||
The midpoints algorithm calculate points IN BETWEEN of other points
|
||||
\par Purpose:
|
||||
- Remove corners in rectangular lines / polygons. Calling them several times will result in smooth lines
|
||||
- Creating 3D models
|
||||
*/
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace midpoints {
|
||||
|
||||
template <typename Src, typename Dst, std::size_t Dimension, std::size_t DimensionCount>
|
||||
struct calculate_coordinate
|
||||
{
|
||||
static inline void apply(Src const& p1, Src const& p2, Dst& p)
|
||||
{
|
||||
geometry::set<Dimension>(p,
|
||||
(geometry::get<Dimension>(p1) + geometry::get<Dimension>(p2)) / 2.0);
|
||||
calculate_coordinate<Src, Dst, Dimension + 1, DimensionCount>::apply(p1, p2, p);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Src, typename Dst, std::size_t DimensionCount>
|
||||
struct calculate_coordinate<Src, Dst, DimensionCount, DimensionCount>
|
||||
{
|
||||
static inline void apply(Src const&, Src const&, Dst&)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Range, typename Iterator>
|
||||
struct range_midpoints
|
||||
{
|
||||
static inline void apply(Range const& range,
|
||||
bool start_and_end, Iterator out)
|
||||
{
|
||||
typedef typename point_type<Range>::type point_type;
|
||||
typedef typename boost::range_const_iterator<Range>::type iterator_type;
|
||||
|
||||
iterator_type it = boost::begin(range);
|
||||
|
||||
if (start_and_end)
|
||||
{
|
||||
*out++ = *it;
|
||||
}
|
||||
|
||||
iterator_type prev = it++;
|
||||
for (; it != boost::end(range); prev = it++)
|
||||
{
|
||||
point_type p;
|
||||
calculate_coordinate
|
||||
<
|
||||
point_type,
|
||||
point_type,
|
||||
0,
|
||||
dimension<point_type>::type::value
|
||||
>::apply(*prev, *it, p);
|
||||
*out++ = p;
|
||||
}
|
||||
|
||||
if (start_and_end)
|
||||
{
|
||||
*out++ = *prev;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::midpoints
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
template <typename GeometryTag, typename G, typename Iterator>
|
||||
struct midpoints {};
|
||||
|
||||
template <typename G, typename Iterator>
|
||||
struct midpoints<ring_tag, G, Iterator>
|
||||
: detail::midpoints::range_midpoints<G, Iterator> {};
|
||||
|
||||
template <typename G, typename Iterator>
|
||||
struct midpoints<linestring_tag, G, Iterator>
|
||||
: detail::midpoints::range_midpoints<G, Iterator> {};
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
/*!
|
||||
\brief Calculate midpoints of a geometry
|
||||
\ingroup midpoints
|
||||
*/
|
||||
template<typename Geometry, typename Iterator>
|
||||
inline void midpoints(Geometry const& geometry,
|
||||
bool start_and_end, Iterator out)
|
||||
{
|
||||
concept::check<const Geometry>();
|
||||
|
||||
dispatch::midpoints
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
Geometry,
|
||||
Iterator
|
||||
>::apply(geometry, start_and_end, out);
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_ALGORITHMS_MIDPOINTS_HPP
|
||||
@@ -0,0 +1,70 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_POINT_ON_LINE_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_POINT_ON_LINE_HPP
|
||||
|
||||
|
||||
#include <boost/geometry/algorithms/distance.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
// Function : point_on_linestring -> rename to alongLine NO, different
|
||||
//----------------------------------------------------------------------
|
||||
// Purpose : Calculates coordinates of a point along a given line
|
||||
// on a specified distance
|
||||
// Parameters : const L& : line,
|
||||
// float position: position to calculate point
|
||||
// P& point: point to calculate
|
||||
// Return : true if point lies on line
|
||||
//----------------------------------------------------------------------
|
||||
// Author : Barend, Geodan BV Amsterdam
|
||||
// Date : spring 1996
|
||||
//----------------------------------------------------------------------
|
||||
template <typename P, typename L>
|
||||
bool point_on_linestring(const L& line, const double& position, P& point)
|
||||
{
|
||||
double current_distance = 0.0;
|
||||
if (line.size() < 2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
typename L::const_iterator vertex = line.begin();
|
||||
typename L::const_iterator previous = vertex++;
|
||||
|
||||
while (vertex != line.end())
|
||||
{
|
||||
double const dist = distance(*previous, *vertex);
|
||||
current_distance += dist;
|
||||
|
||||
if (current_distance > position)
|
||||
{
|
||||
// It is not possible that dist == 0 here because otherwise
|
||||
// the current_distance > position would not become true (current_distance is increased by dist)
|
||||
double const fraction = 1.0 - ((current_distance - position) / dist);
|
||||
|
||||
// point i is too far, point i-1 to near, add fraction of
|
||||
// distance in each direction
|
||||
point.x ( previous->x() + (vertex->x() - previous->x()) * fraction);
|
||||
point.y ( previous->y() + (vertex->y() - previous->y()) * fraction);
|
||||
|
||||
return true;
|
||||
}
|
||||
previous = vertex++;
|
||||
}
|
||||
|
||||
// point at specified position does not lie on line
|
||||
return false;
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_POINT_ON_LINE_HPP
|
||||
149
include/boost/geometry/extensions/algorithms/remove_holes_if.hpp
Normal file
149
include/boost/geometry/extensions/algorithms/remove_holes_if.hpp
Normal file
@@ -0,0 +1,149 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_ALGORITHM_REMOVE_HOLES_IF_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHM_REMOVE_HOLES_IF_HPP
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/geometry/algorithms/area.hpp>
|
||||
#include <boost/geometry/algorithms/perimeter.hpp>
|
||||
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
#include <boost/geometry/multi/core/tags.hpp>
|
||||
#include <boost/geometry/multi/algorithms/detail/modify_with_predicate.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace remove_holes_if {
|
||||
|
||||
|
||||
template<typename Polygon, typename Predicate>
|
||||
struct polygon_remove_holes_if
|
||||
{
|
||||
static inline void apply(Polygon& poly, Predicate const& predicate)
|
||||
{
|
||||
typename interior_type<Polygon>::type& rings = interior_rings(poly);
|
||||
|
||||
// Remove rings using erase-remove-idiom
|
||||
// http://en.wikipedia.org/wiki/Erase-remove_idiom
|
||||
rings.erase(
|
||||
std::remove_if(boost::begin(rings), boost::end(rings), predicate),
|
||||
boost::end(rings));
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::remove_holes_if
|
||||
|
||||
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch {
|
||||
|
||||
// Default implementation does nothing
|
||||
template <typename Tag, typename Geometry, typename Predicate>
|
||||
struct remove_holes_if
|
||||
{};
|
||||
|
||||
|
||||
|
||||
template <typename Geometry, typename Predicate>
|
||||
struct remove_holes_if<polygon_tag, Geometry, Predicate>
|
||||
: detail::remove_holes_if::polygon_remove_holes_if<Geometry, Predicate>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPolygon, typename Predicate>
|
||||
struct remove_holes_if<multi_polygon_tag, MultiPolygon, Predicate>
|
||||
: detail::multi_modify_with_predicate
|
||||
<
|
||||
MultiPolygon,
|
||||
Predicate,
|
||||
detail::remove_holes_if::polygon_remove_holes_if
|
||||
<
|
||||
typename boost::range_value<MultiPolygon>::type, Predicate
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
/*!
|
||||
\brief Remove holes from a geometry (polygon, multi-polygon) using a specified condition
|
||||
*/
|
||||
template <typename Geometry, typename Predicate>
|
||||
inline void remove_holes_if(Geometry& geometry, Predicate const& predicate)
|
||||
{
|
||||
concept::check<Geometry>();
|
||||
|
||||
dispatch::remove_holes_if
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
Geometry,
|
||||
Predicate
|
||||
>::apply(geometry, predicate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// CONVENIENT PREDICATES might be moved elsewhere
|
||||
template <typename Ring>
|
||||
struct elongated_hole
|
||||
{
|
||||
inline elongated_hole(double ratio)
|
||||
: m_ratio(ratio)
|
||||
{}
|
||||
|
||||
inline bool operator()(Ring const& ring) const
|
||||
{
|
||||
if (ring.size() >= 4)
|
||||
{
|
||||
double a = area(ring);
|
||||
double p = perimeter(ring);
|
||||
return std::abs(a/p) < m_ratio;
|
||||
}
|
||||
// Rings with less then 4 points (including closing)
|
||||
// are also considered as small and thus removed
|
||||
return true;
|
||||
}
|
||||
private :
|
||||
double m_ratio;
|
||||
};
|
||||
|
||||
|
||||
template <typename Ring>
|
||||
struct invalid_hole
|
||||
{
|
||||
inline bool operator()(Ring const& ring) const
|
||||
{
|
||||
return ring.size() < 4;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHM_REMOVE_HOLES_IF_HPP
|
||||
287
include/boost/geometry/extensions/algorithms/selected.hpp
Normal file
287
include/boost/geometry/extensions/algorithms/selected.hpp
Normal file
@@ -0,0 +1,287 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_SELECTED_HPP
|
||||
#define BOOST_GEOMETRY_ALGORITHMS_SELECTED_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
#include <boost/geometry/strategies/strategies.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/within.hpp>
|
||||
#include <boost/geometry/core/access.hpp>
|
||||
#include <boost/geometry/core/topological_dimension.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
#include <boost/geometry/util/select_coordinate_type.hpp>
|
||||
|
||||
/*!
|
||||
\defgroup selected selection: check if a geometry is "selected" by a point
|
||||
|
||||
Checks if one geometry is selected by a point lying within or in the neighborhood of that geometry
|
||||
|
||||
\par Geometries:
|
||||
- POINT: checks if points are CLOSE TO each other (< search_radius)
|
||||
- LINESTRING: checks if selection point is CLOSE TO linestring (< search_radius)
|
||||
- RING: checks if selection point is INSIDE the ring, search radius is ignored
|
||||
- POLYGON: checks if selection point is INSIDE the polygon, but not inside any of its holes
|
||||
|
||||
*/
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
/*!
|
||||
\ingroup impl
|
||||
*/
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace selected {
|
||||
|
||||
/*!
|
||||
\details Checks, per dimension, if d[I] not larger than search distance. If true for all
|
||||
dimensions then returns true. If larger stops immediately and returns false.
|
||||
Calculate during this process the sum, which is only valid if returning true
|
||||
*/
|
||||
template <typename P1, typename P2, typename T, std::size_t D, std::size_t N>
|
||||
struct differences_loop
|
||||
{
|
||||
static inline bool apply(P1 const& p1, P2 const& p2, T const& distance, T& sum)
|
||||
{
|
||||
typedef typename select_coordinate_type<P1, P2>::type coordinate_type;
|
||||
|
||||
coordinate_type const c1 = boost::numeric_cast<coordinate_type>(get<D>(p1));
|
||||
coordinate_type const c2 = boost::numeric_cast<coordinate_type>(get<D>(p2));
|
||||
|
||||
T const d = std::abs(c1 - c2);
|
||||
if (d > distance)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
sum += d * d;
|
||||
return differences_loop<P1, P2, T, D + 1, N>::apply(p1, p2, distance, sum);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename P1, typename P2, typename T, std::size_t N>
|
||||
struct differences_loop<P1, P2, T, N, N>
|
||||
{
|
||||
static inline bool apply(P1 const&, P2 const&, T const&, T&)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename PS, typename P, typename T, std::size_t D, std::size_t N>
|
||||
struct outside_loop
|
||||
{
|
||||
static inline bool apply(PS const& seg1, PS const& seg2, P const& point, T const& distance)
|
||||
{
|
||||
typedef typename select_coordinate_type<PS, P>::type coordinate_type;
|
||||
|
||||
coordinate_type const v = boost::numeric_cast<coordinate_type>(get<D>(point));
|
||||
coordinate_type const s1 = get<D>(seg1);
|
||||
coordinate_type const s2 = get<D>(seg2);
|
||||
|
||||
// Out of reach if left/bottom or right/top of both points making up the segment
|
||||
// I know and currently accept that these comparisons/calculations are done twice per point
|
||||
|
||||
if ((v < s1 - distance && v < s2 - distance) || (v > s1 + distance && v > s2 + distance))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return outside_loop<PS, P, T, D + 1, N>::apply(seg1, seg2, point, distance);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename PS, typename P, typename T, std::size_t N>
|
||||
struct outside_loop<PS, P, T, N, N>
|
||||
{
|
||||
static inline bool apply(PS const&, PS const&, P const&, T const&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename P1, typename P2, typename T>
|
||||
struct close_to_point
|
||||
{
|
||||
static inline bool apply(P1 const& point, P1 const& selection_point, T const& search_radius)
|
||||
{
|
||||
assert_dimension_equal<P1, P2>();
|
||||
|
||||
T sum = 0;
|
||||
if (differences_loop
|
||||
<
|
||||
P1, P2, T, 0, dimension<P1>::type::value
|
||||
>::apply(point, selection_point, search_radius, sum))
|
||||
{
|
||||
return sum <= search_radius * search_radius;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename PS, typename P, typename T>
|
||||
struct close_to_segment
|
||||
{
|
||||
static inline bool apply(PS const& seg1, PS const& seg2, P const& selection_point, T const& search_radius)
|
||||
{
|
||||
assert_dimension_equal<PS, P>();
|
||||
|
||||
if (! outside_loop
|
||||
<
|
||||
PS, P, T, 0, dimension<P>::type::value
|
||||
>::apply(seg1, seg2, selection_point, search_radius))
|
||||
{
|
||||
// Not outside, calculate dot product/square distance to segment.
|
||||
// Call corresponding strategy
|
||||
typedef typename strategy_distance_segment
|
||||
<
|
||||
typename cs_tag<P>::type,
|
||||
typename cs_tag<PS>::type,
|
||||
P,
|
||||
PS
|
||||
>::type strategy_type;
|
||||
typedef typename strategy_type::return_type return_type;
|
||||
|
||||
strategy_type strategy;
|
||||
return_type result = strategy.apply(selection_point, seg1, seg2);
|
||||
return result < search_radius;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename R, typename P, typename T>
|
||||
struct close_to_range
|
||||
{
|
||||
static inline bool apply(R const& range, P const& selection_point, T const& search_radius)
|
||||
{
|
||||
assert_dimension_equal<R, P>();
|
||||
|
||||
std::size_t const n = boost::size(range);
|
||||
if (n == 0)
|
||||
{
|
||||
// Line with zero points, never close
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef typename point_type<R>::type point_type;
|
||||
typedef typename boost::range_const_iterator<R>::type iterator_type;
|
||||
|
||||
iterator_type it = boost::begin(range);
|
||||
if (n == 1)
|
||||
{
|
||||
// Line with one point ==> close to point
|
||||
return close_to_point<P, point_type, T>::apply(*it, selection_point, search_radius);
|
||||
}
|
||||
|
||||
iterator_type previous = it++;
|
||||
while(it != boost::end(range))
|
||||
{
|
||||
//typedef segment<const point_type> segment_type;
|
||||
//segment_type s(*previous, *it);
|
||||
if (close_to_segment
|
||||
<
|
||||
point_type, P, T
|
||||
>::apply(*previous, *it, selection_point, search_radius))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
previous = it++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Tag, typename G, typename P, typename T>
|
||||
struct use_within
|
||||
{
|
||||
static inline bool apply(G const& geometry, P const& selection_point, T const& search_radius)
|
||||
{
|
||||
return geometry::within(selection_point, geometry);
|
||||
}
|
||||
};
|
||||
|
||||
}} // namespace detail::selected
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch
|
||||
{
|
||||
|
||||
/*!
|
||||
\tparam TD topological dimension
|
||||
*/
|
||||
template <typename Tag, typename G, std::size_t D, typename P, typename T>
|
||||
struct selected
|
||||
{
|
||||
};
|
||||
|
||||
template <typename P1, typename P2, typename T>
|
||||
struct selected<point_tag, P1, 0, P2, T> : detail::selected::close_to_point<P1, P2, T> { };
|
||||
|
||||
// SEGMENT, TODO HERE (close_to_segment)
|
||||
|
||||
template <typename L, typename P, typename T>
|
||||
struct selected<linestring_tag, L, 1, P, T> : detail::selected::close_to_range<L, P, T> { };
|
||||
|
||||
template <typename Tag, typename G, typename P, typename T>
|
||||
struct selected<Tag, G, 2, P, T> : detail::selected::use_within<Tag, G, P, T> { };
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
/*!
|
||||
\brief Checks if one geometry is selected by a point lying within or in the neighborhood of that geometry
|
||||
\ingroup selected
|
||||
\tparam Geometry type of geometry to check
|
||||
\tparam Point type of point to check
|
||||
\tparam T type of search radius
|
||||
\param geometry geometry which might be located in the neighborhood
|
||||
\param selection_point point to select the geometry
|
||||
\param search_radius for points/linestrings: defines radius of "neighborhood" to find things in
|
||||
\return true if point is within or close to the other geometry
|
||||
|
||||
*/
|
||||
template<typename Geometry, typename Point, typename RadiusType>
|
||||
inline bool selected(Geometry const& geometry,
|
||||
Point const& selection_point,
|
||||
RadiusType const& search_radius)
|
||||
{
|
||||
concept::check<const Geometry>();
|
||||
concept::check<const Point>();
|
||||
|
||||
typedef dispatch::selected
|
||||
<
|
||||
typename tag<Geometry>::type,
|
||||
Geometry,
|
||||
topological_dimension<Geometry>::value,
|
||||
Point,
|
||||
RadiusType
|
||||
> selector_type;
|
||||
|
||||
return selector_type::apply(geometry, selection_point, search_radius);
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_ALGORITHMS_SELECTED_HPP
|
||||
48
include/boost/geometry/extensions/astronomy/core/cs.hpp
Normal file
48
include/boost/geometry/extensions/astronomy/core/cs.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_EXTENSION_ASTRONOMY_CORE_CS_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSION_ASTRONOMY_CORE_CS_HPP
|
||||
|
||||
#include <boost/geometry/core/coordinate_system.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
namespace cs
|
||||
{
|
||||
|
||||
|
||||
namespace celestial
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Ecliptic (celestial) coordinate system
|
||||
\details Defines the astronomical ecliptic coordinate system "that uses the ecliptic for its fundamental plane"
|
||||
It uses Beta and Lambda as its latitude and longitude.
|
||||
\see http://en.wikipedia.org/wiki/Ecliptic_coordinate_system
|
||||
\ingroup cs
|
||||
*/
|
||||
template<typename DegreeOrRadian>
|
||||
struct ecliptic
|
||||
{
|
||||
typedef DegreeOrRadian units;
|
||||
};
|
||||
|
||||
|
||||
} // namespace celestial
|
||||
|
||||
} // namespace cs
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSION_ASTRONOMY_CORE_CS_HPP
|
||||
82
include/boost/geometry/extensions/gis/geographic/core/cs.hpp
Normal file
82
include/boost/geometry/extensions/gis/geographic/core/cs.hpp
Normal file
@@ -0,0 +1,82 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_CORE_CS_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_CORE_CS_HPP
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup cs coordinate systems
|
||||
\brief Defines coordinate systems
|
||||
\details Coordinate systems are essential for any point in the Generic Geometry Library. Many
|
||||
algorithms such as distance or transform use coordinate systems to select the strategy to use.
|
||||
*/
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
namespace cs
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief EPSG Cartesian coordinate system
|
||||
\details EPSG (European Petrol Survey Group) has a standard list of projections,
|
||||
each having a code
|
||||
\see
|
||||
\ingroup cs
|
||||
\tparam Code the EPSG code
|
||||
\todo Maybe derive from boost::mpl::int_<EpsgCode>
|
||||
*/
|
||||
template<std::size_t Code>
|
||||
struct epsg
|
||||
{
|
||||
static const std::size_t epsg_code = Code;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
\brief Earth Centered, Earth Fixed
|
||||
\details Defines a Cartesian coordinate system x,y,z with the center of the earth as its origin,
|
||||
going through the Greenwich
|
||||
\see http://en.wikipedia.org/wiki/ECEF
|
||||
\see http://en.wikipedia.org/wiki/Geodetic_system
|
||||
\note Also known as "Geocentric", but geocentric is also an astronomic coordinate system
|
||||
\ingroup cs
|
||||
*/
|
||||
struct ecef
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
} // namespace cs
|
||||
|
||||
namespace traits
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
template<>
|
||||
struct cs_tag<cs::ecef>
|
||||
{
|
||||
typedef cartesian_tag type;
|
||||
};
|
||||
|
||||
template <std::size_t C>
|
||||
struct cs_tag<cs::epsg<C> >
|
||||
{
|
||||
typedef cartesian_tag type;
|
||||
};
|
||||
|
||||
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
} // namespace traits
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_GEOGRAPHIC_CORE_CS_HPP
|
||||
@@ -0,0 +1,284 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_IO_VESHAPE_WRITE_VESHAPE_HPP
|
||||
#define BOOST_GEOMETRY_IO_VESHAPE_WRITE_VESHAPE_HPP
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/concept/assert.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
#include <boost/range/metafunctions.hpp>
|
||||
|
||||
#include <boost/geometry/core/exterior_ring.hpp>
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/ring_type.hpp>
|
||||
|
||||
#include <boost/geometry/geometries/concepts/point_concept.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/convert.hpp>
|
||||
|
||||
|
||||
/*!
|
||||
\defgroup veshape veshape: stream VEShape (Virtual Earth shapes for in VE Ajax Control)
|
||||
\note VE assumes points in LatLong, Lat first
|
||||
*/
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace veshape {
|
||||
|
||||
|
||||
// Define the coordinate streamer, specialized for either 2 or 3 dimensions.
|
||||
// Any other number of dimensions make no sense for VE, and we have to take care about
|
||||
// the order lat,long (--> y,x)
|
||||
template <typename P, std::size_t D>
|
||||
struct stream_coordinate {};
|
||||
|
||||
|
||||
template <typename P>
|
||||
struct stream_coordinate<P, 2>
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
|
||||
{
|
||||
os << geometry::get<1>(p) << "," << geometry::get<0>(p);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename P>
|
||||
struct stream_coordinate<P, 3>
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
|
||||
{
|
||||
stream_coordinate<P, 2>::stream(os, p);
|
||||
os << "," << geometry::get<2>(p);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename P>
|
||||
struct stream_point
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
|
||||
{
|
||||
os << "new VELatLong(";
|
||||
stream_coordinate<P, dimension<P>::value>::stream(os, p);
|
||||
os << ")";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct prefix_point
|
||||
{
|
||||
static inline const char* prefix()
|
||||
{ return "new VEShape(VEShapeType.Pushpin, "; }
|
||||
|
||||
static inline const char* postfix()
|
||||
{ return ")"; }
|
||||
};
|
||||
|
||||
struct prefix_linestring
|
||||
{
|
||||
static inline const char* prefix()
|
||||
{ return "new VEShape(VEShapeType.Polyline, "; }
|
||||
|
||||
static inline const char* postfix()
|
||||
{ return ")"; }
|
||||
};
|
||||
|
||||
|
||||
struct prefix_polygon
|
||||
{
|
||||
static inline const char* prefix()
|
||||
{ return "new VEShape(VEShapeType.Polygon, "; }
|
||||
|
||||
static inline const char* postfix()
|
||||
{ return ")"; }
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Stream points as \ref VEShape
|
||||
*/
|
||||
template <typename P, typename Policy>
|
||||
struct veshape_point
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, P const& p)
|
||||
{
|
||||
os << Policy::prefix();
|
||||
stream_point<P>::stream(os, p);
|
||||
os << Policy::postfix();
|
||||
}
|
||||
|
||||
private:
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<P>) );
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Stream ranges as VEShape
|
||||
\note policy is used to stream prefix/postfix, enabling derived classes to override this
|
||||
*/
|
||||
template <typename R, typename Policy>
|
||||
struct veshape_range
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, R const& range)
|
||||
{
|
||||
typedef typename boost::range_const_iterator<R>::type iterator;
|
||||
|
||||
bool first = true;
|
||||
|
||||
os << Policy::prefix() << "new Array(";
|
||||
|
||||
for (iterator it = boost::begin(range); it != boost::end(range); ++it)
|
||||
{
|
||||
os << (first ? "" : ", ");
|
||||
stream_point<point>::stream(os, *it);
|
||||
first = false;
|
||||
}
|
||||
|
||||
os << ")" << Policy::postfix();
|
||||
}
|
||||
|
||||
private:
|
||||
typedef typename boost::range_value<R>::type point;
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<point>) );
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename P, typename Policy>
|
||||
struct veshape_poly
|
||||
{
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, P const& poly)
|
||||
{
|
||||
typedef typename ring_type<P>::type ring;
|
||||
typedef typename boost::range_const_iterator<
|
||||
typename interior_type<P>::type>::type iterator;
|
||||
|
||||
veshape_range<ring, Policy>::stream(os, exterior_ring(poly));
|
||||
|
||||
// For VE shapes: inner rings are not supported or undocumented
|
||||
/***
|
||||
for (iterator it = boost::begin(interior_rings(poly));
|
||||
it != boost::end(interior_rings(poly)); it++)
|
||||
{
|
||||
os << ",";
|
||||
veshape_range<ring, null>::stream(os, *it);
|
||||
}
|
||||
os << ")";
|
||||
***/
|
||||
}
|
||||
|
||||
private:
|
||||
BOOST_CONCEPT_ASSERT( (concept::ConstPoint<typename point_type<P>::type>) );
|
||||
};
|
||||
|
||||
|
||||
|
||||
}} // namespace detail::veshape
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DISPATCH
|
||||
namespace dispatch {
|
||||
|
||||
/*!
|
||||
\brief Dispatching base struct for VEShape streaming, specialized below per geometry type
|
||||
\details Specializations should implement a static method "stream" to stream a geometry
|
||||
The static method should have the signature:
|
||||
|
||||
template <typename Char, typename Traits>
|
||||
static inline void stream(std::basic_ostream<Char, Traits>& os, G const& geometry)
|
||||
*/
|
||||
template <typename T, typename G>
|
||||
struct veshape
|
||||
{};
|
||||
|
||||
|
||||
template <typename P>
|
||||
struct veshape<point_tag, P>
|
||||
: detail::veshape::veshape_point<P, detail::veshape::prefix_point>
|
||||
{};
|
||||
|
||||
|
||||
template <typename R>
|
||||
struct veshape<linestring_tag, R>
|
||||
: detail::veshape::veshape_range<R, detail::veshape::prefix_linestring>
|
||||
{};
|
||||
|
||||
|
||||
template <typename R>
|
||||
struct veshape<ring_tag, R>
|
||||
: detail::veshape::veshape_range<R, detail::veshape::prefix_polygon>
|
||||
{};
|
||||
|
||||
|
||||
template <typename P>
|
||||
struct veshape<polygon_tag, P>
|
||||
: detail::veshape::veshape_poly<P, detail::veshape::prefix_polygon>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif // DOXYGEN_NO_DISPATCH
|
||||
|
||||
|
||||
/*!
|
||||
\brief Generic geometry template manipulator class, takes corresponding output class from traits class
|
||||
\ingroup veshape
|
||||
\details Stream manipulator, streams geometry classes as Virtual Earth shape
|
||||
*/
|
||||
template <typename G>
|
||||
class veshape_manip
|
||||
{
|
||||
public:
|
||||
|
||||
inline veshape_manip(G const& g)
|
||||
: m_geometry(g)
|
||||
{}
|
||||
|
||||
template <typename Char, typename Traits>
|
||||
inline friend std::basic_ostream<Char, Traits>& operator<<(
|
||||
std::basic_ostream<Char, Traits>& os, veshape_manip const& m)
|
||||
{
|
||||
dispatch::veshape<typename tag<G>::type, G>::stream(os, m.m_geometry);
|
||||
os.flush();
|
||||
return os;
|
||||
}
|
||||
|
||||
private:
|
||||
G const& m_geometry;
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Object generator to conveniently stream objects without including streamveshape
|
||||
\ingroup veshape
|
||||
\par Example:
|
||||
Small example showing how to use the make_veshape helper function
|
||||
\dontinclude doxygen_1.cpp
|
||||
\skip example_as_veshape_vector
|
||||
\line {
|
||||
\until }
|
||||
*/
|
||||
template <typename T>
|
||||
inline veshape_manip<T> veshape(T const& t)
|
||||
{
|
||||
return veshape_manip<T>(t);
|
||||
}
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_IO_VESHAPE_WRITE_VESHAPE_HPP
|
||||
@@ -0,0 +1,231 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// Use, modification and distribution is subject to the Boost Software License,
|
||||
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_DETAIL_GRATICULE_HPP
|
||||
#define BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_DETAIL_GRATICULE_HPP
|
||||
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Cardinal directions.
|
||||
\ingroup cs
|
||||
\details They are used in the dms-class. When specified by the library user,
|
||||
north/east/south/west is, in general, enough. When parsed or received by an algorithm,
|
||||
the user knows it it is lat/long but not more
|
||||
*/
|
||||
enum cd_selector
|
||||
{
|
||||
/*cd_none, */
|
||||
north,
|
||||
east,
|
||||
south,
|
||||
west,
|
||||
cd_lat,
|
||||
cd_lon
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Utility class to assign poinst with degree,minute,second
|
||||
\ingroup cs
|
||||
\note Normally combined with latitude and longitude classes
|
||||
\tparam CardinalDir selects if it is north/south/west/east
|
||||
\tparam coordinate value, double/float
|
||||
\par Example:
|
||||
Example showing how to use the dms class
|
||||
\dontinclude doxygen_1.cpp
|
||||
\skip example_dms
|
||||
\line {
|
||||
\until }
|
||||
*/
|
||||
template <cd_selector CardinalDir, typename T = double>
|
||||
class dms
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructs with a value
|
||||
inline explicit dms(T v)
|
||||
: m_value(v)
|
||||
{}
|
||||
|
||||
/// Constructs with a degree, minute, optional second
|
||||
inline explicit dms(int d, int m, T s = 0.0)
|
||||
{
|
||||
double v = ((CardinalDir == west || CardinalDir == south) ? -1.0 : 1.0)
|
||||
* (double(d) + (m / 60.0) + (s / 3600.0));
|
||||
|
||||
m_value = boost::numeric_cast<T>(v);
|
||||
}
|
||||
|
||||
// Prohibit automatic conversion to T
|
||||
// because this would enable lon(dms<south>)
|
||||
// inline operator T() const { return m_value; }
|
||||
|
||||
/// Explicit conversion to T (double/float)
|
||||
inline const T& as_value() const
|
||||
{
|
||||
return m_value;
|
||||
}
|
||||
|
||||
/// Get degrees as integer, minutes as integer, seconds as double.
|
||||
inline void get_dms(int& d, int& m, double& s,
|
||||
bool& positive, char& cardinal) const
|
||||
{
|
||||
double value = m_value;
|
||||
|
||||
// Set to normal earth latlong coordinates
|
||||
while (value < -180)
|
||||
{
|
||||
value += 360;
|
||||
}
|
||||
while (value > 180)
|
||||
{
|
||||
value -= 360;
|
||||
}
|
||||
// Make positive and indicate this
|
||||
positive = value > 0;
|
||||
|
||||
// Todo: we might implement template/specializations here
|
||||
// Todo: if it is "west" and "positive", make east? or keep minus sign then?
|
||||
|
||||
cardinal = ((CardinalDir == cd_lat && positive) ? 'N'
|
||||
: (CardinalDir == cd_lat && !positive) ? 'S'
|
||||
: (CardinalDir == cd_lon && positive) ? 'E'
|
||||
: (CardinalDir == cd_lon && !positive) ? 'W'
|
||||
: (CardinalDir == east) ? 'E'
|
||||
: (CardinalDir == west) ? 'W'
|
||||
: (CardinalDir == north) ? 'N'
|
||||
: (CardinalDir == south) ? 'S'
|
||||
: ' ');
|
||||
|
||||
value = std::fabs(value);
|
||||
|
||||
// Calculate the values
|
||||
double fraction = 0;
|
||||
double integer = 0;
|
||||
fraction = std::modf(value, &integer);
|
||||
d = int(integer);
|
||||
s = 60.0 * std::modf(fraction * 60.0, &integer);
|
||||
m = int(integer);
|
||||
}
|
||||
|
||||
/// Get degrees, minutes, seconds as a string, separators can be specified optionally
|
||||
inline std::string get_dms(const std::string& ds = " ",
|
||||
const std::string& ms = "'",
|
||||
const std::string& ss = "\"") const
|
||||
{
|
||||
double s = 0;
|
||||
int d = 0;
|
||||
int m = 0;
|
||||
bool positive = false;
|
||||
char cardinal = 0;
|
||||
get_dms(d, m, s, positive, cardinal);
|
||||
std::ostringstream out;
|
||||
out << d << ds << m << ms << s << ss << " " << cardinal;
|
||||
|
||||
return out.str();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
T m_value;
|
||||
};
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
/*!
|
||||
\brief internal base class for latitude and longitude classes
|
||||
\details The latitude longitude classes define different types for lat and lon. This is convenient
|
||||
to construct latlong class without ambiguity.
|
||||
\note It is called graticule, after <em>"This latitude/longitude "webbing" is known as the common
|
||||
graticule" (http://en.wikipedia.org/wiki/Geographic_coordinate_system)</em>
|
||||
\tparam S latitude/longitude
|
||||
\tparam T coordinate type, double float or int
|
||||
*/
|
||||
template <typename T>
|
||||
class graticule
|
||||
{
|
||||
public:
|
||||
|
||||
// TODO: Pass 'v' by const-ref
|
||||
inline explicit graticule(T v) : m_v(v) {}
|
||||
inline operator T() const { return m_v; }
|
||||
|
||||
private:
|
||||
|
||||
T m_v;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
/*!
|
||||
\brief Utility class to assign points with latitude value (north/south)
|
||||
\ingroup cs
|
||||
\tparam T coordinate type, double / float
|
||||
\note Often combined with dms class
|
||||
*/
|
||||
template <typename T = double>
|
||||
class latitude : public detail::graticule<T>
|
||||
{
|
||||
public:
|
||||
|
||||
/// Can be constructed with a value
|
||||
inline explicit latitude(T v)
|
||||
: detail::graticule<T>(v)
|
||||
{}
|
||||
|
||||
/// Can be constructed with a NORTH dms-class
|
||||
inline explicit latitude(const dms<north,T>& v)
|
||||
: detail::graticule<T>(v.as_value())
|
||||
{}
|
||||
|
||||
/// Can be constructed with a SOUTH dms-class
|
||||
inline explicit latitude(const dms<south,T>& v)
|
||||
: detail::graticule<T>(v.as_value())
|
||||
{}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Utility class to assign points with longitude value (west/east)
|
||||
\ingroup cs
|
||||
\tparam T coordinate type, double / float
|
||||
\note Often combined with dms class
|
||||
*/
|
||||
template <typename T = double>
|
||||
class longitude : public detail::graticule<T>
|
||||
{
|
||||
public:
|
||||
|
||||
/// Can be constructed with a value
|
||||
inline explicit longitude(T v)
|
||||
: detail::graticule<T>(v)
|
||||
{}
|
||||
|
||||
/// Can be constructed with a WEST dms-class
|
||||
inline explicit longitude(const dms<west, T>& v)
|
||||
: detail::graticule<T>(v.as_value())
|
||||
{}
|
||||
|
||||
/// Can be constructed with an EAST dms-class
|
||||
inline explicit longitude(const dms<east, T>& v)
|
||||
: detail::graticule<T>(v.as_value())
|
||||
{}
|
||||
};
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_EXTENSIONS_GIS_LATLONG_DETAIL_GRATICULE_HPP
|
||||
41
include/boost/geometry/extensions/gis/latlong/latlong.hpp
Normal file
41
include/boost/geometry/extensions/gis/latlong/latlong.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_LATLONG_HPP
|
||||
#define BOOST_GEOMETRY_LATLONG_HPP
|
||||
|
||||
// Predeclare common Cartesian 3D points for convenience
|
||||
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/extensions/gis/latlong/point_ll.hpp>
|
||||
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/andoyer.hpp>
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/vincenty.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
typedef point_ll<double, cs::geographic<degree> > point_ll_deg;
|
||||
typedef linestring<point_ll_deg> linestring_ll_deg;
|
||||
typedef linear_ring<point_ll_deg> ring_ll_deg;
|
||||
typedef polygon<point_ll_deg> polygon_ll_deg;
|
||||
typedef box<point_ll_deg> box_ll_deg;
|
||||
typedef segment<point_ll_deg> segment_ll_deg;
|
||||
|
||||
typedef point_ll<double, cs::geographic<radian> > point_ll_rad;
|
||||
typedef linestring<point_ll_rad> linestring_ll_rad;
|
||||
typedef linear_ring<point_ll_rad> ring_ll_rad;
|
||||
typedef polygon<point_ll_rad> polygon_ll_rad;
|
||||
typedef box<point_ll_rad> box_ll_rad;
|
||||
typedef segment<point_ll_rad> segment_ll_rad;
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_LATLONG_HPP
|
||||
192
include/boost/geometry/extensions/gis/latlong/point_ll.hpp
Normal file
192
include/boost/geometry/extensions/gis/latlong/point_ll.hpp
Normal file
@@ -0,0 +1,192 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_GEOMETRIES_POINT_LL_HPP
|
||||
#define BOOST_GEOMETRY_GEOMETRIES_POINT_LL_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
|
||||
#include <boost/geometry/core/cs.hpp>
|
||||
#include <boost/geometry/arithmetic/arithmetic.hpp>
|
||||
#include <boost/geometry/geometries/point.hpp>
|
||||
#include <boost/geometry/util/copy.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/latlong/detail/graticule.hpp>
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
/*!
|
||||
\brief Point using spherical coordinates \a lat and \a lon, on Earth
|
||||
\ingroup Geometry
|
||||
\details The point_ll class implements a point with lat and lon functions.
|
||||
It can be constructed using latitude and longitude classes. The latlong
|
||||
class can be defined in degrees or in radians. There is a conversion method
|
||||
from degree to radian, and from radian to degree.
|
||||
\tparam T coordinate type, double (the default) or float
|
||||
(it might be int as well)
|
||||
\tparam C coordinate system, optional, should includes degree/radian
|
||||
indication, defaults to geographic<degree>
|
||||
\tparam D dimensions, optional, defaults to 2
|
||||
\note There is NO constructor with two values to avoid
|
||||
exchanging lat and long
|
||||
\note Construction with latitude and longitude can be done in both orders,
|
||||
so lat/long and long/lat
|
||||
\par Example:
|
||||
Example showing how the point_ll class can be constructed. Note that it
|
||||
can also be constructed using
|
||||
decimal degrees (43.123).
|
||||
\dontinclude doxygen_1.cpp
|
||||
\skip example_point_ll_construct
|
||||
\line {
|
||||
\until }
|
||||
*/
|
||||
template
|
||||
<
|
||||
typename T = double,
|
||||
typename C = cs::geographic<degree>,
|
||||
std::size_t D = 2
|
||||
>
|
||||
class point_ll : public point<T, D, C>
|
||||
{
|
||||
public:
|
||||
|
||||
/// Default constructor, does not initialize anything
|
||||
inline point_ll() : point<T, D, C>() {}
|
||||
|
||||
/// Constructor with longitude/latitude
|
||||
inline point_ll(longitude<T> const& lo, latitude<T> const& la)
|
||||
: point<T, D, C>(lo, la) {}
|
||||
|
||||
/// Constructor with latitude/longitude
|
||||
inline point_ll(latitude<T> const& la, longitude<T> const& lo)
|
||||
: point<T, D, C>(lo, la) {}
|
||||
|
||||
/// Get longitude
|
||||
inline T const& lon() const { return this->template get<0>(); }
|
||||
/// Get latitude
|
||||
inline T const& lat() const { return this->template get<1>(); }
|
||||
|
||||
/// Set longitude
|
||||
inline void lon(T const& v) { this->template set<0>(v); }
|
||||
/// Set latitude
|
||||
inline void lat(T const& v) { this->template set<1>(v); }
|
||||
|
||||
/// Set longitude using dms class
|
||||
inline void lon(dms<east, T> const& v)
|
||||
{
|
||||
this->template set<0>(v.as_value());
|
||||
}
|
||||
inline void lon(dms<west, T> const& v)
|
||||
{
|
||||
this->template set<0>(v.as_value());
|
||||
}
|
||||
|
||||
inline void lat(dms<north, T> const& v)
|
||||
{
|
||||
this->template set<1>(v.as_value());
|
||||
}
|
||||
inline void lat(dms<south, T> const& v)
|
||||
{
|
||||
this->template set<1>(v.as_value());
|
||||
}
|
||||
};
|
||||
|
||||
// Adapt the point_ll to the concept
|
||||
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
namespace traits
|
||||
{
|
||||
|
||||
template
|
||||
<
|
||||
typename CoordinateType,
|
||||
typename CoordinateSystem,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct tag<point_ll<CoordinateType, CoordinateSystem, DimensionCount> >
|
||||
{
|
||||
typedef point_tag type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename CoordinateType,
|
||||
typename CoordinateSystem,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct coordinate_type
|
||||
<
|
||||
point_ll<CoordinateType, CoordinateSystem, DimensionCount>
|
||||
>
|
||||
{
|
||||
typedef CoordinateType type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename CoordinateType,
|
||||
typename CoordinateSystem,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct coordinate_system
|
||||
<
|
||||
point_ll<CoordinateType, CoordinateSystem, DimensionCount>
|
||||
>
|
||||
{
|
||||
typedef CoordinateSystem type;
|
||||
};
|
||||
|
||||
template
|
||||
<
|
||||
typename CoordinateType,
|
||||
typename CoordinateSystem,
|
||||
std::size_t DimensionCount
|
||||
>
|
||||
struct dimension
|
||||
<
|
||||
point_ll<CoordinateType, CoordinateSystem, DimensionCount>
|
||||
>
|
||||
: boost::mpl::int_<DimensionCount>
|
||||
{};
|
||||
|
||||
template
|
||||
<
|
||||
typename CoordinateType,
|
||||
typename CoordinateSystem,
|
||||
std::size_t DimensionCount,
|
||||
std::size_t Dimension
|
||||
>
|
||||
struct access
|
||||
<
|
||||
point_ll<CoordinateType, CoordinateSystem, DimensionCount>, Dimension
|
||||
>
|
||||
{
|
||||
static inline CoordinateType get(
|
||||
point_ll<CoordinateType, CoordinateSystem, DimensionCount> const& p)
|
||||
{
|
||||
return p.template get<Dimension>();
|
||||
}
|
||||
|
||||
static inline void set(
|
||||
point_ll<CoordinateType, CoordinateSystem, DimensionCount>& p,
|
||||
CoordinateType const& value)
|
||||
{
|
||||
p.template set<Dimension>(value);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace traits
|
||||
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
#endif // BOOST_GEOMETRY_GEOMETRIES_POINT_LL_HPP
|
||||
3566
include/boost/geometry/extensions/gis/projections/epsg.hpp
Normal file
3566
include/boost/geometry/extensions/gis/projections/epsg.hpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,40 @@
|
||||
#ifndef _PROJECTIONS_EPSG_TRAITS_HPP
|
||||
#define _PROJECTIONS_EPSG_TRAITS_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
/*!
|
||||
\brief EPSG traits
|
||||
\details With help of the EPSG traits library users can statically use projections
|
||||
or coordinate systems specifying an EPSG code. The correct projections for transformations
|
||||
are used automically then, still keeping static polymorphism.
|
||||
\ingroup projection
|
||||
\tparam EPSG epsg code
|
||||
\tparam LL latlong point type
|
||||
\tparam XY xy point type
|
||||
\tparam PAR parameter type, normally not specified
|
||||
*/
|
||||
template <size_t EPSG, typename LLR, typename XY, typename PAR = parameters>
|
||||
struct epsg_traits
|
||||
{
|
||||
// Specializations define:
|
||||
// - type to get projection type
|
||||
// - function par to get parameters
|
||||
};
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
|
||||
242
include/boost/geometry/extensions/gis/projections/factory.hpp
Normal file
242
include/boost/geometry/extensions/gis/projections/factory.hpp
Normal file
@@ -0,0 +1,242 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_PROJECTIONS_FACTORY_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/parameters.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/aea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/aeqd.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/airy.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/aitoff.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/august.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/bacon.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/bipc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/boggs.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/bonne.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/cass.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/cc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/cea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/chamb.hpp> // control points XY
|
||||
#include <boost/geometry/extensions/gis/projections/proj/collg.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/crast.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/denoy.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eck1.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eck2.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eck3.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eck4.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eck5.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eqc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/eqdc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/fahey.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/fouc_s.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/gall.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/geocent.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/geos.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/gins8.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/gnom.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/goode.hpp> // includes two other projections
|
||||
#include <boost/geometry/extensions/gis/projections/proj/gstmerc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/hammer.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/hatano.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/krovak.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/imw_p.hpp> // xy functions after inverse
|
||||
#include <boost/geometry/extensions/gis/projections/proj/laea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/labrd.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/lagrng.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/larr.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/lask.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/latlong.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/lcc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/lcca.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/loxim.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/lsat.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/mbtfpp.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/mbtfpq.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/mbt_fps.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/merc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/mill.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/mod_ster.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/moll.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/nell.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/nell_h.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/nocol.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/nsper.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/nzmg.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/ob_tran.hpp> // includes other projection
|
||||
#include <boost/geometry/extensions/gis/projections/proj/ocea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/oea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/omerc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/ortho.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/poly.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/putp2.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/putp3.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/putp4p.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/putp5.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/putp6.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/robin.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/rouss.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/rpoly.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/sconics.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/somerc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/stere.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/sterea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/sts.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/tcc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/tcea.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/tmerc.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/tpeqd.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/urm5.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/urmfps.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/vandg.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/vandg2.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/vandg4.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/wag2.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/wag3.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/wag7.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/wink1.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/wink2.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
|
||||
template <typename LatLong, typename Cartesian, typename Parameters = parameters>
|
||||
class factory : public detail::base_factory<LatLong, Cartesian, Parameters>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef std::map<std::string, boost::shared_ptr<detail::factory_entry<LatLong, Cartesian, Parameters> > > prj_registry;
|
||||
prj_registry m_registry;
|
||||
|
||||
public:
|
||||
|
||||
factory()
|
||||
{
|
||||
detail::aea_init(*this);
|
||||
detail::aeqd_init(*this);
|
||||
detail::airy_init(*this);
|
||||
detail::aitoff_init(*this);
|
||||
detail::august_init(*this);
|
||||
detail::bacon_init(*this);
|
||||
detail::bipc_init(*this);
|
||||
detail::boggs_init(*this);
|
||||
detail::bonne_init(*this);
|
||||
detail::cass_init(*this);
|
||||
detail::cc_init(*this);
|
||||
detail::cea_init(*this);
|
||||
detail::chamb_init(*this);
|
||||
detail::collg_init(*this);
|
||||
detail::crast_init(*this);
|
||||
detail::denoy_init(*this);
|
||||
detail::eck1_init(*this);
|
||||
detail::eck2_init(*this);
|
||||
detail::eck3_init(*this);
|
||||
detail::eck4_init(*this);
|
||||
detail::eck5_init(*this);
|
||||
detail::eqc_init(*this);
|
||||
detail::eqdc_init(*this);
|
||||
detail::fahey_init(*this);
|
||||
detail::fouc_s_init(*this);
|
||||
detail::gall_init(*this);
|
||||
detail::geocent_init(*this);
|
||||
detail::geos_init(*this);
|
||||
detail::gins8_init(*this);
|
||||
detail::gn_sinu_init(*this);
|
||||
detail::gnom_init(*this);
|
||||
detail::goode_init(*this);
|
||||
detail::gstmerc_init(*this);
|
||||
detail::hammer_init(*this);
|
||||
detail::hatano_init(*this);
|
||||
detail::krovak_init(*this);
|
||||
detail::imw_p_init(*this);
|
||||
detail::labrd_init(*this);
|
||||
detail::laea_init(*this);
|
||||
detail::lagrng_init(*this);
|
||||
detail::larr_init(*this);
|
||||
detail::lask_init(*this);
|
||||
detail::latlong_init(*this);
|
||||
detail::lcc_init(*this);
|
||||
detail::lcca_init(*this);
|
||||
detail::loxim_init(*this);
|
||||
detail::lsat_init(*this);
|
||||
detail::mbtfpp_init(*this);
|
||||
detail::mbtfpq_init(*this);
|
||||
detail::mbt_fps_init(*this);
|
||||
detail::merc_init(*this);
|
||||
detail::mill_init(*this);
|
||||
detail::mod_ster_init(*this);
|
||||
detail::moll_init(*this);
|
||||
detail::nell_init(*this);
|
||||
detail::nell_h_init(*this);
|
||||
detail::nocol_init(*this);
|
||||
detail::nsper_init(*this);
|
||||
detail::nzmg_init(*this);
|
||||
detail::ob_tran_init(*this);
|
||||
detail::ocea_init(*this);
|
||||
detail::oea_init(*this);
|
||||
detail::omerc_init(*this);
|
||||
detail::ortho_init(*this);
|
||||
detail::poly_init(*this);
|
||||
detail::putp2_init(*this);
|
||||
detail::putp3_init(*this);
|
||||
detail::putp4p_init(*this);
|
||||
detail::putp5_init(*this);
|
||||
detail::putp6_init(*this);
|
||||
detail::robin_init(*this);
|
||||
detail::rouss_init(*this);
|
||||
detail::rpoly_init(*this);
|
||||
detail::sconics_init(*this);
|
||||
detail::somerc_init(*this);
|
||||
detail::stere_init(*this);
|
||||
detail::sterea_init(*this);
|
||||
detail::sts_init(*this);
|
||||
detail::tcc_init(*this);
|
||||
detail::tcea_init(*this);
|
||||
detail::tmerc_init(*this);
|
||||
detail::tpeqd_init(*this);
|
||||
detail::urm5_init(*this);
|
||||
detail::urmfps_init(*this);
|
||||
detail::vandg_init(*this);
|
||||
detail::vandg2_init(*this);
|
||||
detail::vandg4_init(*this);
|
||||
detail::wag2_init(*this);
|
||||
detail::wag3_init(*this);
|
||||
detail::wag7_init(*this);
|
||||
detail::wink1_init(*this);
|
||||
detail::wink2_init(*this);
|
||||
}
|
||||
|
||||
virtual ~factory() {}
|
||||
|
||||
virtual void add_to_factory(const std::string& name, detail::factory_entry<LatLong, Cartesian, Parameters>* sub)
|
||||
{
|
||||
m_registry[name].reset(sub);
|
||||
}
|
||||
|
||||
inline projection<LatLong, Cartesian>* create_new(const Parameters& parameters)
|
||||
{
|
||||
typename prj_registry::iterator it = m_registry.find(parameters.name);
|
||||
if (it != m_registry.end())
|
||||
{
|
||||
return it->second->create_new(parameters);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_FACTORY_HPP
|
||||
@@ -0,0 +1,96 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace aasincos
|
||||
{
|
||||
static const double ONE_TOL= 1.00000000000001;
|
||||
//static const double TOL = 0.000000001;
|
||||
static const double ATOL = 1e-50;
|
||||
}
|
||||
|
||||
inline double aasin(double v)
|
||||
{
|
||||
double av = 0;
|
||||
|
||||
if ((av = std::fabs(v)) >= 1.0)
|
||||
{
|
||||
if (av > aasincos::ONE_TOL)
|
||||
{
|
||||
throw proj_exception(-19);
|
||||
}
|
||||
return (v < 0.0 ? -HALFPI : HALFPI);
|
||||
}
|
||||
|
||||
return std::asin(v);
|
||||
}
|
||||
|
||||
inline double aacos(double v)
|
||||
{
|
||||
double av = 0;
|
||||
|
||||
if ((av = std::fabs(v)) >= 1.0)
|
||||
{
|
||||
if (av > aasincos::ONE_TOL)
|
||||
{
|
||||
throw proj_exception(-19);
|
||||
}
|
||||
return (v < 0.0 ? PI : 0.0);
|
||||
}
|
||||
|
||||
return acos(v);
|
||||
}
|
||||
|
||||
inline double asqrt(double v)
|
||||
{
|
||||
return ((v <= 0) ? 0. : std::sqrt(v));
|
||||
}
|
||||
|
||||
inline double aatan2(double n, double d)
|
||||
{
|
||||
return ((std::fabs(n) < aasincos::ATOL && std::fabs(d) < aasincos::ATOL) ? 0.0 : std::atan2(n, d));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_AASINCOS_HPP
|
||||
@@ -0,0 +1,68 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/* reduce argument to range +/- PI */
|
||||
inline double adjlon (double lon)
|
||||
{
|
||||
static const double SPI = 3.14159265359;
|
||||
static const double TWOPI = 6.2831853071795864769;
|
||||
static const double ONEPI = 3.14159265358979323846;
|
||||
|
||||
if (std::fabs(lon) <= SPI)
|
||||
{
|
||||
return lon;
|
||||
}
|
||||
|
||||
lon += ONEPI; /* adjust to 0..2pi rad */
|
||||
lon -= TWOPI * std::floor(lon / TWOPI); /* remove integral # of 'revolutions'*/
|
||||
lon -= ONEPI; /* adjust back to -pi..pi rad */
|
||||
|
||||
return lon;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_ADJLON_HPP
|
||||
@@ -0,0 +1,105 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_PROJECTIONS_IMPL_BASE_DYNAMIC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_DYNAMIC_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/projection.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Base-virtual-forward
|
||||
template <typename C, typename LL, typename XY, typename P>
|
||||
class base_v_f : public projection<LL, XY>
|
||||
{
|
||||
protected:
|
||||
|
||||
typedef typename projection<LL, XY>::LL_T LL_T;
|
||||
typedef typename projection<LL, XY>::XY_T XY_T;
|
||||
|
||||
public:
|
||||
|
||||
base_v_f(const P& params) : m_proj(params) {}
|
||||
|
||||
virtual P params() const {return m_proj.params();}
|
||||
|
||||
virtual bool forward(const LL& ll, XY& xy) const
|
||||
{
|
||||
return m_proj.forward(ll, xy);
|
||||
}
|
||||
|
||||
virtual void fwd(LL_T& lp_lon, LL_T& lp_lat, XY_T& xy_x, XY_T& xy_y) const
|
||||
{
|
||||
m_proj.fwd(lp_lon, lp_lat, xy_x, xy_y);
|
||||
}
|
||||
|
||||
virtual bool inverse(const XY& xy, LL& 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
|
||||
{
|
||||
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?
|
||||
}
|
||||
|
||||
virtual std::string name() const
|
||||
{
|
||||
return m_proj.name();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
C m_proj;
|
||||
};
|
||||
|
||||
// Base-virtual-forward/inverse
|
||||
template <typename C, typename LL, typename XY, typename P>
|
||||
class base_v_fi : public base_v_f<C, LL, XY, P>
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename base_v_f<C, LL, XY, P>::LL_T LL_T;
|
||||
typedef typename base_v_f<C, LL, XY, P>::XY_T XY_T;
|
||||
|
||||
public :
|
||||
|
||||
base_v_fi(const P& params) : base_v_f<C, LL, XY, P>(params) {}
|
||||
|
||||
virtual bool inverse(const XY& xy, LL& ll) const
|
||||
{
|
||||
return this->m_proj.inverse(xy, ll);
|
||||
}
|
||||
|
||||
void inv(XY_T& xy_x, XY_T& xy_y, LL_T& lp_lon, LL_T& lp_lat) const
|
||||
{
|
||||
this->m_proj.inv(xy_x, xy_y, lp_lon, lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_DYNAMIC_HPP
|
||||
@@ -0,0 +1,108 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_PROJECTIONS_IMPL_BASE_STATIC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
// For CRTP, *this is acceptable in constructor -> turn warning off
|
||||
#pragma warning( disable : 4355 )
|
||||
#endif // defined(_MSC_VER)
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_fwd.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_inv.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Base-template-forward
|
||||
template <typename Prj, typename LL, typename XY, typename P>
|
||||
struct base_t_f
|
||||
{
|
||||
public:
|
||||
|
||||
inline base_t_f(const Prj& prj, const P& params)
|
||||
: m_par(params), m_prj(prj)
|
||||
{}
|
||||
|
||||
inline P params() const {return m_par;}
|
||||
|
||||
inline bool forward(const LL& lp, XY& xy) const
|
||||
{
|
||||
try
|
||||
{
|
||||
pj_fwd(m_prj, m_par, lp, xy);
|
||||
return true;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string name() const
|
||||
{
|
||||
return this->m_par.name;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
// Some projections do not work with float -> wrong results
|
||||
// TODO: make traits which select <double> from int/float/double and else selects T
|
||||
|
||||
//typedef typename geometry::coordinate_type<LL>::type LL_T;
|
||||
//typedef typename geometry::coordinate_type<XY>::type XY_T;
|
||||
typedef double LL_T;
|
||||
typedef double XY_T;
|
||||
|
||||
P m_par;
|
||||
const Prj& m_prj;
|
||||
};
|
||||
|
||||
// Base-template-forward/inverse
|
||||
template <typename Prj, typename LL, typename XY, typename P>
|
||||
struct base_t_fi : public base_t_f<Prj, LL, XY, P>
|
||||
{
|
||||
public :
|
||||
inline base_t_fi(const Prj& prj, const P& params)
|
||||
: base_t_f<Prj, LL, XY, P>(prj, params)
|
||||
{}
|
||||
|
||||
inline bool inverse(const XY& xy, LL& lp) const
|
||||
{
|
||||
try
|
||||
{
|
||||
pj_inv(this->m_prj, this->m_par, xy, lp);
|
||||
return true;
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_BASE_STATIC_HPP
|
||||
@@ -0,0 +1,41 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_PROJECTIONS_IMPL_FACTORY_ENTRY_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_FACTORY_ENTRY_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/projection.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
template <typename LL, typename XY, typename P>
|
||||
class factory_entry
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~factory_entry() {}
|
||||
virtual projection<LL, XY>* create_new(const P& par) const = 0;
|
||||
};
|
||||
|
||||
template <typename LL, typename XY, typename P>
|
||||
class base_factory
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~base_factory() {}
|
||||
virtual void add_to_factory(const std::string& name, factory_entry<LL, XY, P>* sub) = 0;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_FACTORY_ENTRY_HPP
|
||||
@@ -0,0 +1,34 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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_PROJECTIONS_IMPL_FUNCTION_OVERLOADS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_FUNCTION_OVERLOADS_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
// Functions to resolve ambiguity when compiling with coordinates of different types
|
||||
/*inline double atan2(double a, double b)
|
||||
{
|
||||
return std::atan2(a, b);
|
||||
}
|
||||
inline double pow(double a, double b)
|
||||
{
|
||||
return std::pow(a, b);
|
||||
}
|
||||
*/
|
||||
|
||||
inline int int_floor(double f)
|
||||
{
|
||||
return int(std::floor(f));
|
||||
}
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_FUNCTION_OVERLOADS_HPP
|
||||
@@ -0,0 +1,85 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_AUTH_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_AUTH_HPP
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
static const double P00 = .33333333333333333333;
|
||||
static const double P01 = .17222222222222222222;
|
||||
static const double P02 = .10257936507936507936;
|
||||
static const double P10 = .06388888888888888888;
|
||||
static const double P11 = .06640211640211640211;
|
||||
static const double P20 = .01641501294219154443;
|
||||
static const int APA_SIZE = 3;
|
||||
|
||||
/* determine latitude from authalic latitude */
|
||||
inline void pj_authset(double es, double* APA)
|
||||
{
|
||||
assert(0 != APA);
|
||||
|
||||
double t = 0;
|
||||
|
||||
// if (APA = (double *)pj_malloc(APA_SIZE * sizeof(double)))
|
||||
{
|
||||
APA[0] = es * P00;
|
||||
t = es * es;
|
||||
APA[0] += t * P01;
|
||||
APA[1] = t * P10;
|
||||
t *= es;
|
||||
APA[0] += t * P02;
|
||||
APA[1] += t * P11;
|
||||
APA[2] = t * P20;
|
||||
}
|
||||
}
|
||||
|
||||
inline double pj_authlat(double beta, const double* APA)
|
||||
{
|
||||
assert(0 != APA);
|
||||
|
||||
const double t = beta + beta;
|
||||
|
||||
return(beta + APA[0] * std::sin(t) + APA[1] * std::sin(t + t) + APA[2] * std::sin(t + t + t));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_AUTH_HPP
|
||||
@@ -0,0 +1,167 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUM_SET_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUM_SET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_datums.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_param.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/parameters.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
/* SEC_TO_RAD = Pi/180/3600 */
|
||||
const double SEC_TO_RAD = 4.84813681109535993589914102357e-6;
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_datum_set() */
|
||||
/************************************************************************/
|
||||
|
||||
inline void pj_datum_set(std::vector<pvalue>& pvalues, parameters& projdef)
|
||||
{
|
||||
std::string name, towgs84, nadgrids;
|
||||
|
||||
projdef.datum_type = PJD_UNKNOWN;
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Is there a datum definition in the parameter list? If so, */
|
||||
/* add the defining values to the parameter list. Note that */
|
||||
/* this will append the ellipse definition as well as the */
|
||||
/* towgs84= and related parameters. It should also be pointed */
|
||||
/* out that the addition is permanent rather than temporary */
|
||||
/* like most other keyword expansion so that the ellipse */
|
||||
/* definition will last into the pj_ell_set() function called */
|
||||
/* after this one. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
name = pj_param(pvalues, "sdatum").s;
|
||||
if(! name.empty())
|
||||
{
|
||||
/* find the datum definition */
|
||||
const int n = sizeof(pj_datums) / sizeof(pj_datums[0]);
|
||||
int index = -1;
|
||||
for (int i = 0; i < n && index == -1; i++)
|
||||
{
|
||||
if(pj_datums[i].id == name)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1)
|
||||
{
|
||||
throw proj_exception(-9);
|
||||
}
|
||||
|
||||
if(! pj_datums[index].ellipse_id.empty())
|
||||
{
|
||||
std::string entry("ellps=");
|
||||
entry +=pj_datums[index].ellipse_id;
|
||||
pvalues.push_back(pj_mkparam(entry));
|
||||
}
|
||||
|
||||
if(! pj_datums[index].defn.empty())
|
||||
{
|
||||
pvalues.push_back(pj_mkparam(pj_datums[index].defn));
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Check for nadgrids parameter. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
nadgrids = pj_param(pvalues, "snadgrids").s;
|
||||
towgs84 = pj_param(pvalues, "stowgs84").s;
|
||||
if(! nadgrids.empty())
|
||||
{
|
||||
/* We don't actually save the value separately. It will continue
|
||||
to exist int he param list for use in pj_apply_gridshift.c */
|
||||
|
||||
projdef.datum_type = PJD_GRIDSHIFT;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/* Check for towgs84 parameter. */
|
||||
/* -------------------------------------------------------------------- */
|
||||
else if(! towgs84.empty())
|
||||
{
|
||||
int parm_count = 0;
|
||||
|
||||
int n = sizeof(projdef.datum_params) / sizeof(projdef.datum_params[0]);
|
||||
|
||||
/* parse out the pvalues */
|
||||
std::vector<std::string> parm;
|
||||
boost::split(parm, towgs84, boost::is_any_of(" ,"));
|
||||
for (std::vector<std::string>::const_iterator it = parm.begin();
|
||||
it != parm.end() && parm_count < n;
|
||||
++it)
|
||||
{
|
||||
projdef.datum_params[parm_count++] = atof(it->c_str());
|
||||
}
|
||||
|
||||
if( projdef.datum_params[3] != 0.0
|
||||
|| projdef.datum_params[4] != 0.0
|
||||
|| projdef.datum_params[5] != 0.0
|
||||
|| projdef.datum_params[6] != 0.0 )
|
||||
{
|
||||
projdef.datum_type = PJD_7PARAM;
|
||||
|
||||
/* transform from arc seconds to radians */
|
||||
projdef.datum_params[3] *= SEC_TO_RAD;
|
||||
projdef.datum_params[4] *= SEC_TO_RAD;
|
||||
projdef.datum_params[5] *= SEC_TO_RAD;
|
||||
/* transform from parts per million to scaling factor */
|
||||
projdef.datum_params[6] =
|
||||
(projdef.datum_params[6]/1000000.0) + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
projdef.datum_type = PJD_3PARAM;
|
||||
}
|
||||
|
||||
/* Note that pj_init() will later switch datum_type to
|
||||
PJD_WGS84 if shifts are all zero, and ellipsoid is WGS84 or GRS80 */
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUM_SET_HPP
|
||||
@@ -0,0 +1,106 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/*
|
||||
* The ellipse code must match one from pj_ellps.c. The datum id should
|
||||
* be kept to 12 characters or less if possible. Use the official OGC
|
||||
* datum name for the comments if available.
|
||||
*/
|
||||
|
||||
static const PJ_DATUMS pj_datums[] =
|
||||
{
|
||||
/* id definition ellipse comments */
|
||||
/* -- ---------- ------- -------- */
|
||||
{ "WGS84", "towgs84=0,0,0", "WGS84", "" },
|
||||
|
||||
{ "GGRS87", "towgs84=-199.87,74.79,246.62",
|
||||
"GRS80", "Greek_Geodetic_Reference_System_1987" },
|
||||
|
||||
{ "NAD83", "towgs84=0,0,0", "GRS80","North_American_Datum_1983" },
|
||||
|
||||
{ "NAD27", "nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",
|
||||
"clrk66", "North_American_Datum_1927" },
|
||||
|
||||
{ "potsdam", "towgs84=606.0,23.0,413.0",
|
||||
"bessel", "Potsdam Rauenberg 1950 DHDN" },
|
||||
|
||||
{ "carthage", "towgs84=-263.0,6.0,431.0",
|
||||
"clark80", "Carthage 1934 Tunisia" },
|
||||
|
||||
{ "hermannskogel", "towgs84=653.0,-212.0,449.0",
|
||||
"bessel", "Hermannskogel" },
|
||||
|
||||
{ "ire65", "towgs84=482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",
|
||||
"mod_airy", "Ireland 1965" },
|
||||
|
||||
{ "nzgd49", "towgs84=59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",
|
||||
"intl", "New Zealand Geodetic Datum 1949" },
|
||||
|
||||
{ "OSGB36", "towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",
|
||||
"airy", "Airy 1830" }
|
||||
};
|
||||
|
||||
|
||||
static const PJ_PRIME_MERIDIANS pj_prime_meridians[] =
|
||||
{
|
||||
/* id definition */
|
||||
/* -- ---------- */
|
||||
{ "greenwich", "0dE" },
|
||||
{ "lisbon", "9d07'54.862\"W" },
|
||||
{ "paris", "2d20'14.025\"E" },
|
||||
{ "bogota", "74d04'51.3\"W" },
|
||||
{ "madrid", "3d41'16.58\"W" },
|
||||
{ "rome", "12d27'8.4\"E" },
|
||||
{ "bern", "7d26'22.5\"E" },
|
||||
{ "jakarta", "106d48'27.79\"E" },
|
||||
{ "ferro", "17d40'W" },
|
||||
{ "brussels", "4d22'4.71\"E" },
|
||||
{ "stockholm", "18d3'29.8\"E" },
|
||||
{ "athens", "23d42'58.815\"E" },
|
||||
{ "oslo", "10d43'22.5\"E" }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_DATUMS_HPP
|
||||
@@ -0,0 +1,153 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_ellps.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_param.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/* set ellipsoid parameters a and es */
|
||||
static const double SIXTH = .1666666666666666667; /* 1/6 */
|
||||
static const double RA4 = .04722222222222222222; /* 17/360 */
|
||||
static const double RA6 = .02215608465608465608; /* 67/3024 */
|
||||
static const double RV4 = .06944444444444444444; /* 5/72 */
|
||||
static const double RV6 = .04243827160493827160; /* 55/1296 */
|
||||
|
||||
/* initialize geographic shape parameters */
|
||||
inline void pj_ell_set(std::vector<pvalue>& parameters, double &a, double &es)
|
||||
{
|
||||
int i = 0;
|
||||
double b = 0.0;
|
||||
double e = 0.0;
|
||||
std::string name;
|
||||
|
||||
/* check for varying forms of ellipsoid input */
|
||||
a = es = 0.;
|
||||
|
||||
/* R takes precedence */
|
||||
if (pj_param(parameters, "tR").i)
|
||||
a = pj_param(parameters, "dR").f;
|
||||
else { /* probable elliptical figure */
|
||||
|
||||
/* check if ellps present and temporarily append its values to pl */
|
||||
name = pj_param(parameters, "sellps").s;
|
||||
if (! name.empty())
|
||||
{
|
||||
const int n = sizeof(pj_ellps) / sizeof(pj_ellps[0]);
|
||||
int index = -1;
|
||||
for (int i = 0; i < n && index == -1; i++)
|
||||
{
|
||||
if(pj_ellps[i].id == name)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) { throw proj_exception(-9); }
|
||||
|
||||
parameters.push_back(pj_mkparam(pj_ellps[index].major));
|
||||
parameters.push_back(pj_mkparam(pj_ellps[index].ell));
|
||||
}
|
||||
a = pj_param(parameters, "da").f;
|
||||
if (pj_param(parameters, "tes").i) /* eccentricity squared */
|
||||
es = pj_param(parameters, "des").f;
|
||||
else if (pj_param(parameters, "te").i) { /* eccentricity */
|
||||
e = pj_param(parameters, "de").f;
|
||||
es = e * e;
|
||||
} else if (pj_param(parameters, "trf").i) { /* recip flattening */
|
||||
es = pj_param(parameters, "drf").f;
|
||||
if (!es) {
|
||||
throw proj_exception(-10);
|
||||
}
|
||||
es = 1./ es;
|
||||
es = es * (2. - es);
|
||||
} else if (pj_param(parameters, "tf").i) { /* flattening */
|
||||
es = pj_param(parameters, "df").f;
|
||||
es = es * (2. - es);
|
||||
} else if (pj_param(parameters, "tb").i) { /* minor axis */
|
||||
b = pj_param(parameters, "db").f;
|
||||
es = 1. - (b * b) / (a * a);
|
||||
} /* else es == 0. and sphere of radius a */
|
||||
if (!b)
|
||||
b = a * sqrt(1. - es);
|
||||
/* following options turn ellipsoid into equivalent sphere */
|
||||
if (pj_param(parameters, "bR_A").i) { /* sphere--area of ellipsoid */
|
||||
a *= 1. - es * (SIXTH + es * (RA4 + es * RA6));
|
||||
es = 0.;
|
||||
} else if (pj_param(parameters, "bR_V").i) { /* sphere--vol. of ellipsoid */
|
||||
a *= 1. - es * (SIXTH + es * (RV4 + es * RV6));
|
||||
es = 0.;
|
||||
} else if (pj_param(parameters, "bR_a").i) { /* sphere--arithmetic mean */
|
||||
a = .5 * (a + b);
|
||||
es = 0.;
|
||||
} else if (pj_param(parameters, "bR_g").i) { /* sphere--geometric mean */
|
||||
a = sqrt(a * b);
|
||||
es = 0.;
|
||||
} else if (pj_param(parameters, "bR_h").i) { /* sphere--harmonic mean */
|
||||
a = 2. * a * b / (a + b);
|
||||
es = 0.;
|
||||
} else if ((i = pj_param(parameters, "tR_lat_a").i) || /* sphere--arith. */
|
||||
pj_param(parameters, "tR_lat_g").i) { /* or geom. mean at latitude */
|
||||
double tmp;
|
||||
|
||||
tmp = sin(pj_param(parameters, i ? "rR_lat_a" : "rR_lat_g").f);
|
||||
if (fabs(tmp) > HALFPI) {
|
||||
throw proj_exception(-11);
|
||||
}
|
||||
tmp = 1. - es * tmp * tmp;
|
||||
a *= i ? .5 * (1. - es + tmp) / ( tmp * sqrt(tmp)) :
|
||||
sqrt(1. - es) / tmp;
|
||||
es = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
/* some remaining checks */
|
||||
if (es < 0.)
|
||||
{ throw proj_exception(-12); }
|
||||
if (a <= 0.)
|
||||
{ throw proj_exception(-13); }
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELL_SET_HPP
|
||||
@@ -0,0 +1,93 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELLPS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELLPS_HPP
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
static const PJ_ELLPS pj_ellps[] =
|
||||
{
|
||||
{ "MERIT", "a=6378137.0", "rf=298.257", "MERIT 1983" },
|
||||
{ "SGS85", "a=6378136.0", "rf=298.257", "Soviet Geodetic System 85" },
|
||||
{ "GRS80", "a=6378137.0", "rf=298.257222101", "GRS 1980(IUGG, 1980)" },
|
||||
{ "IAU76", "a=6378140.0", "rf=298.257", "IAU 1976" },
|
||||
{ "airy", "a=6377563.396", "b=6356256.910", "Airy 1830" },
|
||||
{ "APL4.9", "a=6378137.0.", "rf=298.25", "Appl. Physics. 1965" },
|
||||
{ "NWL9D", "a=6378145.0.", "rf=298.25", "Naval Weapons Lab., 1965" },
|
||||
{ "mod_airy", "a=6377340.189", "b=6356034.446", "Modified Airy" },
|
||||
{ "andrae", "a=6377104.43", "rf=300.0", "Andrae 1876 (Den., Iclnd.)" },
|
||||
{ "aust_SA", "a=6378160.0", "rf=298.25", "Australian Natl & S. Amer. 1969" },
|
||||
{ "GRS67", "a=6378160.0", "rf=298.2471674270", "GRS 67(IUGG 1967)" },
|
||||
{ "bessel", "a=6377397.155", "rf=299.1528128", "Bessel 1841" },
|
||||
{ "bess_nam", "a=6377483.865", "rf=299.1528128", "Bessel 1841 (Namibia)" },
|
||||
{ "clrk66", "a=6378206.4", "b=6356583.8", "Clarke 1866" },
|
||||
{ "clrk80", "a=6378249.145", "rf=293.4663", "Clarke 1880 mod." },
|
||||
{ "CPM", "a=6375738.7", "rf=334.29", "Comm. des Poids et Mesures 1799" },
|
||||
{ "delmbr", "a=6376428.", "rf=311.5", "Delambre 1810 (Belgium)" },
|
||||
{ "engelis", "a=6378136.05", "rf=298.2566", "Engelis 1985" },
|
||||
{ "evrst30", "a=6377276.345", "rf=300.8017", "Everest 1830" },
|
||||
{ "evrst48", "a=6377304.063", "rf=300.8017", "Everest 1948" },
|
||||
{ "evrst56", "a=6377301.243", "rf=300.8017", "Everest 1956" },
|
||||
{ "evrst69", "a=6377295.664", "rf=300.8017", "Everest 1969" },
|
||||
{ "evrstSS", "a=6377298.556", "rf=300.8017", "Everest (Sabah & Sarawak)" },
|
||||
{ "fschr60", "a=6378166.", "rf=298.3", "Fischer (Mercury Datum) 1960" },
|
||||
{ "fschr60m", "a=6378155.", "rf=298.3", "Modified Fischer 1960" },
|
||||
{ "fschr68", "a=6378150.", "rf=298.3", "Fischer 1968" },
|
||||
{ "helmert", "a=6378200.", "rf=298.3", "Helmert 1906" },
|
||||
{ "hough", "a=6378270.0", "rf=297.", "Hough" },
|
||||
{ "intl", "a=6378388.0", "rf=297.", "International 1909 (Hayford)" },
|
||||
{ "krass", "a=6378245.0", "rf=298.3", "Krassovsky, 1942" },
|
||||
{ "kaula", "a=6378163.", "rf=298.24", "Kaula 1961" },
|
||||
{ "lerch", "a=6378139.", "rf=298.257", "Lerch 1979" },
|
||||
{ "mprts", "a=6397300.", "rf=191.", "Maupertius 1738" },
|
||||
{ "new_intl", "a=6378157.5", "b=6356772.2","New International 1967" },
|
||||
{ "plessis", "a=6376523.", "b=6355863.", "Plessis 1817 (France)" },
|
||||
{ "SEasia", "a=6378155.0", "b=6356773.3205", "Southeast Asia" },
|
||||
{ "walbeck", "a=6376896.0", "b=6355834.8467", "Walbeck" },
|
||||
{ "WGS60", "a=6378165.0", "rf=298.3", "WGS 60" },
|
||||
{ "WGS66", "a=6378145.0", "rf=298.25", "WGS 66" },
|
||||
{ "WGS72", "a=6378135.0", "rf=298.26", "WGS 72" },
|
||||
{ "WGS84", "a=6378137.0", "rf=298.257223563", "WGS 84" },
|
||||
{ "sphere", "a=6370997.0", "b=6370997.0", "Normal Sphere (r=6370997)" }
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_ELLPS_HPP
|
||||
@@ -0,0 +1,96 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/adjlon.hpp>
|
||||
|
||||
/* general forward projection */
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace forwrd
|
||||
{
|
||||
static const double EPS = 1.0e-12;
|
||||
}
|
||||
|
||||
/* forward projection entry */
|
||||
template <typename Prj, typename LL, typename XY, typename P>
|
||||
inline void pj_fwd(const Prj& prj, const P& par, const LL& ll, XY& xy)
|
||||
{
|
||||
using namespace detail;
|
||||
|
||||
double lp_lon = geometry::get_as_radian<0>(ll);
|
||||
double lp_lat = geometry::get_as_radian<1>(ll);
|
||||
const double t = std::fabs(lp_lat) - HALFPI;
|
||||
|
||||
/* check for forward and latitude or longitude overange */
|
||||
if (t > forwrd::EPS || std::fabs(lp_lon) > 10.)
|
||||
{
|
||||
throw proj_exception();
|
||||
}
|
||||
|
||||
if (std::fabs(t) <= forwrd::EPS)
|
||||
{
|
||||
lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
|
||||
}
|
||||
else if (par.geoc)
|
||||
{
|
||||
lp_lat = std::atan(par.rone_es * std::tan(lp_lat));
|
||||
}
|
||||
|
||||
lp_lon -= par.lam0; /* compute del lp.lam */
|
||||
if (! par.over)
|
||||
{
|
||||
lp_lon = adjlon(lp_lon); /* post_forward del longitude */
|
||||
}
|
||||
|
||||
double x = 0;
|
||||
double y = 0;
|
||||
|
||||
prj.fwd(lp_lon, lp_lat, x, y);
|
||||
geometry::set<0>(xy, par.fr_meter * (par.a * x + par.x0));
|
||||
geometry::set<1>(xy, par.fr_meter * (par.a * y + par.y0));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_FWD_HPP
|
||||
@@ -0,0 +1,127 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GAUSS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GAUSS_HPP
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail { namespace gauss {
|
||||
|
||||
|
||||
static const int MAX_ITER = 20;
|
||||
|
||||
struct GAUSS
|
||||
{
|
||||
double C;
|
||||
double K;
|
||||
double e;
|
||||
double ratexp;
|
||||
};
|
||||
|
||||
static const double DEL_TOL = 1e-14;
|
||||
|
||||
inline double srat(double esinp, double exp)
|
||||
{
|
||||
return (std::pow((1.0 - esinp) / (1.0 + esinp), exp));
|
||||
}
|
||||
|
||||
inline GAUSS gauss_ini(double e, double phi0, double &chi, double &rc)
|
||||
{
|
||||
using std::asin;
|
||||
using std::cos;
|
||||
using std::sin;
|
||||
using std::sqrt;
|
||||
using std::tan;
|
||||
|
||||
double sphi = 0;
|
||||
double cphi = 0;
|
||||
double es = 0;
|
||||
|
||||
GAUSS en;
|
||||
es = e * e;
|
||||
en.e = e;
|
||||
sphi = sin(phi0);
|
||||
cphi = cos(phi0);
|
||||
cphi *= cphi;
|
||||
|
||||
rc = sqrt(1.0 - es) / (1.0 - es * sphi * sphi);
|
||||
en.C = sqrt(1.0 + es * cphi * cphi / (1.0 - es));
|
||||
chi = asin(sphi / en.C);
|
||||
en.ratexp = 0.5 * en.C * e;
|
||||
en.K = tan(0.5 * chi + detail::FORTPI)
|
||||
/ (pow(tan(0.5 * phi0 + detail::FORTPI), en.C) * srat(en.e * sphi, en.ratexp));
|
||||
|
||||
return en;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void gauss(const GAUSS& en, T& lam, T& phi)
|
||||
{
|
||||
phi = 2.0 * std::atan(en.K * std::pow(std::tan(0.5 * phi + FORTPI), en.C)
|
||||
* srat(en.e * std::sin(phi), en.ratexp) ) - HALFPI;
|
||||
|
||||
lam *= en.C;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void inv_gauss(const GAUSS& en, T& lam, T& phi)
|
||||
{
|
||||
lam /= en.C;
|
||||
const double num = std::pow(std::tan(0.5 * phi + FORTPI) / en.K, 1.0 / en.C);
|
||||
|
||||
int i = 0;
|
||||
for (i = MAX_ITER; i; --i)
|
||||
{
|
||||
const double elp_phi = 2.0 * std::atan(num * srat(en.e * std::sin(phi), - 0.5 * en.e)) - HALFPI;
|
||||
|
||||
if (std::fabs(elp_phi - phi) < DEL_TOL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
phi = elp_phi;
|
||||
}
|
||||
|
||||
/* convergence failed */
|
||||
if (!i)
|
||||
{
|
||||
throw proj_exception(-17);
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::gauss
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_GAUSS_HPP
|
||||
@@ -0,0 +1,294 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_INIT_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_INIT_HPP
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/range/functions.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_datum_set.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_datums.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_ell_set.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_param.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_units.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/parameters.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_init() */
|
||||
/* */
|
||||
/* Main entry point for initialing a PJ projections */
|
||||
/* definition. Note that the projection specific function is */
|
||||
/* called to do the initial allocation so it can be created */
|
||||
/* large enough to hold projection specific parameters. */
|
||||
/************************************************************************/
|
||||
template <typename R>
|
||||
parameters pj_init(const R& arguments, bool use_defaults = true)
|
||||
{
|
||||
parameters pin;
|
||||
for (std::vector<std::string>::const_iterator it = boost::begin(arguments);
|
||||
it != boost::end(arguments); it++)
|
||||
{
|
||||
pin.params.push_back(pj_mkparam(*it));
|
||||
}
|
||||
|
||||
/* check if +init present */
|
||||
if (pj_param(pin.params, "tinit").i)
|
||||
{
|
||||
// maybe TODO: handle "init" parameter
|
||||
//if (!(curr = get_init(&arguments, curr, pj_param(pin.params, "sinit").s)))
|
||||
}
|
||||
|
||||
// find projection -> implemented in projection factory
|
||||
pin.name = pj_param(pin.params, "sproj").s;
|
||||
//if (pin.name.empty())
|
||||
//{ throw proj_exception(-4); }
|
||||
|
||||
|
||||
// set defaults, unless inhibited
|
||||
// GL-Addition, if use_defaults is false then defaults are ignored
|
||||
if (use_defaults && ! pj_param(pin.params, "bno_defs").i)
|
||||
{
|
||||
// proj4 gets defaults from "proj_def.dat", file of 94/02/23 with a few defaults.
|
||||
// Here manually
|
||||
if (pin.name == "lcc")
|
||||
{
|
||||
pin.params.push_back(pj_mkparam("lat_1=33"));
|
||||
pin.params.push_back(pj_mkparam("lat_2=45"));
|
||||
}
|
||||
else if (pin.name == "aea")
|
||||
{
|
||||
pin.params.push_back(pj_mkparam("lat_1=29.5"));
|
||||
pin.params.push_back(pj_mkparam("lat_2=45.5 "));
|
||||
}
|
||||
else
|
||||
{
|
||||
//<general>ellps=WGS84
|
||||
}
|
||||
//curr = get_defaults(&arguments, curr, name);
|
||||
}
|
||||
|
||||
/* allocate projection structure */
|
||||
// done by constructor:
|
||||
// pin.is_latlong = 0;
|
||||
// pin.is_geocent = 0;
|
||||
// pin.long_wrap_center = 0.0;
|
||||
|
||||
/* set datum parameters */
|
||||
pj_datum_set(pin.params, pin);
|
||||
|
||||
/* set ellipsoid/sphere parameters */
|
||||
pj_ell_set(pin.params, pin.a, pin.es);
|
||||
|
||||
pin.a_orig = pin.a;
|
||||
pin.es_orig = pin.es;
|
||||
|
||||
pin.e = sqrt(pin.es);
|
||||
pin.ra = 1. / pin.a;
|
||||
pin.one_es = 1. - pin.es;
|
||||
if (pin.one_es == 0.) { throw proj_exception(-6); }
|
||||
pin.rone_es = 1./pin.one_es;
|
||||
|
||||
/* Now that we have ellipse information check for WGS84 datum */
|
||||
if( pin.datum_type == PJD_3PARAM
|
||||
&& pin.datum_params[0] == 0.0
|
||||
&& pin.datum_params[1] == 0.0
|
||||
&& pin.datum_params[2] == 0.0
|
||||
&& pin.a == 6378137.0
|
||||
&& fabs(pin.es - 0.006694379990) < 0.000000000050 )/*WGS84/GRS80*/
|
||||
{
|
||||
pin.datum_type = PJD_WGS84;
|
||||
}
|
||||
|
||||
/* set pin.geoc coordinate system */
|
||||
pin.geoc = (pin.es && pj_param(pin.params, "bgeoc").i);
|
||||
|
||||
/* over-ranging flag */
|
||||
pin.over = pj_param(pin.params, "bover").i;
|
||||
|
||||
/* longitude center for wrapping */
|
||||
pin.long_wrap_center = pj_param(pin.params, "rlon_wrap").f;
|
||||
|
||||
/* central meridian */
|
||||
pin.lam0 = pj_param(pin.params, "rlon_0").f;
|
||||
|
||||
/* central latitude */
|
||||
pin.phi0 = pj_param(pin.params, "rlat_0").f;
|
||||
|
||||
/* false easting and northing */
|
||||
pin.x0 = pj_param(pin.params, "dx_0").f;
|
||||
pin.y0 = pj_param(pin.params, "dy_0").f;
|
||||
|
||||
/* general scaling factor */
|
||||
if (pj_param(pin.params, "tk_0").i)
|
||||
pin.k0 = pj_param(pin.params, "dk_0").f;
|
||||
else if (pj_param(pin.params, "tk").i)
|
||||
pin.k0 = pj_param(pin.params, "dk").f;
|
||||
else
|
||||
pin.k0 = 1.;
|
||||
if (pin.k0 <= 0.) {
|
||||
throw proj_exception(-31);
|
||||
}
|
||||
|
||||
/* set units */
|
||||
std::string s;
|
||||
std::string units = pj_param(pin.params, "sunits").s;
|
||||
if (! units.empty())
|
||||
{
|
||||
const int n = sizeof(pj_units) / sizeof(pj_units[0]);
|
||||
int index = -1;
|
||||
for (int i = 0; i < n && index == -1; i++)
|
||||
{
|
||||
if(pj_units[i].id == units)
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) { throw proj_exception(-7); }
|
||||
s = pj_units[index].to_meter;
|
||||
}
|
||||
|
||||
if (s.empty())
|
||||
{
|
||||
s = pj_param(pin.params, "sto_meter").s;
|
||||
}
|
||||
|
||||
if (! s.empty())
|
||||
{
|
||||
// TODO: IMPLEMENT SPLIT
|
||||
pin.to_meter = atof(s.c_str());
|
||||
//if (*s == '/') /* ratio number */
|
||||
// pin.to_meter /= strtod(++s, 0);
|
||||
pin.fr_meter = 1. / pin.to_meter;
|
||||
}
|
||||
else
|
||||
{
|
||||
pin.to_meter = pin.fr_meter = 1.;
|
||||
}
|
||||
|
||||
/* prime meridian */
|
||||
s.clear();
|
||||
std::string pm = pj_param(pin.params, "spm").s;
|
||||
if (! pm.empty())
|
||||
{
|
||||
std::string value;
|
||||
|
||||
int n = sizeof(pj_prime_meridians) / sizeof(pj_prime_meridians[0]);
|
||||
int index = -1;
|
||||
for (int i = 0; i < n && index == -1; i++)
|
||||
{
|
||||
if(pj_prime_meridians[i].id == pm)
|
||||
{
|
||||
value = pj_prime_meridians[i].defn;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) { throw proj_exception(-7); }
|
||||
if (value.empty()) { throw proj_exception(-46); }
|
||||
|
||||
geometry::strategy::dms_parser<true> parser;
|
||||
pin.from_greenwich = parser(value.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
pin.from_greenwich = 0.0;
|
||||
}
|
||||
|
||||
return pin;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_init_plus() */
|
||||
/* */
|
||||
/* Same as pj_init() except it takes one argument string with */
|
||||
/* individual arguments preceeded by '+', such as "+proj=utm */
|
||||
/* +zone=11 +ellps=WGS84". */
|
||||
/************************************************************************/
|
||||
|
||||
inline parameters pj_init_plus(const std::string& definition, bool use_defaults = true)
|
||||
{
|
||||
static const char* sep = " +";
|
||||
|
||||
/* split into arguments based on '+' and trim white space */
|
||||
|
||||
// boost::split splits on one character, here it should be on " +", so implementation below
|
||||
// todo: put in different routine or sort out
|
||||
std::vector<std::string> arguments;
|
||||
std::string def = boost::trim_copy(definition);
|
||||
boost::trim_left_if(def, boost::is_any_of(sep));
|
||||
|
||||
std::string::size_type loc = def.find(sep);
|
||||
while (loc != std::string::npos)
|
||||
{
|
||||
std::string par = def.substr(0, loc);
|
||||
boost::trim(par);
|
||||
if (! par.empty())
|
||||
{
|
||||
arguments.push_back(par);
|
||||
}
|
||||
|
||||
def.erase(0, loc);
|
||||
boost::trim_left_if(def, boost::is_any_of(sep));
|
||||
loc = def.find(sep);
|
||||
}
|
||||
|
||||
if (! def.empty())
|
||||
{
|
||||
arguments.push_back(def);
|
||||
}
|
||||
|
||||
/*boost::split(arguments, definition, boost::is_any_of("+"));
|
||||
for (std::vector<std::string>::iterator it = arguments.begin(); it != arguments.end(); it++)
|
||||
{
|
||||
boost::trim(*it);
|
||||
}*/
|
||||
return pj_init(arguments, use_defaults);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_INIT_HPP
|
||||
@@ -0,0 +1,76 @@
|
||||
#ifndef _PROJECTIONS_PJ_INV_HPP
|
||||
#define _PROJECTIONS_PJ_INV_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/geometry/extensions/gis/projections/impl/adjlon.hpp>
|
||||
#include <boost/geometry/core/radian_access.hpp>
|
||||
|
||||
/* general inverse projection */
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
namespace inv
|
||||
{
|
||||
static const double EPS = 1.0e-12;
|
||||
}
|
||||
|
||||
/* inverse projection entry */
|
||||
template <typename PRJ, typename LL, typename XY, typename PAR>
|
||||
void pj_inv(const PRJ& prj, const PAR& par, const XY& xy, LL& ll)
|
||||
{
|
||||
/* can't do as much preliminary checking as with forward */
|
||||
/* descale and de-offset */
|
||||
double xy_x = (geometry::get<0>(xy) * par.to_meter - par.x0) * par.ra;
|
||||
double xy_y = (geometry::get<1>(xy) * par.to_meter - par.y0) * par.ra;
|
||||
double lon = 0, lat = 0;
|
||||
prj.inv(xy_x, xy_y, lon, lat); /* inverse project */
|
||||
lon += par.lam0; /* reduce from del lp.lam */
|
||||
if (!par.over)
|
||||
lon = adjlon(lon); /* adjust longitude to CM */
|
||||
if (par.geoc && fabs(fabs(lat)-HALFPI) > inv::EPS)
|
||||
lat = atan(par.one_es * tan(lat));
|
||||
|
||||
geometry::set_from_radian<0>(ll, lon);
|
||||
geometry::set_from_radian<1>(ll, lat);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,106 @@
|
||||
#ifndef _PROJECTIONS_PJ_MLFN_HPP
|
||||
#define _PROJECTIONS_PJ_MLFN_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
/* meridinal distance for ellipsoid and inverse
|
||||
** 8th degree - accurate to < 1e-5 meters when used in conjuction
|
||||
** with typical major axis values.
|
||||
** Inverse determines phi to EPS (1e-11) radians, about 1e-6 seconds.
|
||||
*/
|
||||
static const double C00 = 1.;
|
||||
static const double C02 = .25;
|
||||
static const double C04 = .046875;
|
||||
static const double C06 = .01953125;
|
||||
static const double C08 = .01068115234375;
|
||||
static const double C22 = .75;
|
||||
static const double C44 = .46875;
|
||||
static const double C46 = .01302083333333333333;
|
||||
static const double C48 = .00712076822916666666;
|
||||
static const double C66 = .36458333333333333333;
|
||||
static const double C68 = .00569661458333333333;
|
||||
static const double C88 = .3076171875;
|
||||
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)
|
||||
{
|
||||
double t; //, *en;
|
||||
|
||||
//if (en = (double *)pj_malloc(EN_SIZE * sizeof(double)))
|
||||
{
|
||||
en[0] = C00 - es * (C02 + es * (C04 + es * (C06 + es * C08)));
|
||||
en[1] = es * (C22 - es * (C04 + es * (C06 + es * C08)));
|
||||
en[2] = (t = es * es) * (C44 - es * (C46 + es * C48));
|
||||
en[3] = (t *= es) * (C66 - es * C68);
|
||||
en[4] = t * es * C88;
|
||||
}
|
||||
// return en;
|
||||
}
|
||||
|
||||
inline double pj_mlfn(double phi, double sphi, double cphi, const double *en)
|
||||
{
|
||||
cphi *= sphi;
|
||||
sphi *= sphi;
|
||||
return(en[0] * phi - cphi * (en[1] + sphi*(en[2]
|
||||
+ sphi*(en[3] + sphi*en[4]))));
|
||||
}
|
||||
|
||||
inline double pj_inv_mlfn(double arg, double es, const double *en)
|
||||
{
|
||||
double s, t, phi, k = 1./(1.-es);
|
||||
int i;
|
||||
|
||||
phi = arg;
|
||||
for (i = MAX_ITER; i ; --i) { /* rarely goes over 2 iterations */
|
||||
s = sin(phi);
|
||||
t = 1. - es * s * s;
|
||||
phi -= t = (pj_mlfn(phi, s, cos(phi), en) - arg) * (t * sqrt(t)) * k;
|
||||
if (fabs(t) < EPS)
|
||||
return phi;
|
||||
}
|
||||
throw proj_exception(-17);
|
||||
return phi;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef _PROJECTIONS_PJ_MSFN_HPP
|
||||
#define _PROJECTIONS_PJ_MSFN_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
/* determine constant small m */
|
||||
inline double pj_msfn(double sinphi, double cosphi, double es)
|
||||
{
|
||||
return (cosphi / sqrt (1. - es * sinphi * sinphi));
|
||||
}
|
||||
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,154 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_PJ_PARAM_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_PJ_PARAM_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/geometry/extensions/gis/geographic/strategies/dms_parser.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
namespace detail {
|
||||
|
||||
|
||||
|
||||
/* create pvalue list entry */
|
||||
inline pvalue pj_mkparam(const std::string& str)
|
||||
{
|
||||
std::string name = str;
|
||||
std::string value;
|
||||
boost::trim_left_if(name, boost::is_any_of("+"));
|
||||
std::string::size_type loc = name.find("=");
|
||||
if (loc != std::string::npos)
|
||||
{
|
||||
value = name.substr(loc + 1);
|
||||
name.erase(loc);
|
||||
}
|
||||
|
||||
|
||||
pvalue newitem;
|
||||
newitem.param = name;
|
||||
newitem.s = value;
|
||||
newitem.used = 0;
|
||||
newitem.i = atoi(value.c_str());
|
||||
newitem.f = atof(value.c_str());
|
||||
return newitem;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
/* pj_param() */
|
||||
/* */
|
||||
/* Test for presence or get pvalue value. The first */
|
||||
/* character in `opt' is a pvalue type which can take the */
|
||||
/* values: */
|
||||
/* */
|
||||
/* `t' - test for presence, return TRUE/FALSE in pvalue.i */
|
||||
/* `i' - integer value returned in pvalue.i */
|
||||
/* `d' - simple valued real input returned in pvalue.f */
|
||||
/* `r' - degrees (DMS translation applied), returned as */
|
||||
/* radians in pvalue.f */
|
||||
/* `s' - string returned in pvalue.s */
|
||||
/* `b' - test for t/T/f/F, return in pvalue.i */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
inline pvalue pj_param(const std::vector<pvalue>& pl, std::string opt)
|
||||
{
|
||||
char type = opt[0];
|
||||
opt.erase(opt.begin());
|
||||
|
||||
pvalue value;
|
||||
|
||||
/* simple linear lookup */
|
||||
for (std::vector<pvalue>::const_iterator it = pl.begin(); it != pl.end(); it++)
|
||||
{
|
||||
if (it->param == opt)
|
||||
{
|
||||
//it->used = 1;
|
||||
switch (type)
|
||||
{
|
||||
case 't':
|
||||
value.i = 1;
|
||||
break;
|
||||
case 'i': /* integer input */
|
||||
value.i = atoi(it->s.c_str());
|
||||
break;
|
||||
case 'd': /* simple real input */
|
||||
value.f = atof(it->s.c_str());
|
||||
break;
|
||||
case 'r': /* degrees input */
|
||||
{
|
||||
geometry::strategy::dms_parser<true> parser;
|
||||
value.f = parser(it->s.c_str());
|
||||
}
|
||||
break;
|
||||
case 's': /* char string */
|
||||
value.s = it->s;
|
||||
break;
|
||||
case 'b': /* boolean */
|
||||
switch (it->s[0])
|
||||
{
|
||||
case 'F': case 'f':
|
||||
value.i = 0;
|
||||
break;
|
||||
case '\0': case 'T': case 't':
|
||||
value.i = 1;
|
||||
break;
|
||||
default:
|
||||
value.i = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
value.i = 0;
|
||||
value.f = 0.0;
|
||||
value.s = "";
|
||||
return value;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,70 @@
|
||||
#ifndef _PROJECTIONS_PHI2_HPP
|
||||
#define _PROJECTIONS_PHI2_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
namespace detail {
|
||||
|
||||
namespace phi2
|
||||
{
|
||||
static const double TOL = 1.0e-10;
|
||||
static const int N_ITER = 15;
|
||||
}
|
||||
|
||||
inline double pj_phi2(double ts, double e)
|
||||
{
|
||||
double eccnth, Phi, con, dphi;
|
||||
int i;
|
||||
|
||||
eccnth = .5 * e;
|
||||
Phi = HALFPI - 2. * atan (ts);
|
||||
i = phi2::N_ITER;
|
||||
do {
|
||||
con = e * sin (Phi);
|
||||
dphi = HALFPI - 2. * atan (ts * pow((1. - con) /
|
||||
(1. + con), eccnth)) - Phi;
|
||||
Phi += dphi;
|
||||
} while ( fabs(dphi) > phi2::TOL && --i);
|
||||
if (i <= 0)
|
||||
throw proj_exception(-18);
|
||||
return Phi;
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,83 @@
|
||||
#ifndef _PROJECTIONS_PJ_QSFN_HPP
|
||||
#define _PROJECTIONS_PJ_QSFN_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{ namespace detail {
|
||||
|
||||
/* determine small q */
|
||||
inline double pj_qsfn(double sinphi, double e, double one_es)
|
||||
{
|
||||
static const double EPSILON = 1.0e-7;
|
||||
|
||||
if (e >= EPSILON)
|
||||
{
|
||||
double con = e * sinphi;
|
||||
return (one_es * (sinphi / (1. - con * con) -
|
||||
(.5 / e) * log ((1. - con) / (1. + con))));
|
||||
} else
|
||||
return (sinphi + sinphi);
|
||||
}
|
||||
|
||||
|
||||
#define MAX_C 9
|
||||
struct AUTHALIC
|
||||
{
|
||||
double C[MAX_C], CP[MAX_C], CQ[MAX_C];
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief determine authalic latitude
|
||||
* @param[in] phi geographic latitude
|
||||
* @param[in] a initialized structure pointer
|
||||
* @return authalic latitude
|
||||
*/
|
||||
inline double proj_qsfn(double phi, const AUTHALIC& a)
|
||||
{
|
||||
double s, s2, sum;
|
||||
int i = MAX_C;
|
||||
|
||||
s = sin(phi);
|
||||
s2 = s * s;
|
||||
sum = a.CQ[MAX_C - 1];
|
||||
while (--i) sum = a.CQ[i] + s2 * sum;
|
||||
return(s * sum);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,53 @@
|
||||
#ifndef _PROJECTIONS_PJ_TSFN_HPP
|
||||
#define _PROJECTIONS_PJ_TSFN_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
namespace detail {
|
||||
|
||||
/* determine small t */
|
||||
inline double pj_tsfn(double phi, double sinphi, double e)
|
||||
{
|
||||
sinphi *= e;
|
||||
return (tan (.5 * (HALFPI - phi)) /
|
||||
pow((1. - sinphi) / (1. + sinphi), .5 * e));
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
#endif
|
||||
@@ -0,0 +1,75 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_UNITS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_UNITS_HPP
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
namespace detail {
|
||||
|
||||
/* Field 2 that contains the multiplier to convert named units to meters
|
||||
** may be expressed by either a simple floating point constant or a
|
||||
** numerator/denomenator values (e.g. 1/1000) */
|
||||
|
||||
static const PJ_UNITS pj_units[] =
|
||||
{
|
||||
{ "km", "1000.", "Kilometer" },
|
||||
{ "m", "1.", "Meter" },
|
||||
{ "dm", "1/10", "Decimeter" },
|
||||
{ "cm", "1/100", "Centimeter" },
|
||||
{ "mm", "1/1000", "Millimeter" },
|
||||
{ "kmi", "1852.0", "International Nautical Mile" },
|
||||
{ "in", "0.0254", "International Inch" },
|
||||
{ "ft", "0.3048", "International Foot" },
|
||||
{ "yd", "0.9144", "International Yard" },
|
||||
{ "mi", "1609.344", "International Statute Mile" },
|
||||
{ "fath", "1.8288", "International Fathom" },
|
||||
{ "ch", "20.1168", "International Chain" },
|
||||
{ "link", "0.201168", "International Link" },
|
||||
{ "us-in", "1./39.37", "U.S. Surveyor's Inch" },
|
||||
{ "us-ft", "0.304800609601219", "U.S. Surveyor's Foot" },
|
||||
{ "us-yd", "0.914401828803658", "U.S. Surveyor's Yard" },
|
||||
{ "us-ch", "20.11684023368047", "U.S. Surveyor's Chain" },
|
||||
{ "us-mi", "1609.347218694437", "U.S. Surveyor's Statute Mile" },
|
||||
{ "ind-yd", "0.91439523", "Indian Yard" },
|
||||
{ "ind-ft", "0.30479841", "Indian Foot" },
|
||||
{ "ind-ch", "20.11669506", "Indian Chain" }
|
||||
};
|
||||
|
||||
} // detail
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PJ_UNITS_HPP
|
||||
@@ -0,0 +1,100 @@
|
||||
#ifndef _PROJECTIONS_ZPOLY1_HPP
|
||||
#define _PROJECTIONS_ZPOLY1_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projection { namespace detail {
|
||||
|
||||
/* evaluate complex polynomial */
|
||||
|
||||
/* note: coefficients are always from C_1 to C_n
|
||||
** i.e. C_0 == (0., 0)
|
||||
** n should always be >= 1 though no checks are made
|
||||
*/
|
||||
inline COMPLEX
|
||||
pj_zpoly1(COMPLEX z, COMPLEX *C, int n)
|
||||
{
|
||||
COMPLEX a;
|
||||
double t;
|
||||
|
||||
a = *(C += n);
|
||||
while (n-- > 0)
|
||||
{
|
||||
a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
|
||||
a.i = C->i + z.r * a.i + z.i * t;
|
||||
}
|
||||
a.r = z.r * (t = a.r) - z.i * a.i;
|
||||
a.i = z.r * a.i + z.i * t;
|
||||
return a;
|
||||
}
|
||||
|
||||
/* evaluate complex polynomial and derivative */
|
||||
inline COMPLEX
|
||||
pj_zpolyd1(COMPLEX z, COMPLEX *C, int n, COMPLEX *der)
|
||||
{
|
||||
double t;
|
||||
bool first = true;
|
||||
|
||||
COMPLEX a = *(C += n);
|
||||
COMPLEX b = a;
|
||||
while (n-- > 0)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
b.r = a.r + z.r * (t = b.r) - z.i * b.i;
|
||||
b.i = a.i + z.r * b.i + z.i * t;
|
||||
}
|
||||
a.r = (--C)->r + z.r * (t = a.r) - z.i * a.i;
|
||||
a.i = C->i + z.r * a.i + z.i * t;
|
||||
}
|
||||
b.r = a.r + z.r * (t = b.r) - z.i * b.i;
|
||||
b.i = a.i + z.r * b.i + z.i * t;
|
||||
a.r = z.r * (t = a.r) - z.i * a.i;
|
||||
a.i = z.r * a.i + z.i * t;
|
||||
*der = b;
|
||||
return a;
|
||||
}
|
||||
|
||||
}}}} // namespace boost::geometry::projection::impl
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,133 @@
|
||||
#ifndef _PROJECTIONS_PROJ_MDIST_HPP
|
||||
#define _PROJECTIONS_PROJ_MDIST_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
static const int MDIST_MAX_ITER = 20;
|
||||
|
||||
struct MDIST
|
||||
{
|
||||
int nb;
|
||||
double es;
|
||||
double E;
|
||||
double b[MDIST_MAX_ITER];
|
||||
};
|
||||
|
||||
inline void proj_mdist_ini(double es, MDIST& b)
|
||||
{
|
||||
double numf, numfi, twon1, denf, denfi, ens, T, twon;
|
||||
double den, El, Es;
|
||||
double E[MDIST_MAX_ITER];
|
||||
int i, j;
|
||||
|
||||
/* generate E(e^2) and its terms E[] */
|
||||
ens = es;
|
||||
numf = twon1 = denfi = 1.;
|
||||
denf = 1.;
|
||||
twon = 4.;
|
||||
Es = El = E[0] = 1.;
|
||||
for (i = 1; i < MDIST_MAX_ITER ; ++i)
|
||||
{
|
||||
numf *= (twon1 * twon1);
|
||||
den = twon * denf * denf * twon1;
|
||||
T = numf/den;
|
||||
Es -= (E[i] = T * ens);
|
||||
ens *= es;
|
||||
twon *= 4.;
|
||||
denf *= ++denfi;
|
||||
twon1 += 2.;
|
||||
if (Es == El) /* jump out if no change */
|
||||
break;
|
||||
El = Es;
|
||||
}
|
||||
b.nb = i - 1;
|
||||
b.es = es;
|
||||
b.E = Es;
|
||||
/* generate b_n coefficients--note: collapse with prefix ratios */
|
||||
b.b[0] = Es = 1. - Es;
|
||||
numf = denf = 1.;
|
||||
numfi = 2.;
|
||||
denfi = 3.;
|
||||
for (j = 1; j < i; ++j)
|
||||
{
|
||||
Es -= E[j];
|
||||
numf *= numfi;
|
||||
denf *= denfi;
|
||||
b.b[j] = Es * numf / denf;
|
||||
numfi += 2.;
|
||||
denfi += 2.;
|
||||
}
|
||||
}
|
||||
inline double proj_mdist(double phi, double sphi, double cphi, const MDIST& b)
|
||||
{
|
||||
double sc, sum, sphi2, D;
|
||||
int i;
|
||||
|
||||
sc = sphi * cphi;
|
||||
sphi2 = sphi * sphi;
|
||||
D = phi * b.E - b.es * sc / sqrt(1. - b.es * sphi2);
|
||||
sum = b.b[i = b.nb];
|
||||
while (i) sum = b.b[--i] + sphi2 * sum;
|
||||
return(D + sc * sum);
|
||||
}
|
||||
inline double proj_inv_mdist(double dist, const MDIST& b)
|
||||
{
|
||||
static const double TOL = 1e-14;
|
||||
double s, t, phi, k;
|
||||
int i;
|
||||
|
||||
k = 1./(1.- b.es);
|
||||
i = MDIST_MAX_ITER;
|
||||
phi = dist;
|
||||
while ( i-- ) {
|
||||
s = sin(phi);
|
||||
t = 1. - b.es * s * s;
|
||||
phi -= t = (proj_mdist(phi, s, cos(phi), b) - dist) *
|
||||
(t * sqrt(t)) * k;
|
||||
if (fabs(t) < TOL) /* that is no change */
|
||||
return phi;
|
||||
}
|
||||
/* convergence failed */
|
||||
throw proj_exception(-17);
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,184 @@
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library) - projections (based on PROJ4)
|
||||
// This file is manually converted from PROJ4 (projects.h)
|
||||
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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.
|
||||
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/concept_check.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/* some useful constants */
|
||||
static const double HALFPI = 1.5707963267948966;
|
||||
static const double FORTPI = 0.78539816339744833;
|
||||
static const double PI = 3.14159265358979323846;
|
||||
static const double TWOPI = 6.2831853071795864769;
|
||||
|
||||
static const double RAD_TO_DEG = 57.29577951308232;
|
||||
static const double DEG_TO_RAD = .0174532925199432958;
|
||||
|
||||
static const int PJD_UNKNOWN =0;
|
||||
static const int PJD_3PARAM = 1;
|
||||
static const int PJD_7PARAM = 2;
|
||||
static const int PJD_GRIDSHIFT = 3;
|
||||
static const int PJD_WGS84 = 4; /* WGS84 (or anything considered equivelent) */
|
||||
|
||||
|
||||
struct pvalue
|
||||
{
|
||||
std::string param;
|
||||
int used;
|
||||
|
||||
int i;
|
||||
double f;
|
||||
std::string s;
|
||||
};
|
||||
|
||||
struct pj_const_pod
|
||||
{
|
||||
int over; /* over-range flag */
|
||||
int geoc; /* geocentric latitude flag */
|
||||
int is_latlong; /* proj=latlong ... not really a projection at all */
|
||||
int is_geocent; /* proj=geocent ... not really a projection at all */
|
||||
double
|
||||
a, /* major axis or radius if es==0 */
|
||||
a_orig, /* major axis before any +proj related adjustment */
|
||||
es, /* e ^ 2 */
|
||||
es_orig, /* es before any +proj related adjustment */
|
||||
e, /* eccentricity */
|
||||
ra, /* 1/A */
|
||||
one_es, /* 1 - e^2 */
|
||||
rone_es, /* 1/one_es */
|
||||
lam0, phi0, /* central longitude, latitude */
|
||||
x0, y0, /* easting and northing */
|
||||
k0, /* general scaling factor */
|
||||
to_meter, fr_meter; /* cartesian scaling */
|
||||
|
||||
int datum_type; /* PJD_UNKNOWN/3PARAM/7PARAM/GRIDSHIFT/WGS84 */
|
||||
double datum_params[7];
|
||||
double from_greenwich; /* prime meridian offset (in radians) */
|
||||
double long_wrap_center; /* 0.0 for -180 to 180, actually in radians*/
|
||||
|
||||
// Initialize all variables to zero
|
||||
pj_const_pod()
|
||||
{
|
||||
std::memset(this, 0, sizeof(pj_const_pod));
|
||||
}
|
||||
};
|
||||
|
||||
// PROJ4 complex. Might be replaced with std::complex
|
||||
struct COMPLEX { double r, i; };
|
||||
|
||||
struct PJ_ELLPS
|
||||
{
|
||||
std::string id; /* ellipse keyword name */
|
||||
std::string major; /* a= value */
|
||||
std::string ell; /* elliptical parameter */
|
||||
std::string name; /* comments */
|
||||
};
|
||||
|
||||
struct PJ_DATUMS
|
||||
{
|
||||
std::string id; /* datum keyword */
|
||||
std::string defn; /* ie. "to_wgs84=..." */
|
||||
std::string ellipse_id; /* ie from ellipse table */
|
||||
std::string comments; /* EPSG code, etc */
|
||||
};
|
||||
|
||||
struct PJ_PRIME_MERIDIANS
|
||||
{
|
||||
std::string id; /* prime meridian keyword */
|
||||
std::string defn; /* offset from greenwich in DMS format. */
|
||||
};
|
||||
|
||||
struct PJ_UNITS
|
||||
{
|
||||
std::string id; /* units keyword */
|
||||
std::string to_meter; /* multiply by value to get meters */
|
||||
std::string name; /* comments */
|
||||
};
|
||||
|
||||
struct DERIVS
|
||||
{
|
||||
double x_l, x_p; /* derivatives of x for lambda-phi */
|
||||
double y_l, y_p; /* derivatives of y for lambda-phi */
|
||||
};
|
||||
|
||||
struct FACTORS
|
||||
{
|
||||
struct DERIVS der;
|
||||
double h, k; /* meridinal, parallel scales */
|
||||
double omega, thetap; /* angular distortion, theta prime */
|
||||
double conv; /* convergence */
|
||||
double s; /* areal scale factor */
|
||||
double a, b; /* max-min scale error */
|
||||
int code; /* info as to analytics, see following */
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
#endif // DOXYGEN_NO_DETAIL
|
||||
|
||||
/*!
|
||||
\brief parameters, projection parameters
|
||||
\details This structure initializes all projections
|
||||
\ingroup projection
|
||||
*/
|
||||
struct parameters : public detail::pj_const_pod
|
||||
{
|
||||
std::string name;
|
||||
std::vector<detail::pvalue> params;
|
||||
};
|
||||
|
||||
// TODO: derived from boost::exception / make more for forward/inverse/init/setup
|
||||
class proj_exception
|
||||
{
|
||||
public:
|
||||
|
||||
proj_exception(int code = 0)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(code);
|
||||
}
|
||||
};
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMPL_PROJECTS_HPP
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef _PROJECTIONS_PARAMETERS_HPP
|
||||
#define _PROJECTIONS_PARAMETERS_HPP
|
||||
|
||||
// Boost.Geometry (aka GGL, Generic Geometry Library)
|
||||
//
|
||||
// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande 2008, 2009
|
||||
// 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 <string>
|
||||
#include <vector>
|
||||
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_init.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry { namespace projection {
|
||||
|
||||
template <typename R>
|
||||
inline parameters init(const R& arguments)
|
||||
{
|
||||
return detail::pj_init(arguments);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup projection
|
||||
\brief Initializes a projection as a string, using the format with + and =
|
||||
\details The projection can be initialized with a string (with the same format as the PROJ4 package) for
|
||||
convenient initialization from, for example, the command line
|
||||
\par Example
|
||||
<tt>+proj=labrd +ellps=intl +lon_0=46d26'13.95E +lat_0=18d54S +azi=18d54 +k_0=.9995 +x_0=400000 +y_0=800000</tt>
|
||||
for the Madagascar projection.
|
||||
\note Parameters are described in the group
|
||||
*/
|
||||
inline parameters init(const std::string& arguments)
|
||||
{
|
||||
return detail::pj_init_plus(arguments);
|
||||
}
|
||||
|
||||
/*!
|
||||
\ingroup projection
|
||||
\brief Overload using a const char*
|
||||
*/
|
||||
inline parameters init(const char* arguments)
|
||||
{
|
||||
return detail::pj_init_plus(arguments);
|
||||
}
|
||||
|
||||
|
||||
// todo:
|
||||
/*
|
||||
parameters init(const std::map<std::string, std::string>& arguments)
|
||||
{
|
||||
return detail::pj_init_plus(arguments);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
#endif
|
||||
525
include/boost/geometry/extensions/gis/projections/proj/aea.hpp
Normal file
525
include/boost/geometry/extensions/gis/projections/proj/aea.hpp
Normal file
@@ -0,0 +1,525 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_AEA_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_AEA_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace aea{
|
||||
static const double EPS10 = 1.e-10;
|
||||
static const double TOL7 = 1.e-7;
|
||||
static const int N_ITER = 15;
|
||||
static const double EPSILON = 1.0e-7;
|
||||
static const double TOL = 1.0e-10;
|
||||
|
||||
struct par_aea
|
||||
{
|
||||
double ec;
|
||||
double n;
|
||||
double c;
|
||||
double dd;
|
||||
double n2;
|
||||
double rho0;
|
||||
double rho;
|
||||
double phi1;
|
||||
double phi2;
|
||||
double en[EN_SIZE];
|
||||
int ellips;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* determine latitude angle phi-1 */
|
||||
inline double
|
||||
phi1_(double qs, double Te, double Tone_es) {
|
||||
int i;
|
||||
double Phi, sinpi, cospi, con, com, dphi;
|
||||
|
||||
Phi = asin (.5 * qs);
|
||||
if (Te < EPSILON)
|
||||
return( Phi );
|
||||
i = N_ITER;
|
||||
do {
|
||||
sinpi = sin (Phi);
|
||||
cospi = cos (Phi);
|
||||
con = Te * sinpi;
|
||||
com = 1. - con * con;
|
||||
dphi = .5 * com * com / cospi * (qs / Tone_es -
|
||||
sinpi / com + .5 / Te * log ((1. - con) /
|
||||
(1. + con)));
|
||||
Phi += dphi;
|
||||
} while (fabs(dphi) > TOL && --i);
|
||||
return( i ? Phi : HUGE_VAL );
|
||||
}
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_aea_ellipsoid : public base_t_fi<base_aea_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
mutable par_aea m_proj_parm;
|
||||
|
||||
inline base_aea_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_aea_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if ((this->m_proj_parm.rho = this->m_proj_parm.c - (this->m_proj_parm.ellips ? this->m_proj_parm.n * pj_qsfn(sin(lp_lat),
|
||||
this->m_par.e, this->m_par.one_es) : this->m_proj_parm.n2 * sin(lp_lat))) < 0.) throw proj_exception();
|
||||
this->m_proj_parm.rho = this->m_proj_parm.dd * sqrt(this->m_proj_parm.rho);
|
||||
xy_x = this->m_proj_parm.rho * sin( lp_lon *= this->m_proj_parm.n );
|
||||
xy_y = this->m_proj_parm.rho0 - this->m_proj_parm.rho * cos(lp_lon);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
if( (this->m_proj_parm.rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) {
|
||||
if (this->m_proj_parm.n < 0.) {
|
||||
this->m_proj_parm.rho = -this->m_proj_parm.rho;
|
||||
xy_x = -xy_x;
|
||||
xy_y = -xy_y;
|
||||
}
|
||||
lp_lat = this->m_proj_parm.rho / this->m_proj_parm.dd;
|
||||
if (this->m_proj_parm.ellips) {
|
||||
lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n;
|
||||
if (fabs(this->m_proj_parm.ec - fabs(lp_lat)) > TOL7) {
|
||||
if ((lp_lat = phi1_(lp_lat, this->m_par.e, this->m_par.one_es)) == HUGE_VAL)
|
||||
throw proj_exception();
|
||||
} else
|
||||
lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
|
||||
} else if (fabs(lp_lat = (this->m_proj_parm.c - lp_lat * lp_lat) / this->m_proj_parm.n2) <= 1.)
|
||||
lp_lat = asin(lp_lat);
|
||||
else
|
||||
lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
|
||||
lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
|
||||
} else {
|
||||
lp_lon = 0.;
|
||||
lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_aea& proj_parm)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(proj_parm);
|
||||
double cosphi, sinphi;
|
||||
int secant;
|
||||
if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21);
|
||||
proj_parm.n = sinphi = sin(proj_parm.phi1);
|
||||
cosphi = cos(proj_parm.phi1);
|
||||
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);
|
||||
m1 = pj_msfn(sinphi, cosphi, par.es);
|
||||
ml1 = pj_qsfn(sinphi, par.e, par.one_es);
|
||||
if (secant) { /* secant cone */
|
||||
double ml2, m2;
|
||||
sinphi = sin(proj_parm.phi2);
|
||||
cosphi = cos(proj_parm.phi2);
|
||||
m2 = pj_msfn(sinphi, cosphi, par.es);
|
||||
ml2 = pj_qsfn(sinphi, par.e, par.one_es);
|
||||
proj_parm.n = (m1 * m1 - m2 * m2) / (ml2 - ml1);
|
||||
}
|
||||
proj_parm.ec = 1. - .5 * par.one_es * log((1. - par.e) /
|
||||
(1. + par.e)) / par.e;
|
||||
proj_parm.c = m1 * m1 + proj_parm.n * ml1;
|
||||
proj_parm.dd = 1. / proj_parm.n;
|
||||
proj_parm.rho0 = proj_parm.dd * sqrt(proj_parm.c - proj_parm.n * pj_qsfn(sin(par.phi0),
|
||||
par.e, par.one_es));
|
||||
} else {
|
||||
if (secant) proj_parm.n = .5 * (proj_parm.n + sin(proj_parm.phi2));
|
||||
proj_parm.n2 = proj_parm.n + proj_parm.n;
|
||||
proj_parm.c = cosphi * cosphi + proj_parm.n2 * sinphi;
|
||||
proj_parm.dd = 1. / proj_parm.n;
|
||||
proj_parm.rho0 = proj_parm.dd * sqrt(proj_parm.c - proj_parm.n2 * sin(par.phi0));
|
||||
}
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
|
||||
// Albers Equal Area
|
||||
template <typename Parameters>
|
||||
void setup_aea(Parameters& par, par_aea& proj_parm)
|
||||
{
|
||||
proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
|
||||
proj_parm.phi2 = pj_param(par.params, "rlat_2").f;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Lambert Equal Area Conic
|
||||
template <typename Parameters>
|
||||
void setup_leac(Parameters& par, par_aea& proj_parm)
|
||||
{
|
||||
proj_parm.phi2 = pj_param(par.params, "rlat_1").f;
|
||||
proj_parm.phi1 = pj_param(par.params, "bsouth").i ? - HALFPI: HALFPI;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
}} // namespace detail::aea
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Albers Equal Area projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_1= lat_2=
|
||||
\par Example
|
||||
\image html ex_aea.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct aea_ellipsoid : public detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline aea_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aea::setup_aea(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Lambert Equal Area Conic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_1= south
|
||||
\par Example
|
||||
\image html ex_leac.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct leac_ellipsoid : public detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline leac_ellipsoid(const Parameters& par) : detail::aea::base_aea_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aea::setup_leac(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class aea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<aea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class leac_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<leac_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void aea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("aea", new aea_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("leac", new leac_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
// Create EPSG specializations
|
||||
// (Proof of Concept, only for some)
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<2964, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=clrk66 +datum=NAD27 +to_meter=0.3048006096012192";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3005, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3083, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3085, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3086, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3087, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3153, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=50 +lat_2=58.5 +lat_0=45 +lon_0=-126 +x_0=1000000 +y_0=0 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3174, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=42.122774 +lat_2=49.01518 +lat_0=45.568977 +lon_0=-84.455955 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3175, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=42.122774 +lat_2=49.01518 +lat_0=45.568977 +lon_0=-83.248627 +x_0=1000000 +y_0=1000000 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3309, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=clrk66 +datum=NAD27 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3310, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3311, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3338, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3467, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=55 +lat_2=65 +lat_0=50 +lon_0=-154 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3488, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=34 +lat_2=40.5 +lat_0=0 +lon_0=-120 +x_0=0 +y_0=-4000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3513, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=24 +lat_2=31.5 +lat_0=24 +lon_0=-84 +x_0=400000 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3577, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=-18 +lat_2=-36 +lat_0=0 +lon_0=132 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3578, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=61.66666666666666 +lat_2=68 +lat_0=59 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +datum=NAD83 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3579, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=61.66666666666666 +lat_2=68 +lat_0=59 +lon_0=-132.5 +x_0=500000 +y_0=500000 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3665, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef aea_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=aea +lat_1=27.5 +lat_2=35 +lat_0=18 +lon_0=-100 +x_0=1500000 +y_0=6000000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_AEA_HPP
|
||||
|
||||
454
include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp
Normal file
454
include/boost/geometry/extensions/gis/projections/proj/aeqd.hpp
Normal file
@@ -0,0 +1,454 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/aasincos.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/proj_mdist.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace aeqd{
|
||||
static const double EPS10 = 1.e-10;
|
||||
static const double TOL = 1.e-14;
|
||||
static const int N_POLE = 0;
|
||||
static const int S_POLE = 1;
|
||||
static const int EQUIT = 2;
|
||||
static const int OBLIQ = 3;
|
||||
|
||||
struct par_aeqd
|
||||
{
|
||||
double sinph0;
|
||||
double cosph0;
|
||||
double en[EN_SIZE];
|
||||
double M1;
|
||||
double N1;
|
||||
double Mp;
|
||||
double He;
|
||||
double G;
|
||||
int mode;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_aeqd_ellipsoid : public base_t_fi<base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_aeqd m_proj_parm;
|
||||
|
||||
inline base_aeqd_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, cosphi, sinphi, rho, s, H, H2, c, Az, t, ct, st, cA, sA;
|
||||
|
||||
coslam = cos(lp_lon);
|
||||
cosphi = cos(lp_lat);
|
||||
sinphi = sin(lp_lat);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case N_POLE:
|
||||
coslam = - coslam;
|
||||
case S_POLE:
|
||||
xy_x = (rho = fabs(this->m_proj_parm.Mp - pj_mlfn(lp_lat, sinphi, cosphi, this->m_proj_parm.en))) *
|
||||
sin(lp_lon);
|
||||
xy_y = rho * coslam;
|
||||
break;
|
||||
case EQUIT:
|
||||
case OBLIQ:
|
||||
if (fabs(lp_lon) < EPS10 && fabs(lp_lat - this->m_par.phi0) < EPS10) {
|
||||
xy_x = xy_y = 0.;
|
||||
break;
|
||||
}
|
||||
t = atan2(this->m_par.one_es * sinphi + this->m_par.es * this->m_proj_parm.N1 * this->m_proj_parm.sinph0 *
|
||||
sqrt(1. - this->m_par.es * sinphi * sinphi), cosphi);
|
||||
ct = cos(t); st = sin(t);
|
||||
Az = atan2(sin(lp_lon) * ct, this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct);
|
||||
cA = cos(Az); sA = sin(Az);
|
||||
s = aasin( fabs(sA) < TOL ?
|
||||
(this->m_proj_parm.cosph0 * st - this->m_proj_parm.sinph0 * coslam * ct) / cA :
|
||||
sin(lp_lon) * ct / sA );
|
||||
H = this->m_proj_parm.He * cA;
|
||||
H2 = H * H;
|
||||
c = this->m_proj_parm.N1 * s * (1. + s * s * (- H2 * (1. - H2)/6. +
|
||||
s * ( this->m_proj_parm.G * H * (1. - 2. * H2 * H2) / 8. +
|
||||
s * ((H2 * (4. - 7. * H2) - 3. * this->m_proj_parm.G * this->m_proj_parm.G * (1. - 7. * H2)) /
|
||||
120. - s * this->m_proj_parm.G * H / 48.))));
|
||||
xy_x = c * sA;
|
||||
xy_y = c * cA;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double c, Az, cosAz, A, B, D, E, F, psi, t;
|
||||
|
||||
if ((c = boost::math::hypot(xy_x, xy_y)) < EPS10) {
|
||||
lp_lat = this->m_par.phi0;
|
||||
lp_lon = 0.;
|
||||
return;
|
||||
}
|
||||
if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
|
||||
cosAz = cos(Az = atan2(xy_x, xy_y));
|
||||
t = this->m_proj_parm.cosph0 * cosAz;
|
||||
B = this->m_par.es * t / this->m_par.one_es;
|
||||
A = - B * t;
|
||||
B *= 3. * (1. - A) * this->m_proj_parm.sinph0;
|
||||
D = c / this->m_proj_parm.N1;
|
||||
E = D * (1. - D * D * (A * (1. + A) / 6. + B * (1. + 3.*A) * D / 24.));
|
||||
F = 1. - E * E * (A / 2. + B * E / 6.);
|
||||
psi = aasin(this->m_proj_parm.sinph0 * cos(E) + t * sin(E));
|
||||
lp_lon = aasin(sin(Az) * sin(E) / cos(psi));
|
||||
if ((t = fabs(psi)) < EPS10)
|
||||
lp_lat = 0.;
|
||||
else if (fabs(t - HALFPI) < 0.)
|
||||
lp_lat = HALFPI;
|
||||
else
|
||||
lp_lat = atan((1. - this->m_par.es * F * this->m_proj_parm.sinph0 / sin(psi)) * tan(psi) /
|
||||
this->m_par.one_es);
|
||||
} else { /* Polar */
|
||||
lp_lat = pj_inv_mlfn(this->m_proj_parm.mode == N_POLE ? this->m_proj_parm.Mp - c : this->m_proj_parm.Mp + c,
|
||||
this->m_par.es, this->m_proj_parm.en);
|
||||
lp_lon = atan2(xy_x, this->m_proj_parm.mode == N_POLE ? -xy_y : xy_y);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_aeqd_guam : public base_t_fi<base_aeqd_guam<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_aeqd m_proj_parm;
|
||||
|
||||
inline base_aeqd_guam(const Parameters& par)
|
||||
: base_t_fi<base_aeqd_guam<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double cosphi, sinphi, t;
|
||||
|
||||
cosphi = cos(lp_lat);
|
||||
sinphi = sin(lp_lat);
|
||||
t = 1. / sqrt(1. - this->m_par.es * sinphi * sinphi);
|
||||
xy_x = lp_lon * cosphi * t;
|
||||
xy_y = pj_mlfn(lp_lat, sinphi, cosphi, this->m_proj_parm.en) - this->m_proj_parm.M1 +
|
||||
.5 * lp_lon * lp_lon * cosphi * sinphi * t;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double x2, t;
|
||||
int i;
|
||||
|
||||
x2 = 0.5 * xy_x * xy_x;
|
||||
lp_lat = this->m_par.phi0;
|
||||
for (i = 0; i < 3; ++i) {
|
||||
t = this->m_par.e * sin(lp_lat);
|
||||
lp_lat = pj_inv_mlfn(this->m_proj_parm.M1 + xy_y -
|
||||
x2 * tan(lp_lat) * (t = sqrt(1. - t * t)), this->m_par.es, this->m_proj_parm.en);
|
||||
}
|
||||
lp_lon = xy_x * t / cos(lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_aeqd_spheroid : public base_t_fi<base_aeqd_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_aeqd m_proj_parm;
|
||||
|
||||
inline base_aeqd_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_aeqd_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, cosphi, sinphi;
|
||||
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
coslam = cos(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
xy_y = cosphi * coslam;
|
||||
goto oblcon;
|
||||
case OBLIQ:
|
||||
xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam;
|
||||
oblcon:
|
||||
if (fabs(fabs(xy_y) - 1.) < TOL)
|
||||
if (xy_y < 0.)
|
||||
throw proj_exception();
|
||||
else
|
||||
xy_x = xy_y = 0.;
|
||||
else {
|
||||
xy_y = acos(xy_y);
|
||||
xy_y /= sin(xy_y);
|
||||
xy_x = xy_y * cosphi * sin(lp_lon);
|
||||
xy_y *= (this->m_proj_parm.mode == EQUIT) ? sinphi :
|
||||
this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam;
|
||||
}
|
||||
break;
|
||||
case N_POLE:
|
||||
lp_lat = -lp_lat;
|
||||
coslam = -coslam;
|
||||
case S_POLE:
|
||||
if (fabs(lp_lat - HALFPI) < EPS10) throw proj_exception();;
|
||||
xy_x = (xy_y = (HALFPI + lp_lat)) * sin(lp_lon);
|
||||
xy_y *= coslam;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double cosc, c_rh, sinc;
|
||||
|
||||
if ((c_rh = boost::math::hypot(xy_x, xy_y)) > PI) {
|
||||
if (c_rh - EPS10 > PI) throw proj_exception();;
|
||||
c_rh = PI;
|
||||
} else if (c_rh < EPS10) {
|
||||
lp_lat = this->m_par.phi0;
|
||||
lp_lon = 0.;
|
||||
return;
|
||||
}
|
||||
if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
|
||||
sinc = sin(c_rh);
|
||||
cosc = cos(c_rh);
|
||||
if (this->m_proj_parm.mode == EQUIT) {
|
||||
lp_lat = aasin(xy_y * sinc / c_rh);
|
||||
xy_x *= sinc;
|
||||
xy_y = cosc * c_rh;
|
||||
} else {
|
||||
lp_lat = aasin(cosc * this->m_proj_parm.sinph0 + xy_y * sinc * this->m_proj_parm.cosph0 /
|
||||
c_rh);
|
||||
xy_y = (cosc - this->m_proj_parm.sinph0 * sin(lp_lat)) * c_rh;
|
||||
xy_x *= sinc * this->m_proj_parm.cosph0;
|
||||
}
|
||||
lp_lon = xy_y == 0. ? 0. : atan2(xy_x, xy_y);
|
||||
} else if (this->m_proj_parm.mode == N_POLE) {
|
||||
lp_lat = HALFPI - c_rh;
|
||||
lp_lon = atan2(xy_x, -xy_y);
|
||||
} else {
|
||||
lp_lat = c_rh - HALFPI;
|
||||
lp_lon = atan2(xy_x, xy_y);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Azimuthal Equidistant
|
||||
template <typename Parameters>
|
||||
void setup_aeqd(Parameters& par, par_aeqd& proj_parm)
|
||||
{
|
||||
par.phi0 = pj_param(par.params, "rlat_0").f;
|
||||
if (fabs(fabs(par.phi0) - HALFPI) < EPS10) {
|
||||
proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
|
||||
proj_parm.sinph0 = par.phi0 < 0. ? -1. : 1.;
|
||||
proj_parm.cosph0 = 0.;
|
||||
} else if (fabs(par.phi0) < EPS10) {
|
||||
proj_parm.mode = EQUIT;
|
||||
proj_parm.sinph0 = 0.;
|
||||
proj_parm.cosph0 = 1.;
|
||||
} else {
|
||||
proj_parm.mode = OBLIQ;
|
||||
proj_parm.sinph0 = sin(par.phi0);
|
||||
proj_parm.cosph0 = cos(par.phi0);
|
||||
}
|
||||
if (! par.es) {
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
} else {
|
||||
pj_enfn(par.es, proj_parm.en);
|
||||
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;
|
||||
// par.fwd = e_guam_fwd;
|
||||
} else {
|
||||
switch (proj_parm.mode) {
|
||||
case N_POLE:
|
||||
proj_parm.Mp = pj_mlfn(HALFPI, 1., 0., proj_parm.en);
|
||||
break;
|
||||
case S_POLE:
|
||||
proj_parm.Mp = pj_mlfn(-HALFPI, -1., 0., proj_parm.en);
|
||||
break;
|
||||
case EQUIT:
|
||||
case OBLIQ:
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
proj_parm.N1 = 1. / sqrt(1. - par.es * proj_parm.sinph0 * proj_parm.sinph0);
|
||||
proj_parm.G = proj_parm.sinph0 * (proj_parm.He = par.e / sqrt(par.one_es));
|
||||
proj_parm.He *= proj_parm.cosph0;
|
||||
break;
|
||||
}
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::aeqd
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Azimuthal Equidistant projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_0 guam
|
||||
\par Example
|
||||
\image html ex_aeqd.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct aeqd_ellipsoid : public detail::aeqd::base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline aeqd_ellipsoid(const Parameters& par) : detail::aeqd::base_aeqd_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Azimuthal Equidistant projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_0 guam
|
||||
\par Example
|
||||
\image html ex_aeqd.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct aeqd_guam : public detail::aeqd::base_aeqd_guam<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline aeqd_guam(const Parameters& par) : detail::aeqd::base_aeqd_guam<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Azimuthal Equidistant projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_0 guam
|
||||
\par Example
|
||||
\image html ex_aeqd.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct aeqd_spheroid : public detail::aeqd::base_aeqd_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline aeqd_spheroid(const Parameters& par) : detail::aeqd::base_aeqd_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aeqd::setup_aeqd(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class aeqd_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (! par.es)
|
||||
return new base_v_fi<aeqd_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else if (pj_param(par.params, "bguam").i)
|
||||
return new base_v_fi<aeqd_guam<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<aeqd_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void aeqd_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("aeqd", new aeqd_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_AEQD_HPP
|
||||
|
||||
217
include/boost/geometry/extensions/gis/projections/proj/airy.hpp
Normal file
217
include/boost/geometry/extensions/gis/projections/proj/airy.hpp
Normal file
@@ -0,0 +1,217 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace airy{
|
||||
static const double EPS = 1.e-10;
|
||||
static const int N_POLE = 0;
|
||||
static const int S_POLE = 1;
|
||||
static const int EQUIT = 2;
|
||||
static const int OBLIQ = 3;
|
||||
|
||||
struct par_airy
|
||||
{
|
||||
double p_halfpi;
|
||||
double sinph0;
|
||||
double cosph0;
|
||||
double Cb;
|
||||
int mode;
|
||||
int no_cut; /* do not cut at hemisphere limit */
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_airy_spheroid : public base_t_f<base_airy_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_airy m_proj_parm;
|
||||
|
||||
inline base_airy_spheroid(const Parameters& par)
|
||||
: base_t_f<base_airy_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double sinlam, coslam, cosphi, sinphi, t, s, Krho, cosz;
|
||||
|
||||
sinlam = sin(lp_lon);
|
||||
coslam = cos(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
case OBLIQ:
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
cosz = cosphi * coslam;
|
||||
if (this->m_proj_parm.mode == OBLIQ)
|
||||
cosz = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosz;
|
||||
if (!this->m_proj_parm.no_cut && cosz < -EPS)
|
||||
throw proj_exception();;
|
||||
if (fabs(s = 1. - cosz) > EPS) {
|
||||
t = 0.5 * (1. + cosz);
|
||||
Krho = -log(t)/s - this->m_proj_parm.Cb / t;
|
||||
} else
|
||||
Krho = 0.5 - this->m_proj_parm.Cb;
|
||||
xy_x = Krho * cosphi * sinlam;
|
||||
if (this->m_proj_parm.mode == OBLIQ)
|
||||
xy_y = Krho * (this->m_proj_parm.cosph0 * sinphi -
|
||||
this->m_proj_parm.sinph0 * cosphi * coslam);
|
||||
else
|
||||
xy_y = Krho * sinphi;
|
||||
break;
|
||||
case S_POLE:
|
||||
case N_POLE:
|
||||
lp_lat = fabs(this->m_proj_parm.p_halfpi - lp_lat);
|
||||
if (!this->m_proj_parm.no_cut && (lp_lat - EPS) > HALFPI)
|
||||
throw proj_exception();;
|
||||
if ((lp_lat *= 0.5) > EPS) {
|
||||
t = tan(lp_lat);
|
||||
Krho = -2.*(log(cos(lp_lat)) / t + t * this->m_proj_parm.Cb);
|
||||
xy_x = Krho * sinlam;
|
||||
xy_y = Krho * coslam;
|
||||
if (this->m_proj_parm.mode == N_POLE)
|
||||
xy_y = -xy_y;
|
||||
} else
|
||||
xy_x = xy_y = 0.;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Airy
|
||||
template <typename Parameters>
|
||||
void setup_airy(Parameters& par, par_airy& proj_parm)
|
||||
{
|
||||
double beta;
|
||||
proj_parm.no_cut = pj_param(par.params, "bno_cut").i;
|
||||
beta = 0.5 * (HALFPI - pj_param(par.params, "rlat_b").f);
|
||||
if (fabs(beta) < EPS)
|
||||
proj_parm.Cb = -0.5;
|
||||
else {
|
||||
proj_parm.Cb = 1./tan(beta);
|
||||
proj_parm.Cb *= proj_parm.Cb * log(cos(beta));
|
||||
}
|
||||
if (fabs(fabs(par.phi0) - HALFPI) < EPS)
|
||||
if (par.phi0 < 0.) {
|
||||
proj_parm.p_halfpi = -HALFPI;
|
||||
proj_parm.mode = S_POLE;
|
||||
} else {
|
||||
proj_parm.p_halfpi = HALFPI;
|
||||
proj_parm.mode = N_POLE;
|
||||
}
|
||||
else {
|
||||
if (fabs(par.phi0) < EPS)
|
||||
proj_parm.mode = EQUIT;
|
||||
else {
|
||||
proj_parm.mode = OBLIQ;
|
||||
proj_parm.sinph0 = sin(par.phi0);
|
||||
proj_parm.cosph0 = cos(par.phi0);
|
||||
}
|
||||
}
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::airy
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Airy projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
- no_cut lat_b=
|
||||
\par Example
|
||||
\image html ex_airy.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct airy_spheroid : public detail::airy::base_airy_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline airy_spheroid(const Parameters& par) : detail::airy::base_airy_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::airy::setup_airy(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class airy_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<airy_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void airy_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("airy", new airy_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_AIRY_HPP
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace aitoff{
|
||||
|
||||
struct par_aitoff
|
||||
{
|
||||
double cosphi1;
|
||||
int mode;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_aitoff_spheroid : public base_t_f<base_aitoff_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_aitoff m_proj_parm;
|
||||
|
||||
inline base_aitoff_spheroid(const Parameters& par)
|
||||
: base_t_f<base_aitoff_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double c, d;
|
||||
|
||||
if((d = acos(cos(lp_lat) * cos(c = 0.5 * lp_lon)))) {/* basic Aitoff */
|
||||
xy_x = 2. * d * cos(lp_lat) * sin(c) * (xy_y = 1. / sin(d));
|
||||
xy_y *= d * sin(lp_lat);
|
||||
} else
|
||||
xy_x = xy_y = 0.;
|
||||
if (this->m_proj_parm.mode) { /* Winkel Tripel */
|
||||
xy_x = (xy_x + lp_lon * this->m_proj_parm.cosphi1) * 0.5;
|
||||
xy_y = (xy_y + lp_lat) * 0.5;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_aitoff& proj_parm)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(proj_parm);
|
||||
// par.inv = 0;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
|
||||
// Aitoff
|
||||
template <typename Parameters>
|
||||
void setup_aitoff(Parameters& par, par_aitoff& proj_parm)
|
||||
{
|
||||
proj_parm.mode = 0;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Winkel Tripel
|
||||
template <typename Parameters>
|
||||
void setup_wintri(Parameters& par, par_aitoff& proj_parm)
|
||||
{
|
||||
proj_parm.mode = 1;
|
||||
if (pj_param(par.params, "tlat_1").i)
|
||||
{
|
||||
if ((proj_parm.cosphi1 = cos(pj_param(par.params, "rlat_1").f)) == 0.)
|
||||
throw proj_exception(-22);
|
||||
}
|
||||
else /* 50d28' or acos(2/pi) */
|
||||
proj_parm.cosphi1 = 0.636619772367581343;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
}} // namespace detail::aitoff
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Aitoff projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_aitoff.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct aitoff_spheroid : public detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline aitoff_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aitoff::setup_aitoff(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Winkel Tripel projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- lat_1
|
||||
\par Example
|
||||
\image html ex_wintri.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct wintri_spheroid : public detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline wintri_spheroid(const Parameters& par) : detail::aitoff::base_aitoff_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::aitoff::setup_wintri(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class aitoff_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<aitoff_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class wintri_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<wintri_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void aitoff_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("aitoff", new aitoff_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("wintri", new wintri_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_AITOFF_HPP
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace august{
|
||||
static const double M = 1.333333333333333;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_august_spheroid : public base_t_f<base_august_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_august_spheroid(const Parameters& par)
|
||||
: base_t_f<base_august_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double t, c1, c, x1, x12, y1, y12;
|
||||
|
||||
t = tan(.5 * lp_lat);
|
||||
c1 = sqrt(1. - t * t);
|
||||
c = 1. + c1 * cos(lp_lon *= .5);
|
||||
x1 = sin(lp_lon) * c1 / c;
|
||||
y1 = t / c;
|
||||
xy_x = M * x1 * (3. + (x12 = x1 * x1) - 3. * (y12 = y1 * y1));
|
||||
xy_y = M * y1 * (3. + 3. * x12 - y12);
|
||||
}
|
||||
};
|
||||
|
||||
// August Epicycloidal
|
||||
template <typename Parameters>
|
||||
void setup_august(Parameters& par)
|
||||
{
|
||||
// par.inv = 0;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::august
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief August Epicycloidal projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_august.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct august_spheroid : public detail::august::base_august_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline august_spheroid(const Parameters& par) : detail::august::base_august_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::august::setup_august(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class august_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<august_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void august_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("august", new august_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_AUGUST_HPP
|
||||
|
||||
238
include/boost/geometry/extensions/gis/projections/proj/bacon.hpp
Normal file
238
include/boost/geometry/extensions/gis/projections/proj/bacon.hpp
Normal file
@@ -0,0 +1,238 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace bacon{
|
||||
static const double HLFPI2 = 2.46740110027233965467;
|
||||
static const double EPS = 1e-10;
|
||||
|
||||
struct par_bacon
|
||||
{
|
||||
int bacn;
|
||||
int ortl;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_bacon_spheroid : public base_t_f<base_bacon_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_bacon m_proj_parm;
|
||||
|
||||
inline base_bacon_spheroid(const Parameters& par)
|
||||
: base_t_f<base_bacon_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double ax, f;
|
||||
|
||||
xy_y = this->m_proj_parm.bacn ? HALFPI * sin(lp_lat) : lp_lat;
|
||||
if ((ax = fabs(lp_lon)) >= EPS) {
|
||||
if (this->m_proj_parm.ortl && ax >= HALFPI)
|
||||
xy_x = sqrt(HLFPI2 - lp_lat * lp_lat + EPS) + ax - HALFPI;
|
||||
else {
|
||||
f = 0.5 * (HLFPI2 / ax + ax);
|
||||
xy_x = ax - f + sqrt(f * f - xy_y * xy_y);
|
||||
}
|
||||
if (lp_lon < 0.) xy_x = - xy_x;
|
||||
} else
|
||||
xy_x = 0.;
|
||||
}
|
||||
};
|
||||
|
||||
// Apian Globular I
|
||||
template <typename Parameters>
|
||||
void setup_apian(Parameters& par, par_bacon& proj_parm)
|
||||
{
|
||||
proj_parm.bacn = proj_parm.ortl = 0;
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
// Ortelius Oval
|
||||
template <typename Parameters>
|
||||
void setup_ortel(Parameters& par, par_bacon& proj_parm)
|
||||
{
|
||||
proj_parm.bacn = 0;
|
||||
proj_parm.ortl = 1;
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
// Bacon Globular
|
||||
template <typename Parameters>
|
||||
void setup_bacon(Parameters& par, par_bacon& proj_parm)
|
||||
{
|
||||
proj_parm.bacn = 1;
|
||||
proj_parm.ortl = 0;
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::bacon
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Apian Globular I projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_apian.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct apian_spheroid : public detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline apian_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::bacon::setup_apian(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Ortelius Oval projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_ortel.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct ortel_spheroid : public detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline ortel_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::bacon::setup_ortel(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Bacon Globular projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_bacon.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct bacon_spheroid : public detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline bacon_spheroid(const Parameters& par) : detail::bacon::base_bacon_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::bacon::setup_bacon(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class apian_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<apian_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class ortel_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<ortel_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class bacon_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<bacon_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void bacon_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("apian", new apian_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("ortel", new ortel_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("bacon", new bacon_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_BACON_HPP
|
||||
|
||||
253
include/boost/geometry/extensions/gis/projections/proj/bipc.hpp
Normal file
253
include/boost/geometry/extensions/gis/projections/proj/bipc.hpp
Normal file
@@ -0,0 +1,253 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace bipc{
|
||||
static const double EPS = 1e-10;
|
||||
static const double EPS10 = 1e-10;
|
||||
static const double ONEEPS = 1.000000001;
|
||||
static const int NITER = 10;
|
||||
static const double lamB = -.34894976726250681539;
|
||||
static const double n = .63055844881274687180;
|
||||
static const double F = 1.89724742567461030582;
|
||||
static const double Azab = .81650043674686363166;
|
||||
static const double Azba = 1.82261843856185925133;
|
||||
static const double T = 1.27246578267089012270;
|
||||
static const double rhoc = 1.20709121521568721927;
|
||||
static const double cAzc = .69691523038678375519;
|
||||
static const double sAzc = .71715351331143607555;
|
||||
static const double C45 = .70710678118654752469;
|
||||
static const double S45 = .70710678118654752410;
|
||||
static const double C20 = .93969262078590838411;
|
||||
static const double S20 = -.34202014332566873287;
|
||||
static const double R110 = 1.91986217719376253360;
|
||||
static const double R104 = 1.81514242207410275904;
|
||||
|
||||
struct par_bipc
|
||||
{
|
||||
int noskew;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_bipc_spheroid : public base_t_fi<base_bipc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_bipc m_proj_parm;
|
||||
|
||||
inline base_bipc_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_bipc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double cphi, sphi, tphi, t, al, Az, z, Av, cdlam, sdlam, r;
|
||||
int tag;
|
||||
|
||||
cphi = cos(lp_lat);
|
||||
sphi = sin(lp_lat);
|
||||
cdlam = cos(sdlam = lamB - lp_lon);
|
||||
sdlam = sin(sdlam);
|
||||
if (fabs(fabs(lp_lat) - HALFPI) < EPS10) {
|
||||
Az = lp_lat < 0. ? PI : 0.;
|
||||
tphi = HUGE_VAL;
|
||||
} else {
|
||||
tphi = sphi / cphi;
|
||||
Az = atan2(sdlam , C45 * (tphi - cdlam));
|
||||
}
|
||||
if( (tag = (Az > Azba)) ) {
|
||||
cdlam = cos(sdlam = lp_lon + R110);
|
||||
sdlam = sin(sdlam);
|
||||
z = S20 * sphi + C20 * cphi * cdlam;
|
||||
if (fabs(z) > 1.) {
|
||||
if (fabs(z) > ONEEPS) throw proj_exception();
|
||||
else z = z < 0. ? -1. : 1.;
|
||||
} else
|
||||
z = acos(z);
|
||||
if (tphi != HUGE_VAL)
|
||||
Az = atan2(sdlam, (C20 * tphi - S20 * cdlam));
|
||||
Av = Azab;
|
||||
xy_y = rhoc;
|
||||
} else {
|
||||
z = S45 * (sphi + cphi * cdlam);
|
||||
if (fabs(z) > 1.) {
|
||||
if (fabs(z) > ONEEPS) throw proj_exception();
|
||||
else z = z < 0. ? -1. : 1.;
|
||||
} else
|
||||
z = acos(z);
|
||||
Av = Azba;
|
||||
xy_y = -rhoc;
|
||||
}
|
||||
if (z < 0.) throw proj_exception();;
|
||||
r = F * (t = pow(tan(.5 * z), n));
|
||||
if ((al = .5 * (R104 - z)) < 0.) throw proj_exception();;
|
||||
al = (t + pow(al, n)) / T;
|
||||
if (fabs(al) > 1.) {
|
||||
if (fabs(al) > ONEEPS) throw proj_exception();
|
||||
else al = al < 0. ? -1. : 1.;
|
||||
} else
|
||||
al = acos(al);
|
||||
if (fabs(t = n * (Av - Az)) < al)
|
||||
r /= cos(al + (tag ? t : -t));
|
||||
xy_x = r * sin(t);
|
||||
xy_y += (tag ? -r : r) * cos(t);
|
||||
if (this->m_proj_parm.noskew) {
|
||||
t = xy_x;
|
||||
xy_x = -xy_x * cAzc - xy_y * sAzc;
|
||||
xy_y = -xy_y * cAzc + t * sAzc;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double t, r, rp, rl, al, z, fAz, Az, s, c, Av;
|
||||
int neg, i;
|
||||
|
||||
if (this->m_proj_parm.noskew) {
|
||||
t = xy_x;
|
||||
xy_x = -xy_x * cAzc + xy_y * sAzc;
|
||||
xy_y = -xy_y * cAzc - t * sAzc;
|
||||
}
|
||||
if( (neg = (xy_x < 0.)) ) {
|
||||
xy_y = rhoc - xy_y;
|
||||
s = S20;
|
||||
c = C20;
|
||||
Av = Azab;
|
||||
} else {
|
||||
xy_y += rhoc;
|
||||
s = S45;
|
||||
c = C45;
|
||||
Av = Azba;
|
||||
}
|
||||
rl = rp = r = boost::math::hypot(xy_x, xy_y);
|
||||
fAz = fabs(Az = atan2(xy_x, xy_y));
|
||||
for (i = NITER; i ; --i) {
|
||||
z = 2. * atan(pow(r / F,1 / n));
|
||||
al = acos((pow(tan(.5 * z), n) +
|
||||
pow(tan(.5 * (R104 - z)), n)) / T);
|
||||
if (fAz < al)
|
||||
r = rp * cos(al + (neg ? Az : -Az));
|
||||
if (fabs(rl - r) < EPS)
|
||||
break;
|
||||
rl = r;
|
||||
}
|
||||
if (! i) throw proj_exception();;
|
||||
Az = Av - Az / n;
|
||||
lp_lat = asin(s * cos(z) + c * sin(z) * cos(Az));
|
||||
lp_lon = atan2(sin(Az), c / tan(z) - s * cos(Az));
|
||||
if (neg)
|
||||
lp_lon -= R110;
|
||||
else
|
||||
lp_lon = lamB - lp_lon;
|
||||
}
|
||||
};
|
||||
|
||||
// Bipolar conic of western hemisphere
|
||||
template <typename Parameters>
|
||||
void setup_bipc(Parameters& par, par_bipc& proj_parm)
|
||||
{
|
||||
proj_parm.noskew = pj_param(par.params, "bns").i;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::bipc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Bipolar conic of western hemisphere projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_bipc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct bipc_spheroid : public detail::bipc::base_bipc_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline bipc_spheroid(const Parameters& par) : detail::bipc::base_bipc_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::bipc::setup_bipc(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class bipc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<bipc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void bipc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("bipc", new bipc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_BIPC_HPP
|
||||
|
||||
154
include/boost/geometry/extensions/gis/projections/proj/boggs.hpp
Normal file
154
include/boost/geometry/extensions/gis/projections/proj/boggs.hpp
Normal file
@@ -0,0 +1,154 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace boggs{
|
||||
static const int NITER = 20;
|
||||
static const double EPS = 1e-7;
|
||||
static const double ONETOL = 1.000001;
|
||||
static const double FXC = 2.00276;
|
||||
static const double FXC2 = 1.11072;
|
||||
static const double FYC = 0.49931;
|
||||
static const double FYC2 = 1.41421356237309504880;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_boggs_spheroid : public base_t_f<base_boggs_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_boggs_spheroid(const Parameters& par)
|
||||
: base_t_f<base_boggs_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double theta, th1, c;
|
||||
int i;
|
||||
|
||||
theta = lp_lat;
|
||||
if (fabs(fabs(lp_lat) - HALFPI) < EPS)
|
||||
xy_x = 0.;
|
||||
else {
|
||||
c = sin(theta) * PI;
|
||||
for (i = NITER; i; --i) {
|
||||
theta -= th1 = (theta + sin(theta) - c) /
|
||||
(1. + cos(theta));
|
||||
if (fabs(th1) < EPS) break;
|
||||
}
|
||||
theta *= 0.5;
|
||||
xy_x = FXC * lp_lon / (1. / cos(lp_lat) + FXC2 / cos(theta));
|
||||
}
|
||||
xy_y = FYC * (lp_lat + FYC2 * sin(theta));
|
||||
}
|
||||
};
|
||||
|
||||
// Boggs Eumorphic
|
||||
template <typename Parameters>
|
||||
void setup_boggs(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::boggs
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Boggs Eumorphic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Pseudocylindrical
|
||||
- no inverse
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_boggs.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct boggs_spheroid : public detail::boggs::base_boggs_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline boggs_spheroid(const Parameters& par) : detail::boggs::base_boggs_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::boggs::setup_boggs(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class boggs_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<boggs_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void boggs_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("boggs", new boggs_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_BOGGS_HPP
|
||||
|
||||
246
include/boost/geometry/extensions/gis/projections/proj/bonne.hpp
Normal file
246
include/boost/geometry/extensions/gis/projections/proj/bonne.hpp
Normal file
@@ -0,0 +1,246 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace bonne{
|
||||
static const double EPS10 = 1e-10;
|
||||
|
||||
struct par_bonne
|
||||
{
|
||||
double phi1;
|
||||
double cphi1;
|
||||
double am1;
|
||||
double m1;
|
||||
double en[EN_SIZE];
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_bonne_ellipsoid : public base_t_fi<base_bonne_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_bonne m_proj_parm;
|
||||
|
||||
inline base_bonne_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_bonne_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double rh, E, c;
|
||||
|
||||
rh = this->m_proj_parm.am1 + this->m_proj_parm.m1 - pj_mlfn(lp_lat, E = sin(lp_lat), c = cos(lp_lat), this->m_proj_parm.en);
|
||||
E = c * lp_lon / (rh * sqrt(1. - this->m_par.es * E * E));
|
||||
xy_x = rh * sin(E);
|
||||
xy_y = this->m_proj_parm.am1 - rh * cos(E);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double s, rh;
|
||||
|
||||
rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.am1 - xy_y);
|
||||
lp_lat = pj_inv_mlfn(this->m_proj_parm.am1 + this->m_proj_parm.m1 - rh, this->m_par.es, this->m_proj_parm.en);
|
||||
if ((s = fabs(lp_lat)) < HALFPI) {
|
||||
s = sin(lp_lat);
|
||||
lp_lon = rh * atan2(xy_x, xy_y) *
|
||||
sqrt(1. - this->m_par.es * s * s) / cos(lp_lat);
|
||||
} else if (fabs(s - HALFPI) <= EPS10)
|
||||
lp_lon = 0.;
|
||||
else throw proj_exception();;
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_bonne_spheroid : public base_t_fi<base_bonne_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_bonne m_proj_parm;
|
||||
|
||||
inline base_bonne_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_bonne_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double E, rh;
|
||||
|
||||
rh = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - lp_lat;
|
||||
if (fabs(rh) > EPS10) {
|
||||
xy_x = rh * sin(E = lp_lon * cos(lp_lat) / rh);
|
||||
xy_y = this->m_proj_parm.cphi1 - rh * cos(E);
|
||||
} else
|
||||
xy_x = xy_y = 0.;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double rh;
|
||||
|
||||
rh = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.cphi1 - xy_y);
|
||||
lp_lat = this->m_proj_parm.cphi1 + this->m_proj_parm.phi1 - rh;
|
||||
if (fabs(lp_lat) > HALFPI) throw proj_exception();;
|
||||
if (fabs(fabs(lp_lat) - HALFPI) <= EPS10)
|
||||
lp_lon = 0.;
|
||||
else
|
||||
lp_lon = rh * atan2(xy_x, xy_y) / cos(lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
// Bonne (Werner lat_1=90)
|
||||
template <typename Parameters>
|
||||
void setup_bonne(Parameters& par, par_bonne& proj_parm)
|
||||
{
|
||||
double c;
|
||||
proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
|
||||
if (fabs(proj_parm.phi1) < EPS10) throw proj_exception(-23);
|
||||
if (par.es) {
|
||||
pj_enfn(par.es, proj_parm.en);
|
||||
proj_parm.m1 = pj_mlfn(proj_parm.phi1, proj_parm.am1 = sin(proj_parm.phi1),
|
||||
c = cos(proj_parm.phi1), proj_parm.en);
|
||||
proj_parm.am1 = c / (sqrt(1. - par.es * proj_parm.am1 * proj_parm.am1) * proj_parm.am1);
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else {
|
||||
if (fabs(proj_parm.phi1) + EPS10 >= HALFPI)
|
||||
proj_parm.cphi1 = 0.;
|
||||
else
|
||||
proj_parm.cphi1 = 1. / tan(proj_parm.phi1);
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::bonne
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Bonne (Werner lat_1=90) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_1=
|
||||
\par Example
|
||||
\image html ex_bonne.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct bonne_ellipsoid : public detail::bonne::base_bonne_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline bonne_ellipsoid(const Parameters& par) : detail::bonne::base_bonne_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::bonne::setup_bonne(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Bonne (Werner lat_1=90) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_1=
|
||||
\par Example
|
||||
\image html ex_bonne.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct bonne_spheroid : public detail::bonne::base_bonne_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline bonne_spheroid(const Parameters& par) : detail::bonne::base_bonne_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::bonne::setup_bonne(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class bonne_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<bonne_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<bonne_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void bonne_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("bonne", new bonne_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_BONNE_HPP
|
||||
|
||||
465
include/boost/geometry/extensions/gis/projections/proj/cass.hpp
Normal file
465
include/boost/geometry/extensions/gis/projections/proj/cass.hpp
Normal file
@@ -0,0 +1,465 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_CASS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_CASS_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace cass{
|
||||
static const double EPS10 = 1e-10;
|
||||
static const double C1 = .16666666666666666666;
|
||||
static const double C2 = .00833333333333333333;
|
||||
static const double C3 = .04166666666666666666;
|
||||
static const double C4 = .33333333333333333333;
|
||||
static const double C5 = .06666666666666666666;
|
||||
|
||||
struct par_cass
|
||||
{
|
||||
double m0;
|
||||
double n;
|
||||
double t;
|
||||
double a1;
|
||||
double c;
|
||||
double r;
|
||||
double dd;
|
||||
double d2;
|
||||
double a2;
|
||||
double tn;
|
||||
double en[EN_SIZE];
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_cass_ellipsoid : public base_t_fi<base_cass_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
mutable par_cass m_proj_parm;
|
||||
|
||||
inline base_cass_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_cass_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_y = pj_mlfn(lp_lat, this->m_proj_parm.n = sin(lp_lat), this->m_proj_parm.c = cos(lp_lat), this->m_proj_parm.en);
|
||||
this->m_proj_parm.n = 1./sqrt(1. - this->m_par.es * this->m_proj_parm.n * this->m_proj_parm.n);
|
||||
this->m_proj_parm.tn = tan(lp_lat); this->m_proj_parm.t = this->m_proj_parm.tn * this->m_proj_parm.tn;
|
||||
this->m_proj_parm.a1 = lp_lon * this->m_proj_parm.c;
|
||||
this->m_proj_parm.c *= this->m_par.es * this->m_proj_parm.c / (1 - this->m_par.es);
|
||||
this->m_proj_parm.a2 = this->m_proj_parm.a1 * this->m_proj_parm.a1;
|
||||
xy_x = this->m_proj_parm.n * this->m_proj_parm.a1 * (1. - this->m_proj_parm.a2 * this->m_proj_parm.t *
|
||||
(C1 - (8. - this->m_proj_parm.t + 8. * this->m_proj_parm.c) * this->m_proj_parm.a2 * C2));
|
||||
xy_y -= this->m_proj_parm.m0 - this->m_proj_parm.n * this->m_proj_parm.tn * this->m_proj_parm.a2 *
|
||||
(.5 + (5. - this->m_proj_parm.t + 6. * this->m_proj_parm.c) * this->m_proj_parm.a2 * C3);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double ph1;
|
||||
|
||||
ph1 = pj_inv_mlfn(this->m_proj_parm.m0 + xy_y, this->m_par.es, this->m_proj_parm.en);
|
||||
this->m_proj_parm.tn = tan(ph1); this->m_proj_parm.t = this->m_proj_parm.tn * this->m_proj_parm.tn;
|
||||
this->m_proj_parm.n = sin(ph1);
|
||||
this->m_proj_parm.r = 1. / (1. - this->m_par.es * this->m_proj_parm.n * this->m_proj_parm.n);
|
||||
this->m_proj_parm.n = sqrt(this->m_proj_parm.r);
|
||||
this->m_proj_parm.r *= (1. - this->m_par.es) * this->m_proj_parm.n;
|
||||
this->m_proj_parm.dd = xy_x / this->m_proj_parm.n;
|
||||
this->m_proj_parm.d2 = this->m_proj_parm.dd * this->m_proj_parm.dd;
|
||||
lp_lat = ph1 - (this->m_proj_parm.n * this->m_proj_parm.tn / this->m_proj_parm.r) * this->m_proj_parm.d2 *
|
||||
(.5 - (1. + 3. * this->m_proj_parm.t) * this->m_proj_parm.d2 * C3);
|
||||
lp_lon = this->m_proj_parm.dd * (1. + this->m_proj_parm.t * this->m_proj_parm.d2 *
|
||||
(-C4 + (1. + 3. * this->m_proj_parm.t) * this->m_proj_parm.d2 * C5)) / cos(ph1);
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_cass_spheroid : public base_t_fi<base_cass_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
mutable par_cass m_proj_parm;
|
||||
|
||||
inline base_cass_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_cass_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = asin(cos(lp_lat) * sin(lp_lon));
|
||||
xy_y = atan2(tan(lp_lat) , cos(lp_lon)) - this->m_par.phi0;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = asin(sin(this->m_proj_parm.dd = xy_y + this->m_par.phi0) * cos(xy_x));
|
||||
lp_lon = atan2(tan(xy_x), cos(this->m_proj_parm.dd));
|
||||
}
|
||||
};
|
||||
|
||||
// Cassini
|
||||
template <typename Parameters>
|
||||
void setup_cass(Parameters& par, par_cass& proj_parm)
|
||||
{
|
||||
if (par.es) {
|
||||
pj_enfn(par.es, proj_parm.en);
|
||||
proj_parm.m0 = pj_mlfn(par.phi0, sin(par.phi0), cos(par.phi0), proj_parm.en);
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else {
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::cass
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Cassini projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
\par Example
|
||||
\image html ex_cass.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct cass_ellipsoid : public detail::cass::base_cass_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline cass_ellipsoid(const Parameters& par) : detail::cass::base_cass_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::cass::setup_cass(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Cassini projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
\par Example
|
||||
\image html ex_cass.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct cass_spheroid : public detail::cass::base_cass_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline cass_spheroid(const Parameters& par) : detail::cass::base_cass_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::cass::setup_cass(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class cass_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<cass_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<cass_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void cass_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("cass", new cass_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
// Create EPSG specializations
|
||||
// (Proof of Concept, only for some)
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<2066, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=11.25217861111111 +lon_0=-60.68600888888889 +x_0=37718.66159325 +y_0=36209.91512952 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.201166195164";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<2099, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=25.38236111111111 +lon_0=50.76138888888889 +x_0=100000 +y_0=100000 +ellps=helmert +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<2314, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=10.44166666666667 +lon_0=-61.33333333333334 +x_0=86501.46392052001 +y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3068, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=52.41864827777778 +lon_0=13.62720366666667 +x_0=40000 +y_0=10000 +ellps=bessel +datum=potsdam +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3140, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=-18 +lon_0=178 +x_0=109435.392 +y_0=141622.272 +a=6378306.3696 +b=6356571.996 +towgs84=51,391,-36,0,0,0,0 +to_meter=0.201168";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3366, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3377, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=2.121679744444445 +lon_0=103.4279362361111 +x_0=-14810.562 +y_0=8758.32 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3378, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=2.682347636111111 +lon_0=101.9749050416667 +x_0=3673.785 +y_0=-4240.573 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3379, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=3.769388088888889 +lon_0=102.3682989833333 +x_0=-7368.228 +y_0=6485.858 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3380, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=3.68464905 +lon_0=101.3891079138889 +x_0=-34836.161 +y_0=56464.049 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3381, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=4.9762852 +lon_0=103.070275625 +x_0=19594.245 +y_0=3371.895 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3382, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=5.421517541666667 +lon_0=100.3443769638889 +x_0=-23.414 +y_0=62.283 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3383, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=5.964672713888889 +lon_0=100.6363711111111 +x_0=0 +y_0=0 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3384, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=4.859063022222222 +lon_0=100.8154105861111 +x_0=-1.769 +y_0=133454.779 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3385, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=5.972543658333334 +lon_0=102.2952416694444 +x_0=13227.851 +y_0=8739.894 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<3407, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=22.31213333333334 +lon_0=114.1785555555556 +x_0=40243.57775604237 +y_0=19069.93351512578 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.3047972654";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<24500, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=1.287646666666667 +lon_0=103.8530022222222 +x_0=30000 +y_0=30000 +a=6377304.063 +b=6356103.038993155 +towgs84=-11,851,5,0,0,0,0 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<28191, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<28193, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=1126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<30200, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef cass_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=cass +lat_0=10.44166666666667 +lon_0=-61.33333333333334 +x_0=86501.46392051999 +y_0=65379.0134283 +a=6378293.645208759 +b=6356617.987679838 +to_meter=0.201166195164";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_CASS_HPP
|
||||
|
||||
145
include/boost/geometry/extensions/gis/projections/proj/cc.hpp
Normal file
145
include/boost/geometry/extensions/gis/projections/proj/cc.hpp
Normal file
@@ -0,0 +1,145 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_CC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_CC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace cc{
|
||||
static const double EPS10 = 1.e-10;
|
||||
|
||||
struct par_cc
|
||||
{
|
||||
double ap;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_cc_spheroid : public base_t_fi<base_cc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_cc m_proj_parm;
|
||||
|
||||
inline base_cc_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_cc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception();;
|
||||
xy_x = lp_lon;
|
||||
xy_y = tan(lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = atan(xy_y);
|
||||
lp_lon = xy_x;
|
||||
}
|
||||
};
|
||||
|
||||
// Central Cylindrical
|
||||
template <typename Parameters>
|
||||
void setup_cc(Parameters& par, par_cc& proj_parm)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::cc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Central Cylindrical projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_cc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct cc_spheroid : public detail::cc::base_cc_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline cc_spheroid(const Parameters& par) : detail::cc::base_cc_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::cc::setup_cc(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class cc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<cc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void cc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("cc", new cc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_CC_HPP
|
||||
|
||||
224
include/boost/geometry/extensions/gis/projections/proj/cea.hpp
Normal file
224
include/boost/geometry/extensions/gis/projections/proj/cea.hpp
Normal file
@@ -0,0 +1,224 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_CEA_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_CEA_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_auth.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace cea{
|
||||
static const double EPS = 1e-10;
|
||||
|
||||
struct par_cea
|
||||
{
|
||||
double qp;
|
||||
double apa[APA_SIZE];
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_cea_ellipsoid : public base_t_fi<base_cea_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_cea m_proj_parm;
|
||||
|
||||
inline base_cea_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_cea_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = this->m_par.k0 * lp_lon;
|
||||
xy_y = .5 * pj_qsfn(sin(lp_lat), this->m_par.e, this->m_par.one_es) / this->m_par.k0;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = pj_authlat(asin( 2. * xy_y * this->m_par.k0 / this->m_proj_parm.qp), this->m_proj_parm.apa);
|
||||
lp_lon = xy_x / this->m_par.k0;
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_cea_spheroid : public base_t_fi<base_cea_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_cea m_proj_parm;
|
||||
|
||||
inline base_cea_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_cea_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = this->m_par.k0 * lp_lon;
|
||||
xy_y = sin(lp_lat) / this->m_par.k0;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double t;
|
||||
|
||||
if ((t = fabs(xy_y *= this->m_par.k0)) - EPS <= 1.) {
|
||||
if (t >= 1.)
|
||||
lp_lat = xy_y < 0. ? -HALFPI : HALFPI;
|
||||
else
|
||||
lp_lat = asin(xy_y);
|
||||
lp_lon = xy_x / this->m_par.k0;
|
||||
} else throw proj_exception();;
|
||||
}
|
||||
};
|
||||
|
||||
// Equal Area Cylindrical
|
||||
template <typename Parameters>
|
||||
void setup_cea(Parameters& par, par_cea& proj_parm)
|
||||
{
|
||||
double t;
|
||||
if (pj_param(par.params, "tlat_ts").i &&
|
||||
(par.k0 = cos(t = pj_param(par.params, "rlat_ts").f)) < 0.) throw proj_exception(-24);
|
||||
else
|
||||
t = 0.;
|
||||
if (par.es) {
|
||||
t = sin(t);
|
||||
par.k0 /= sqrt(1. - par.es * t * t);
|
||||
par.e = sqrt(par.es);
|
||||
pj_authset(par.es, proj_parm.apa);
|
||||
proj_parm.qp = pj_qsfn(1., par.e, par.one_es);
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else {
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::cea
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Equal Area Cylindrical projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_ts=
|
||||
\par Example
|
||||
\image html ex_cea.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct cea_ellipsoid : public detail::cea::base_cea_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline cea_ellipsoid(const Parameters& par) : detail::cea::base_cea_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::cea::setup_cea(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Equal Area Cylindrical projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_ts=
|
||||
\par Example
|
||||
\image html ex_cea.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct cea_spheroid : public detail::cea::base_cea_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline cea_spheroid(const Parameters& par) : detail::cea::base_cea_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::cea::setup_cea(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class cea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<cea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<cea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void cea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("cea", new cea_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_CEA_HPP
|
||||
|
||||
242
include/boost/geometry/extensions/gis/projections/proj/chamb.hpp
Normal file
242
include/boost/geometry/extensions/gis/projections/proj/chamb.hpp
Normal file
@@ -0,0 +1,242 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <cstdio>
|
||||
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/aasincos.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace chamb{
|
||||
static const double THIRD = 0.333333333333333333;
|
||||
static const double TOL = 1e-9;
|
||||
|
||||
struct VECT { double r, Az; };
|
||||
struct CXY { double x, y; }; // x/y for chamb
|
||||
|
||||
struct par_chamb
|
||||
{
|
||||
struct { /* control point data */
|
||||
double phi, lam;
|
||||
double cosphi, sinphi;
|
||||
VECT v;
|
||||
CXY p;
|
||||
double Az;
|
||||
} c[3];
|
||||
CXY 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;
|
||||
double cdl, dp, dl;
|
||||
|
||||
cdl = cos(dlam);
|
||||
if (fabs(dphi) > 1. || fabs(dlam) > 1.)
|
||||
v.r = aacos(s1 * s2 + c1 * c2 * cdl);
|
||||
else { /* more accurate for smaller distances */
|
||||
dp = sin(.5 * dphi);
|
||||
dl = sin(.5 * dlam);
|
||||
v.r = 2. * aasin(sqrt(dp * dp + c1 * c2 * dl * dl));
|
||||
}
|
||||
if (fabs(v.r) > TOL)
|
||||
v.Az = atan2(c2 * sin(dlam), c1 * s2 - s1 * c2 * cdl);
|
||||
else
|
||||
v.r = v.Az = 0.;
|
||||
return v;
|
||||
}
|
||||
inline double /* law of cosines */
|
||||
lc(double b,double c,double a) {
|
||||
return aacos(.5 * (b * b + c * c - a * a) / (b * c));
|
||||
}
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_chamb_spheroid : public base_t_f<base_chamb_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_chamb m_proj_parm;
|
||||
|
||||
inline base_chamb_spheroid(const Parameters& par)
|
||||
: base_t_f<base_chamb_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double sinphi, cosphi, a;
|
||||
VECT v[3];
|
||||
int i, j;
|
||||
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
for (i = 0; i < 3; ++i) { /* dist/azimiths from control */
|
||||
v[i] = vect(lp_lat - this->m_proj_parm.c[i].phi, this->m_proj_parm.c[i].cosphi, this->m_proj_parm.c[i].sinphi,
|
||||
cosphi, sinphi, lp_lon - this->m_proj_parm.c[i].lam);
|
||||
if ( ! v[i].r)
|
||||
break;
|
||||
v[i].Az = adjlon(v[i].Az - this->m_proj_parm.c[i].v.Az);
|
||||
}
|
||||
if (i < 3) /* current point at control point */
|
||||
{ xy_x = this->m_proj_parm.c[i].p.x; xy_y = this->m_proj_parm.c[i].p.y; }
|
||||
else { /* point mean of intersepts */
|
||||
{ xy_x = this->m_proj_parm.p.x; xy_y = this->m_proj_parm.p.y; }
|
||||
for (i = 0; i < 3; ++i) {
|
||||
j = i == 2 ? 0 : i + 1;
|
||||
a = lc(this->m_proj_parm.c[i].v.r, v[i].r, v[j].r);
|
||||
if (v[i].Az < 0.)
|
||||
a = -a;
|
||||
if (! i) { /* coord comp unique to each arc */
|
||||
xy_x += v[i].r * cos(a);
|
||||
xy_y -= v[i].r * sin(a);
|
||||
} else if (i == 1) {
|
||||
a = this->m_proj_parm.beta_1 - a;
|
||||
xy_x -= v[i].r * cos(a);
|
||||
xy_y -= v[i].r * sin(a);
|
||||
} else {
|
||||
a = this->m_proj_parm.beta_2 - a;
|
||||
xy_x += v[i].r * cos(a);
|
||||
xy_y += v[i].r * sin(a);
|
||||
}
|
||||
}
|
||||
xy_x *= THIRD; /* mean of arc intercepts */
|
||||
xy_y *= THIRD;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Chamberlin Trimetric
|
||||
template <typename Parameters>
|
||||
void setup_chamb(Parameters& par, par_chamb& proj_parm)
|
||||
{
|
||||
int i, j;
|
||||
char line[10];
|
||||
for (i = 0;
|
||||
i < 3;
|
||||
++i) { /* get control point locations */
|
||||
(void)sprintf(line, "rlat_%d", i+1);
|
||||
proj_parm.c[i].phi = pj_param(par.params, line).f;
|
||||
(void)sprintf(line, "rlon_%d", i+1);
|
||||
proj_parm.c[i].lam = pj_param(par.params, line).f;
|
||||
proj_parm.c[i].lam = adjlon(proj_parm.c[i].lam - par.lam0);
|
||||
proj_parm.c[i].cosphi = cos(proj_parm.c[i].phi);
|
||||
proj_parm.c[i].sinphi = sin(proj_parm.c[i].phi);
|
||||
}
|
||||
for (i = 0;
|
||||
i < 3;
|
||||
++i) { /* inter ctl pt. distances and azimuths */
|
||||
j = i == 2 ? 0 : i + 1;
|
||||
proj_parm.c[i].v = vect(proj_parm.c[j].phi - proj_parm.c[i].phi, proj_parm.c[i].cosphi, proj_parm.c[i].sinphi,
|
||||
proj_parm.c[j].cosphi, proj_parm.c[j].sinphi, proj_parm.c[j].lam - proj_parm.c[i].lam);
|
||||
if (! proj_parm.c[i].v.r) throw proj_exception(-25);
|
||||
/* co-linearity problem ignored for now */
|
||||
}
|
||||
proj_parm.beta_0 = lc(proj_parm.c[0].v.r, proj_parm.c[2].v.r, proj_parm.c[1].v.r);
|
||||
proj_parm.beta_1 = lc(proj_parm.c[0].v.r, proj_parm.c[1].v.r, proj_parm.c[2].v.r);
|
||||
proj_parm.beta_2 = PI - proj_parm.beta_0;
|
||||
proj_parm.p.y = 2. * (proj_parm.c[0].p.y = proj_parm.c[1].p.y = proj_parm.c[2].v.r * sin(proj_parm.beta_0));
|
||||
proj_parm.c[2].p.y = 0.;
|
||||
proj_parm.c[0].p.x = - (proj_parm.c[1].p.x = 0.5 * proj_parm.c[0].v.r);
|
||||
proj_parm.p.x = proj_parm.c[2].p.x = proj_parm.c[0].p.x + proj_parm.c[2].v.r * cos(proj_parm.beta_0);
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::chamb
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Chamberlin Trimetric projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
- lat_1= lon_1= lat_2= lon_2= lat_3= lon_3=
|
||||
\par Example
|
||||
\image html ex_chamb.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct chamb_spheroid : public detail::chamb::base_chamb_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline chamb_spheroid(const Parameters& par) : detail::chamb::base_chamb_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::chamb::setup_chamb(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class chamb_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<chamb_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void chamb_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("chamb", new chamb_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_CHAMB_HPP
|
||||
|
||||
152
include/boost/geometry/extensions/gis/projections/proj/collg.hpp
Normal file
152
include/boost/geometry/extensions/gis/projections/proj/collg.hpp
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace collg{
|
||||
static const double FXC = 1.12837916709551257390;
|
||||
static const double FYC = 1.77245385090551602729;
|
||||
static const double ONEEPS = 1.0000001;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_collg_spheroid : public base_t_fi<base_collg_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_collg_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_collg_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if ((xy_y = 1. - sin(lp_lat)) <= 0.)
|
||||
xy_y = 0.;
|
||||
else
|
||||
xy_y = sqrt(xy_y);
|
||||
xy_x = FXC * lp_lon * xy_y;
|
||||
xy_y = FYC * (1. - xy_y);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = xy_y / FYC - 1.;
|
||||
if (fabs(lp_lat = 1. - lp_lat * lp_lat) < 1.)
|
||||
lp_lat = asin(lp_lat);
|
||||
else if (fabs(lp_lat) > ONEEPS) throw proj_exception();
|
||||
else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
|
||||
if ((lp_lon = 1. - sin(lp_lat)) <= 0.)
|
||||
lp_lon = 0.;
|
||||
else
|
||||
lp_lon = xy_x / (FXC * sqrt(lp_lon));
|
||||
}
|
||||
};
|
||||
|
||||
// Collignon
|
||||
template <typename Parameters>
|
||||
void setup_collg(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::collg
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Collignon 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_collg.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct collg_spheroid : public detail::collg::base_collg_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline collg_spheroid(const Parameters& par) : detail::collg::base_collg_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::collg::setup_collg(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class collg_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<collg_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void collg_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("collg", new collg_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_COLLG_HPP
|
||||
|
||||
144
include/boost/geometry/extensions/gis/projections/proj/crast.hpp
Normal file
144
include/boost/geometry/extensions/gis/projections/proj/crast.hpp
Normal file
@@ -0,0 +1,144 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace crast{
|
||||
static const double XM = 0.97720502380583984317;
|
||||
static const double RXM = 1.02332670794648848847;
|
||||
static const double YM = 3.06998012383946546542;
|
||||
static const double RYM = 0.32573500793527994772;
|
||||
static const double THIRD = 0.333333333333333333;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_crast_spheroid : public base_t_fi<base_crast_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_crast_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_crast_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
lp_lat *= THIRD;
|
||||
xy_x = XM * lp_lon * (2. * cos(lp_lat + lp_lat) - 1.);
|
||||
xy_y = YM * sin(lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = 3. * asin(xy_y * RYM);
|
||||
lp_lon = xy_x * RXM / (2. * cos((lp_lat + lp_lat) * THIRD) - 1);
|
||||
}
|
||||
};
|
||||
|
||||
// Craster Parabolic (Putnins P4)
|
||||
template <typename Parameters>
|
||||
void setup_crast(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::crast
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Craster Parabolic (Putnins P4) 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_crast.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct crast_spheroid : public detail::crast::base_crast_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline crast_spheroid(const Parameters& par) : detail::crast::base_crast_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::crast::setup_crast(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class crast_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<crast_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void crast_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("crast", new crast_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_CRAST_HPP
|
||||
|
||||
140
include/boost/geometry/extensions/gis/projections/proj/denoy.hpp
Normal file
140
include/boost/geometry/extensions/gis/projections/proj/denoy.hpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace denoy{
|
||||
static const double C0 = 0.95;
|
||||
static const double C1 = -.08333333333333333333;
|
||||
static const double C3 = .00166666666666666666;
|
||||
static const double D1 = 0.9;
|
||||
static const double D5 = 0.03;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_denoy_spheroid : public base_t_f<base_denoy_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_denoy_spheroid(const Parameters& par)
|
||||
: base_t_f<base_denoy_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_y = lp_lat;
|
||||
xy_x = lp_lon;
|
||||
lp_lon = fabs(lp_lon);
|
||||
xy_x *= cos((C0 + lp_lon * (C1 + lp_lon * lp_lon * C3)) *
|
||||
(lp_lat * (D1 + D5 * lp_lat * lp_lat * lp_lat * lp_lat)));
|
||||
}
|
||||
};
|
||||
|
||||
// Denoyer Semi-Elliptical
|
||||
template <typename Parameters>
|
||||
void setup_denoy(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::denoy
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Denoyer Semi-Elliptical projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Pseudocylindrical
|
||||
- no inverse
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_denoy.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct denoy_spheroid : public detail::denoy::base_denoy_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline denoy_spheroid(const Parameters& par) : detail::denoy::base_denoy_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::denoy::setup_denoy(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class denoy_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<denoy_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void denoy_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("denoy", new denoy_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_DENOY_HPP
|
||||
|
||||
140
include/boost/geometry/extensions/gis/projections/proj/eck1.hpp
Normal file
140
include/boost/geometry/extensions/gis/projections/proj/eck1.hpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eck1{
|
||||
static const double FC = .92131773192356127802;
|
||||
static const double RP = .31830988618379067154;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eck1_spheroid : public base_t_fi<base_eck1_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_eck1_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_eck1_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = FC * lp_lon * (1. - RP * fabs(lp_lat));
|
||||
xy_y = FC * lp_lat;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = xy_y / FC;
|
||||
lp_lon = xy_x / (FC * (1. - RP * fabs(lp_lat)));
|
||||
}
|
||||
};
|
||||
|
||||
// Eckert I
|
||||
template <typename Parameters>
|
||||
void setup_eck1(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::eck1
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Eckert I 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_eck1.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eck1_spheroid : public detail::eck1::base_eck1_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eck1_spheroid(const Parameters& par) : detail::eck1::base_eck1_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck1::setup_eck1(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eck1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eck1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eck1_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eck1", new eck1_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_ECK1_HPP
|
||||
|
||||
151
include/boost/geometry/extensions/gis/projections/proj/eck2.hpp
Normal file
151
include/boost/geometry/extensions/gis/projections/proj/eck2.hpp
Normal file
@@ -0,0 +1,151 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eck2{
|
||||
static const double FXC = 0.46065886596178063902;
|
||||
static const double FYC = 1.44720250911653531871;
|
||||
static const double C13 = 0.33333333333333333333;
|
||||
static const double ONEEPS = 1.0000001;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eck2_spheroid : public base_t_fi<base_eck2_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_eck2_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_eck2_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = FXC * lp_lon * (xy_y = sqrt(4. - 3. * sin(fabs(lp_lat))));
|
||||
xy_y = FYC * (2. - xy_y);
|
||||
if ( lp_lat < 0.) xy_y = -xy_y;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lon = xy_x / (FXC * ( lp_lat = 2. - fabs(xy_y) / FYC) );
|
||||
lp_lat = (4. - lp_lat * lp_lat) * C13;
|
||||
if (fabs(lp_lat) >= 1.) {
|
||||
if (fabs(lp_lat) > ONEEPS) throw proj_exception();
|
||||
else
|
||||
lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
|
||||
} else
|
||||
lp_lat = asin(lp_lat);
|
||||
if (xy_y < 0)
|
||||
lp_lat = -lp_lat;
|
||||
}
|
||||
};
|
||||
|
||||
// Eckert II
|
||||
template <typename Parameters>
|
||||
void setup_eck2(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::eck2
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Eckert II 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_eck2.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eck2_spheroid : public detail::eck2::base_eck2_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eck2_spheroid(const Parameters& par) : detail::eck2::base_eck2_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck2::setup_eck2(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eck2_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eck2_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eck2_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eck2", new eck2_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_ECK2_HPP
|
||||
|
||||
286
include/boost/geometry/extensions/gis/projections/proj/eck3.hpp
Normal file
286
include/boost/geometry/extensions/gis/projections/proj/eck3.hpp
Normal file
@@ -0,0 +1,286 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eck3{
|
||||
|
||||
struct par_eck3
|
||||
{
|
||||
double C_x, C_y, A, B;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eck3_spheroid : public base_t_fi<base_eck3_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_eck3 m_proj_parm;
|
||||
|
||||
inline base_eck3_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_eck3_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_y = this->m_proj_parm.C_y * lp_lat;
|
||||
xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat));
|
||||
}
|
||||
|
||||
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_proj_parm.C_y;
|
||||
lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.A + asqrt(1. - this->m_proj_parm.B * lp_lat * lp_lat)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_eck3& proj_parm)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(proj_parm);
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
|
||||
// Eckert III
|
||||
template <typename Parameters>
|
||||
void setup_eck3(Parameters& par, par_eck3& proj_parm)
|
||||
{
|
||||
proj_parm.C_x = .42223820031577120149;
|
||||
proj_parm.C_y = .84447640063154240298;
|
||||
proj_parm.A = 1.;
|
||||
proj_parm.B = 0.4052847345693510857755;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Putnins P1
|
||||
template <typename Parameters>
|
||||
void setup_putp1(Parameters& par, par_eck3& proj_parm)
|
||||
{
|
||||
proj_parm.C_x = 1.89490;
|
||||
proj_parm.C_y = 0.94745;
|
||||
proj_parm.A = -0.5;
|
||||
proj_parm.B = 0.30396355092701331433;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Wagner VI
|
||||
template <typename Parameters>
|
||||
void setup_wag6(Parameters& par, par_eck3& proj_parm)
|
||||
{
|
||||
proj_parm.C_x = proj_parm.C_y = 0.94745;
|
||||
proj_parm.A = 0.;
|
||||
proj_parm.B = 0.30396355092701331433;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Kavraisky VII
|
||||
template <typename Parameters>
|
||||
void setup_kav7(Parameters& par, par_eck3& proj_parm)
|
||||
{
|
||||
proj_parm.C_x = 0.2632401569273184856851;
|
||||
proj_parm.C_x = 0.8660254037844;
|
||||
proj_parm.C_y = 1.;
|
||||
proj_parm.A = 0.;
|
||||
proj_parm.B = 0.30396355092701331433;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
}} // namespace detail::eck3
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Eckert III 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_eck3.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eck3_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eck3_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck3::setup_eck3(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Putnins P1 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_putp1.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct putp1_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline putp1_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck3::setup_putp1(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Wagner 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_wag6.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct wag6_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline wag6_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck3::setup_wag6(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Kavraisky VII 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_kav7.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct kav7_spheroid : public detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline kav7_spheroid(const Parameters& par) : detail::eck3::base_eck3_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck3::setup_kav7(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eck3_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eck3_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class putp1_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<putp1_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class wag6_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<wag6_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class kav7_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<kav7_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eck3_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eck3", new eck3_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("putp1", new putp1_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("wag6", new wag6_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("kav7", new kav7_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_ECK3_HPP
|
||||
|
||||
167
include/boost/geometry/extensions/gis/projections/proj/eck4.hpp
Normal file
167
include/boost/geometry/extensions/gis/projections/proj/eck4.hpp
Normal file
@@ -0,0 +1,167 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eck4{
|
||||
static const double C_x = .42223820031577120149;
|
||||
static const double C_y = 1.32650042817700232218;
|
||||
static const double RC_y = .75386330736002178205;
|
||||
static const double C_p = 3.57079632679489661922;
|
||||
static const double RC_p = .28004957675577868795;
|
||||
static const double EPS = 1e-7;
|
||||
static const int NITER = 6;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eck4_spheroid : public base_t_fi<base_eck4_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_eck4_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_eck4_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double p, V, s, c;
|
||||
int i;
|
||||
|
||||
p = C_p * sin(lp_lat);
|
||||
V = lp_lat * lp_lat;
|
||||
lp_lat *= 0.895168 + V * ( 0.0218849 + V * 0.00826809 );
|
||||
for (i = NITER; i ; --i) {
|
||||
c = cos(lp_lat);
|
||||
s = sin(lp_lat);
|
||||
lp_lat -= V = (lp_lat + s * (c + 2.) - p) /
|
||||
(1. + c * (c + 2.) - s * s);
|
||||
if (fabs(V) < EPS)
|
||||
break;
|
||||
}
|
||||
if (!i) {
|
||||
xy_x = C_x * lp_lon;
|
||||
xy_y = lp_lat < 0. ? -C_y : C_y;
|
||||
} else {
|
||||
xy_x = C_x * lp_lon * (1. + cos(lp_lat));
|
||||
xy_y = C_y * sin(lp_lat);
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double c;
|
||||
|
||||
lp_lat = aasin(xy_y / C_y);
|
||||
lp_lon = xy_x / (C_x * (1. + (c = cos(lp_lat))));
|
||||
lp_lat = aasin((lp_lat + sin(lp_lat) * (c + 2.)) / C_p);
|
||||
}
|
||||
};
|
||||
|
||||
// Eckert IV
|
||||
template <typename Parameters>
|
||||
void setup_eck4(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::eck4
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Eckert IV 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_eck4.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eck4_spheroid : public detail::eck4::base_eck4_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eck4_spheroid(const Parameters& par) : detail::eck4::base_eck4_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck4::setup_eck4(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eck4_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eck4_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eck4_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eck4", new eck4_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_ECK4_HPP
|
||||
|
||||
141
include/boost/geometry/extensions/gis/projections/proj/eck5.hpp
Normal file
141
include/boost/geometry/extensions/gis/projections/proj/eck5.hpp
Normal file
@@ -0,0 +1,141 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eck5{
|
||||
static const double XF = 0.44101277172455148219;
|
||||
static const double RXF = 2.26750802723822639137;
|
||||
static const double YF = 0.88202554344910296438;
|
||||
static const double RYF = 1.13375401361911319568;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eck5_spheroid : public base_t_fi<base_eck5_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_eck5_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_eck5_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = XF * (1. + cos(lp_lat)) * lp_lon;
|
||||
xy_y = YF * lp_lat;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lon = RXF * xy_x / (1. + cos( lp_lat = RYF * xy_y));
|
||||
}
|
||||
};
|
||||
|
||||
// Eckert V
|
||||
template <typename Parameters>
|
||||
void setup_eck5(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::eck5
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Eckert V 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_eck5.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eck5_spheroid : public detail::eck5::base_eck5_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eck5_spheroid(const Parameters& par) : detail::eck5::base_eck5_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eck5::setup_eck5(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eck5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eck5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eck5_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eck5", new eck5_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_ECK5_HPP
|
||||
|
||||
146
include/boost/geometry/extensions/gis/projections/proj/eqc.hpp
Normal file
146
include/boost/geometry/extensions/gis/projections/proj/eqc.hpp
Normal file
@@ -0,0 +1,146 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_EQC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_EQC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eqc{
|
||||
|
||||
struct par_eqc
|
||||
{
|
||||
double rc;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eqc_spheroid : public base_t_fi<base_eqc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_eqc m_proj_parm;
|
||||
|
||||
inline base_eqc_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_eqc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = this->m_proj_parm.rc * lp_lon;
|
||||
xy_y = lp_lat - this->m_par.phi0;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lon = xy_x / this->m_proj_parm.rc;
|
||||
lp_lat = xy_y + this->m_par.phi0;
|
||||
}
|
||||
};
|
||||
|
||||
// Equidistant Cylindrical (Plate Caree)
|
||||
template <typename Parameters>
|
||||
void setup_eqc(Parameters& par, par_eqc& proj_parm)
|
||||
{
|
||||
if ((proj_parm.rc = cos(pj_param(par.params, "rlat_ts").f)) <= 0.) throw proj_exception(-24);
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::eqc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Equidistant Cylindrical (Plate Caree) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- lat_ts=[
|
||||
- lat_0=0]
|
||||
\par Example
|
||||
\image html ex_eqc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eqc_spheroid : public detail::eqc::base_eqc_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eqc_spheroid(const Parameters& par) : detail::eqc::base_eqc_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eqc::setup_eqc(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eqc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eqc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eqc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eqc", new eqc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_EQC_HPP
|
||||
|
||||
212
include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp
Normal file
212
include/boost/geometry/extensions/gis/projections/proj/eqdc.hpp
Normal file
@@ -0,0 +1,212 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace eqdc{
|
||||
static const double EPS10 = 1.e-10;
|
||||
|
||||
struct par_eqdc
|
||||
{
|
||||
double phi1;
|
||||
double phi2;
|
||||
double n;
|
||||
double rho;
|
||||
double rho0;
|
||||
double c;
|
||||
double en[EN_SIZE];
|
||||
int ellips;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_eqdc_ellipsoid : public base_t_fi<base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
mutable par_eqdc m_proj_parm;
|
||||
|
||||
inline base_eqdc_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
this->m_proj_parm.rho = this->m_proj_parm.c - (this->m_proj_parm.ellips ? pj_mlfn(lp_lat, sin(lp_lat),
|
||||
cos(lp_lat), this->m_proj_parm.en) : lp_lat);
|
||||
xy_x = this->m_proj_parm.rho * sin( lp_lon *= this->m_proj_parm.n );
|
||||
xy_y = this->m_proj_parm.rho0 - this->m_proj_parm.rho * cos(lp_lon);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
if ((this->m_proj_parm.rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0 ) {
|
||||
if (this->m_proj_parm.n < 0.) {
|
||||
this->m_proj_parm.rho = -this->m_proj_parm.rho;
|
||||
xy_x = -xy_x;
|
||||
xy_y = -xy_y;
|
||||
}
|
||||
lp_lat = this->m_proj_parm.c - this->m_proj_parm.rho;
|
||||
if (this->m_proj_parm.ellips)
|
||||
lp_lat = pj_inv_mlfn(lp_lat, this->m_par.es, this->m_proj_parm.en);
|
||||
lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
|
||||
} else {
|
||||
lp_lon = 0.;
|
||||
lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SPECIAL_FACTORS_NOT_CONVERTED
|
||||
inline void fac(Geographic lp, Factors &fac) const
|
||||
{
|
||||
double sinphi, cosphi;
|
||||
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
this->m_fac.code |= IS_ANAL_HK;
|
||||
this->m_fac.h = 1.;
|
||||
this->m_fac.k = this->m_proj_parm.n * (this->m_proj_parm.c - (this->m_proj_parm.ellips ? pj_mlfn(lp_lat, sinphi,
|
||||
cosphi, this->m_proj_parm.en) : lp_lat)) / pj_msfn(sinphi, cosphi, this->m_par.es);
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// Equidistant Conic
|
||||
template <typename Parameters>
|
||||
void setup_eqdc(Parameters& par, par_eqdc& proj_parm)
|
||||
{
|
||||
double cosphi, sinphi;
|
||||
int secant;
|
||||
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);
|
||||
|
||||
proj_parm.n = sinphi = sin(proj_parm.phi1);
|
||||
cosphi = cos(proj_parm.phi1);
|
||||
secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10;
|
||||
if( (proj_parm.ellips = (par.es > 0.)) ) {
|
||||
double ml1, m1;
|
||||
m1 = pj_msfn(sinphi, cosphi, par.es);
|
||||
ml1 = pj_mlfn(proj_parm.phi1, sinphi, cosphi, proj_parm.en);
|
||||
if (secant) { /* secant cone */
|
||||
sinphi = sin(proj_parm.phi2);
|
||||
cosphi = cos(proj_parm.phi2);
|
||||
proj_parm.n = (m1 - pj_msfn(sinphi, cosphi, par.es)) /
|
||||
(pj_mlfn(proj_parm.phi2, sinphi, cosphi, proj_parm.en) - ml1);
|
||||
}
|
||||
proj_parm.c = ml1 + m1 / proj_parm.n;
|
||||
proj_parm.rho0 = proj_parm.c - pj_mlfn(par.phi0, sin(par.phi0),
|
||||
cos(par.phi0), proj_parm.en);
|
||||
} else {
|
||||
if (secant)
|
||||
proj_parm.n = (cosphi - cos(proj_parm.phi2)) / (proj_parm.phi2 - proj_parm.phi1);
|
||||
proj_parm.c = proj_parm.phi1 + cos(proj_parm.phi1) / proj_parm.n;
|
||||
proj_parm.rho0 = proj_parm.c - par.phi0;
|
||||
}
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
// par.spc = fac;
|
||||
}
|
||||
|
||||
}} // namespace detail::eqdc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Equidistant Conic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_1= lat_2=
|
||||
\par Example
|
||||
\image html ex_eqdc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eqdc_ellipsoid : public detail::eqdc::base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eqdc_ellipsoid(const Parameters& par) : detail::eqdc::base_eqdc_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::eqdc::setup_eqdc(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eqdc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eqdc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void eqdc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("eqdc", new eqdc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_EQDC_HPP
|
||||
|
||||
140
include/boost/geometry/extensions/gis/projections/proj/fahey.hpp
Normal file
140
include/boost/geometry/extensions/gis/projections/proj/fahey.hpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace fahey{
|
||||
static const double TOL = 1e-6;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_fahey_spheroid : public base_t_fi<base_fahey_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_fahey_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_fahey_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_y = 1.819152 * ( xy_x = tan(0.5 * lp_lat) );
|
||||
xy_x = 0.819152 * lp_lon * asqrt(1 - xy_x * xy_x);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = 2. * atan(xy_y /= 1.819152);
|
||||
lp_lon = fabs(xy_y = 1. - xy_y * xy_y) < TOL ? 0. :
|
||||
xy_x / (0.819152 * sqrt(xy_y));
|
||||
}
|
||||
};
|
||||
|
||||
// Fahey
|
||||
template <typename Parameters>
|
||||
void setup_fahey(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::fahey
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Fahey 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_fahey.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct fahey_spheroid : public detail::fahey::base_fahey_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline fahey_spheroid(const Parameters& par) : detail::fahey::base_fahey_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::fahey::setup_fahey(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class fahey_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<fahey_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void fahey_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("fahey", new fahey_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_FAHEY_HPP
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace fouc_s{
|
||||
static const int MAX_ITER = 10;
|
||||
static const double LOOP_TOL = 1e-7;
|
||||
|
||||
struct par_fouc_s
|
||||
{
|
||||
double n, n1;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_fouc_s_spheroid : public base_t_fi<base_fouc_s_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_fouc_s m_proj_parm;
|
||||
|
||||
inline base_fouc_s_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_fouc_s_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double t;
|
||||
|
||||
t = cos(lp_lat);
|
||||
xy_x = lp_lon * t / (this->m_proj_parm.n + this->m_proj_parm.n1 * t);
|
||||
xy_y = this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double V;
|
||||
int i;
|
||||
|
||||
if (this->m_proj_parm.n) {
|
||||
lp_lat = xy_y;
|
||||
for (i = MAX_ITER; i ; --i) {
|
||||
lp_lat -= V = (this->m_proj_parm.n * lp_lat + this->m_proj_parm.n1 * sin(lp_lat) - xy_y ) /
|
||||
(this->m_proj_parm.n + this->m_proj_parm.n1 * cos(lp_lat));
|
||||
if (fabs(V) < LOOP_TOL)
|
||||
break;
|
||||
}
|
||||
if (!i)
|
||||
lp_lat = xy_y < 0. ? -HALFPI : HALFPI;
|
||||
} else
|
||||
lp_lat = aasin(xy_y);
|
||||
V = cos(lp_lat);
|
||||
lp_lon = xy_x * (this->m_proj_parm.n + this->m_proj_parm.n1 * V) / V;
|
||||
}
|
||||
};
|
||||
|
||||
// Foucaut Sinusoidal
|
||||
template <typename Parameters>
|
||||
void setup_fouc_s(Parameters& par, par_fouc_s& proj_parm)
|
||||
{
|
||||
proj_parm.n = pj_param(par.params, "dn").f;
|
||||
if (proj_parm.n < 0. || proj_parm.n > 1.)
|
||||
throw proj_exception(-99);
|
||||
proj_parm.n1 = 1. - proj_parm.n;
|
||||
par.es = 0;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::fouc_s
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Foucaut 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_fouc_s.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct fouc_s_spheroid : public detail::fouc_s::base_fouc_s_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline fouc_s_spheroid(const Parameters& par) : detail::fouc_s::base_fouc_s_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::fouc_s::setup_fouc_s(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class fouc_s_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<fouc_s_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void fouc_s_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("fouc_s", new fouc_s_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_FOUC_S_HPP
|
||||
|
||||
142
include/boost/geometry/extensions/gis/projections/proj/gall.hpp
Normal file
142
include/boost/geometry/extensions/gis/projections/proj/gall.hpp
Normal file
@@ -0,0 +1,142 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GALL_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GALL_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace gall{
|
||||
static const double YF = 1.70710678118654752440;
|
||||
static const double XF = 0.70710678118654752440;
|
||||
static const double RYF = 0.58578643762690495119;
|
||||
static const double RXF = 1.41421356237309504880;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_gall_spheroid : public base_t_fi<base_gall_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_gall_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_gall_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = XF * lp_lon;
|
||||
xy_y = YF * tan(.5 * lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lon = RXF * xy_x;
|
||||
lp_lat = 2. * atan(xy_y * RYF);
|
||||
}
|
||||
};
|
||||
|
||||
// Gall (Gall Stereographic)
|
||||
template <typename Parameters>
|
||||
void setup_gall(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::gall
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Gall (Gall Stereographic) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_gall.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gall_spheroid : public detail::gall::base_gall_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gall_spheroid(const Parameters& par) : detail::gall::base_gall_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gall::setup_gall(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gall_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<gall_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void gall_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("gall", new gall_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GALL_HPP
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace geocent{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_geocent_other : public base_t_fi<base_geocent_other<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_geocent_other(const Parameters& par)
|
||||
: base_t_fi<base_geocent_other<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = lp_lon;
|
||||
xy_y = lp_lat;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = xy_y;
|
||||
lp_lon = xy_x;
|
||||
}
|
||||
};
|
||||
|
||||
// Geocentric
|
||||
template <typename Parameters>
|
||||
void setup_geocent(Parameters& par)
|
||||
{
|
||||
par.is_geocent = 1;
|
||||
|
||||
par.x0 = 0.0;
|
||||
par.y0 = 0.0;
|
||||
// par.inv = inverse;
|
||||
// par.fwd = forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::geocent
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Geocentric projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
\par Example
|
||||
\image html ex_geocent.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct geocent_other : public detail::geocent::base_geocent_other<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline geocent_other(const Parameters& par) : detail::geocent::base_geocent_other<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::geocent::setup_geocent(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class geocent_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<geocent_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void geocent_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("geocent", new geocent_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GEOCENT_HPP
|
||||
|
||||
280
include/boost/geometry/extensions/gis/projections/proj/geos.hpp
Normal file
280
include/boost/geometry/extensions/gis/projections/proj/geos.hpp
Normal file
@@ -0,0 +1,280 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace geos{
|
||||
|
||||
struct par_geos
|
||||
{
|
||||
double h;
|
||||
double radius_p;
|
||||
double radius_p2;
|
||||
double radius_p_inv2;
|
||||
double radius_g;
|
||||
double radius_g_1;
|
||||
double C;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_geos_ellipsoid : public base_t_fi<base_geos_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_geos m_proj_parm;
|
||||
|
||||
inline base_geos_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_geos_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double r, Vx, Vy, Vz, tmp;
|
||||
|
||||
/* Calculation of geocentric latitude. */
|
||||
lp_lat = atan (this->m_proj_parm.radius_p2 * tan (lp_lat));
|
||||
/* Calculation of the three components of the vector from satellite to
|
||||
** position on earth surface (lon,lat).*/
|
||||
r = (this->m_proj_parm.radius_p) / boost::math::hypot(this->m_proj_parm.radius_p * cos (lp_lat), sin (lp_lat));
|
||||
Vx = r * cos (lp_lon) * cos (lp_lat);
|
||||
Vy = r * sin (lp_lon) * cos (lp_lat);
|
||||
Vz = r * sin (lp_lat);
|
||||
/* Check visibility. */
|
||||
if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz * this->m_proj_parm.radius_p_inv2) < 0.)
|
||||
throw proj_exception();;
|
||||
/* Calculation based on view angles from satellite. */
|
||||
tmp = this->m_proj_parm.radius_g - Vx;
|
||||
xy_x = this->m_proj_parm.radius_g_1 * atan (Vy / tmp);
|
||||
xy_y = this->m_proj_parm.radius_g_1 * atan (Vz / boost::math::hypot (Vy, tmp));
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double Vx, Vy, Vz, a, b, det, k;
|
||||
|
||||
/* Setting three components of vector from satellite to position.*/
|
||||
Vx = -1.0;
|
||||
Vy = tan (xy_x / this->m_proj_parm.radius_g_1);
|
||||
Vz = tan (xy_y / this->m_proj_parm.radius_g_1) * boost::math::hypot(1.0, Vy);
|
||||
/* Calculation of terms in cubic equation and determinant.*/
|
||||
a = Vz / this->m_proj_parm.radius_p;
|
||||
a = Vy * Vy + a * a + Vx * Vx;
|
||||
b = 2 * this->m_proj_parm.radius_g * Vx;
|
||||
if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception();;
|
||||
/* Calculation of three components of vector from satellite to position.*/
|
||||
k = (-b - sqrt(det)) / (2. * a);
|
||||
Vx = this->m_proj_parm.radius_g + k * Vx;
|
||||
Vy *= k;
|
||||
Vz *= k;
|
||||
/* Calculation of longitude and latitude.*/
|
||||
lp_lon = atan2 (Vy, Vx);
|
||||
lp_lat = atan (Vz * cos (lp_lon) / Vx);
|
||||
lp_lat = atan (this->m_proj_parm.radius_p_inv2 * tan (lp_lat));
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_geos_spheroid : public base_t_fi<base_geos_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_geos m_proj_parm;
|
||||
|
||||
inline base_geos_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_geos_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double Vx, Vy, Vz, tmp;
|
||||
|
||||
/* Calculation of the three components of the vector from satellite to
|
||||
** position on earth surface (lon,lat).*/
|
||||
tmp = cos(lp_lat);
|
||||
Vx = cos (lp_lon) * tmp;
|
||||
Vy = sin (lp_lon) * tmp;
|
||||
Vz = sin (lp_lat);
|
||||
/* Check visibility.*/
|
||||
if (((this->m_proj_parm.radius_g - Vx) * Vx - Vy * Vy - Vz * Vz) < 0.) throw proj_exception();;
|
||||
/* Calculation based on view angles from satellite.*/
|
||||
tmp = this->m_proj_parm.radius_g - Vx;
|
||||
xy_x = this->m_proj_parm.radius_g_1 * atan(Vy / tmp);
|
||||
xy_y = this->m_proj_parm.radius_g_1 * atan(Vz / boost::math::hypot(Vy, tmp));
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double Vx, Vy, Vz, a, b, det, k;
|
||||
|
||||
/* Setting three components of vector from satellite to position.*/
|
||||
Vx = -1.0;
|
||||
Vy = tan (xy_x / (this->m_proj_parm.radius_g - 1.0));
|
||||
Vz = tan (xy_y / (this->m_proj_parm.radius_g - 1.0)) * sqrt (1.0 + Vy * Vy);
|
||||
/* Calculation of terms in cubic equation and determinant.*/
|
||||
a = Vy * Vy + Vz * Vz + Vx * Vx;
|
||||
b = 2 * this->m_proj_parm.radius_g * Vx;
|
||||
if ((det = (b * b) - 4 * a * this->m_proj_parm.C) < 0.) throw proj_exception();;
|
||||
/* Calculation of three components of vector from satellite to position.*/
|
||||
k = (-b - sqrt(det)) / (2 * a);
|
||||
Vx = this->m_proj_parm.radius_g + k * Vx;
|
||||
Vy *= k;
|
||||
Vz *= k;
|
||||
/* Calculation of longitude and latitude.*/
|
||||
lp_lon = atan2 (Vy, Vx);
|
||||
lp_lat = atan (Vz * cos (lp_lon) / Vx);
|
||||
}
|
||||
};
|
||||
|
||||
// Geostationary Satellite View
|
||||
template <typename Parameters>
|
||||
void setup_geos(Parameters& par, par_geos& proj_parm)
|
||||
{
|
||||
if ((proj_parm.h = pj_param(par.params, "dh").f) <= 0.) throw proj_exception(-30);
|
||||
if (par.phi0) throw proj_exception(-46);
|
||||
proj_parm.radius_g = 1. + (proj_parm.radius_g_1 = proj_parm.h / par.a);
|
||||
proj_parm.C = proj_parm.radius_g * proj_parm.radius_g - 1.0;
|
||||
if (par.es) {
|
||||
proj_parm.radius_p = sqrt (par.one_es);
|
||||
proj_parm.radius_p2 = par.one_es;
|
||||
proj_parm.radius_p_inv2 = par.rone_es;
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else {
|
||||
proj_parm.radius_p = proj_parm.radius_p2 = proj_parm.radius_p_inv2 = 1.0;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::geos
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Geostationary Satellite View projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- h=
|
||||
\par Example
|
||||
\image html ex_geos.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct geos_ellipsoid : public detail::geos::base_geos_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline geos_ellipsoid(const Parameters& par) : detail::geos::base_geos_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::geos::setup_geos(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Geostationary Satellite View projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- h=
|
||||
\par Example
|
||||
\image html ex_geos.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct geos_spheroid : public detail::geos::base_geos_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline geos_spheroid(const Parameters& par) : detail::geos::base_geos_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::geos::setup_geos(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class geos_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<geos_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<geos_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void geos_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("geos", new geos_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GEOS_HPP
|
||||
|
||||
140
include/boost/geometry/extensions/gis/projections/proj/gins8.hpp
Normal file
140
include/boost/geometry/extensions/gis/projections/proj/gins8.hpp
Normal file
@@ -0,0 +1,140 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace gins8{
|
||||
static const double Cl = 0.000952426;
|
||||
static const double Cp = 0.162388;
|
||||
static const double C12 = 0.08333333333333333;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_gins8_spheroid : public base_t_f<base_gins8_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_gins8_spheroid(const Parameters& par)
|
||||
: base_t_f<base_gins8_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double t = lp_lat * lp_lat;
|
||||
|
||||
xy_y = lp_lat * (1. + t * C12);
|
||||
xy_x = lp_lon * (1. - Cp * t);
|
||||
t = lp_lon * lp_lon;
|
||||
xy_x *= (0.87 - Cl * t * t);
|
||||
}
|
||||
};
|
||||
|
||||
// Ginsburg VIII (TsNIIGAiK)
|
||||
template <typename Parameters>
|
||||
void setup_gins8(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = 0;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::gins8
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Ginsburg VIII (TsNIIGAiK) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Pseudocylindrical
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_gins8.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gins8_spheroid : public detail::gins8::base_gins8_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gins8_spheroid(const Parameters& par) : detail::gins8::base_gins8_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gins8::setup_gins8(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gins8_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<gins8_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void gins8_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("gins8", new gins8_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GINS8_HPP
|
||||
|
||||
@@ -0,0 +1,380 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace gn_sinu{
|
||||
static const double EPS10 = 1e-10;
|
||||
static const int MAX_ITER = 8;
|
||||
static const double LOOP_TOL = 1e-7;
|
||||
|
||||
struct par_gn_sinu
|
||||
{
|
||||
double en[EN_SIZE];
|
||||
double m, n, C_x, C_y;
|
||||
};
|
||||
/* Ellipsoidal Sinusoidal only */
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_gn_sinu_ellipsoid : public base_t_fi<base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_gn_sinu m_proj_parm;
|
||||
|
||||
inline base_gn_sinu_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double s, c;
|
||||
|
||||
xy_y = pj_mlfn(lp_lat, s = sin(lp_lat), c = cos(lp_lat), this->m_proj_parm.en);
|
||||
xy_x = lp_lon * c / sqrt(1. - this->m_par.es * s * s);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double s; boost::ignore_unused_variable_warning(s);
|
||||
|
||||
if ((s = fabs(lp_lat = pj_inv_mlfn(xy_y, this->m_par.es, this->m_proj_parm.en))) < HALFPI) {
|
||||
s = sin(lp_lat);
|
||||
lp_lon = xy_x * sqrt(1. - this->m_par.es * s * s) / cos(lp_lat);
|
||||
} else if ((s - EPS10) < HALFPI)
|
||||
lp_lon = 0.;
|
||||
else throw proj_exception();;
|
||||
return;
|
||||
}
|
||||
/* General spherical sinusoidals */
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_gn_sinu_spheroid : public base_t_fi<base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_gn_sinu m_proj_parm;
|
||||
|
||||
inline base_gn_sinu_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if (!this->m_proj_parm.m)
|
||||
lp_lat = this->m_proj_parm.n != 1. ? aasin(this->m_proj_parm.n * sin(lp_lat)): lp_lat;
|
||||
else {
|
||||
double k, V;
|
||||
int i;
|
||||
|
||||
k = this->m_proj_parm.n * sin(lp_lat);
|
||||
for (i = MAX_ITER; i ; --i) {
|
||||
lp_lat -= V = (this->m_proj_parm.m * lp_lat + sin(lp_lat) - k) /
|
||||
(this->m_proj_parm.m + cos(lp_lat));
|
||||
if (fabs(V) < LOOP_TOL)
|
||||
break;
|
||||
}
|
||||
if (!i)
|
||||
throw proj_exception();
|
||||
}
|
||||
xy_x = this->m_proj_parm.C_x * lp_lon * (this->m_proj_parm.m + cos(lp_lat));
|
||||
xy_y = this->m_proj_parm.C_y * lp_lat;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double s; boost::ignore_unused_variable_warning(s);
|
||||
|
||||
xy_y /= this->m_proj_parm.C_y;
|
||||
lp_lat = this->m_proj_parm.m ? aasin((this->m_proj_parm.m * xy_y + sin(xy_y)) / this->m_proj_parm.n) :
|
||||
( this->m_proj_parm.n != 1. ? aasin(sin(xy_y) / this->m_proj_parm.n) : xy_y );
|
||||
lp_lon = xy_x / (this->m_proj_parm.C_x * (this->m_proj_parm.m + cos(xy_y)));
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_gn_sinu& proj_parm)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(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;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
|
||||
// General Sinusoidal Series
|
||||
template <typename Parameters>
|
||||
void setup_gn_sinu(Parameters& par, par_gn_sinu& proj_parm)
|
||||
{
|
||||
if (pj_param(par.params, "tn").i && pj_param(par.params, "tm").i) {
|
||||
proj_parm.n = pj_param(par.params, "dn").f;
|
||||
proj_parm.m = pj_param(par.params, "dm").f;
|
||||
} else
|
||||
throw proj_exception(-99);
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Sinusoidal (Sanson-Flamsteed)
|
||||
template <typename Parameters>
|
||||
void setup_sinu(Parameters& par, par_gn_sinu& proj_parm)
|
||||
{
|
||||
pj_enfn(par.es, proj_parm.en);
|
||||
|
||||
if (par.es) {
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else {
|
||||
proj_parm.n = 1.;
|
||||
proj_parm.m = 0.;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
}
|
||||
|
||||
// Eckert VI
|
||||
template <typename Parameters>
|
||||
void setup_eck6(Parameters& par, par_gn_sinu& proj_parm)
|
||||
{
|
||||
proj_parm.m = 1.;
|
||||
proj_parm.n = 2.570796326794896619231321691;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// McBryde-Thomas Flat-Polar Sinusoidal
|
||||
template <typename Parameters>
|
||||
void setup_mbtfps(Parameters& par, par_gn_sinu& proj_parm)
|
||||
{
|
||||
proj_parm.m = 0.5;
|
||||
proj_parm.n = 1.785398163397448309615660845;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
}} // namespace detail::gn_sinu
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Sinusoidal (Sanson-Flamsteed) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Pseudocylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
\par Example
|
||||
\image html ex_sinu.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct sinu_ellipsoid : public detail::gn_sinu::base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline sinu_ellipsoid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gn_sinu::setup_sinu(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gn_sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gn_sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gn_sinu::setup_gn_sinu(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Sinusoidal (Sanson-Flamsteed) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Pseudocylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
\par Example
|
||||
\image html ex_sinu.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct sinu_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline sinu_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gn_sinu::setup_sinu(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\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 <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct eck6_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline eck6_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(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 <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct mbtfps_spheroid : public detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline mbtfps_spheroid(const Parameters& par) : detail::gn_sinu::base_gn_sinu_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gn_sinu::setup_mbtfps(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gn_sinu_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<gn_sinu_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class sinu_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<sinu_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<sinu_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class eck6_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<eck6_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class mbtfps_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<mbtfps_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void gn_sinu_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("gn_sinu", new gn_sinu_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("sinu", new sinu_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("eck6", new eck6_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("mbtfps", new mbtfps_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GN_SINU_HPP
|
||||
|
||||
227
include/boost/geometry/extensions/gis/projections/proj/gnom.hpp
Normal file
227
include/boost/geometry/extensions/gis/projections/proj/gnom.hpp
Normal file
@@ -0,0 +1,227 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace gnom{
|
||||
static const double EPS10 = 1.e-10;
|
||||
static const int N_POLE = 0;
|
||||
static const int S_POLE = 1;
|
||||
static const int EQUIT = 2;
|
||||
static const int OBLIQ = 3;
|
||||
|
||||
struct par_gnom
|
||||
{
|
||||
double sinph0;
|
||||
double cosph0;
|
||||
int mode;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_gnom_spheroid : public base_t_fi<base_gnom_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_gnom m_proj_parm;
|
||||
|
||||
inline base_gnom_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_gnom_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, cosphi, sinphi;
|
||||
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
coslam = cos(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
xy_y = cosphi * coslam;
|
||||
break;
|
||||
case OBLIQ:
|
||||
xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam;
|
||||
break;
|
||||
case S_POLE:
|
||||
xy_y = - sinphi;
|
||||
break;
|
||||
case N_POLE:
|
||||
xy_y = sinphi;
|
||||
break;
|
||||
}
|
||||
if (xy_y <= EPS10) throw proj_exception();;
|
||||
xy_x = (xy_y = 1. / xy_y) * cosphi * sin(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
xy_y *= sinphi;
|
||||
break;
|
||||
case OBLIQ:
|
||||
xy_y *= this->m_proj_parm.cosph0 * sinphi - this->m_proj_parm.sinph0 * cosphi * coslam;
|
||||
break;
|
||||
case N_POLE:
|
||||
coslam = - coslam;
|
||||
case S_POLE:
|
||||
xy_y *= cosphi * coslam;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double rh, cosz, sinz;
|
||||
|
||||
rh = boost::math::hypot(xy_x, xy_y);
|
||||
sinz = sin(lp_lat = atan(rh));
|
||||
cosz = sqrt(1. - sinz * sinz);
|
||||
if (fabs(rh) <= EPS10) {
|
||||
lp_lat = this->m_par.phi0;
|
||||
lp_lon = 0.;
|
||||
} else {
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case OBLIQ:
|
||||
lp_lat = cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh;
|
||||
if (fabs(lp_lat) >= 1.)
|
||||
lp_lat = lp_lat > 0. ? HALFPI : - HALFPI;
|
||||
else
|
||||
lp_lat = asin(lp_lat);
|
||||
xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh;
|
||||
xy_x *= sinz * this->m_proj_parm.cosph0;
|
||||
break;
|
||||
case EQUIT:
|
||||
lp_lat = xy_y * sinz / rh;
|
||||
if (fabs(lp_lat) >= 1.)
|
||||
lp_lat = lp_lat > 0. ? HALFPI : - HALFPI;
|
||||
else
|
||||
lp_lat = asin(lp_lat);
|
||||
xy_y = cosz * rh;
|
||||
xy_x *= sinz;
|
||||
break;
|
||||
case S_POLE:
|
||||
lp_lat -= HALFPI;
|
||||
break;
|
||||
case N_POLE:
|
||||
lp_lat = HALFPI - lp_lat;
|
||||
xy_y = -xy_y;
|
||||
break;
|
||||
}
|
||||
lp_lon = atan2(xy_x, xy_y);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Gnomonic
|
||||
template <typename Parameters>
|
||||
void setup_gnom(Parameters& par, par_gnom& proj_parm)
|
||||
{
|
||||
if (fabs(fabs(par.phi0) - HALFPI) < EPS10)
|
||||
proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
|
||||
else if (fabs(par.phi0) < EPS10)
|
||||
proj_parm.mode = EQUIT;
|
||||
else {
|
||||
proj_parm.mode = OBLIQ;
|
||||
proj_parm.sinph0 = sin(par.phi0);
|
||||
proj_parm.cosph0 = cos(par.phi0);
|
||||
}
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::gnom
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Gnomonic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_gnom.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gnom_spheroid : public detail::gnom::base_gnom_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gnom_spheroid(const Parameters& par) : detail::gnom::base_gnom_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gnom::setup_gnom(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gnom_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<gnom_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void gnom_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("gnom", new gnom_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GNOM_HPP
|
||||
|
||||
160
include/boost/geometry/extensions/gis/projections/proj/goode.hpp
Normal file
160
include/boost/geometry/extensions/gis/projections/proj/goode.hpp
Normal file
@@ -0,0 +1,160 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/proj/moll.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/proj/gn_sinu.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace goode{
|
||||
static const double Y_COR = 0.05280;
|
||||
static const double PHI_LIM = .71093078197902358062;
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct par_goode
|
||||
{
|
||||
sinu_ellipsoid<Geographic, Cartesian, Parameters> sinu;
|
||||
moll_spheroid<Geographic, Cartesian, Parameters> moll;
|
||||
|
||||
par_goode(const Parameters& par) : sinu(par), moll(par) {}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_goode_spheroid : public base_t_fi<base_goode_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_goode<Geographic, Cartesian, Parameters> m_proj_parm;
|
||||
|
||||
inline base_goode_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_goode_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>(*this, par), m_proj_parm(par) {}
|
||||
|
||||
inline void fwd(geographic_type& lp_lon, geographic_type& lp_lat, cartesian_type& xy_x, cartesian_type& xy_y) const
|
||||
{
|
||||
if (fabs(lp_lat) <= PHI_LIM)
|
||||
this->m_proj_parm.sinu.fwd(lp_lon, lp_lat, xy_x, xy_y);
|
||||
else {
|
||||
this->m_proj_parm.moll.fwd(lp_lon, lp_lat, xy_x, xy_y);
|
||||
xy_y -= lp_lat >= 0.0 ? Y_COR : -Y_COR;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
if (fabs(xy_y) <= PHI_LIM)
|
||||
this->m_proj_parm.sinu.inv(xy_x, xy_y, lp_lon, lp_lat);
|
||||
else {
|
||||
xy_y += xy_y >= 0.0 ? Y_COR : -Y_COR;
|
||||
this->m_proj_parm.moll.inv(xy_x, xy_y, lp_lon, lp_lat);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Goode Homolosine
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
void setup_goode(Parameters& par, par_goode<Geographic, Cartesian, Parameters>& proj_parm)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
// par.inv = s_inverse;
|
||||
}
|
||||
|
||||
}} // namespace detail::goode
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Goode Homolosine 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_goode.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct goode_spheroid : public detail::goode::base_goode_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline goode_spheroid(const Parameters& par) : detail::goode::base_goode_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::goode::setup_goode(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class goode_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<goode_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void goode_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("goode", new goode_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GOODE_HPP
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace gstmerc{
|
||||
|
||||
struct par_gstmerc
|
||||
{
|
||||
double lamc;
|
||||
double phic;
|
||||
double c;
|
||||
double n1;
|
||||
double n2;
|
||||
double XS;
|
||||
double YS;
|
||||
};
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_gstmerc_spheroid : public base_t_fi<base_gstmerc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_gstmerc m_proj_parm;
|
||||
|
||||
inline base_gstmerc_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_gstmerc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double L, Ls, sinLs1, Ls1;
|
||||
L= this->m_proj_parm.n1*lp_lon;
|
||||
Ls= this->m_proj_parm.c+this->m_proj_parm.n1*log(pj_tsfn(-1.0*lp_lat,-1.0*sin(lp_lat),this->m_par.e));
|
||||
sinLs1= sin(L)/cosh(Ls);
|
||||
Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
|
||||
xy_x= (this->m_proj_parm.XS + this->m_proj_parm.n2*Ls1)*this->m_par.ra;
|
||||
xy_y= (this->m_proj_parm.YS + this->m_proj_parm.n2*atan(sinh(Ls)/cos(L)))*this->m_par.ra;
|
||||
/*fprintf(stderr,"fwd:\nL =%16.13f\nLs =%16.13f\nLs1 =%16.13f\nLP(%16.13f,%16.13f)=XY(%16.4f,%16.4f)\n",L,Ls,Ls1,lp_lon+this->m_par.lam0,lp_lat,(xy_x*this->m_par.a + this->m_par.x0)*this->m_par.to_meter,(xy_y*this->m_par.a + this->m_par.y0)*this->m_par.to_meter);*/
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double L, LC, sinC;
|
||||
L= atan(sinh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2)/cos((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2));
|
||||
sinC= sin((xy_y*this->m_par.a - this->m_proj_parm.YS)/this->m_proj_parm.n2)/cosh((xy_x*this->m_par.a - this->m_proj_parm.XS)/this->m_proj_parm.n2);
|
||||
LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
|
||||
lp_lon= L/this->m_proj_parm.n1;
|
||||
lp_lat= -1.0*pj_phi2(exp((LC-this->m_proj_parm.c)/this->m_proj_parm.n1),this->m_par.e);
|
||||
/*fprintf(stderr,"inv:\nL =%16.13f\nsinC =%16.13f\nLC =%16.13f\nXY(%16.4f,%16.4f)=LP(%16.13f,%16.13f)\n",L,sinC,LC,((xy_x/this->m_par.ra)+this->m_par.x0)/this->m_par.to_meter,((xy_y/this->m_par.ra)+this->m_par.y0)/this->m_par.to_meter,lp_lon+this->m_par.lam0,lp_lat);*/
|
||||
}
|
||||
};
|
||||
|
||||
// Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion)
|
||||
template <typename Parameters>
|
||||
void setup_gstmerc(Parameters& par, par_gstmerc& proj_parm)
|
||||
{
|
||||
proj_parm.lamc= par.lam0;
|
||||
proj_parm.n1= sqrt(1.0+par.es*pow(cos(par.phi0),4.0)/(1.0-par.es));
|
||||
proj_parm.phic= asin(sin(par.phi0)/proj_parm.n1);
|
||||
proj_parm.c= log(pj_tsfn(-1.0*proj_parm.phic,0.0,0.0))
|
||||
-proj_parm.n1*log(pj_tsfn(-1.0*par.phi0,-1.0*sin(par.phi0),par.e));
|
||||
proj_parm.n2= par.k0*par.a*sqrt(1.0-par.es)/(1.0-par.es*sin(par.phi0)*sin(par.phi0));
|
||||
proj_parm.XS= 0;
|
||||
/* -par.x0 */
|
||||
proj_parm.YS= -1.0*proj_parm.n2*proj_parm.phic;
|
||||
/* -par.y0 */
|
||||
// par.inv= s_inverse;
|
||||
// par.fwd= s_forward;
|
||||
/*fprintf(stderr,"a (m) =%16.4f\ne =%16.13f\nl0(rad)=%16.13f\np0(rad)=%16.13f\nk0 =%16.4f\nX0 (m)=%16.4f\nY0 (m)=%16.4f\n\nlC(rad)=%16.13f\npC(rad)=%16.13f\nc =%16.13f\nn1 =%16.13f\nn2 (m) =%16.4f\nXS (m) =%16.4f\nYS (m) =%16.4f\n", par.a, par.e, par.lam0, par.phi0, par.k0, par.x0, par.y0, proj_parm.lamc, proj_parm.phic, proj_parm.c, proj_parm.n1, proj_parm.n2, proj_parm.XS +par.x0, proj_parm.YS + par.y0);
|
||||
*/
|
||||
}
|
||||
|
||||
}} // namespace detail::gstmerc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde Reunion) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_0= lon_0= k_0=
|
||||
\par Example
|
||||
\image html ex_gstmerc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gstmerc_spheroid : public detail::gstmerc::base_gstmerc_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gstmerc_spheroid(const Parameters& par) : detail::gstmerc::base_gstmerc_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::gstmerc::setup_gstmerc(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gstmerc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<gstmerc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void gstmerc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("gstmerc", new gstmerc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_GSTMERC_HPP
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace hammer{
|
||||
|
||||
struct par_hammer
|
||||
{
|
||||
double w;
|
||||
double m, rm;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_hammer_spheroid : public base_t_f<base_hammer_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_hammer m_proj_parm;
|
||||
|
||||
inline base_hammer_spheroid(const Parameters& par)
|
||||
: base_t_f<base_hammer_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double cosphi, d;
|
||||
|
||||
d = sqrt(2./(1. + (cosphi = cos(lp_lat)) * cos(lp_lon *= this->m_proj_parm.w)));
|
||||
xy_x = this->m_proj_parm.m * d * cosphi * sin(lp_lon);
|
||||
xy_y = this->m_proj_parm.rm * d * sin(lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
// Hammer & Eckert-Greifendorff
|
||||
template <typename Parameters>
|
||||
void setup_hammer(Parameters& par, par_hammer& proj_parm)
|
||||
{
|
||||
if (pj_param(par.params, "tW").i) {
|
||||
if ((proj_parm.w = fabs(pj_param(par.params, "dW").f)) <= 0.) throw proj_exception(-27);
|
||||
} else
|
||||
proj_parm.w = .5;
|
||||
if (pj_param(par.params, "tM").i) {
|
||||
if ((proj_parm.m = fabs(pj_param(par.params, "dM").f)) <= 0.) throw proj_exception(-27);
|
||||
} else
|
||||
proj_parm.m = 1.;
|
||||
proj_parm.rm = 1. / proj_parm.m;
|
||||
proj_parm.m /= proj_parm.w;
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::hammer
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Hammer & Eckert-Greifendorff projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
- W= M=
|
||||
\par Example
|
||||
\image html ex_hammer.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct hammer_spheroid : public detail::hammer::base_hammer_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline hammer_spheroid(const Parameters& par) : detail::hammer::base_hammer_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::hammer::setup_hammer(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class hammer_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<hammer_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void hammer_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("hammer", new hammer_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_HAMMER_HPP
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace hatano{
|
||||
static const int NITER = 20;
|
||||
static const double EPS = 1e-7;
|
||||
static const double ONETOL = 1.000001;
|
||||
static const double CN = 2.67595;
|
||||
static const double CS = 2.43763;
|
||||
static const double RCN = 0.37369906014686373063;
|
||||
static const double RCS = 0.41023453108141924738;
|
||||
static const double FYCN = 1.75859;
|
||||
static const double FYCS = 1.93052;
|
||||
static const double RYCN = 0.56863737426006061674;
|
||||
static const double RYCS = 0.51799515156538134803;
|
||||
static const double FXC = 0.85;
|
||||
static const double RXC = 1.17647058823529411764;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_hatano_spheroid : public base_t_fi<base_hatano_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_hatano_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_hatano_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double th1, c;
|
||||
int i;
|
||||
|
||||
c = sin(lp_lat) * (lp_lat < 0. ? CS : CN);
|
||||
for (i = NITER; i; --i) {
|
||||
lp_lat -= th1 = (lp_lat + sin(lp_lat) - c) / (1. + cos(lp_lat));
|
||||
if (fabs(th1) < EPS) break;
|
||||
}
|
||||
xy_x = FXC * lp_lon * cos(lp_lat *= .5);
|
||||
xy_y = sin(lp_lat) * (lp_lat < 0. ? FYCS : FYCN);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double th;
|
||||
|
||||
th = xy_y * ( xy_y < 0. ? RYCS : RYCN);
|
||||
if (fabs(th) > 1.)
|
||||
if (fabs(th) > ONETOL) throw proj_exception();
|
||||
else th = th > 0. ? HALFPI : - HALFPI;
|
||||
else
|
||||
th = asin(th);
|
||||
lp_lon = RXC * xy_x / cos(th);
|
||||
th += th;
|
||||
lp_lat = (th + sin(th)) * (xy_y < 0. ? RCS : RCN);
|
||||
if (fabs(lp_lat) > 1.)
|
||||
if (fabs(lp_lat) > ONETOL) throw proj_exception();
|
||||
else lp_lat = lp_lat > 0. ? HALFPI : - HALFPI;
|
||||
else
|
||||
lp_lat = asin(lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
// Hatano Asymmetrical Equal Area
|
||||
template <typename Parameters>
|
||||
void setup_hatano(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::hatano
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Hatano Asymmetrical Equal Area 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_hatano.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct hatano_spheroid : public detail::hatano::base_hatano_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline hatano_spheroid(const Parameters& par) : detail::hatano::base_hatano_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::hatano::setup_hatano(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class hatano_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<hatano_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void hatano_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("hatano", new hatano_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_HATANO_HPP
|
||||
|
||||
281
include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp
Normal file
281
include/boost/geometry/extensions/gis/projections/proj/imw_p.hpp
Normal file
@@ -0,0 +1,281 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace imw_p{
|
||||
static const double TOL = 1e-10;
|
||||
static const double EPS = 1e-10;
|
||||
|
||||
struct PXY { double x, y; }; // x/y projection specific
|
||||
|
||||
struct par_imw_p
|
||||
{
|
||||
double P, Pp, Q, Qp, R_1, R_2, sphi_1, sphi_2, C2;
|
||||
double phi_1, phi_2, lam_1;
|
||||
double en[EN_SIZE];
|
||||
int mode; /* = 0, phi_1 and phi_2 != 0, = 1, phi_1 = 0, = -1 phi_2 = 0 */
|
||||
};
|
||||
template <typename Parameters>
|
||||
inline int
|
||||
phi12(Parameters& par, par_imw_p& proj_parm, double *del, double *sig) {
|
||||
int err = 0;
|
||||
|
||||
if (!pj_param(par.params, "tlat_1").i ||
|
||||
!pj_param(par.params, "tlat_2").i) {
|
||||
err = -41;
|
||||
} else {
|
||||
proj_parm.phi_1 = pj_param(par.params, "rlat_1").f;
|
||||
proj_parm.phi_2 = pj_param(par.params, "rlat_2").f;
|
||||
*del = 0.5 * (proj_parm.phi_2 - proj_parm.phi_1);
|
||||
*sig = 0.5 * (proj_parm.phi_2 + proj_parm.phi_1);
|
||||
err = (fabs(*del) < EPS || fabs(*sig) < EPS) ? -42 : 0;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
template <typename Parameters>
|
||||
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;
|
||||
|
||||
if (! lp_phi) {
|
||||
xy.x = lp_lam;
|
||||
xy.y = 0.;
|
||||
} else {
|
||||
double xa, ya, xb, yb, xc, D, B, m, sp, t, R, C;
|
||||
|
||||
sp = sin(lp_phi);
|
||||
m = pj_mlfn(lp_phi, sp, cos(lp_phi), proj_parm.en);
|
||||
xa = proj_parm.Pp + proj_parm.Qp * m;
|
||||
ya = proj_parm.P + proj_parm.Q * m;
|
||||
R = 1. / (tan(lp_phi) * sqrt(1. - par.es * sp * sp));
|
||||
C = sqrt(R * R - xa * xa);
|
||||
if (lp_phi < 0.) C = - C;
|
||||
C += ya - R;
|
||||
if (proj_parm.mode < 0) {
|
||||
xb = lp_lam;
|
||||
yb = proj_parm.C2;
|
||||
} else {
|
||||
t = lp_lam * proj_parm.sphi_2;
|
||||
xb = proj_parm.R_2 * sin(t);
|
||||
yb = proj_parm.C2 + proj_parm.R_2 * (1. - cos(t));
|
||||
}
|
||||
if (proj_parm.mode > 0) {
|
||||
xc = lp_lam;
|
||||
*yc = 0.;
|
||||
} else {
|
||||
t = lp_lam * proj_parm.sphi_1;
|
||||
xc = proj_parm.R_1 * sin(t);
|
||||
*yc = proj_parm.R_1 * (1. - cos(t));
|
||||
}
|
||||
D = (xb - xc)/(yb - *yc);
|
||||
B = xc + D * (C + R - *yc);
|
||||
xy.x = D * sqrt(R * R * (1 + D * D) - B * B);
|
||||
if (lp_phi > 0)
|
||||
xy.x = - xy.x;
|
||||
xy.x = (B + xy.x) / (1. + D * D);
|
||||
xy.y = sqrt(R * R - xy.x * xy.x);
|
||||
if (lp_phi > 0)
|
||||
xy.y = - xy.y;
|
||||
xy.y += C + R;
|
||||
}
|
||||
return (xy);
|
||||
}
|
||||
|
||||
template <typename Parameters>
|
||||
inline void
|
||||
xy(Parameters& par, par_imw_p& proj_parm, double phi, double *x, double *y, double *sp, double *R) {
|
||||
double F;
|
||||
|
||||
*sp = sin(phi);
|
||||
*R = 1./(tan(phi) * sqrt(1. - par.es * *sp * *sp ));
|
||||
F = proj_parm.lam_1 * *sp;
|
||||
*y = *R * (1 - cos(F));
|
||||
*x = *R * sin(F);
|
||||
}
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_imw_p_ellipsoid : public base_t_fi<base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_imw_p m_proj_parm;
|
||||
|
||||
inline base_imw_p_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double yc = 0;
|
||||
PXY 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;
|
||||
double yc = 0;
|
||||
|
||||
lp_lat = this->m_proj_parm.phi_2;
|
||||
lp_lon = xy_x / cos(lp_lat);
|
||||
do {
|
||||
t = loc_for(lp_lon, lp_lat, this->m_par, m_proj_parm, &yc);
|
||||
lp_lat = ((lp_lat - this->m_proj_parm.phi_1) * (xy_y - yc) / (t.y - yc)) + this->m_proj_parm.phi_1;
|
||||
lp_lon = lp_lon * xy_x / t.x;
|
||||
} while (fabs(t.x - xy_x) > TOL || fabs(t.y - xy_y) > TOL);
|
||||
}
|
||||
};
|
||||
|
||||
// International Map of the World Polyconic
|
||||
template <typename Parameters>
|
||||
void setup_imw_p(Parameters& par, par_imw_p& proj_parm)
|
||||
{
|
||||
double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
|
||||
int i;
|
||||
pj_enfn(par.es, proj_parm.en);
|
||||
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 */
|
||||
del = proj_parm.phi_1;
|
||||
proj_parm.phi_1 = proj_parm.phi_2;
|
||||
proj_parm.phi_2 = del;
|
||||
}
|
||||
if (pj_param(par.params, "tlon_1").i)
|
||||
proj_parm.lam_1 = pj_param(par.params, "rlon_1").f;
|
||||
else { /* use predefined based upon latitude */
|
||||
sig = fabs(sig * RAD_TO_DEG);
|
||||
if (sig <= 60) sig = 2.;
|
||||
else if (sig <= 76) sig = 4.;
|
||||
else sig = 8.;
|
||||
proj_parm.lam_1 = sig * DEG_TO_RAD;
|
||||
}
|
||||
proj_parm.mode = 0;
|
||||
if (proj_parm.phi_1) xy(par, proj_parm, proj_parm.phi_1, &x1, &y1, &proj_parm.sphi_1, &proj_parm.R_1);
|
||||
else {
|
||||
proj_parm.mode = 1;
|
||||
y1 = 0.;
|
||||
x1 = proj_parm.lam_1;
|
||||
}
|
||||
if (proj_parm.phi_2) xy(par, proj_parm, proj_parm.phi_2, &x2, &T2, &proj_parm.sphi_2, &proj_parm.R_2);
|
||||
else {
|
||||
proj_parm.mode = -1;
|
||||
T2 = 0.;
|
||||
x2 = proj_parm.lam_1;
|
||||
}
|
||||
m1 = pj_mlfn(proj_parm.phi_1, proj_parm.sphi_1, cos(proj_parm.phi_1), proj_parm.en);
|
||||
m2 = pj_mlfn(proj_parm.phi_2, proj_parm.sphi_2, cos(proj_parm.phi_2), proj_parm.en);
|
||||
t = m2 - m1;
|
||||
s = x2 - x1;
|
||||
y2 = sqrt(t * t - s * s) + y1;
|
||||
proj_parm.C2 = y2 - T2;
|
||||
t = 1. / t;
|
||||
proj_parm.P = (m2 * y1 - m1 * y2) * t;
|
||||
proj_parm.Q = (y2 - y1) * t;
|
||||
proj_parm.Pp = (m2 * x1 - m1 * x2) * t;
|
||||
proj_parm.Qp = (x2 - x1) * t;
|
||||
// par.fwd = e_forward;
|
||||
// par.inv = e_inverse;
|
||||
}
|
||||
|
||||
}} // namespace detail::imw_p
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief International Map of the World Polyconic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Mod Polyconic
|
||||
- Ellipsoid
|
||||
- lat_1= and lat_2= [lon_1=]
|
||||
\par Example
|
||||
\image html ex_imw_p.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct imw_p_ellipsoid : public detail::imw_p::base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline imw_p_ellipsoid(const Parameters& par) : detail::imw_p::base_imw_p_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::imw_p::setup_imw_p(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class imw_p_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<imw_p_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void imw_p_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("imw_p", new imw_p_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_IMW_P_HPP
|
||||
|
||||
@@ -0,0 +1,338 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace krovak{
|
||||
|
||||
struct par_krovak
|
||||
{
|
||||
double C_x;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
NOTES: According to EPSG the full Krovak projection method should have
|
||||
the following parameters. Within PROJ.4 the azimuth, and pseudo
|
||||
standard parallel are hardcoded in the algorithm and can't be
|
||||
altered from outside. The others all have defaults to match the
|
||||
common usage with Krovak projection.
|
||||
|
||||
lat_0 = latitude of centre of the projection
|
||||
|
||||
lon_0 = longitude of centre of the projection
|
||||
|
||||
** = azimuth (true) of the centre line passing through the centre of the projection
|
||||
|
||||
** = latitude of pseudo standard parallel
|
||||
|
||||
k = scale factor on the pseudo standard parallel
|
||||
|
||||
x_0 = False Easting of the centre of the projection at the apex of the cone
|
||||
|
||||
y_0 = False Northing of the centre of the projection at the apex of the cone
|
||||
|
||||
**/
|
||||
|
||||
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_krovak_ellipsoid : public base_t_fi<base_krovak_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_krovak m_proj_parm;
|
||||
|
||||
inline base_krovak_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_krovak_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
/* calculate xy from lat/lon */
|
||||
|
||||
|
||||
|
||||
|
||||
/* Constants, identical to inverse transform function */
|
||||
double s45, s90, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n;
|
||||
double gfi, u, fi0, deltav, s, d, eps, ro;
|
||||
|
||||
|
||||
s45 = 0.785398163397448; /* 45 DEG */
|
||||
s90 = 2 * s45;
|
||||
fi0 = this->m_par.phi0; /* Latitude of projection centre 49 DEG 30' */
|
||||
|
||||
/* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must
|
||||
be set to 1 here.
|
||||
Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
|
||||
e2=0.006674372230614;
|
||||
*/
|
||||
a = 1; /* 6377397.155; */
|
||||
/* e2 = this->m_par.es;*/ /* 0.006674372230614; */
|
||||
e2 = 0.006674372230614;
|
||||
e = sqrt(e2);
|
||||
|
||||
alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2));
|
||||
|
||||
uq = 1.04216856380474; /* DU(2, 59, 42, 42.69689) */
|
||||
u0 = asin(sin(fi0) / alfa);
|
||||
g = pow( (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2. );
|
||||
|
||||
k = tan( u0 / 2. + s45) / pow (tan(fi0 / 2. + s45) , alfa) * g;
|
||||
|
||||
k1 = this->m_par.k0;
|
||||
n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2));
|
||||
s0 = 1.37008346281555; /* Latitude of pseudo standard parallel 78 DEG 30'00" N */
|
||||
n = sin(s0);
|
||||
ro0 = k1 * n0 / tan(s0);
|
||||
ad = s90 - uq;
|
||||
|
||||
/* Transformation */
|
||||
|
||||
gfi =pow ( ((1. + e * sin(lp_lat)) /
|
||||
(1. - e * sin(lp_lat))) , (alfa * e / 2.));
|
||||
|
||||
u= 2. * (atan(k * pow( tan(lp_lat / 2. + s45), alfa) / gfi)-s45);
|
||||
|
||||
deltav = - lp_lon * alfa;
|
||||
|
||||
s = asin(cos(ad) * sin(u) + sin(ad) * cos(u) * cos(deltav));
|
||||
d = asin(cos(u) * sin(deltav) / cos(s));
|
||||
eps = n * d;
|
||||
ro = ro0 * pow(tan(s0 / 2. + s45) , n) / pow(tan(s / 2. + s45) , n) ;
|
||||
|
||||
/* x and y are reverted! */
|
||||
xy_y = ro * cos(eps) / a;
|
||||
xy_x = ro * sin(eps) / a;
|
||||
|
||||
if( !pj_param(this->m_par.params, "tczech").i )
|
||||
{
|
||||
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 */
|
||||
|
||||
/* Constants, identisch wie in der Umkehrfunktion */
|
||||
double s45, s90, fi0, e2, e, alfa, uq, u0, g, k, k1, n0, ro0, ad, a, s0, n;
|
||||
double u, deltav, s, d, eps, ro, fi1, xy0;
|
||||
int ok;
|
||||
|
||||
s45 = 0.785398163397448; /* 45 DEG */
|
||||
s90 = 2 * s45;
|
||||
fi0 = this->m_par.phi0; /* Latitude of projection centre 49 DEG 30' */
|
||||
|
||||
|
||||
/* Ellipsoid is used as Parameter in for.c and inv.c, therefore a must
|
||||
be set to 1 here.
|
||||
Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
|
||||
e2=0.006674372230614;
|
||||
*/
|
||||
a = 1; /* 6377397.155; */
|
||||
/* e2 = this->m_par.es; */ /* 0.006674372230614; */
|
||||
e2 = 0.006674372230614;
|
||||
e = sqrt(e2);
|
||||
|
||||
alfa = sqrt(1. + (e2 * pow(cos(fi0), 4)) / (1. - e2));
|
||||
uq = 1.04216856380474; /* DU(2, 59, 42, 42.69689) */
|
||||
u0 = asin(sin(fi0) / alfa);
|
||||
g = pow( (1. + e * sin(fi0)) / (1. - e * sin(fi0)) , alfa * e / 2. );
|
||||
|
||||
k = tan( u0 / 2. + s45) / pow (tan(fi0 / 2. + s45) , alfa) * g;
|
||||
|
||||
k1 = this->m_par.k0;
|
||||
n0 = a * sqrt(1. - e2) / (1. - e2 * pow(sin(fi0), 2));
|
||||
s0 = 1.37008346281555; /* Latitude of pseudo standard parallel 78 DEG 30'00" N */
|
||||
n = sin(s0);
|
||||
ro0 = k1 * n0 / tan(s0);
|
||||
ad = s90 - uq;
|
||||
|
||||
|
||||
/* Transformation */
|
||||
/* revert y, x*/
|
||||
xy0=xy_x;
|
||||
xy_x=xy_y;
|
||||
xy_y=xy0;
|
||||
|
||||
if( !pj_param(this->m_par.params, "tczech").i )
|
||||
{
|
||||
xy_x *= -1.0;
|
||||
xy_y *= -1.0;
|
||||
}
|
||||
|
||||
ro = sqrt(xy_x * xy_x + xy_y * xy_y);
|
||||
eps = atan2(xy_y, xy_x);
|
||||
d = eps / sin(s0);
|
||||
s = 2. * (atan( pow(ro0 / ro, 1. / n) * tan(s0 / 2. + s45)) - s45);
|
||||
|
||||
u = asin(cos(ad) * sin(s) - sin(ad) * cos(s) * cos(d));
|
||||
deltav = asin(cos(s) * sin(d) / cos(u));
|
||||
|
||||
lp_lon = this->m_par.lam0 - deltav / alfa;
|
||||
|
||||
/* ITERATION FOR lp_lat */
|
||||
fi1 = u;
|
||||
|
||||
ok = 0;
|
||||
do
|
||||
{
|
||||
lp_lat = 2. * ( atan( pow( k, -1. / alfa) *
|
||||
pow( tan(u / 2. + s45) , 1. / alfa) *
|
||||
pow( (1. + e * sin(fi1)) / (1. - e * sin(fi1)) , e / 2.)
|
||||
) - s45);
|
||||
|
||||
if (fabs(fi1 - lp_lat) < 0.000000000000001) ok=1;
|
||||
fi1 = lp_lat;
|
||||
|
||||
}
|
||||
while (ok==0);
|
||||
|
||||
lp_lon -= this->m_par.lam0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Krovak
|
||||
template <typename Parameters>
|
||||
void setup_krovak(Parameters& par, par_krovak& proj_parm)
|
||||
{
|
||||
double ts;
|
||||
/* read some Parameters,
|
||||
* here Latitude Truescale */
|
||||
ts = pj_param(par.params, "rlat_ts").f;
|
||||
proj_parm.C_x = ts;
|
||||
|
||||
/* we want Bessel as fixed ellipsoid */
|
||||
par.a = 6377397.155;
|
||||
par.e = sqrt(par.es = 0.006674372230614);
|
||||
/* if latitude of projection center is not set, use 49d30'N */
|
||||
if (!pj_param(par.params, "tlat_0").i)
|
||||
par.phi0 = 0.863937979737193;
|
||||
|
||||
/* if center long is not set use 42d30'E of Ferro - 17d40' for Ferro */
|
||||
/* that will correspond to using longitudes relative to greenwich */
|
||||
/* as input and output, instead of lat/long relative to Ferro */
|
||||
if (!pj_param(par.params, "tlon_0").i)
|
||||
par.lam0 = 0.7417649320975901 - 0.308341501185665;
|
||||
/* if scale not set default to 0.9999 */
|
||||
if (!pj_param(par.params, "tk").i)
|
||||
par.k0 = 0.9999;
|
||||
/* always the same */
|
||||
// par.inv = e_inverse;
|
||||
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::krovak
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Krovak projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Pseudocylindrical
|
||||
- Ellps
|
||||
\par Example
|
||||
\image html ex_krovak.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct krovak_ellipsoid : public detail::krovak::base_krovak_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline krovak_ellipsoid(const Parameters& par) : detail::krovak::base_krovak_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::krovak::setup_krovak(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class krovak_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<krovak_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void krovak_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("krovak", new krovak_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_KROVAK_HPP
|
||||
|
||||
231
include/boost/geometry/extensions/gis/projections/proj/labrd.hpp
Normal file
231
include/boost/geometry/extensions/gis/projections/proj/labrd.hpp
Normal file
@@ -0,0 +1,231 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace labrd{
|
||||
static const double EPS = 1.e-10;
|
||||
|
||||
struct par_labrd
|
||||
{
|
||||
double Az, kRg, p0s, A, C, Ca, Cb, Cc, Cd;
|
||||
int rot;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_labrd_ellipsoid : public base_t_fi<base_labrd_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_labrd m_proj_parm;
|
||||
|
||||
inline base_labrd_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_labrd_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double V1, V2, ps, sinps, cosps, sinps2, cosps2, I1, I2, I3, I4, I5, I6,
|
||||
x2, y2, t;
|
||||
|
||||
V1 = this->m_proj_parm.A * log( tan(FORTPI + .5 * lp_lat) );
|
||||
t = this->m_par.e * sin(lp_lat);
|
||||
V2 = .5 * this->m_par.e * this->m_proj_parm.A * log ((1. + t)/(1. - t));
|
||||
ps = 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - FORTPI);
|
||||
I1 = ps - this->m_proj_parm.p0s;
|
||||
cosps = cos(ps); cosps2 = cosps * cosps;
|
||||
sinps = sin(ps); sinps2 = sinps * sinps;
|
||||
I4 = this->m_proj_parm.A * cosps;
|
||||
I2 = .5 * this->m_proj_parm.A * I4 * sinps;
|
||||
I3 = I2 * this->m_proj_parm.A * this->m_proj_parm.A * (5. * cosps2 - sinps2) / 12.;
|
||||
I6 = I4 * this->m_proj_parm.A * this->m_proj_parm.A;
|
||||
I5 = I6 * (cosps2 - sinps2) / 6.;
|
||||
I6 *= this->m_proj_parm.A * this->m_proj_parm.A *
|
||||
(5. * cosps2 * cosps2 + sinps2 * (sinps2 - 18. * cosps2)) / 120.;
|
||||
t = lp_lon * lp_lon;
|
||||
xy_x = this->m_proj_parm.kRg * lp_lon * (I4 + t * (I5 + t * I6));
|
||||
xy_y = this->m_proj_parm.kRg * (I1 + t * (I2 + t * I3));
|
||||
x2 = xy_x * xy_x;
|
||||
y2 = xy_y * xy_y;
|
||||
V1 = 3. * xy_x * y2 - xy_x * x2;
|
||||
V2 = xy_y * y2 - 3. * x2 * xy_y;
|
||||
xy_x += this->m_proj_parm.Ca * V1 + this->m_proj_parm.Cb * V2;
|
||||
xy_y += this->m_proj_parm.Ca * V2 - this->m_proj_parm.Cb * V1;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double x2, y2, V1, V2, V3, V4, t, t2, ps, pe, tpe, s,
|
||||
I7, I8, I9, I10, I11, d, Re;
|
||||
int i;
|
||||
|
||||
x2 = xy_x * xy_x;
|
||||
y2 = xy_y * xy_y;
|
||||
V1 = 3. * xy_x * y2 - xy_x * x2;
|
||||
V2 = xy_y * y2 - 3. * x2 * xy_y;
|
||||
V3 = xy_x * (5. * y2 * y2 + x2 * (-10. * y2 + x2 ));
|
||||
V4 = xy_y * (5. * x2 * x2 + y2 * (-10. * x2 + y2 ));
|
||||
xy_x += - this->m_proj_parm.Ca * V1 - this->m_proj_parm.Cb * V2 + this->m_proj_parm.Cc * V3 + this->m_proj_parm.Cd * V4;
|
||||
xy_y += this->m_proj_parm.Cb * V1 - this->m_proj_parm.Ca * V2 - this->m_proj_parm.Cd * V3 + this->m_proj_parm.Cc * V4;
|
||||
ps = this->m_proj_parm.p0s + xy_y / this->m_proj_parm.kRg;
|
||||
pe = ps + this->m_par.phi0 - this->m_proj_parm.p0s;
|
||||
for ( i = 20; i; --i) {
|
||||
V1 = this->m_proj_parm.A * log(tan(FORTPI + .5 * pe));
|
||||
tpe = this->m_par.e * sin(pe);
|
||||
V2 = .5 * this->m_par.e * this->m_proj_parm.A * log((1. + tpe)/(1. - tpe));
|
||||
t = ps - 2. * (atan(exp(V1 - V2 + this->m_proj_parm.C)) - FORTPI);
|
||||
pe += t;
|
||||
if (fabs(t) < EPS)
|
||||
break;
|
||||
}
|
||||
/*
|
||||
if (!i) {
|
||||
} else {
|
||||
}
|
||||
*/
|
||||
t = this->m_par.e * sin(pe);
|
||||
t = 1. - t * t;
|
||||
Re = this->m_par.one_es / ( t * sqrt(t) );
|
||||
t = tan(ps);
|
||||
t2 = t * t;
|
||||
s = this->m_proj_parm.kRg * this->m_proj_parm.kRg;
|
||||
d = Re * this->m_par.k0 * this->m_proj_parm.kRg;
|
||||
I7 = t / (2. * d);
|
||||
I8 = t * (5. + 3. * t2) / (24. * d * s);
|
||||
d = cos(ps) * this->m_proj_parm.kRg * this->m_proj_parm.A;
|
||||
I9 = 1. / d;
|
||||
d *= s;
|
||||
I10 = (1. + 2. * t2) / (6. * d);
|
||||
I11 = (5. + t2 * (28. + 24. * t2)) / (120. * d * s);
|
||||
x2 = xy_x * xy_x;
|
||||
lp_lat = pe + x2 * (-I7 + I8 * x2);
|
||||
lp_lon = xy_x * (I9 + x2 * (-I10 + x2 * I11));
|
||||
}
|
||||
};
|
||||
|
||||
// Laborde
|
||||
template <typename Parameters>
|
||||
void setup_labrd(Parameters& par, par_labrd& proj_parm)
|
||||
{
|
||||
double Az, sinp, R, N, t;
|
||||
proj_parm.rot = pj_param(par.params, "bno_rot").i == 0;
|
||||
Az = pj_param(par.params, "razi").f;
|
||||
sinp = sin(par.phi0);
|
||||
t = 1. - par.es * sinp * sinp;
|
||||
N = 1. / sqrt(t);
|
||||
R = par.one_es * N / t;
|
||||
proj_parm.kRg = par.k0 * sqrt( N * R );
|
||||
proj_parm.p0s = atan( sqrt(R / N) * tan(par.phi0) );
|
||||
proj_parm.A = sinp / sin(proj_parm.p0s);
|
||||
t = par.e * sinp;
|
||||
proj_parm.C = .5 * par.e * proj_parm.A * log((1. + t)/(1. - t)) +
|
||||
- proj_parm.A * log( tan(FORTPI + .5 * par.phi0))
|
||||
+ log( tan(FORTPI + .5 * proj_parm.p0s));
|
||||
t = Az + Az;
|
||||
proj_parm.Ca = (1. - cos(t)) * ( proj_parm.Cb = 1. / (12. * proj_parm.kRg * proj_parm.kRg) );
|
||||
proj_parm.Cb *= sin(t);
|
||||
proj_parm.Cc = 3. * (proj_parm.Ca * proj_parm.Ca - proj_parm.Cb * proj_parm.Cb);
|
||||
proj_parm.Cd = 6. * proj_parm.Ca * proj_parm.Cb;
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::labrd
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Laborde projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Special for Madagascar
|
||||
\par Example
|
||||
\image html ex_labrd.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct labrd_ellipsoid : public detail::labrd::base_labrd_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline labrd_ellipsoid(const Parameters& par) : detail::labrd::base_labrd_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::labrd::setup_labrd(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class labrd_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<labrd_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void labrd_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("labrd", new labrd_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LABRD_HPP
|
||||
|
||||
391
include/boost/geometry/extensions/gis/projections/proj/laea.hpp
Normal file
391
include/boost/geometry/extensions/gis/projections/proj/laea.hpp
Normal file
@@ -0,0 +1,391 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_qsfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_auth.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace laea{
|
||||
static const double EPS10 = 1.e-10;
|
||||
static const int NITER = 20;
|
||||
static const double CONV = 1.e-10;
|
||||
static const int N_POLE = 0;
|
||||
static const int S_POLE = 1;
|
||||
static const int EQUIT = 2;
|
||||
static const int OBLIQ = 3;
|
||||
|
||||
struct par_laea
|
||||
{
|
||||
double sinb1;
|
||||
double cosb1;
|
||||
double xmf;
|
||||
double ymf;
|
||||
double mmf;
|
||||
double qp;
|
||||
double dd;
|
||||
double rq;
|
||||
double apa[APA_SIZE];
|
||||
int mode;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_laea_ellipsoid : public base_t_fi<base_laea_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_laea m_proj_parm;
|
||||
|
||||
inline base_laea_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_laea_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, sinlam, sinphi, q, sinb=0.0, cosb=0.0, b=0.0;
|
||||
|
||||
coslam = cos(lp_lon);
|
||||
sinlam = sin(lp_lon);
|
||||
sinphi = sin(lp_lat);
|
||||
q = pj_qsfn(sinphi, this->m_par.e, this->m_par.one_es);
|
||||
if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
|
||||
sinb = q / this->m_proj_parm.qp;
|
||||
cosb = sqrt(1. - sinb * sinb);
|
||||
}
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case OBLIQ:
|
||||
b = 1. + this->m_proj_parm.sinb1 * sinb + this->m_proj_parm.cosb1 * cosb * coslam;
|
||||
break;
|
||||
case EQUIT:
|
||||
b = 1. + cosb * coslam;
|
||||
break;
|
||||
case N_POLE:
|
||||
b = HALFPI + lp_lat;
|
||||
q = this->m_proj_parm.qp - q;
|
||||
break;
|
||||
case S_POLE:
|
||||
b = lp_lat - HALFPI;
|
||||
q = this->m_proj_parm.qp + q;
|
||||
break;
|
||||
}
|
||||
if (fabs(b) < EPS10) throw proj_exception();;
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case OBLIQ:
|
||||
xy_y = this->m_proj_parm.ymf * ( b = sqrt(2. / b) )
|
||||
* (this->m_proj_parm.cosb1 * sinb - this->m_proj_parm.sinb1 * cosb * coslam);
|
||||
goto eqcon;
|
||||
break;
|
||||
case EQUIT:
|
||||
xy_y = (b = sqrt(2. / (1. + cosb * coslam))) * sinb * this->m_proj_parm.ymf;
|
||||
eqcon:
|
||||
xy_x = this->m_proj_parm.xmf * b * cosb * sinlam;
|
||||
break;
|
||||
case N_POLE:
|
||||
case S_POLE:
|
||||
if (q >= 0.) {
|
||||
xy_x = (b = sqrt(q)) * sinlam;
|
||||
xy_y = coslam * (this->m_proj_parm.mode == S_POLE ? b : -b);
|
||||
} else
|
||||
xy_x = xy_y = 0.;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double cCe, sCe, q, rho, ab=0.0;
|
||||
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
case OBLIQ:
|
||||
if ((rho = boost::math::hypot(xy_x /= this->m_proj_parm.dd, xy_y *= this->m_proj_parm.dd)) < EPS10) {
|
||||
lp_lon = 0.;
|
||||
lp_lat = this->m_par.phi0;
|
||||
return;
|
||||
}
|
||||
cCe = cos(sCe = 2. * asin(.5 * rho / this->m_proj_parm.rq));
|
||||
xy_x *= (sCe = sin(sCe));
|
||||
if (this->m_proj_parm.mode == OBLIQ) {
|
||||
q = this->m_proj_parm.qp * (ab = cCe * this->m_proj_parm.sinb1 + xy_y * sCe * this->m_proj_parm.cosb1 / rho);
|
||||
xy_y = rho * this->m_proj_parm.cosb1 * cCe - xy_y * this->m_proj_parm.sinb1 * sCe;
|
||||
} else {
|
||||
q = this->m_proj_parm.qp * (ab = xy_y * sCe / rho);
|
||||
xy_y = rho * cCe;
|
||||
}
|
||||
break;
|
||||
case N_POLE:
|
||||
xy_y = -xy_y;
|
||||
case S_POLE:
|
||||
if (!(q = (xy_x * xy_x + xy_y * xy_y)) ) {
|
||||
lp_lon = 0.;
|
||||
lp_lat = this->m_par.phi0;
|
||||
return;
|
||||
}
|
||||
/*
|
||||
q = this->m_proj_parm.qp - q;
|
||||
*/
|
||||
ab = 1. - q / this->m_proj_parm.qp;
|
||||
if (this->m_proj_parm.mode == S_POLE)
|
||||
ab = - ab;
|
||||
break;
|
||||
}
|
||||
lp_lon = atan2(xy_x, xy_y);
|
||||
lp_lat = pj_authlat(asin(ab), this->m_proj_parm.apa);
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_laea_spheroid : public base_t_fi<base_laea_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_laea m_proj_parm;
|
||||
|
||||
inline base_laea_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_laea_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, cosphi, sinphi;
|
||||
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
coslam = cos(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
xy_y = 1. + cosphi * coslam;
|
||||
goto oblcon;
|
||||
case OBLIQ:
|
||||
xy_y = 1. + this->m_proj_parm.sinb1 * sinphi + this->m_proj_parm.cosb1 * cosphi * coslam;
|
||||
oblcon:
|
||||
if (xy_y <= EPS10) throw proj_exception();;
|
||||
xy_x = (xy_y = sqrt(2. / xy_y)) * cosphi * sin(lp_lon);
|
||||
xy_y *= this->m_proj_parm.mode == EQUIT ? sinphi :
|
||||
this->m_proj_parm.cosb1 * sinphi - this->m_proj_parm.sinb1 * cosphi * coslam;
|
||||
break;
|
||||
case N_POLE:
|
||||
coslam = -coslam;
|
||||
case S_POLE:
|
||||
if (fabs(lp_lat + this->m_par.phi0) < EPS10) throw proj_exception();;
|
||||
xy_y = FORTPI - lp_lat * .5;
|
||||
xy_y = 2. * (this->m_proj_parm.mode == S_POLE ? cos(xy_y) : sin(xy_y));
|
||||
xy_x = xy_y * sin(lp_lon);
|
||||
xy_y *= coslam;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double cosz=0.0, rh, sinz=0.0;
|
||||
|
||||
rh = boost::math::hypot(xy_x, xy_y);
|
||||
if ((lp_lat = rh * .5 ) > 1.) throw proj_exception();;
|
||||
lp_lat = 2. * asin(lp_lat);
|
||||
if (this->m_proj_parm.mode == OBLIQ || this->m_proj_parm.mode == EQUIT) {
|
||||
sinz = sin(lp_lat);
|
||||
cosz = cos(lp_lat);
|
||||
}
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case EQUIT:
|
||||
lp_lat = fabs(rh) <= EPS10 ? 0. : asin(xy_y * sinz / rh);
|
||||
xy_x *= sinz;
|
||||
xy_y = cosz * rh;
|
||||
break;
|
||||
case OBLIQ:
|
||||
lp_lat = fabs(rh) <= EPS10 ? this->m_par.phi0 :
|
||||
asin(cosz * this->m_proj_parm.sinb1 + xy_y * sinz * this->m_proj_parm.cosb1 / rh);
|
||||
xy_x *= sinz * this->m_proj_parm.cosb1;
|
||||
xy_y = (cosz - sin(lp_lat) * this->m_proj_parm.sinb1) * rh;
|
||||
break;
|
||||
case N_POLE:
|
||||
xy_y = -xy_y;
|
||||
lp_lat = HALFPI - lp_lat;
|
||||
break;
|
||||
case S_POLE:
|
||||
lp_lat -= HALFPI;
|
||||
break;
|
||||
}
|
||||
lp_lon = (xy_y == 0. && (this->m_proj_parm.mode == EQUIT || this->m_proj_parm.mode == OBLIQ)) ?
|
||||
0. : atan2(xy_x, xy_y);
|
||||
}
|
||||
};
|
||||
|
||||
// Lambert Azimuthal Equal Area
|
||||
template <typename Parameters>
|
||||
void setup_laea(Parameters& par, par_laea& proj_parm)
|
||||
{
|
||||
double t;
|
||||
if (fabs((t = fabs(par.phi0)) - HALFPI) < EPS10)
|
||||
proj_parm.mode = par.phi0 < 0. ? S_POLE : N_POLE;
|
||||
else if (fabs(t) < EPS10)
|
||||
proj_parm.mode = EQUIT;
|
||||
else
|
||||
proj_parm.mode = OBLIQ;
|
||||
if (par.es) {
|
||||
double sinphi;
|
||||
par.e = sqrt(par.es);
|
||||
proj_parm.qp = pj_qsfn(1., par.e, par.one_es);
|
||||
proj_parm.mmf = .5 / (1. - par.es);
|
||||
pj_authset(par.es, proj_parm.apa);
|
||||
switch (proj_parm.mode) {
|
||||
case N_POLE:
|
||||
case S_POLE:
|
||||
proj_parm.dd = 1.;
|
||||
break;
|
||||
case EQUIT:
|
||||
proj_parm.dd = 1. / (proj_parm.rq = sqrt(.5 * proj_parm.qp));
|
||||
proj_parm.xmf = 1.;
|
||||
proj_parm.ymf = .5 * proj_parm.qp;
|
||||
break;
|
||||
case OBLIQ:
|
||||
proj_parm.rq = sqrt(.5 * proj_parm.qp);
|
||||
sinphi = sin(par.phi0);
|
||||
proj_parm.sinb1 = pj_qsfn(sinphi, par.e, par.one_es) / proj_parm.qp;
|
||||
proj_parm.cosb1 = sqrt(1. - proj_parm.sinb1 * proj_parm.sinb1);
|
||||
proj_parm.dd = cos(par.phi0) / (sqrt(1. - par.es * sinphi * sinphi) *
|
||||
proj_parm.rq * proj_parm.cosb1);
|
||||
proj_parm.ymf = (proj_parm.xmf = proj_parm.rq) / proj_parm.dd;
|
||||
proj_parm.xmf *= proj_parm.dd;
|
||||
break;
|
||||
}
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else {
|
||||
if (proj_parm.mode == OBLIQ) {
|
||||
proj_parm.sinb1 = sin(par.phi0);
|
||||
proj_parm.cosb1 = cos(par.phi0);
|
||||
}
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::laea
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Lambert Azimuthal Equal Area projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
\par Example
|
||||
\image html ex_laea.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct laea_ellipsoid : public detail::laea::base_laea_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline laea_ellipsoid(const Parameters& par) : detail::laea::base_laea_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::laea::setup_laea(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Lambert Azimuthal Equal Area projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
\par Example
|
||||
\image html ex_laea.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct laea_spheroid : public detail::laea::base_laea_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline laea_spheroid(const Parameters& par) : detail::laea::base_laea_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::laea::setup_laea(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class laea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<laea_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<laea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void laea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("laea", new laea_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LAEA_HPP
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace lagrng{
|
||||
static const double TOL = 1e-10;
|
||||
|
||||
struct par_lagrng
|
||||
{
|
||||
double hrw;
|
||||
double rw;
|
||||
double a1;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_lagrng_spheroid : public base_t_f<base_lagrng_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_lagrng m_proj_parm;
|
||||
|
||||
inline base_lagrng_spheroid(const Parameters& par)
|
||||
: base_t_f<base_lagrng_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double v, c;
|
||||
|
||||
if (fabs(fabs(lp_lat) - HALFPI) < TOL) {
|
||||
xy_x = 0;
|
||||
xy_y = lp_lat < 0 ? -2. : 2.;
|
||||
} else {
|
||||
lp_lat = sin(lp_lat);
|
||||
v = this->m_proj_parm.a1 * pow((1. + lp_lat)/(1. - lp_lat), this->m_proj_parm.hrw);
|
||||
if ((c = 0.5 * (v + 1./v) + cos(lp_lon *= this->m_proj_parm.rw)) < TOL)
|
||||
throw proj_exception();;
|
||||
xy_x = 2. * sin(lp_lon) / c;
|
||||
xy_y = (v - 1./v) / c;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Lagrange
|
||||
template <typename Parameters>
|
||||
void setup_lagrng(Parameters& par, par_lagrng& proj_parm)
|
||||
{
|
||||
double phi1;
|
||||
if ((proj_parm.rw = pj_param(par.params, "dW").f) <= 0) throw proj_exception(-27);
|
||||
proj_parm.hrw = 0.5 * (proj_parm.rw = 1. / proj_parm.rw);
|
||||
phi1 = pj_param(par.params, "rlat_1").f;
|
||||
if (fabs(fabs(phi1 = sin(phi1)) - 1.) < TOL) throw proj_exception(-22);
|
||||
proj_parm.a1 = pow((1. - phi1)/(1. + phi1), proj_parm.hrw);
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::lagrng
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Lagrange projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
- W=
|
||||
\par Example
|
||||
\image html ex_lagrng.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lagrng_spheroid : public detail::lagrng::base_lagrng_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lagrng_spheroid(const Parameters& par) : detail::lagrng::base_lagrng_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::lagrng::setup_lagrng(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lagrng_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<lagrng_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void lagrng_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("lagrng", new lagrng_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LAGRNG_HPP
|
||||
|
||||
134
include/boost/geometry/extensions/gis/projections/proj/larr.hpp
Normal file
134
include/boost/geometry/extensions/gis/projections/proj/larr.hpp
Normal file
@@ -0,0 +1,134 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LARR_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LARR_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace larr{
|
||||
static const double SIXTH = .16666666666666666;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_larr_spheroid : public base_t_f<base_larr_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_larr_spheroid(const Parameters& par)
|
||||
: base_t_f<base_larr_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = 0.5 * lp_lon * (1. + sqrt(cos(lp_lat)));
|
||||
xy_y = lp_lat / (cos(0.5 * lp_lat) * cos(SIXTH * lp_lon));
|
||||
}
|
||||
};
|
||||
|
||||
// Larrivee
|
||||
template <typename Parameters>
|
||||
void setup_larr(Parameters& par)
|
||||
{
|
||||
// par.fwd = s_forward;
|
||||
// par.inv = 0;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::larr
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Larrivee projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_larr.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct larr_spheroid : public detail::larr::base_larr_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline larr_spheroid(const Parameters& par) : detail::larr::base_larr_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::larr::setup_larr(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class larr_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<larr_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void larr_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("larr", new larr_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LARR_HPP
|
||||
|
||||
148
include/boost/geometry/extensions/gis/projections/proj/lask.hpp
Normal file
148
include/boost/geometry/extensions/gis/projections/proj/lask.hpp
Normal file
@@ -0,0 +1,148 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LASK_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LASK_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace lask{
|
||||
static const double a10 = 0.975534;
|
||||
static const double a12 = -0.119161;
|
||||
static const double a32 = -0.0143059;
|
||||
static const double a14 = -0.0547009;
|
||||
static const double b01 = 1.00384;
|
||||
static const double b21 = 0.0802894;
|
||||
static const double b03 = 0.0998909;
|
||||
static const double b41 = 0.000199025;
|
||||
static const double b23 = -0.0285500;
|
||||
static const double b05 = -0.0491032;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_lask_spheroid : public base_t_f<base_lask_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_lask_spheroid(const Parameters& par)
|
||||
: base_t_f<base_lask_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double l2, p2;
|
||||
|
||||
l2 = lp_lon * lp_lon;
|
||||
p2 = lp_lat * lp_lat;
|
||||
xy_x = lp_lon * (a10 + p2 * (a12 + l2 * a32 + p2 * a14));
|
||||
xy_y = lp_lat * (b01 + l2 * (b21 + p2 * b23 + l2 * b41) +
|
||||
p2 * (b03 + p2 * b05));
|
||||
}
|
||||
};
|
||||
|
||||
// Laskowski
|
||||
template <typename Parameters>
|
||||
void setup_lask(Parameters& par)
|
||||
{
|
||||
// par.fwd = s_forward;
|
||||
// par.inv = 0;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::lask
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Laskowski projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_lask.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lask_spheroid : public detail::lask::base_lask_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lask_spheroid(const Parameters& par) : detail::lask::base_lask_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::lask::setup_lask(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lask_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<lask_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void lask_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("lask", new lask_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LASK_HPP
|
||||
|
||||
@@ -0,0 +1,282 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#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 <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_latlong_other : public base_t_fi<base_latlong_other<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_latlong_other(const Parameters& par)
|
||||
: base_t_fi<base_latlong_other<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
// Lat/long (Geodetic)
|
||||
template <typename Parameters>
|
||||
void setup_lonlat(Parameters& par)
|
||||
{
|
||||
par.is_latlong = 1;
|
||||
par.x0 = 0.0;
|
||||
par.y0 = 0.0;
|
||||
// par.inv = inverse;
|
||||
// par.fwd = forward;
|
||||
}
|
||||
|
||||
// Lat/long (Geodetic alias)
|
||||
template <typename Parameters>
|
||||
void setup_latlon(Parameters& par)
|
||||
{
|
||||
par.is_latlong = 1;
|
||||
par.x0 = 0.0;
|
||||
par.y0 = 0.0;
|
||||
// par.inv = inverse;
|
||||
// par.fwd = forward;
|
||||
}
|
||||
|
||||
// Lat/long (Geodetic alias)
|
||||
template <typename Parameters>
|
||||
void setup_latlong(Parameters& par)
|
||||
{
|
||||
par.is_latlong = 1;
|
||||
par.x0 = 0.0;
|
||||
par.y0 = 0.0;
|
||||
// par.inv = inverse;
|
||||
// par.fwd = forward;
|
||||
}
|
||||
|
||||
// Lat/long (Geodetic alias)
|
||||
template <typename Parameters>
|
||||
void setup_longlat(Parameters& par)
|
||||
{
|
||||
par.is_latlong = 1;
|
||||
par.x0 = 0.0;
|
||||
par.y0 = 0.0;
|
||||
// par.inv = inverse;
|
||||
// par.fwd = forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::latlong
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Lat/long (Geodetic) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
\par Example
|
||||
\image html ex_lonlat.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lonlat_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lonlat_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::latlong::setup_lonlat(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Lat/long (Geodetic alias) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
\par Example
|
||||
\image html ex_latlon.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct latlon_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline latlon_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::latlong::setup_latlon(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Lat/long (Geodetic alias) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
\par Example
|
||||
\image html ex_latlong.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct latlong_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline latlong_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::latlong::setup_latlong(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Lat/long (Geodetic alias) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
\par Example
|
||||
\image html ex_longlat.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct longlat_other : public detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline longlat_other(const Parameters& par) : detail::latlong::base_latlong_other<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::latlong::setup_longlat(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lonlat_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<lonlat_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class latlon_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<latlon_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class latlong_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<latlong_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class longlat_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<longlat_other<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void latlong_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("lonlat", new lonlat_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("latlon", new latlon_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("latlong", new latlong_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("longlat", new longlat_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
// Create EPSG specializations
|
||||
// (Proof of Concept, only for some)
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<4326, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef longlat_other<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=longlat +ellps=WGS84 +datum=WGS84";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LATLONG_HPP
|
||||
|
||||
249
include/boost/geometry/extensions/gis/projections/proj/lcc.hpp
Normal file
249
include/boost/geometry/extensions/gis/projections/proj/lcc.hpp
Normal file
@@ -0,0 +1,249 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LCC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LCC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/epsg_traits.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace lcc{
|
||||
static const double EPS10 = 1.e-10;
|
||||
|
||||
struct par_lcc
|
||||
{
|
||||
double phi1;
|
||||
double phi2;
|
||||
double n;
|
||||
double rho0;
|
||||
double c;
|
||||
int ellips;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_lcc_ellipsoid : public base_t_fi<base_lcc_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
mutable par_lcc m_proj_parm;
|
||||
|
||||
inline base_lcc_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_lcc_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double rho;
|
||||
if (fabs(fabs(lp_lat) - HALFPI) < EPS10) {
|
||||
if ((lp_lat * this->m_proj_parm.n) <= 0.) throw proj_exception();;
|
||||
rho = 0.;
|
||||
}
|
||||
else
|
||||
rho = this->m_proj_parm.c * (this->m_proj_parm.ellips ? pow(pj_tsfn(lp_lat, sin(lp_lat),
|
||||
this->m_par.e), this->m_proj_parm.n) : pow(tan(FORTPI + .5 * lp_lat), -this->m_proj_parm.n));
|
||||
xy_x = this->m_par.k0 * (rho * sin( lp_lon *= this->m_proj_parm.n ) );
|
||||
xy_y = this->m_par.k0 * (this->m_proj_parm.rho0 - rho * cos(lp_lon) );
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double rho;
|
||||
xy_x /= this->m_par.k0;
|
||||
xy_y /= this->m_par.k0;
|
||||
if( (rho = boost::math::hypot(xy_x, xy_y = this->m_proj_parm.rho0 - xy_y)) != 0.0) {
|
||||
if (this->m_proj_parm.n < 0.) {
|
||||
rho = -rho;
|
||||
xy_x = -xy_x;
|
||||
xy_y = -xy_y;
|
||||
}
|
||||
if (this->m_proj_parm.ellips) {
|
||||
if ((lp_lat = pj_phi2(pow(rho / this->m_proj_parm.c, 1./this->m_proj_parm.n), this->m_par.e))
|
||||
== HUGE_VAL)
|
||||
throw proj_exception();;
|
||||
} else
|
||||
lp_lat = 2. * atan(pow(this->m_proj_parm.c / rho, 1./this->m_proj_parm.n)) - HALFPI;
|
||||
lp_lon = atan2(xy_x, xy_y) / this->m_proj_parm.n;
|
||||
} else {
|
||||
lp_lon = 0.;
|
||||
lp_lat = this->m_proj_parm.n > 0. ? HALFPI : - HALFPI;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SPECIAL_FACTORS_NOT_CONVERTED
|
||||
inline void fac(Geographic lp, Factors &fac) const
|
||||
{
|
||||
double rho;
|
||||
if (fabs(fabs(lp_lat) - HALFPI) < EPS10) {
|
||||
if ((lp_lat * this->m_proj_parm.n) <= 0.) return;
|
||||
rho = 0.;
|
||||
} else
|
||||
rho = this->m_proj_parm.c * (this->m_proj_parm.ellips ? pow(pj_tsfn(lp_lat, sin(lp_lat),
|
||||
this->m_par.e), this->m_proj_parm.n) : pow(tan(FORTPI + .5 * lp_lat), -this->m_proj_parm.n));
|
||||
this->m_fac.code |= IS_ANAL_HK + IS_ANAL_CONV;
|
||||
this->m_fac.k = this->m_fac.h = this->m_par.k0 * this->m_proj_parm.n * rho /
|
||||
pj_msfn(sin(lp_lat), cos(lp_lat), this->m_par.es);
|
||||
this->m_fac.conv = - this->m_proj_parm.n * lp_lon;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
// Lambert Conformal Conic
|
||||
template <typename Parameters>
|
||||
void setup_lcc(Parameters& par, par_lcc& proj_parm)
|
||||
{
|
||||
double cosphi, sinphi;
|
||||
int secant;
|
||||
proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
|
||||
if (pj_param(par.params, "tlat_2").i)
|
||||
proj_parm.phi2 = pj_param(par.params, "rlat_2").f;
|
||||
else {
|
||||
proj_parm.phi2 = proj_parm.phi1;
|
||||
if (!pj_param(par.params, "tlat_0").i)
|
||||
par.phi0 = proj_parm.phi1;
|
||||
}
|
||||
if (fabs(proj_parm.phi1 + proj_parm.phi2) < EPS10) throw proj_exception(-21);
|
||||
proj_parm.n = sinphi = sin(proj_parm.phi1);
|
||||
cosphi = cos(proj_parm.phi1);
|
||||
secant = fabs(proj_parm.phi1 - proj_parm.phi2) >= EPS10;
|
||||
if( (proj_parm.ellips = (par.es != 0.)) ) {
|
||||
double ml1, m1;
|
||||
par.e = sqrt(par.es);
|
||||
m1 = pj_msfn(sinphi, cosphi, par.es);
|
||||
ml1 = pj_tsfn(proj_parm.phi1, sinphi, par.e);
|
||||
if (secant) { /* secant cone */
|
||||
proj_parm.n = log(m1 /
|
||||
pj_msfn(sinphi = sin(proj_parm.phi2), cos(proj_parm.phi2), par.es));
|
||||
proj_parm.n /= log(ml1 / pj_tsfn(proj_parm.phi2, sinphi, par.e));
|
||||
}
|
||||
proj_parm.c = (proj_parm.rho0 = m1 * pow(ml1, -proj_parm.n) / proj_parm.n);
|
||||
proj_parm.rho0 *= (fabs(fabs(par.phi0) - HALFPI) < EPS10) ? 0. :
|
||||
pow(pj_tsfn(par.phi0, sin(par.phi0), par.e), proj_parm.n);
|
||||
} else {
|
||||
if (secant)
|
||||
proj_parm.n = log(cosphi / cos(proj_parm.phi2)) /
|
||||
log(tan(FORTPI + .5 * proj_parm.phi2) /
|
||||
tan(FORTPI + .5 * proj_parm.phi1));
|
||||
proj_parm.c = cosphi * pow(tan(FORTPI + .5 * proj_parm.phi1), proj_parm.n) / proj_parm.n;
|
||||
proj_parm.rho0 = (fabs(fabs(par.phi0) - HALFPI) < EPS10) ? 0. :
|
||||
proj_parm.c * pow(tan(FORTPI + .5 * par.phi0), -proj_parm.n);
|
||||
}
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
// par.spc = fac;
|
||||
}
|
||||
|
||||
}} // namespace detail::lcc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Lambert Conformal Conic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_1= and lat_2= or lat_0
|
||||
\par Example
|
||||
\image html ex_lcc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lcc_ellipsoid : public detail::lcc::base_lcc_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lcc_ellipsoid(const Parameters& par) : detail::lcc::base_lcc_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::lcc::setup_lcc(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lcc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<lcc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void lcc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("lcc", new lcc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
// Create EPSG specializations
|
||||
// (Proof of Concept, only for some)
|
||||
|
||||
template<typename LatLongRadian, typename Cartesian, typename Parameters>
|
||||
struct epsg_traits<2805, LatLongRadian, Cartesian, Parameters>
|
||||
{
|
||||
typedef lcc_ellipsoid<LatLongRadian, Cartesian, Parameters> type;
|
||||
static inline std::string par()
|
||||
{
|
||||
return "+proj=lcc +lat_1=42.68333333333333 +lat_2=41.71666666666667 +lat_0=41 +lon_0=-71.5 +x_0=200000 +y_0=750000 +ellps=GRS80 +units=m";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LCC_HPP
|
||||
|
||||
191
include/boost/geometry/extensions/gis/projections/proj/lcca.hpp
Normal file
191
include/boost/geometry/extensions/gis/projections/proj/lcca.hpp
Normal file
@@ -0,0 +1,191 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_mlfn.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace lcca{
|
||||
static const int MAX_ITER = 10;
|
||||
static const double DEL_TOL = 1e-12;
|
||||
|
||||
struct par_lcca
|
||||
{
|
||||
double en[EN_SIZE];
|
||||
double r0, l, M0;
|
||||
double C;
|
||||
};
|
||||
|
||||
|
||||
inline double /* func to compute dr */
|
||||
fS(double S, double C) {
|
||||
return(S * ( 1. + S * S * C));
|
||||
}
|
||||
inline double /* deriv of fs */
|
||||
fSp(double S, double C) {
|
||||
return(1. + 3.* S * S * C);
|
||||
}
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_lcca_ellipsoid : public base_t_fi<base_lcca_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_lcca m_proj_parm;
|
||||
|
||||
inline base_lcca_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_lcca_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double S, r, dr;
|
||||
|
||||
S = pj_mlfn(lp_lat, sin(lp_lat), cos(lp_lat), this->m_proj_parm.en) - this->m_proj_parm.M0;
|
||||
dr = fS(S, this->m_proj_parm.C);
|
||||
r = this->m_proj_parm.r0 - dr;
|
||||
xy_x = this->m_par.k0 * (r * sin( lp_lon *= this->m_proj_parm.l ) );
|
||||
xy_y = this->m_par.k0 * (this->m_proj_parm.r0 - r * cos(lp_lon) );
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double theta, dr, S, dif;
|
||||
int i;
|
||||
|
||||
xy_x /= this->m_par.k0;
|
||||
xy_y /= this->m_par.k0;
|
||||
theta = atan2(xy_x , this->m_proj_parm.r0 - xy_y);
|
||||
dr = xy_y - xy_x * tan(0.5 * theta);
|
||||
lp_lon = theta / this->m_proj_parm.l;
|
||||
S = dr;
|
||||
for (i = MAX_ITER; i ; --i) {
|
||||
S -= (dif = (fS(S, this->m_proj_parm.C) - dr) / fSp(S, this->m_proj_parm.C));
|
||||
if (fabs(dif) < DEL_TOL) break;
|
||||
}
|
||||
if (!i) throw proj_exception();
|
||||
lp_lat = pj_inv_mlfn(S + this->m_proj_parm.M0, this->m_par.es, this->m_proj_parm.en);
|
||||
}
|
||||
};
|
||||
|
||||
// Lambert Conformal Conic Alternative
|
||||
template <typename Parameters>
|
||||
void setup_lcca(Parameters& par, par_lcca& proj_parm)
|
||||
{
|
||||
double s2p0, N0, R0, tan0, tan20;
|
||||
pj_enfn(par.es, proj_parm.en);
|
||||
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);
|
||||
proj_parm.M0 = pj_mlfn(par.phi0, proj_parm.l, cos(par.phi0), proj_parm.en);
|
||||
s2p0 = proj_parm.l * proj_parm.l;
|
||||
R0 = 1. / (1. - par.es * s2p0);
|
||||
N0 = sqrt(R0);
|
||||
R0 *= par.one_es * N0;
|
||||
tan0 = tan(par.phi0);
|
||||
tan20 = tan0 * tan0;
|
||||
proj_parm.r0 = N0 / tan0;
|
||||
proj_parm.C = 1. / (6. * R0 * N0);
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::lcca
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Lambert Conformal Conic Alternative projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Conic
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_0=
|
||||
\par Example
|
||||
\image html ex_lcca.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lcca_ellipsoid : public detail::lcca::base_lcca_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lcca_ellipsoid(const Parameters& par) : detail::lcca::base_lcca_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::lcca::setup_lcca(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lcca_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<lcca_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void lcca_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("lcca", new lcca_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LCCA_HPP
|
||||
|
||||
164
include/boost/geometry/extensions/gis/projections/proj/loxim.hpp
Normal file
164
include/boost/geometry/extensions/gis/projections/proj/loxim.hpp
Normal file
@@ -0,0 +1,164 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace loxim{
|
||||
static const double EPS = 1e-8;
|
||||
|
||||
struct par_loxim
|
||||
{
|
||||
double phi1;
|
||||
double cosphi1;
|
||||
double tanphi1;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_loxim_spheroid : public base_t_fi<base_loxim_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_loxim m_proj_parm;
|
||||
|
||||
inline base_loxim_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_loxim_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_y = lp_lat - this->m_proj_parm.phi1;
|
||||
if (fabs(xy_y) < EPS)
|
||||
xy_x = lp_lon * this->m_proj_parm.cosphi1;
|
||||
else {
|
||||
xy_x = FORTPI + 0.5 * lp_lat;
|
||||
if (fabs(xy_x) < EPS || fabs(fabs(xy_x) - HALFPI) < EPS)
|
||||
xy_x = 0.;
|
||||
else
|
||||
xy_x = lp_lon * xy_y / log( tan(xy_x) / this->m_proj_parm.tanphi1 );
|
||||
}
|
||||
}
|
||||
|
||||
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_proj_parm.phi1;
|
||||
if (fabs(xy_y) < EPS)
|
||||
lp_lon = xy_x / this->m_proj_parm.cosphi1;
|
||||
else
|
||||
if (fabs( lp_lon = FORTPI + 0.5 * lp_lat ) < EPS ||
|
||||
fabs(fabs(lp_lon) - HALFPI) < EPS)
|
||||
lp_lon = 0.;
|
||||
else
|
||||
lp_lon = xy_x * log( tan(lp_lon) / this->m_proj_parm.tanphi1 ) / xy_y ;
|
||||
}
|
||||
};
|
||||
|
||||
// Loximuthal
|
||||
template <typename Parameters>
|
||||
void setup_loxim(Parameters& par, par_loxim& proj_parm)
|
||||
{
|
||||
proj_parm.phi1 = pj_param(par.params, "rlat_1").f;
|
||||
if ((proj_parm.cosphi1 = cos(proj_parm.phi1)) < EPS) throw proj_exception(-22);
|
||||
proj_parm.tanphi1 = tan(FORTPI + 0.5 * proj_parm.phi1);
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::loxim
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Loximuthal 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_loxim.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct loxim_spheroid : public detail::loxim::base_loxim_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline loxim_spheroid(const Parameters& par) : detail::loxim::base_loxim_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::loxim::setup_loxim(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class loxim_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<loxim_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void loxim_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("loxim", new loxim_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LOXIM_HPP
|
||||
|
||||
299
include/boost/geometry/extensions/gis/projections/proj/lsat.hpp
Normal file
299
include/boost/geometry/extensions/gis/projections/proj/lsat.hpp
Normal file
@@ -0,0 +1,299 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace lsat{
|
||||
static const double TOL = 1e-7;
|
||||
static const double PI_HALFPI = 4.71238898038468985766;
|
||||
static const double TWOPI_HALFPI = 7.85398163397448309610;
|
||||
|
||||
struct par_lsat
|
||||
{
|
||||
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 <typename Parameters>
|
||||
inline void
|
||||
seraz0(double lam, double mult, Parameters& par, par_lsat& proj_parm) {
|
||||
double sdsq, h, s, fc, sd, sq, d__1;
|
||||
|
||||
lam *= DEG_TO_RAD;
|
||||
sd = sin(lam);
|
||||
sdsq = sd * sd;
|
||||
s = proj_parm.p22 * proj_parm.sa * cos(lam) * sqrt((1. + proj_parm.t * sdsq) / ((
|
||||
1. + proj_parm.w * sdsq) * (1. + proj_parm.q * sdsq)));
|
||||
d__1 = 1. + proj_parm.q * sdsq;
|
||||
h = sqrt((1. + proj_parm.q * sdsq) / (1. + proj_parm.w * sdsq)) * ((1. +
|
||||
proj_parm.w * sdsq) / (d__1 * d__1) - proj_parm.p22 * proj_parm.ca);
|
||||
sq = sqrt(proj_parm.xj * proj_parm.xj + s * s);
|
||||
proj_parm.b += fc = mult * (h * proj_parm.xj - s * s) / sq;
|
||||
proj_parm.a2 += fc * cos(lam + lam);
|
||||
proj_parm.a4 += fc * cos(lam * 4.);
|
||||
fc = mult * s * (h + proj_parm.xj) / sq;
|
||||
proj_parm.c1 += fc * cos(lam);
|
||||
proj_parm.c3 += fc * cos(lam * 3.);
|
||||
}
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_lsat_ellipsoid : public base_t_fi<base_lsat_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_lsat m_proj_parm;
|
||||
|
||||
inline base_lsat_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_lsat_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
int l, nn;
|
||||
double lamt, xlam, sdsq, c, d, s, lamdp, phidp, lampp, tanph,
|
||||
lamtp, cl, sd, sp, fac, sav, tanphi;
|
||||
|
||||
if (lp_lat > HALFPI)
|
||||
lp_lat = HALFPI;
|
||||
else if (lp_lat < -HALFPI)
|
||||
lp_lat = -HALFPI;
|
||||
lampp = lp_lat >= 0. ? HALFPI : PI_HALFPI;
|
||||
tanphi = tan(lp_lat);
|
||||
for (nn = 0;;) {
|
||||
sav = lampp;
|
||||
lamtp = lp_lon + this->m_proj_parm.p22 * lampp;
|
||||
cl = cos(lamtp);
|
||||
if (fabs(cl) < TOL)
|
||||
lamtp -= TOL;
|
||||
fac = lampp - sin(lampp) * (cl < 0. ? -HALFPI : HALFPI);
|
||||
for (l = 50; l; --l) {
|
||||
lamt = lp_lon + this->m_proj_parm.p22 * sav;
|
||||
if (fabs(c = cos(lamt)) < TOL)
|
||||
lamt -= TOL;
|
||||
xlam = (this->m_par.one_es * tanphi * this->m_proj_parm.sa + sin(lamt) * this->m_proj_parm.ca) / c;
|
||||
lamdp = atan(xlam) + fac;
|
||||
if (fabs(fabs(sav) - fabs(lamdp)) < TOL)
|
||||
break;
|
||||
sav = lamdp;
|
||||
}
|
||||
if (!l || ++nn >= 3 || (lamdp > this->m_proj_parm.rlm && lamdp < this->m_proj_parm.rlm2))
|
||||
break;
|
||||
if (lamdp <= this->m_proj_parm.rlm)
|
||||
lampp = TWOPI_HALFPI;
|
||||
else if (lamdp >= this->m_proj_parm.rlm2)
|
||||
lampp = HALFPI;
|
||||
}
|
||||
if (l) {
|
||||
sp = sin(lp_lat);
|
||||
phidp = aasin((this->m_par.one_es * this->m_proj_parm.ca * sp - this->m_proj_parm.sa * cos(lp_lat) *
|
||||
sin(lamt)) / sqrt(1. - this->m_par.es * sp * sp));
|
||||
tanph = log(tan(FORTPI + .5 * phidp));
|
||||
sd = sin(lamdp);
|
||||
sdsq = sd * sd;
|
||||
s = this->m_proj_parm.p22 * this->m_proj_parm.sa * cos(lamdp) * sqrt((1. + this->m_proj_parm.t * sdsq)
|
||||
/ ((1. + this->m_proj_parm.w * sdsq) * (1. + this->m_proj_parm.q * sdsq)));
|
||||
d = sqrt(this->m_proj_parm.xj * this->m_proj_parm.xj + s * s);
|
||||
xy_x = this->m_proj_parm.b * lamdp + this->m_proj_parm.a2 * sin(2. * lamdp) + this->m_proj_parm.a4 *
|
||||
sin(lamdp * 4.) - tanph * s / d;
|
||||
xy_y = this->m_proj_parm.c1 * sd + this->m_proj_parm.c3 * sin(lamdp * 3.) + tanph * this->m_proj_parm.xj / d;
|
||||
} else
|
||||
xy_x = xy_y = HUGE_VAL;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
int nn;
|
||||
double lamt, sdsq, s, lamdp, phidp, sppsq, dd, sd, sl, fac, scl, sav, spp;
|
||||
|
||||
lamdp = xy_x / this->m_proj_parm.b;
|
||||
nn = 50;
|
||||
do {
|
||||
sav = lamdp;
|
||||
sd = sin(lamdp);
|
||||
sdsq = sd * sd;
|
||||
s = this->m_proj_parm.p22 * this->m_proj_parm.sa * cos(lamdp) * sqrt((1. + this->m_proj_parm.t * sdsq)
|
||||
/ ((1. + this->m_proj_parm.w * sdsq) * (1. + this->m_proj_parm.q * sdsq)));
|
||||
lamdp = xy_x + xy_y * s / this->m_proj_parm.xj - this->m_proj_parm.a2 * sin(
|
||||
2. * lamdp) - this->m_proj_parm.a4 * sin(lamdp * 4.) - s / this->m_proj_parm.xj * (
|
||||
this->m_proj_parm.c1 * sin(lamdp) + this->m_proj_parm.c3 * sin(lamdp * 3.));
|
||||
lamdp /= this->m_proj_parm.b;
|
||||
} while (fabs(lamdp - sav) >= TOL && --nn);
|
||||
sl = sin(lamdp);
|
||||
fac = exp(sqrt(1. + s * s / this->m_proj_parm.xj / this->m_proj_parm.xj) * (xy_y -
|
||||
this->m_proj_parm.c1 * sl - this->m_proj_parm.c3 * sin(lamdp * 3.)));
|
||||
phidp = 2. * (atan(fac) - FORTPI);
|
||||
dd = sl * sl;
|
||||
if (fabs(cos(lamdp)) < TOL)
|
||||
lamdp -= TOL;
|
||||
spp = sin(phidp);
|
||||
sppsq = spp * spp;
|
||||
lamt = atan(((1. - sppsq * this->m_par.rone_es) * tan(lamdp) *
|
||||
this->m_proj_parm.ca - spp * this->m_proj_parm.sa * sqrt((1. + this->m_proj_parm.q * dd) * (
|
||||
1. - sppsq) - sppsq * this->m_proj_parm.u) / cos(lamdp)) / (1. - sppsq
|
||||
* (1. + this->m_proj_parm.u)));
|
||||
sl = lamt >= 0. ? 1. : -1.;
|
||||
scl = cos(lamdp) >= 0. ? 1. : -1;
|
||||
lamt -= HALFPI * (1. - scl) * sl;
|
||||
lp_lon = lamt - this->m_proj_parm.p22 * lamdp;
|
||||
if (fabs(this->m_proj_parm.sa) < TOL)
|
||||
lp_lat = aasin(spp / sqrt(this->m_par.one_es * this->m_par.one_es + this->m_par.es * sppsq));
|
||||
else
|
||||
lp_lat = atan((tan(lamdp) * cos(lamt) - this->m_proj_parm.ca * sin(lamt)) /
|
||||
(this->m_par.one_es * this->m_proj_parm.sa));
|
||||
}
|
||||
};
|
||||
|
||||
// Space oblique for LANDSAT
|
||||
template <typename Parameters>
|
||||
void setup_lsat(Parameters& par, par_lsat& proj_parm)
|
||||
{
|
||||
int land, path;
|
||||
double lam, alf, esc, ess;
|
||||
land = pj_param(par.params, "ilsat").i;
|
||||
if (land <= 0 || land > 5) throw proj_exception(-28);
|
||||
path = pj_param(par.params, "ipath").i;
|
||||
if (path <= 0 || path > (land <= 3 ? 251 : 233)) throw proj_exception(-29);
|
||||
if (land <= 3) {
|
||||
par.lam0 = DEG_TO_RAD * 128.87 - TWOPI / 251. * path;
|
||||
proj_parm.p22 = 103.2669323;
|
||||
alf = DEG_TO_RAD * 99.092;
|
||||
} else {
|
||||
par.lam0 = DEG_TO_RAD * 129.3 - TWOPI / 233. * path;
|
||||
proj_parm.p22 = 98.8841202;
|
||||
alf = DEG_TO_RAD * 98.2;
|
||||
}
|
||||
proj_parm.p22 /= 1440.;
|
||||
proj_parm.sa = sin(alf);
|
||||
proj_parm.ca = cos(alf);
|
||||
if (fabs(proj_parm.ca) < 1e-9)
|
||||
proj_parm.ca = 1e-9;
|
||||
esc = par.es * proj_parm.ca * proj_parm.ca;
|
||||
ess = par.es * proj_parm.sa * proj_parm.sa;
|
||||
proj_parm.w = (1. - esc) * par.rone_es;
|
||||
proj_parm.w = proj_parm.w * proj_parm.w - 1.;
|
||||
proj_parm.q = ess * par.rone_es;
|
||||
proj_parm.t = ess * (2. - par.es) * par.rone_es * par.rone_es;
|
||||
proj_parm.u = esc * par.rone_es;
|
||||
proj_parm.xj = par.one_es * par.one_es * par.one_es;
|
||||
proj_parm.rlm = PI * (1. / 248. + .5161290322580645);
|
||||
proj_parm.rlm2 = proj_parm.rlm + TWOPI;
|
||||
proj_parm.a2 = proj_parm.a4 = proj_parm.b = proj_parm.c1 = proj_parm.c3 = 0.;
|
||||
seraz0(0., 1., par, proj_parm);
|
||||
for (lam = 9.;
|
||||
lam <= 81.0001;
|
||||
lam += 18.)
|
||||
seraz0(lam, 4., par, proj_parm);
|
||||
for (lam = 18;
|
||||
lam <= 72.0001;
|
||||
lam += 18.)
|
||||
seraz0(lam, 2., par, proj_parm);
|
||||
seraz0(90., 1., par, proj_parm);
|
||||
proj_parm.a2 /= 30.;
|
||||
proj_parm.a4 /= 60.;
|
||||
proj_parm.b /= 30.;
|
||||
proj_parm.c1 /= 15.;
|
||||
proj_parm.c3 /= 45.;
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::lsat
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Space oblique for LANDSAT projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lsat= path=
|
||||
\par Example
|
||||
\image html ex_lsat.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lsat_ellipsoid : public detail::lsat::base_lsat_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lsat_ellipsoid(const Parameters& par) : detail::lsat::base_lsat_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::lsat::setup_lsat(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lsat_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<lsat_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void lsat_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("lsat", new lsat_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_LSAT_HPP
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace mbt_fps{
|
||||
static const int MAX_ITER = 10;
|
||||
static const double LOOP_TOL = 1e-7;
|
||||
static const double C1 = 0.45503;
|
||||
static const double C2 = 1.36509;
|
||||
static const double C3 = 1.41546;
|
||||
static const double C_x = 0.22248;
|
||||
static const double C_y = 1.44492;
|
||||
static const double C1_2 = 0.33333333333333333333333333;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_mbt_fps_spheroid : public base_t_fi<base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_mbt_fps_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double k, V, t;
|
||||
int i;
|
||||
|
||||
k = C3 * sin(lp_lat);
|
||||
for (i = MAX_ITER; i ; --i) {
|
||||
t = lp_lat / C2;
|
||||
lp_lat -= V = (C1 * sin(t) + sin(lp_lat) - k) /
|
||||
(C1_2 * cos(t) + cos(lp_lat));
|
||||
if (fabs(V) < LOOP_TOL)
|
||||
break;
|
||||
}
|
||||
t = lp_lat / C2;
|
||||
xy_x = C_x * lp_lon * (1. + 3. * cos(lp_lat)/cos(t) );
|
||||
xy_y = C_y * sin(t);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double t;
|
||||
|
||||
lp_lat = C2 * (t = aasin(xy_y / C_y));
|
||||
lp_lon = xy_x / (C_x * (1. + 3. * cos(lp_lat)/cos(t)));
|
||||
lp_lat = aasin((C1 * sin(t) + sin(lp_lat)) / C3);
|
||||
}
|
||||
};
|
||||
|
||||
// McBryde-Thomas Flat-Pole Sine (No. 2)
|
||||
template <typename Parameters>
|
||||
void setup_mbt_fps(Parameters& par)
|
||||
{
|
||||
par.es = 0;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::mbt_fps
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief McBryde-Thomas Flat-Pole Sine (No. 2) projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_mbt_fps.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct mbt_fps_spheroid : public detail::mbt_fps::base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline mbt_fps_spheroid(const Parameters& par) : detail::mbt_fps::base_mbt_fps_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mbt_fps::setup_mbt_fps(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class mbt_fps_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<mbt_fps_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void mbt_fps_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("mbt_fps", new mbt_fps_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MBT_FPS_HPP
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace mbtfpp{
|
||||
static const double CS = .95257934441568037152;
|
||||
static const double FXC = .92582009977255146156;
|
||||
static const double FYC = 3.40168025708304504493;
|
||||
static const double C23 = .66666666666666666666;
|
||||
static const double C13 = .33333333333333333333;
|
||||
static const double ONEEPS = 1.0000001;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_mbtfpp_spheroid : public base_t_fi<base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_mbtfpp_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
lp_lat = asin(CS * sin(lp_lat));
|
||||
xy_x = FXC * lp_lon * (2. * cos(C23 * lp_lat) - 1.);
|
||||
xy_y = FYC * sin(C13 * lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = xy_y / FYC;
|
||||
if (fabs(lp_lat) >= 1.) {
|
||||
if (fabs(lp_lat) > ONEEPS) throw proj_exception();
|
||||
else lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
|
||||
} else
|
||||
lp_lat = asin(lp_lat);
|
||||
lp_lon = xy_x / ( FXC * (2. * cos(C23 * (lp_lat *= 3.)) - 1.) );
|
||||
if (fabs(lp_lat = sin(lp_lat) / CS) >= 1.) {
|
||||
if (fabs(lp_lat) > ONEEPS) throw proj_exception();
|
||||
else lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
|
||||
} else
|
||||
lp_lat = asin(lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
// McBride-Thomas Flat-Polar Parabolic
|
||||
template <typename Parameters>
|
||||
void setup_mbtfpp(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::mbtfpp
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief McBride-Thomas Flat-Polar Parabolic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_mbtfpp.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct mbtfpp_spheroid : public detail::mbtfpp::base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline mbtfpp_spheroid(const Parameters& par) : detail::mbtfpp::base_mbtfpp_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mbtfpp::setup_mbtfpp(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class mbtfpp_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<mbtfpp_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void mbtfpp_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("mbtfpp", new mbtfpp_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MBTFPP_HPP
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace mbtfpq{
|
||||
static const int NITER = 20;
|
||||
static const double EPS = 1e-7;
|
||||
static const double ONETOL = 1.000001;
|
||||
static const double C = 1.70710678118654752440;
|
||||
static const double RC = 0.58578643762690495119;
|
||||
static const double FYC = 1.87475828462269495505;
|
||||
static const double RYC = 0.53340209679417701685;
|
||||
static const double FXC = 0.31245971410378249250;
|
||||
static const double RXC = 3.20041258076506210122;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_mbtfpq_spheroid : public base_t_fi<base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_mbtfpq_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double th1, c;
|
||||
int i;
|
||||
|
||||
c = C * sin(lp_lat);
|
||||
for (i = NITER; i; --i) {
|
||||
lp_lat -= th1 = (sin(.5*lp_lat) + sin(lp_lat) - c) /
|
||||
(.5*cos(.5*lp_lat) + cos(lp_lat));
|
||||
if (fabs(th1) < EPS) break;
|
||||
}
|
||||
xy_x = FXC * lp_lon * (1.0 + 2. * cos(lp_lat)/cos(0.5 * lp_lat));
|
||||
xy_y = FYC * sin(0.5 * lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double t;
|
||||
|
||||
lp_lat = RYC * xy_y;
|
||||
if (fabs(lp_lat) > 1.) {
|
||||
if (fabs(lp_lat) > ONETOL) throw proj_exception();
|
||||
else if (lp_lat < 0.) { t = -1.; lp_lat = -PI; }
|
||||
else { t = 1.; lp_lat = PI; }
|
||||
} else
|
||||
lp_lat = 2. * asin(t = lp_lat);
|
||||
lp_lon = RXC * xy_x / (1. + 2. * cos(lp_lat)/cos(0.5 * lp_lat));
|
||||
lp_lat = RC * (t + sin(lp_lat));
|
||||
if (fabs(lp_lat) > 1.)
|
||||
if (fabs(lp_lat) > ONETOL) throw proj_exception();
|
||||
else lp_lat = lp_lat < 0. ? -HALFPI : HALFPI;
|
||||
else
|
||||
lp_lat = asin(lp_lat);
|
||||
}
|
||||
};
|
||||
|
||||
// McBryde-Thomas Flat-Polar Quartic
|
||||
template <typename Parameters>
|
||||
void setup_mbtfpq(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::mbtfpq
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief McBryde-Thomas Flat-Polar Quartic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_mbtfpq.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct mbtfpq_spheroid : public detail::mbtfpq::base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline mbtfpq_spheroid(const Parameters& par) : detail::mbtfpq::base_mbtfpq_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mbtfpq::setup_mbtfpq(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class mbtfpq_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<mbtfpq_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void mbtfpq_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("mbtfpq", new mbtfpq_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MBTFPQ_HPP
|
||||
|
||||
213
include/boost/geometry/extensions/gis/projections/proj/merc.hpp
Normal file
213
include/boost/geometry/extensions/gis/projections/proj/merc.hpp
Normal file
@@ -0,0 +1,213 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MERC_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MERC_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_msfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_tsfn.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_phi2.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace merc{
|
||||
static const double EPS10 = 1.e-10;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_merc_ellipsoid : public base_t_fi<base_merc_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_merc_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_merc_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception();;
|
||||
xy_x = this->m_par.k0 * lp_lon;
|
||||
xy_y = - this->m_par.k0 * log(pj_tsfn(lp_lat, sin(lp_lat), this->m_par.e));
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
if ((lp_lat = pj_phi2(exp(- xy_y / this->m_par.k0), this->m_par.e)) == HUGE_VAL) throw proj_exception();;
|
||||
lp_lon = xy_x / this->m_par.k0;
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_merc_spheroid : public base_t_fi<base_merc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_merc_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_merc_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if (fabs(fabs(lp_lat) - HALFPI) <= EPS10) throw proj_exception();;
|
||||
xy_x = this->m_par.k0 * lp_lon;
|
||||
xy_y = this->m_par.k0 * log(tan(FORTPI + .5 * lp_lat));
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lat = HALFPI - 2. * atan(exp(-xy_y / this->m_par.k0));
|
||||
lp_lon = xy_x / this->m_par.k0;
|
||||
}
|
||||
};
|
||||
|
||||
// Mercator
|
||||
template <typename Parameters>
|
||||
void setup_merc(Parameters& par)
|
||||
{
|
||||
double phits=0.0;
|
||||
int is_phits;
|
||||
if( (is_phits = pj_param(par.params, "tlat_ts").i) ) {
|
||||
phits = fabs(pj_param(par.params, "rlat_ts").f);
|
||||
if (phits >= HALFPI) throw proj_exception(-24);
|
||||
}
|
||||
if (par.es) { /* ellipsoid */
|
||||
if (is_phits)
|
||||
par.k0 = pj_msfn(sin(phits), cos(phits), par.es);
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
} else { /* sphere */
|
||||
if (is_phits)
|
||||
par.k0 = cos(phits);
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace detail::merc
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Mercator projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_ts=
|
||||
\par Example
|
||||
\image html ex_merc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct merc_ellipsoid : public detail::merc::base_merc_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline merc_ellipsoid(const Parameters& par) : detail::merc::base_merc_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::merc::setup_merc(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Mercator projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
- Ellipsoid
|
||||
- lat_ts=
|
||||
\par Example
|
||||
\image html ex_merc.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct merc_spheroid : public detail::merc::base_merc_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline merc_spheroid(const Parameters& par) : detail::merc::base_merc_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::merc::setup_merc(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class merc_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
if (par.es)
|
||||
return new base_v_fi<merc_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<merc_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void merc_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("merc", new merc_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MERC_HPP
|
||||
|
||||
138
include/boost/geometry/extensions/gis/projections/proj/mill.hpp
Normal file
138
include/boost/geometry/extensions/gis/projections/proj/mill.hpp
Normal file
@@ -0,0 +1,138 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MILL_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MILL_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace mill{
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_mill_spheroid : public base_t_fi<base_mill_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_mill_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_mill_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = lp_lon;
|
||||
xy_y = log(tan(FORTPI + lp_lat * .4)) * 1.25;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
lp_lon = xy_x;
|
||||
lp_lat = 2.5 * (atan(exp(.8 * xy_y)) - FORTPI);
|
||||
}
|
||||
};
|
||||
|
||||
// Miller Cylindrical
|
||||
template <typename Parameters>
|
||||
void setup_mill(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::mill
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Miller Cylindrical projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Spheroid
|
||||
\par Example
|
||||
\image html ex_mill.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct mill_spheroid : public detail::mill::base_mill_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline mill_spheroid(const Parameters& par) : detail::mill::base_mill_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mill::setup_mill(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class mill_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<mill_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void mill_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("mill", new mill_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MILL_HPP
|
||||
|
||||
@@ -0,0 +1,474 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/pj_zpoly1.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace mod_ster{
|
||||
static const double EPSLN = 1e-10;
|
||||
|
||||
struct par_mod_ster
|
||||
{
|
||||
COMPLEX *zcoeff;
|
||||
double cchio, schio;
|
||||
int n;
|
||||
};
|
||||
/* based upon Snyder and Linck, USGS-NMD */
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_mod_ster_ellipsoid : public base_t_fi<base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_mod_ster m_proj_parm;
|
||||
|
||||
inline base_mod_ster_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double sinlon, coslon, esphi, chi, schi, cchi, s;
|
||||
COMPLEX p;
|
||||
|
||||
sinlon = sin(lp_lon);
|
||||
coslon = cos(lp_lon);
|
||||
esphi = this->m_par.e * sin(lp_lat);
|
||||
chi = 2. * atan(tan((HALFPI + lp_lat) * .5) *
|
||||
pow((1. - esphi) / (1. + esphi), this->m_par.e * .5)) - HALFPI;
|
||||
schi = sin(chi);
|
||||
cchi = cos(chi);
|
||||
s = 2. / (1. + this->m_proj_parm.schio * schi + this->m_proj_parm.cchio * cchi * coslon);
|
||||
p.r = s * cchi * sinlon;
|
||||
p.i = s * (this->m_proj_parm.cchio * schi - this->m_proj_parm.schio * cchi * coslon);
|
||||
p = pj_zpoly1(p, this->m_proj_parm.zcoeff, this->m_proj_parm.n);
|
||||
xy_x = p.r;
|
||||
xy_y = p.i;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
int nn;
|
||||
COMPLEX p, fxy, fpxy, dp;
|
||||
double den, rh = 0, z, sinz = 0, cosz = 0, chi, phi = 0, dphi, esphi;
|
||||
|
||||
p.r = xy_x;
|
||||
p.i = xy_y;
|
||||
for (nn = 20; nn ;--nn) {
|
||||
fxy = pj_zpolyd1(p, this->m_proj_parm.zcoeff, this->m_proj_parm.n, &fpxy);
|
||||
fxy.r -= xy_x;
|
||||
fxy.i -= xy_y;
|
||||
den = fpxy.r * fpxy.r + fpxy.i * fpxy.i;
|
||||
dp.r = -(fxy.r * fpxy.r + fxy.i * fpxy.i) / den;
|
||||
dp.i = -(fxy.i * fpxy.r - fxy.r * fpxy.i) / den;
|
||||
p.r += dp.r;
|
||||
p.i += dp.i;
|
||||
if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
|
||||
break;
|
||||
}
|
||||
if (nn) {
|
||||
rh = boost::math::hypot(p.r, p.i);
|
||||
z = 2. * atan(.5 * rh);
|
||||
sinz = sin(z);
|
||||
cosz = cos(z);
|
||||
lp_lon = this->m_par.lam0;
|
||||
if (fabs(rh) <= EPSLN) {
|
||||
lp_lat = this->m_par.phi0;
|
||||
return;
|
||||
}
|
||||
chi = aasin(cosz * this->m_proj_parm.schio + p.i * sinz * this->m_proj_parm.cchio / rh);
|
||||
phi = chi;
|
||||
for (nn = 20; nn ;--nn) {
|
||||
esphi = this->m_par.e * sin(phi);
|
||||
dphi = 2. * atan(tan((HALFPI + chi) * .5) *
|
||||
pow((1. + esphi) / (1. - esphi), this->m_par.e * .5)) - HALFPI - phi;
|
||||
phi += dphi;
|
||||
if (fabs(dphi) <= EPSLN)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nn) {
|
||||
lp_lat = phi;
|
||||
lp_lon = atan2(p.r * sinz, rh * this->m_proj_parm.cchio * cosz - p.i *
|
||||
this->m_proj_parm.schio * sinz);
|
||||
} else
|
||||
lp_lon = lp_lat = HUGE_VAL;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_mod_ster& proj_parm) /* general initialization */
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(proj_parm);
|
||||
double esphi, chio;
|
||||
if (par.es) {
|
||||
esphi = par.e * sin(par.phi0);
|
||||
chio = 2. * atan(tan((HALFPI + par.phi0) * .5) *
|
||||
pow((1. - esphi) / (1. + esphi), par.e * .5)) - HALFPI;
|
||||
} else
|
||||
chio = par.phi0;
|
||||
proj_parm.schio = sin(chio);
|
||||
proj_parm.cchio = cos(chio);
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
|
||||
// Miller Oblated Stereographic
|
||||
template <typename Parameters>
|
||||
void setup_mil_os(Parameters& par, par_mod_ster& proj_parm)
|
||||
{
|
||||
static COMPLEX /* Miller Oblated Stereographic */
|
||||
AB[] = {
|
||||
{0.924500, 0.},
|
||||
{0., 0.},
|
||||
{0.019430, 0.}
|
||||
};
|
||||
proj_parm.n = 2;
|
||||
par.lam0 = DEG_TO_RAD * 20.;
|
||||
par.phi0 = DEG_TO_RAD * 18.;
|
||||
proj_parm.zcoeff = AB;
|
||||
par.es = 0.;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Lee Oblated Stereographic
|
||||
template <typename Parameters>
|
||||
void setup_lee_os(Parameters& par, par_mod_ster& proj_parm)
|
||||
{
|
||||
static COMPLEX /* Lee Oblated Stereographic */
|
||||
AB[] = {
|
||||
{0.721316, 0.},
|
||||
{0., 0.},
|
||||
{-0.0088162, -0.00617325}
|
||||
};
|
||||
proj_parm.n = 2;
|
||||
par.lam0 = DEG_TO_RAD * -165.;
|
||||
par.phi0 = DEG_TO_RAD * -10.;
|
||||
proj_parm.zcoeff = AB;
|
||||
par.es = 0.;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Mod. Stererographics of 48 U.S.
|
||||
template <typename Parameters>
|
||||
void setup_gs48(Parameters& par, par_mod_ster& proj_parm)
|
||||
{
|
||||
static COMPLEX /* 48 United States */
|
||||
AB[] = {
|
||||
{0.98879, 0.},
|
||||
{0., 0.},
|
||||
{-0.050909, 0.},
|
||||
{0., 0.},
|
||||
{0.075528, 0.}
|
||||
};
|
||||
proj_parm.n = 4;
|
||||
par.lam0 = DEG_TO_RAD * -96.;
|
||||
par.phi0 = DEG_TO_RAD * -39.;
|
||||
proj_parm.zcoeff = AB;
|
||||
par.es = 0.;
|
||||
par.a = 6370997.;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Mod. Stererographics of Alaska
|
||||
template <typename Parameters>
|
||||
void setup_alsk(Parameters& par, par_mod_ster& proj_parm)
|
||||
{
|
||||
static COMPLEX
|
||||
ABe[] = { /* Alaska ellipsoid */
|
||||
{.9945303, 0.},
|
||||
{.0052083, -.0027404},
|
||||
{.0072721, .0048181},
|
||||
{-.0151089, -.1932526},
|
||||
{.0642675, -.1381226},
|
||||
{.3582802, -.2884586}},
|
||||
ABs[] = { /* Alaska sphere */
|
||||
{.9972523, 0.},
|
||||
{.0052513, -.0041175},
|
||||
{.0074606, .0048125},
|
||||
{-.0153783, -.1968253},
|
||||
{.0636871, -.1408027},
|
||||
{.3660976, -.2937382}
|
||||
};
|
||||
proj_parm.n = 5;
|
||||
par.lam0 = DEG_TO_RAD * -152.;
|
||||
par.phi0 = DEG_TO_RAD * 64.;
|
||||
if (par.es) { /* fixed ellipsoid/sphere */
|
||||
proj_parm.zcoeff = ABe;
|
||||
par.a = 6378206.4;
|
||||
par.e = sqrt(par.es = 0.00676866);
|
||||
} else {
|
||||
proj_parm.zcoeff = ABs;
|
||||
par.a = 6370997.;
|
||||
}
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Mod. Stererographics of 50 U.S.
|
||||
template <typename Parameters>
|
||||
void setup_gs50(Parameters& par, par_mod_ster& proj_parm)
|
||||
{
|
||||
static COMPLEX
|
||||
ABe[] = { /* GS50 ellipsoid */
|
||||
{.9827497, 0.},
|
||||
{.0210669, .0053804},
|
||||
{-.1031415, -.0571664},
|
||||
{-.0323337, -.0322847},
|
||||
{.0502303, .1211983},
|
||||
{.0251805, .0895678},
|
||||
{-.0012315, -.1416121},
|
||||
{.0072202, -.1317091},
|
||||
{-.0194029, .0759677},
|
||||
{-.0210072, .0834037}
|
||||
},
|
||||
ABs[] = { /* GS50 sphere */
|
||||
{.9842990, 0.},
|
||||
{.0211642, .0037608},
|
||||
{-.1036018, -.0575102},
|
||||
{-.0329095, -.0320119},
|
||||
{.0499471, .1223335},
|
||||
{.0260460, .0899805},
|
||||
{.0007388, -.1435792},
|
||||
{.0075848, -.1334108},
|
||||
{-.0216473, .0776645},
|
||||
{-.0225161, .0853673}
|
||||
};
|
||||
proj_parm.n = 9;
|
||||
par.lam0 = DEG_TO_RAD * -120.;
|
||||
par.phi0 = DEG_TO_RAD * 45.;
|
||||
if (par.es) { /* fixed ellipsoid/sphere */
|
||||
proj_parm.zcoeff = ABe;
|
||||
par.a = 6378206.4;
|
||||
par.e = sqrt(par.es = 0.00676866);
|
||||
} else {
|
||||
proj_parm.zcoeff = ABs;
|
||||
par.a = 6370997.;
|
||||
}
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
}} // namespace detail::mod_ster
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Miller Oblated Stereographic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azi(mod)
|
||||
\par Example
|
||||
\image html ex_mil_os.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct mil_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline mil_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mod_ster::setup_mil_os(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Lee Oblated Stereographic projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azi(mod)
|
||||
\par Example
|
||||
\image html ex_lee_os.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct lee_os_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline lee_os_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mod_ster::setup_lee_os(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Mod. Stererographics of 48 U.S. projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azi(mod)
|
||||
\par Example
|
||||
\image html ex_gs48.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gs48_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gs48_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mod_ster::setup_gs48(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Mod. Stererographics of Alaska projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azi(mod)
|
||||
\par Example
|
||||
\image html ex_alsk.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct alsk_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline alsk_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mod_ster::setup_alsk(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Mod. Stererographics of 50 U.S. projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azi(mod)
|
||||
\par Example
|
||||
\image html ex_gs50.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct gs50_ellipsoid : public detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline gs50_ellipsoid(const Parameters& par) : detail::mod_ster::base_mod_ster_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::mod_ster::setup_gs50(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class mil_os_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<mil_os_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class lee_os_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<lee_os_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gs48_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<gs48_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class alsk_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<alsk_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class gs50_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<gs50_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void mod_ster_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("mil_os", new mil_os_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("lee_os", new lee_os_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("gs48", new gs48_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("alsk", new alsk_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("gs50", new gs50_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MOD_STER_HPP
|
||||
|
||||
262
include/boost/geometry/extensions/gis/projections/proj/moll.hpp
Normal file
262
include/boost/geometry/extensions/gis/projections/proj/moll.hpp
Normal file
@@ -0,0 +1,262 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace moll{
|
||||
static const int MAX_ITER = 10;
|
||||
static const double LOOP_TOL = 1e-7;
|
||||
|
||||
struct par_moll
|
||||
{
|
||||
double C_x, C_y, C_p;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_moll_spheroid : public base_t_fi<base_moll_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_moll m_proj_parm;
|
||||
|
||||
inline base_moll_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_moll_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double k, V;
|
||||
int i;
|
||||
|
||||
k = this->m_proj_parm.C_p * sin(lp_lat);
|
||||
for (i = MAX_ITER; i ; --i) {
|
||||
lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
|
||||
(1. + cos(lp_lat));
|
||||
if (fabs(V) < LOOP_TOL)
|
||||
break;
|
||||
}
|
||||
if (!i)
|
||||
lp_lat = (lp_lat < 0.) ? -HALFPI : HALFPI;
|
||||
else
|
||||
lp_lat *= 0.5;
|
||||
xy_x = this->m_proj_parm.C_x * lp_lon * cos(lp_lat);
|
||||
xy_y = this->m_proj_parm.C_y * sin(lp_lat);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
|
||||
|
||||
lp_lat = aasin(xy_y / this->m_proj_parm.C_y);
|
||||
lp_lon = xy_x / (this->m_proj_parm.C_x * cos(lp_lat));
|
||||
lp_lat += lp_lat;
|
||||
lp_lat = aasin((lp_lat + sin(lp_lat)) / this->m_proj_parm.C_p);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_moll& proj_parm, double p)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(proj_parm);
|
||||
double r, sp, p2 = p + p;
|
||||
par.es = 0;
|
||||
sp = sin(p);
|
||||
r = sqrt(TWOPI * sp / (p2 + sin(p2)));
|
||||
proj_parm.C_x = 2. * r / PI;
|
||||
proj_parm.C_y = r / sp;
|
||||
proj_parm.C_p = p2 + sin(p2);
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
|
||||
// Mollweide
|
||||
template <typename Parameters>
|
||||
void setup_moll(Parameters& par, par_moll& proj_parm)
|
||||
{
|
||||
setup(par, proj_parm, HALFPI);
|
||||
}
|
||||
|
||||
// Wagner IV
|
||||
template <typename Parameters>
|
||||
void setup_wag4(Parameters& par, par_moll& proj_parm)
|
||||
{
|
||||
setup(par, proj_parm, PI/3.);
|
||||
}
|
||||
|
||||
// Wagner V
|
||||
template <typename Parameters>
|
||||
void setup_wag5(Parameters& par, par_moll& proj_parm)
|
||||
{
|
||||
par.es = 0;
|
||||
proj_parm.C_x = 0.90977;
|
||||
proj_parm.C_y = 1.65014;
|
||||
proj_parm.C_p = 3.00896;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::moll
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Mollweide 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_moll.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct moll_spheroid : public detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline moll_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::moll::setup_moll(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Wagner IV 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_wag4.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct wag4_spheroid : public detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline wag4_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::moll::setup_wag4(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Wagner V 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_wag5.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct wag5_spheroid : public detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline wag5_spheroid(const Parameters& par) : detail::moll::base_moll_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::moll::setup_wag5(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class moll_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<moll_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class wag4_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<wag4_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class wag5_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<wag5_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void moll_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("moll", new moll_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("wag4", new wag4_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("wag5", new wag5_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_MOLL_HPP
|
||||
|
||||
154
include/boost/geometry/extensions/gis/projections/proj/nell.hpp
Normal file
154
include/boost/geometry/extensions/gis/projections/proj/nell.hpp
Normal file
@@ -0,0 +1,154 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_NELL_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace nell{
|
||||
static const int MAX_ITER = 10;
|
||||
static const double LOOP_TOL = 1e-7;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_nell_spheroid : public base_t_fi<base_nell_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_nell_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_nell_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double k, V;
|
||||
int i;
|
||||
|
||||
k = 2. * sin(lp_lat);
|
||||
V = lp_lat * lp_lat;
|
||||
lp_lat *= 1.00371 + V * (-0.0935382 + V * -0.011412);
|
||||
for (i = MAX_ITER; i ; --i) {
|
||||
lp_lat -= V = (lp_lat + sin(lp_lat) - k) /
|
||||
(1. + cos(lp_lat));
|
||||
if (fabs(V) < LOOP_TOL)
|
||||
break;
|
||||
}
|
||||
xy_x = 0.5 * lp_lon * (1. + cos(lp_lat));
|
||||
xy_y = lp_lat;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
|
||||
|
||||
lp_lon = 2. * xy_x / (1. + cos(xy_y));
|
||||
lp_lat = aasin(0.5 * (xy_y + sin(xy_y)));
|
||||
}
|
||||
};
|
||||
|
||||
// Nell
|
||||
template <typename Parameters>
|
||||
void setup_nell(Parameters& par)
|
||||
{
|
||||
par.es = 0;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::nell
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Nell 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_nell.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct nell_spheroid : public detail::nell::base_nell_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline nell_spheroid(const Parameters& par) : detail::nell::base_nell_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::nell::setup_nell(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class nell_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<nell_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void nell_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("nell", new nell_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_NELL_HPP
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace nell_h{
|
||||
static const int NITER = 9;
|
||||
static const double EPS = 1e-7;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_nell_h_spheroid : public base_t_fi<base_nell_h_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_nell_h_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_nell_h_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
xy_x = 0.5 * lp_lon * (1. + cos(lp_lat));
|
||||
xy_y = 2.0 * (lp_lat - tan(0.5 *lp_lat));
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double V, c, p;
|
||||
int i;
|
||||
|
||||
p = 0.5 * xy_y;
|
||||
for (i = NITER; i ; --i) {
|
||||
c = cos(0.5 * lp_lat);
|
||||
lp_lat -= V = (lp_lat - tan(lp_lat/2) - p)/(1. - 0.5/(c*c));
|
||||
if (fabs(V) < EPS)
|
||||
break;
|
||||
}
|
||||
if (!i) {
|
||||
lp_lat = p < 0. ? -HALFPI : HALFPI;
|
||||
lp_lon = 2. * xy_x;
|
||||
} else
|
||||
lp_lon = 2. * xy_x / (1. + cos(lp_lat));
|
||||
}
|
||||
};
|
||||
|
||||
// Nell-Hammer
|
||||
template <typename Parameters>
|
||||
void setup_nell_h(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::nell_h
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Nell-Hammer 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_nell_h.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct nell_h_spheroid : public detail::nell_h::base_nell_h_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline nell_h_spheroid(const Parameters& par) : detail::nell_h::base_nell_h_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::nell_h::setup_nell_h(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class nell_h_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<nell_h_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void nell_h_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("nell_h", new nell_h_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_NELL_H_HPP
|
||||
|
||||
160
include/boost/geometry/extensions/gis/projections/proj/nocol.hpp
Normal file
160
include/boost/geometry/extensions/gis/projections/proj/nocol.hpp
Normal file
@@ -0,0 +1,160 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace nocol{
|
||||
static const double EPS = 1e-10;
|
||||
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_nocol_spheroid : public base_t_f<base_nocol_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_nocol_spheroid(const Parameters& par)
|
||||
: base_t_f<base_nocol_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
if (fabs(lp_lon) < EPS) {
|
||||
xy_x = 0;
|
||||
xy_y = lp_lat;
|
||||
} else if (fabs(lp_lat) < EPS) {
|
||||
xy_x = lp_lon;
|
||||
xy_y = 0.;
|
||||
} else if (fabs(fabs(lp_lon) - HALFPI) < EPS) {
|
||||
xy_x = lp_lon * cos(lp_lat);
|
||||
xy_y = HALFPI * sin(lp_lat);
|
||||
} else if (fabs(fabs(lp_lat) - HALFPI) < EPS) {
|
||||
xy_x = 0;
|
||||
xy_y = lp_lat;
|
||||
} else {
|
||||
double tb, c, d, m, n, r2, sp;
|
||||
|
||||
tb = HALFPI / lp_lon - lp_lon / HALFPI;
|
||||
c = lp_lat / HALFPI;
|
||||
d = (1 - c * c)/((sp = sin(lp_lat)) - c);
|
||||
r2 = tb / d;
|
||||
r2 *= r2;
|
||||
m = (tb * sp / d - 0.5 * tb)/(1. + r2);
|
||||
n = (sp / r2 + 0.5 * d)/(1. + 1./r2);
|
||||
xy_x = cos(lp_lat);
|
||||
xy_x = sqrt(m * m + xy_x * xy_x / (1. + r2));
|
||||
xy_x = HALFPI * ( m + (lp_lon < 0. ? -xy_x : xy_x));
|
||||
xy_y = sqrt(n * n - (sp * sp / r2 + d * sp - 1.) /
|
||||
(1. + 1./r2));
|
||||
xy_y = HALFPI * ( n + (lp_lat < 0. ? xy_y : -xy_y ));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Nicolosi Globular
|
||||
template <typename Parameters>
|
||||
void setup_nicol(Parameters& par)
|
||||
{
|
||||
par.es = 0.;
|
||||
// par.fwd = s_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::nocol
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Nicolosi Globular projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- no inverse
|
||||
\par Example
|
||||
\image html ex_nicol.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct nicol_spheroid : public detail::nocol::base_nocol_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline nicol_spheroid(const Parameters& par) : detail::nocol::base_nocol_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::nocol::setup_nicol(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class nicol_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_f<nicol_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void nocol_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("nicol", new nicol_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_NOCOL_HPP
|
||||
|
||||
317
include/boost/geometry/extensions/gis/projections/proj/nsper.hpp
Normal file
317
include/boost/geometry/extensions/gis/projections/proj/nsper.hpp
Normal file
@@ -0,0 +1,317 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/concept_check.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace nsper{
|
||||
static const double EPS10 = 1.e-10;
|
||||
static const int N_POLE = 0;
|
||||
static const int S_POLE = 1;
|
||||
static const int EQUIT = 2;
|
||||
static const int OBLIQ = 3;
|
||||
|
||||
struct par_nsper
|
||||
{
|
||||
double height;
|
||||
double sinph0;
|
||||
double cosph0;
|
||||
double p;
|
||||
double rp;
|
||||
double pn1;
|
||||
double pfact;
|
||||
double h;
|
||||
double cg;
|
||||
double sg;
|
||||
double sw;
|
||||
double cw;
|
||||
int mode;
|
||||
int tilt;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_nsper_spheroid : public base_t_fi<base_nsper_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_nsper m_proj_parm;
|
||||
|
||||
inline base_nsper_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_nsper_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, cosphi, sinphi;
|
||||
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
coslam = cos(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case OBLIQ:
|
||||
xy_y = this->m_proj_parm.sinph0 * sinphi + this->m_proj_parm.cosph0 * cosphi * coslam;
|
||||
break;
|
||||
case EQUIT:
|
||||
xy_y = cosphi * coslam;
|
||||
break;
|
||||
case S_POLE:
|
||||
xy_y = - sinphi;
|
||||
break;
|
||||
case N_POLE:
|
||||
xy_y = sinphi;
|
||||
break;
|
||||
}
|
||||
if (xy_y < this->m_proj_parm.rp) throw proj_exception();;
|
||||
xy_y = this->m_proj_parm.pn1 / (this->m_proj_parm.p - xy_y);
|
||||
xy_x = xy_y * cosphi * sin(lp_lon);
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case OBLIQ:
|
||||
xy_y *= (this->m_proj_parm.cosph0 * sinphi -
|
||||
this->m_proj_parm.sinph0 * cosphi * coslam);
|
||||
break;
|
||||
case EQUIT:
|
||||
xy_y *= sinphi;
|
||||
break;
|
||||
case N_POLE:
|
||||
coslam = - coslam;
|
||||
case S_POLE:
|
||||
xy_y *= cosphi * coslam;
|
||||
break;
|
||||
}
|
||||
if (this->m_proj_parm.tilt) {
|
||||
double yt, ba;
|
||||
|
||||
yt = xy_y * this->m_proj_parm.cg + xy_x * this->m_proj_parm.sg;
|
||||
ba = 1. / (yt * this->m_proj_parm.sw * this->m_proj_parm.h + this->m_proj_parm.cw);
|
||||
xy_x = (xy_x * this->m_proj_parm.cg - xy_y * this->m_proj_parm.sg) * this->m_proj_parm.cw * ba;
|
||||
xy_y = yt * ba;
|
||||
}
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double rh, cosz, sinz;
|
||||
|
||||
if (this->m_proj_parm.tilt) {
|
||||
double bm, bq, yt;
|
||||
|
||||
yt = 1./(this->m_proj_parm.pn1 - xy_y * this->m_proj_parm.sw);
|
||||
bm = this->m_proj_parm.pn1 * xy_x * yt;
|
||||
bq = this->m_proj_parm.pn1 * xy_y * this->m_proj_parm.cw * yt;
|
||||
xy_x = bm * this->m_proj_parm.cg + bq * this->m_proj_parm.sg;
|
||||
xy_y = bq * this->m_proj_parm.cg - bm * this->m_proj_parm.sg;
|
||||
}
|
||||
rh = boost::math::hypot(xy_x, xy_y);
|
||||
if ((sinz = 1. - rh * rh * this->m_proj_parm.pfact) < 0.) throw proj_exception();;
|
||||
sinz = (this->m_proj_parm.p - sqrt(sinz)) / (this->m_proj_parm.pn1 / rh + rh / this->m_proj_parm.pn1);
|
||||
cosz = sqrt(1. - sinz * sinz);
|
||||
if (fabs(rh) <= EPS10) {
|
||||
lp_lon = 0.;
|
||||
lp_lat = this->m_par.phi0;
|
||||
} else {
|
||||
switch (this->m_proj_parm.mode) {
|
||||
case OBLIQ:
|
||||
lp_lat = asin(cosz * this->m_proj_parm.sinph0 + xy_y * sinz * this->m_proj_parm.cosph0 / rh);
|
||||
xy_y = (cosz - this->m_proj_parm.sinph0 * sin(lp_lat)) * rh;
|
||||
xy_x *= sinz * this->m_proj_parm.cosph0;
|
||||
break;
|
||||
case EQUIT:
|
||||
lp_lat = asin(xy_y * sinz / rh);
|
||||
xy_y = cosz * rh;
|
||||
xy_x *= sinz;
|
||||
break;
|
||||
case N_POLE:
|
||||
lp_lat = asin(cosz);
|
||||
xy_y = -xy_y;
|
||||
break;
|
||||
case S_POLE:
|
||||
lp_lat = - asin(cosz);
|
||||
break;
|
||||
}
|
||||
lp_lon = atan2(xy_x, xy_y);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Parameters>
|
||||
void setup(Parameters& par, par_nsper& proj_parm)
|
||||
{
|
||||
boost::ignore_unused_variable_warning(par);
|
||||
boost::ignore_unused_variable_warning(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;
|
||||
else if (fabs(par.phi0) < EPS10)
|
||||
proj_parm.mode = EQUIT;
|
||||
else {
|
||||
proj_parm.mode = OBLIQ;
|
||||
proj_parm.sinph0 = sin(par.phi0);
|
||||
proj_parm.cosph0 = cos(par.phi0);
|
||||
}
|
||||
proj_parm.pn1 = proj_parm.height / par.a;
|
||||
/* normalize by radius */
|
||||
proj_parm.p = 1. + proj_parm.pn1;
|
||||
proj_parm.rp = 1. / proj_parm.p;
|
||||
proj_parm.h = 1. / proj_parm.pn1;
|
||||
proj_parm.pfact = (proj_parm.p + 1.) * proj_parm.h;
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
|
||||
// Near-sided perspective
|
||||
template <typename Parameters>
|
||||
void setup_nsper(Parameters& par, par_nsper& proj_parm)
|
||||
{
|
||||
proj_parm.tilt = 0;
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
// Tilted perspective
|
||||
template <typename Parameters>
|
||||
void setup_tpers(Parameters& par, par_nsper& proj_parm)
|
||||
{
|
||||
double omega, gamma;
|
||||
omega = pj_param(par.params, "dtilt").f * DEG_TO_RAD;
|
||||
gamma = pj_param(par.params, "dazi").f * DEG_TO_RAD;
|
||||
proj_parm.tilt = 1;
|
||||
proj_parm.cg = cos(gamma);
|
||||
proj_parm.sg = sin(gamma);
|
||||
proj_parm.cw = cos(omega);
|
||||
proj_parm.sw = sin(omega);
|
||||
setup(par, proj_parm);
|
||||
}
|
||||
|
||||
}} // namespace detail::nsper
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Near-sided perspective projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- h=
|
||||
\par Example
|
||||
\image html ex_nsper.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct nsper_spheroid : public detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline nsper_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::nsper::setup_nsper(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Tilted perspective projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Azimuthal
|
||||
- Spheroid
|
||||
- tilt= azi= h=
|
||||
\par Example
|
||||
\image html ex_tpers.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct tpers_spheroid : public detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline tpers_spheroid(const Parameters& par) : detail::nsper::base_nsper_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::nsper::setup_tpers(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class nsper_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<nsper_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class tpers_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<tpers_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void nsper_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("nsper", new nsper_entry<Geographic, Cartesian, Parameters>);
|
||||
factory.add_to_factory("tpers", new tpers_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_NSPER_HPP
|
||||
|
||||
196
include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp
Normal file
196
include/boost/geometry/extensions/gis/projections/proj/nzmg.hpp
Normal file
@@ -0,0 +1,196 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace nzmg{
|
||||
static const double EPSLN = 1e-10;
|
||||
static const double SEC5_TO_RAD = 0.4848136811095359935899141023;
|
||||
static const double RAD_TO_SEC5 = 2.062648062470963551564733573;
|
||||
static const int Nbf = 5;
|
||||
static const int Ntpsi = 9;
|
||||
static const int Ntphi = 8;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static COMPLEX
|
||||
bf[] = {
|
||||
{.7557853228, 0.0},
|
||||
{.249204646, .003371507},
|
||||
{-.001541739, .041058560},
|
||||
{-.10162907, .01727609},
|
||||
{-.26623489, -.36249218},
|
||||
{-.6870983, -1.1651967} };
|
||||
static double
|
||||
tphi[] = { 1.5627014243, .5185406398, -.03333098, -.1052906, -.0368594,
|
||||
.007317, .01220, .00394, -.0013 },
|
||||
tpsi[] = { .6399175073, -.1358797613, .063294409, -.02526853, .0117879,
|
||||
-.0055161, .0026906, -.001333, .00067, -.00034 };
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_nzmg_ellipsoid : public base_t_fi<base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
|
||||
inline base_nzmg_ellipsoid(const Parameters& par)
|
||||
: base_t_fi<base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
COMPLEX p;
|
||||
double *C;
|
||||
int i;
|
||||
|
||||
lp_lat = (lp_lat - this->m_par.phi0) * RAD_TO_SEC5;
|
||||
for (p.r = *(C = tpsi + (i = Ntpsi)); i ; --i)
|
||||
p.r = *--C + lp_lat * p.r;
|
||||
p.r *= lp_lat;
|
||||
p.i = lp_lon;
|
||||
p = pj_zpoly1(p, bf, Nbf);
|
||||
xy_x = p.i;
|
||||
xy_y = p.r;
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
int nn, i;
|
||||
COMPLEX p, f, fp, dp;
|
||||
double den, *C;
|
||||
|
||||
p.r = xy_y;
|
||||
p.i = xy_x;
|
||||
for (nn = 20; nn ;--nn) {
|
||||
f = pj_zpolyd1(p, bf, Nbf, &fp);
|
||||
f.r -= xy_y;
|
||||
f.i -= xy_x;
|
||||
den = fp.r * fp.r + fp.i * fp.i;
|
||||
p.r += dp.r = -(f.r * fp.r + f.i * fp.i) / den;
|
||||
p.i += dp.i = -(f.i * fp.r - f.r * fp.i) / den;
|
||||
if ((fabs(dp.r) + fabs(dp.i)) <= EPSLN)
|
||||
break;
|
||||
}
|
||||
if (nn) {
|
||||
lp_lon = p.i;
|
||||
for (lp_lat = *(C = tphi + (i = Ntphi)); i ; --i)
|
||||
lp_lat = *--C + p.r * lp_lat;
|
||||
lp_lat = this->m_par.phi0 + p.r * lp_lat * SEC5_TO_RAD;
|
||||
} else
|
||||
lp_lon = lp_lat = HUGE_VAL;
|
||||
}
|
||||
};
|
||||
|
||||
// New Zealand Map Grid
|
||||
template <typename Parameters>
|
||||
void setup_nzmg(Parameters& par)
|
||||
{
|
||||
/* force to International major axis */
|
||||
par.ra = 1. / (par.a = 6378388.0);
|
||||
par.lam0 = DEG_TO_RAD * 173.;
|
||||
par.phi0 = DEG_TO_RAD * -41.;
|
||||
par.x0 = 2510000.;
|
||||
par.y0 = 6023150.;
|
||||
// par.inv = e_inverse;
|
||||
// par.fwd = e_forward;
|
||||
}
|
||||
|
||||
}} // namespace detail::nzmg
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief New Zealand Map Grid projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- fixed Earth
|
||||
\par Example
|
||||
\image html ex_nzmg.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct nzmg_ellipsoid : public detail::nzmg::base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline nzmg_ellipsoid(const Parameters& par) : detail::nzmg::base_nzmg_ellipsoid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::nzmg::setup_nzmg(this->m_par);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class nzmg_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<nzmg_ellipsoid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void nzmg_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("nzmg", new nzmg_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_NZMG_HPP
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/shared_ptr.hpp>
|
||||
#include <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters> class factory;
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace ob_tran{
|
||||
static const double TOL = 1e-10;
|
||||
|
||||
template <typename Geographic, typename Cartesian>
|
||||
struct par_ob_tran
|
||||
{
|
||||
boost::shared_ptr<projection<Geographic, Cartesian> > link;
|
||||
double lamp;
|
||||
double cphip, sphip;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_ob_tran_oblique : public base_t_fi<base_ob_tran_oblique<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_ob_tran<Geographic, Cartesian> m_proj_parm;
|
||||
|
||||
inline base_ob_tran_oblique(const Parameters& par)
|
||||
: base_t_fi<base_ob_tran_oblique<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double coslam, sinphi, cosphi;
|
||||
|
||||
|
||||
|
||||
coslam = cos(lp_lon);
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
lp_lon = adjlon(aatan2(cosphi * sin(lp_lon), this->m_proj_parm.sphip * cosphi * coslam +
|
||||
this->m_proj_parm.cphip * sinphi) + this->m_proj_parm.lamp);
|
||||
lp_lat = aasin(this->m_proj_parm.sphip * sinphi - this->m_proj_parm.cphip * cosphi * coslam);
|
||||
m_proj_parm.link->fwd(lp_lon, lp_lat, xy_x, xy_y);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double coslam, sinphi, cosphi;
|
||||
|
||||
m_proj_parm.link->inv(xy_x, xy_y, lp_lon, lp_lat);
|
||||
if (lp_lon != HUGE_VAL) {
|
||||
coslam = cos(lp_lon -= this->m_proj_parm.lamp);
|
||||
sinphi = sin(lp_lat);
|
||||
cosphi = cos(lp_lat);
|
||||
lp_lat = aasin(this->m_proj_parm.sphip * sinphi + this->m_proj_parm.cphip * cosphi * coslam);
|
||||
lp_lon = aatan2(cosphi * sin(lp_lon), this->m_proj_parm.sphip * cosphi * coslam -
|
||||
this->m_proj_parm.cphip * sinphi);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_ob_tran_transverse : public base_t_fi<base_ob_tran_transverse<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_ob_tran<Geographic, Cartesian> m_proj_parm;
|
||||
|
||||
inline base_ob_tran_transverse(const Parameters& par)
|
||||
: base_t_fi<base_ob_tran_transverse<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
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);
|
||||
lp_lat = aasin(- cosphi * coslam);
|
||||
m_proj_parm.link->fwd(lp_lon, lp_lat, xy_x, xy_y);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double cosphi, t;
|
||||
|
||||
m_proj_parm.link->inv(xy_x, xy_y, lp_lon, lp_lat);
|
||||
if (lp_lon != HUGE_VAL) {
|
||||
cosphi = cos(lp_lat);
|
||||
t = lp_lon - this->m_proj_parm.lamp;
|
||||
lp_lon = aatan2(cosphi * sin(t), - sin(lp_lat));
|
||||
lp_lat = aasin(cosphi * cos(t));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// General Oblique Transformation
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
double setup_ob_tran(Parameters& par, par_ob_tran<Geographic, Cartesian>& proj_parm, bool create = true)
|
||||
{
|
||||
int i;
|
||||
double phip;
|
||||
|
||||
|
||||
Parameters pj;
|
||||
/* copy existing header into new */
|
||||
par.es = 0.;
|
||||
/* force to spherical */
|
||||
pj.params = par.params;
|
||||
pj.over = par.over;
|
||||
pj.geoc = par.geoc;
|
||||
pj.a = par.a;
|
||||
pj.es = par.es;
|
||||
pj.ra = par.ra;
|
||||
pj.lam0 = par.lam0;
|
||||
pj.phi0 = par.phi0;
|
||||
pj.x0 = par.x0;
|
||||
pj.y0 = par.y0;
|
||||
pj.k0 = par.k0;
|
||||
/* 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<Geographic, Cartesian, Parameters> fac;
|
||||
if (create)
|
||||
{
|
||||
proj_parm.link.reset(fac.create_new(pj));
|
||||
if (! proj_parm.link.get()) throw proj_exception(-26);
|
||||
}
|
||||
if (pj_param(par.params, "to_alpha").i) {
|
||||
double lamc, phic, alpha;
|
||||
lamc = pj_param(par.params, "ro_lon_c").f;
|
||||
phic = pj_param(par.params, "ro_lat_c").f;
|
||||
alpha = pj_param(par.params, "ro_alpha").f;
|
||||
/*
|
||||
if (fabs(phic) <= TOL ||
|
||||
fabs(fabs(phic) - HALFPI) <= TOL ||
|
||||
fabs(fabs(alpha) - HALFPI) <= TOL)
|
||||
*/
|
||||
if (fabs(fabs(phic) - HALFPI) <= TOL)
|
||||
throw proj_exception(-32);
|
||||
proj_parm.lamp = lamc + aatan2(-cos(alpha), -sin(alpha) * sin(phic));
|
||||
phip = aasin(cos(phic) * sin(alpha));
|
||||
} else if (pj_param(par.params, "to_lat_p").i) { /* specified new pole */
|
||||
proj_parm.lamp = pj_param(par.params, "ro_lon_p").f;
|
||||
phip = pj_param(par.params, "ro_lat_p").f;
|
||||
} else { /* specified new "equator" points */
|
||||
double lam1, lam2, phi1, phi2, con;
|
||||
lam1 = pj_param(par.params, "ro_lon_1").f;
|
||||
phi1 = pj_param(par.params, "ro_lat_1").f;
|
||||
lam2 = pj_param(par.params, "ro_lon_2").f;
|
||||
phi2 = pj_param(par.params, "ro_lat_2").f;
|
||||
if (fabs(phi1 - phi2) <= TOL ||
|
||||
(con = fabs(phi1)) <= TOL ||
|
||||
fabs(con - HALFPI) <= TOL ||
|
||||
fabs(fabs(phi2) - HALFPI) <= TOL) throw proj_exception(-33);
|
||||
proj_parm.lamp = atan2(cos(phi1) * sin(phi2) * cos(lam1) -
|
||||
sin(phi1) * cos(phi2) * cos(lam2),
|
||||
sin(phi1) * cos(phi2) * sin(lam2) -
|
||||
cos(phi1) * sin(phi2) * sin(lam1));
|
||||
phip = atan(-cos(proj_parm.lamp - lam1) / tan(phi1));
|
||||
}
|
||||
if (fabs(phip) > TOL) { /* oblique */
|
||||
proj_parm.cphip = cos(phip);
|
||||
proj_parm.sphip = sin(phip);
|
||||
// par.fwd = o_forward;
|
||||
// par.inv = pj.inv ? o_inverse : 0;
|
||||
} else { /* transverse */
|
||||
// par.fwd = t_forward;
|
||||
// par.inv = pj.inv ? t_inverse : 0;
|
||||
}
|
||||
boost::ignore_unused_variable_warning(i);
|
||||
// return phip to choose model
|
||||
return phip;
|
||||
}
|
||||
|
||||
}} // namespace detail::ob_tran
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief General Oblique Transformation projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- o_proj= plus parameters for projection
|
||||
- o_lat_p= o_lon_p= (new pole) or
|
||||
- o_alpha= o_lon_c= o_lat_c= or
|
||||
- o_lon_1= o_lat_1= o_lon_2= o_lat_2=
|
||||
\par Example
|
||||
\image html ex_ob_tran.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct ob_tran_oblique : public detail::ob_tran::base_ob_tran_oblique<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline ob_tran_oblique(const Parameters& par) : detail::ob_tran::base_ob_tran_oblique<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief General Oblique Transformation projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Miscellaneous
|
||||
- Spheroid
|
||||
- o_proj= plus parameters for projection
|
||||
- o_lat_p= o_lon_p= (new pole) or
|
||||
- o_alpha= o_lon_c= o_lat_c= or
|
||||
- o_lon_1= o_lat_1= o_lon_2= o_lat_2=
|
||||
\par Example
|
||||
\image html ex_ob_tran.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct ob_tran_transverse : public detail::ob_tran::base_ob_tran_transverse<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline ob_tran_transverse(const Parameters& par) : detail::ob_tran::base_ob_tran_transverse<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::ob_tran::setup_ob_tran(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class ob_tran_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
detail::ob_tran::par_ob_tran<Geographic, Cartesian> proj_parm;
|
||||
Parameters p = par;
|
||||
double phip = setup_ob_tran(p, proj_parm, false);
|
||||
if (fabs(phip) > detail::ob_tran::TOL)
|
||||
return new base_v_fi<ob_tran_oblique<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
else
|
||||
return new base_v_fi<ob_tran_transverse<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void ob_tran_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("ob_tran", new ob_tran_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_OB_TRAN_HPP
|
||||
|
||||
189
include/boost/geometry/extensions/gis/projections/proj/ocea.hpp
Normal file
189
include/boost/geometry/extensions/gis/projections/proj/ocea.hpp
Normal file
@@ -0,0 +1,189 @@
|
||||
#ifndef BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
|
||||
#define BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
|
||||
|
||||
// Generic Geometry Library - projections (based on PROJ4)
|
||||
// This file is automatically generated. DO NOT EDIT.
|
||||
|
||||
// Copyright Barend Gehrels (1995-2009), Geodan Holding B.V. Amsterdam, the Netherlands.
|
||||
// Copyright Bruno Lalande (2008-2009)
|
||||
// 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 Geometry Library by Barend Gehrels (Geodan, Amsterdam)
|
||||
|
||||
// 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 <boost/math/special_functions/hypot.hpp>
|
||||
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_static.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/base_dynamic.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/projects.hpp>
|
||||
#include <boost/geometry/extensions/gis/projections/impl/factory_entry.hpp>
|
||||
|
||||
namespace boost { namespace geometry { namespace projection
|
||||
{
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace ocea{
|
||||
|
||||
struct par_ocea
|
||||
{
|
||||
double rok;
|
||||
double rtk;
|
||||
double sinphi;
|
||||
double cosphi;
|
||||
double singam;
|
||||
double cosgam;
|
||||
};
|
||||
|
||||
// template class, using CRTP to implement forward/inverse
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
struct base_ocea_spheroid : public base_t_fi<base_ocea_spheroid<Geographic, Cartesian, Parameters>,
|
||||
Geographic, Cartesian, Parameters>
|
||||
{
|
||||
|
||||
typedef double geographic_type;
|
||||
typedef double cartesian_type;
|
||||
|
||||
par_ocea m_proj_parm;
|
||||
|
||||
inline base_ocea_spheroid(const Parameters& par)
|
||||
: base_t_fi<base_ocea_spheroid<Geographic, Cartesian, Parameters>,
|
||||
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
|
||||
{
|
||||
double t;
|
||||
|
||||
xy_y = sin(lp_lon);
|
||||
/*
|
||||
xy_x = atan2((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) , cos(lp_lon));
|
||||
*/
|
||||
t = cos(lp_lon);
|
||||
xy_x = atan((tan(lp_lat) * this->m_proj_parm.cosphi + this->m_proj_parm.sinphi * xy_y) / t);
|
||||
if (t < 0.)
|
||||
xy_x += PI;
|
||||
xy_x *= this->m_proj_parm.rtk;
|
||||
xy_y = this->m_proj_parm.rok * (this->m_proj_parm.sinphi * sin(lp_lat) - this->m_proj_parm.cosphi * cos(lp_lat) * xy_y);
|
||||
}
|
||||
|
||||
inline void inv(cartesian_type& xy_x, cartesian_type& xy_y, geographic_type& lp_lon, geographic_type& lp_lat) const
|
||||
{
|
||||
double t, s;
|
||||
|
||||
xy_y /= this->m_proj_parm.rok;
|
||||
xy_x /= this->m_proj_parm.rtk;
|
||||
t = sqrt(1. - xy_y * xy_y);
|
||||
lp_lat = asin(xy_y * this->m_proj_parm.sinphi + t * this->m_proj_parm.cosphi * (s = sin(xy_x)));
|
||||
lp_lon = atan2(t * this->m_proj_parm.sinphi * s - xy_y * this->m_proj_parm.cosphi,
|
||||
t * cos(xy_x));
|
||||
}
|
||||
};
|
||||
|
||||
// Oblique Cylindrical Equal Area
|
||||
template <typename Parameters>
|
||||
void setup_ocea(Parameters& par, par_ocea& proj_parm)
|
||||
{
|
||||
double phi_0=0.0, phi_1, phi_2, lam_1, lam_2, lonz, alpha;
|
||||
proj_parm.rok = par.a / par.k0;
|
||||
proj_parm.rtk = par.a * par.k0;
|
||||
if ( pj_param(par.params, "talpha").i) {
|
||||
alpha = pj_param(par.params, "ralpha").f;
|
||||
lonz = pj_param(par.params, "rlonc").f;
|
||||
proj_parm.singam = atan(-cos(alpha)/(-sin(phi_0) * sin(alpha))) + lonz;
|
||||
proj_parm.sinphi = asin(cos(phi_0) * sin(alpha));
|
||||
} else {
|
||||
phi_1 = pj_param(par.params, "rlat_1").f;
|
||||
phi_2 = pj_param(par.params, "rlat_2").f;
|
||||
lam_1 = pj_param(par.params, "rlon_1").f;
|
||||
lam_2 = pj_param(par.params, "rlon_2").f;
|
||||
proj_parm.singam = atan2(cos(phi_1) * sin(phi_2) * cos(lam_1) -
|
||||
sin(phi_1) * cos(phi_2) * cos(lam_2),
|
||||
sin(phi_1) * cos(phi_2) * sin(lam_2) -
|
||||
cos(phi_1) * sin(phi_2) * sin(lam_1) );
|
||||
proj_parm.sinphi = atan(-cos(proj_parm.singam - lam_1) / tan(phi_1));
|
||||
}
|
||||
par.lam0 = proj_parm.singam + HALFPI;
|
||||
proj_parm.cosphi = cos(proj_parm.sinphi);
|
||||
proj_parm.sinphi = sin(proj_parm.sinphi);
|
||||
proj_parm.cosgam = cos(proj_parm.singam);
|
||||
proj_parm.singam = sin(proj_parm.singam);
|
||||
// par.inv = s_inverse;
|
||||
// par.fwd = s_forward;
|
||||
par.es = 0.;
|
||||
}
|
||||
|
||||
}} // namespace detail::ocea
|
||||
#endif // doxygen
|
||||
|
||||
/*!
|
||||
\brief Oblique Cylindrical Equal Area projection
|
||||
\ingroup projections
|
||||
\tparam Geographic latlong point type
|
||||
\tparam Cartesian xy point type
|
||||
\tparam Parameters parameter type
|
||||
\par Projection characteristics
|
||||
- Cylindrical
|
||||
- Sph lonc= alpha= or
|
||||
- lat_1= lat_2= lon_1= lon_2=
|
||||
\par Example
|
||||
\image html ex_ocea.gif
|
||||
*/
|
||||
template <typename Geographic, typename Cartesian, typename Parameters = parameters>
|
||||
struct ocea_spheroid : public detail::ocea::base_ocea_spheroid<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
inline ocea_spheroid(const Parameters& par) : detail::ocea::base_ocea_spheroid<Geographic, Cartesian, Parameters>(par)
|
||||
{
|
||||
detail::ocea::setup_ocea(this->m_par, this->m_proj_parm);
|
||||
}
|
||||
};
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// Factory entry(s)
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
class ocea_entry : public detail::factory_entry<Geographic, Cartesian, Parameters>
|
||||
{
|
||||
public :
|
||||
virtual projection<Geographic, Cartesian>* create_new(const Parameters& par) const
|
||||
{
|
||||
return new base_v_fi<ocea_spheroid<Geographic, Cartesian, Parameters>, Geographic, Cartesian, Parameters>(par);
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Geographic, typename Cartesian, typename Parameters>
|
||||
inline void ocea_init(detail::base_factory<Geographic, Cartesian, Parameters>& factory)
|
||||
{
|
||||
factory.add_to_factory("ocea", new ocea_entry<Geographic, Cartesian, Parameters>);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
#endif // doxygen
|
||||
|
||||
}}} // namespace boost::geometry::projection
|
||||
|
||||
#endif // BOOST_GEOMETRY_PROJECTIONS_OCEA_HPP
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user