WGS84toCartesian - a simple header-only, single-file library to convert WGS84 positions (latitude/longitude) to/from Cartesian positions using Mercator projection for C++
WGS84toCartesian is a small and efficient library written in modern C++ library to convert WGS84 latitude/longitude positions to/from Cartesian positions using Mercator projection.
WGS84toCartesian is available as single-file, header-only library - just drop WGS84toCartesian.hpp into your project, #include "WGS84toCartesian.hpp"
, and compile your project with a modern C++ compiler (C++11 or newer).
This library is partially based on the work from Gerald I. Evenden on proj 4.3 released under public domain terms. See thirdparty/proj-4.3 for further details.
- Written in highly portable and high quality C++11
- Available as header-only, single-file distribution - just drop WGS84toCartesian.hpp into your project,
#include "WGS84toCartesian.hpp"
, and compile your project with a modern C++ compiler (C++11 or newer) - The positions are passed to and returned from the functions as
std::array
so that this library integrates well with other math libraries (e.g., Eigen). - Convert a given WGS84 position to a Cartesian position using a given WGS84 reference position with Mercator projection:
std::array<double, 2> cartesianPosition = wgs84::toCartesian({52.247041, 10.575830} /* reference position */, {52.248091, 10.57417} /* position to be converted */));
- Convert a given WGS84 position to a Cartesian position using a given WGS84 reference position with Mercator projection: Another example
- Approximate a given Cartesian position with a WGS84 position using a given WGS84 reference position with Mercator projection:
std::array<double, 2> approximatedWGS84Position = wgs84::fromCartesian({52.247041, 10.575830} /* reference position */, {-154.48, 441.75} /* position to be converted */);
- Approximate a given Cartesian position with a WGS84 position using a given WGS84 reference position with Mercator projection: Another example
No dependencies! All you need is a C++11-compliant compiler (we are testing with GCC 6.3.0 and MSVC 19.0.24215.1) as the project ships the following dependencies as part of the source distribution:
WGS84toCartesian is provided as header-only, single-file library as well - just drop WGS84toCartesian.hpp into your project, #include "WGS84toCartesian.hpp"
, and compile your project with a modern C++ compiler (C++11 or newer)
If your project is using WGS84toCartesian, just let us know :-)
We are happy to receive your PRs to accelerate libcluon's development; before contributing, please take a look at the Contribution Documents.