Home

Awesome

<img src="https://docs.geodesk.com/img/github-header.png">

GeoDesk is a fast and storage-efficient geospatial database for OpenStreetMap data. Also available for Python and for Java.

Why GeoDesk?

Get Started

Requirements

Build & Link

If your project uses CMake, add this to your CMakeLists.txt:

include(FetchContent)
FetchContent_Declare(geodesk GIT_REPOSITORY 
    https://github.com/clarisma/libgeodesk.git)
FetchContent_MakeAvailable(geodesk)

target_link_libraries(my_program geodesk)

Alternatively, build GeoDesk explicitly:

git clone https://github.com/clarisma/libgeodesk.git
cd libgeodesk
mkdir build
cd build
cmake ..
cmake --build .

Create a GOL

Create a Geographic Object Library based on any .osm.pbf file, using the GOL Tool (Requires Java 16+).

For example:

gol build switzerland switzerland-latest.osm.pbf

Example Application

Find all the pubs in Zurich (Switzerland) and print their names:

#include <geodesk/geodesk.h>

using namespace geodesk;

int main(int argc, char* argv[])
{
    // Open switzerland.gol
    Features features("switzerland");      

    // Get the feature that represents the area of the city of Zurich
    Feature zurich = features(
        "a[boundary=administrative][admin_level=8]"
        "[name:en=Zurich]").one();

    // Define a set that contains nodes and areas that are pubs
    Features pubs = features("na[amenity=pub]");

    // Iterate through the pubs that are contained 
    // in the area of Zurich and print their names
    for (Feature pub: pubs.within(zurich)
    {
        std::cout << pub["name"] << std::endl;
    }
}

More Examples

Find all movie theaters within 500 meters from a given point:

Features movieTheaters = features("na[amenity=cinema]")
    .maxMetersFromLonLat(500, myLon, myLat);

Remember, OSM uses British English for its terminology.

Discover the bus routes that traverse a given street:

for (Relation route: street.parents("[route=bus]"))
{
    std::cout << route["ref"] 
        << " from " << route["from"] 
        << " to " << route["to"] << std::endl;
}

Count the number of entrances of a building:

int numberOfEntrances = building.nodes("[entrance]").count();

Documentation

Related Repositories


OpenStreetMap is a trademark of the OpenStreetMap Foundation, and is used with their permission. GeoDesk is not endorsed by or affiliated with the OpenStreetMap Foundation.