Skip to content

📦 Go SDK for OSRM (Open Source Routing Machine), which combines sophisticated routing algorithms with the open and free road network data of the OpenStreetMap (OSM) project

Notifications You must be signed in to change notification settings

openmarketplaceengine/go-osrm

Repository files navigation

Go client library for OSRM

GoDoc Go Report Card

Description

Currently supported OSRM APIs are:

Not implemeted yet:

Usage

Sample usage:

package main

import (
	"context"
	"log"
	"time"

	osrm "github.com/openmarketplaceengine/go-osrm"
	geo "github.com/paulmach/go.geo"
)

func main() {
	client := osrm.NewFromURL("https://router.project-osrm.org")

	ctx, cancelFn := context.WithTimeout(context.Background(), time.Second)
	defer cancelFn()

	resp, err := client.Route(ctx, osrm.RouteRequest{
		Profile: "car",
		Coordinates: osrm.NewGeometryFromPointSet(geo.PointSet{
			{-73.980020, 40.751739},
			{-73.962662, 40.794156},
		}),
		Steps:       osrm.StepsTrue,
		Annotations: osrm.AnnotationsTrue,
		Overview:    osrm.OverviewFalse,
		Geometries:  osrm.GeometriesPolyline6,
	})
	if err != nil {
		log.Fatalf("route failed: %v", err)
	}

	log.Printf("routes are: %+v", resp.Routes)
}

About

📦 Go SDK for OSRM (Open Source Routing Machine), which combines sophisticated routing algorithms with the open and free road network data of the OpenStreetMap (OSM) project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published