1 #ifndef OSMIUM_GEOM_PROJECTION_HPP 2 #define OSMIUM_GEOM_PROJECTION_HPP 51 #ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 52 # include <proj_api.h> 54 # define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 55 # include <proj_api.h> 56 # undef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 79 std::unique_ptr<void, ProjCRSDeleter>
m_crs;
83 explicit CRS(
const char* crs) :
90 explicit CRS(
const std::string& crs) :
94 explicit CRS(
int epsg) :
95 CRS(
std::string{
"+init=epsg:"} + std::to_string(epsg)) {
101 projPJ
get()
const noexcept {
106 return pj_is_latlong(m_crs.get()) != 0;
110 return pj_is_geocent(m_crs.get()) != 0;
127 const int result = pj_transform(src.
get(), dest.
get(), 1, 1, &c.
x, &c.
y,
nullptr);
158 m_proj_string(proj_string),
159 m_crs_user(proj_string) {
164 m_proj_string(proj_string),
165 m_crs_user(proj_string) {
170 m_proj_string(
std::string{
"+init=epsg:"} + std::to_string(epsg)),
181 if (m_epsg == 4326) {
185 if (m_epsg == 3857) {
187 detail::lat_to_y(location.
lat())};
205 return m_proj_string;
214 #endif // OSMIUM_GEOM_PROJECTION_HPP double y
Definition: coordinates.hpp:51
projPJ get() const noexcept
Definition: projection.hpp:101
#define OSMIUM_DEPRECATED
Definition: compatibility.hpp:51
double lon() const
Definition: location.hpp:396
std::string proj_string() const
Definition: projection.hpp:204
bool is_latlong() const noexcept
Definition: projection.hpp:105
Definition: projection.hpp:73
double lat() const
Definition: location.hpp:415
Definition: location.hpp:551
CRS(int epsg)
Definition: projection.hpp:94
bool is_geocent() const noexcept
Definition: projection.hpp:109
Projection(int epsg)
Definition: projection.hpp:168
CRS(const std::string &crs)
Definition: projection.hpp:90
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
constexpr double deg_to_rad(double degree) noexcept
Convert angle from degrees to radians.
Definition: util.hpp:62
std::string m_proj_string
Definition: projection.hpp:150
Definition: coordinates.hpp:48
CRS m_crs_user
Definition: projection.hpp:152
std::unique_ptr< void, ProjCRSDeleter > m_crs
Definition: projection.hpp:79
CRS(const char *crs)
Definition: projection.hpp:83
Definition: projection.hpp:147
Definition: location.hpp:271
int m_epsg
Definition: projection.hpp:149
void operator()(void *crs)
Definition: projection.hpp:74
Definition: projection.hpp:71
Projection(const std::string &proj_string)
Definition: projection.hpp:156
Projection(const char *proj_string)
Definition: projection.hpp:162
int epsg() const noexcept
Definition: projection.hpp:200
OSMIUM_DEPRECATED Coordinates transform(const CRS &src, const CRS &dest, Coordinates c)
Definition: projection.hpp:126
double x
Definition: coordinates.hpp:50
Coordinates operator()(osmium::Location location) const
Definition: projection.hpp:180
constexpr double rad_to_deg(double radians) noexcept
Convert angle from radians to degrees.
Definition: util.hpp:67