Provides header-only, generic C++ interfaces for geometry types, geometry collections, and features.
maplibre::geometry::point
maplibre::geometry::multi_point
maplibre::geometry::line_string
maplibre::geometry::multi_line_string
maplibre::geometry::polygon
maplibre::geometry::multi_polygon
maplibre::geometry::geometry_collection
maplibre::feature::feature
Dependency of MapLibre Native.
These types are designed to be easy to parse and serialize to GeoJSON.
They should also be a robust and high performance container for data processing and conversion.
- Header-only
- Fast compile
- C++20
- No external dependencies for usage of core types (point, line_string, etc)
- No dependencies for usage of enclosing
geometry
type - Easily adaptable to
boost::geometry
Using a single type directly:
#include <maplibre/geometry/point.hpp>
#include <iostream>
using maplibre::geometry::point;
int main() {
point<double> pt(1.0,0.0);
std::clog << "x: " << pt.x << " y: " << pt.y << "\n";
}
Creating a geometry collection:
#include <maplibre/geometry/geometry.hpp>
#include <variant>
#include <iostream>
using maplibre::geometry::geometry_collection;
using maplibre::geometry::geometry;
using maplibre::geometry::point;
using point_type = point<double>;
struct printer
{
printer() {}
void operator()(point_type const& pt) const
{
std::clog << "x: " << pt.x << " y: " << pt.y << "\n";
}
template <typename T>
void operator()(T const& g) const
{
std::clog << "encountered non-point geometry\n";
}
};
int main() {
geometry_collection<double> gc;
gc.emplace_back(point_type(1.0,0.0));
geometry<double> const& geom = gc.at(0);
printer visitor;
std::visit(visitor, geom);
}