Header-only C++17 library for geographic (lat/lng) geometry (no dependencies).
Provides utilities for distance, bearing, polygon area, point-in-polygon, and path proximity checks on Earth coordinates.
API inspired by Google Maps geometry utilities. Uses spherical Earth approximation (like Google Maps).
geo::spherical functions — distance, bearing, area, interpolationgeo::polygon functions — point-in-polygon, path proximity, distance to segments
- Lightweight and header-only (no dependencies)
- Simple API for common GPS/lat-lng calculations
- Suitable for backend, GIS, navigation and tracking systems
- If you need high-precision geodesic calculations on an ellipsoid
- If you need advanced spatial indexing (use S2 / CGAL instead)
include(FetchContent)
FetchContent_Declare(
GeoUtilsCpp
GIT_REPOSITORY https://github.com/gistrec/geo-utils-cpp.git
GIT_TAG v1.0.1
)
FetchContent_MakeAvailable(GeoUtilsCpp)
target_link_libraries(your_target PRIVATE geo::utils)vcpkg install geo-utils-cppThen in your CMakeLists.txt:
find_package(GeoUtilsCpp 1.0.1 REQUIRED)
target_link_libraries(your_target PRIVATE geo::utils)find_package(GeoUtilsCpp 1.0.1 REQUIRED)
target_link_libraries(your_target PRIVATE geo::utils)Copy the include/ directory into your project and add it to your include path.
For more details see docs/getting-started.md.
#include <iostream>
#include <geo/spherical.hpp>
int main() {
geo::LatLng newYork = { 40.7128, -74.0060 };
geo::LatLng london = { 51.5074, -0.1278 };
double distance = geo::distance_between(newYork, london);
double heading = geo::heading(newYork, london);
std::cout << "Distance: " << distance / 1000.0 << " km\n";
std::cout << "Heading: " << heading << " deg\n";
}See docs/api.md for the full API reference.
Please open an issue on GitHub
Licensed under the Apache License, Version 2.0. See LICENSE for details.