GithubHelp home page GithubHelp logo

isabella232 / geometry.hpp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mapbox/geometry.hpp

0.0 0.0 0.0 140 KB

C++ geometry types

License: ISC License

C++ 69.87% Makefile 1.51% CMake 17.76% Shell 10.86%

geometry.hpp's Introduction

geometry.hpp

badge Build Status

Provides header-only, generic C++ interfaces for geometry types, geometry collections, and features.

  • mapbox::geometry::point
  • mapbox::geometry::multi_point
  • mapbox::geometry::line_string
  • mapbox::geometry::multi_line_string
  • mapbox::geometry::polygon
  • mapbox::geometry::multi_polygon
  • mapbox::geometry::geometry_collection
  • mapbox::feature::feature (experimental)

Design

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.

Goals

  • Header-only
  • Fast compile
  • c++11/c++14 compatibility
  • No external dependencies for usage of core types (point, line_string, etc)
  • Minimal dependencies for usage of enclosing geometry type (mapbox::variant)
  • Easily adaptable to boost::geometry

Usage

Using a single type directly (requires no external dependencies):

#include <mapbox/geometry/point.hpp>
#include <iostream>

using mapbox::geometry::point;

int main() {
    point<double> pt(1.0,0.0);
    std::clog << "x: " << pt.x << " y: " << pt.y << "\n";
}

Creating a geometry collection (depends on https://github.com/mapbox/variant):

#include <mapbox/geometry/geometry.hpp>
#include <mapbox/variant.hpp>
#include <iostream>

using mapbox::geometry::geometry_collection;
using mapbox::geometry::geometry;
using mapbox::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;
    mapbox::util::apply_visitor(visitor,geom);
}

geometry.hpp's People

Contributors

artemp avatar brunoabinader avatar flippmoke avatar jfirebaugh avatar jmalanen avatar kkaefer avatar mapsam avatar mourner avatar nagineni avatar pozdnyakov avatar springmeyer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.