Code Monkey home page Code Monkey logo

graphhopperrouting's Introduction

GraphHopperRouting

๐Ÿ—บ The GraphHopper Routing API wrapped in an easy-to-use Swift framework.

The Routing API is part of the GraphHopper Directions API. Routing is the process of finding the 'best' path(s) between two or more points, where best depends on the vehicle and use case. With our API you have a fast and solid way to find this best path.

Installation

Use CocoaPods to install the framework. Add this to your Podfile:

pod 'GraphHopperRouting'

Then run the following command:

$ pod install

In order to use the framework, you'll also need a GraphHopper Access Token. You can either set your access token in the Info.plist (Key is GraphHopperAccessToken) or pass it as an argument to the initializer of the Routing class.

Example

Basics

Setup the Routing class

import CoreLocation
import GraphHopperRouting

// use this
let routing = Routing(accessToken: "YOUR ACCESS TOKEN")
// or if you have set your access token in the Info.plist
let routing = Routing()

Route options

Specify multiple points for which the route should be calculated.

let points = [
    CLLocationCoordinate2D(latitude: 52.545669, longitude: 13.359375),
    CLLocationCoordinate2D(latitude: 52.543164, longitude: 13.399887)
]

Configure the route options

let options = RouteOptions(points)
options.elevation = true
options.instructions = true
options.locale = "de-DE"
options.vehicle = .foot
options.optimize = true

Flexible route options

Flexible route options are used to specify flexible features when querying the GraphHopper Routing API.

let options = FlexibleRouteOptions()
options.weighting = .shortest
options.algorithm = .dijkstrabi

Routing request

Make the async request by calling the calculate(_:completionHandler) method and passing the options.

let task = routing.calculate(options, completionHandler: { (paths, error) in
    paths?.forEach({ path in
        print(path.time)
        print(path.distance)
        print(path.descend)
        print(path.ascend)
        path.points.forEach({ point in
        	print(point)
        })
    })
})

More information

For more information, consider reading the official documentation to learn more about the options and the result.

License

This project is released under the MIT license.

About

The GraphHopper Routing Swift Framework is crafted with โค๏ธ by @rmnblm and @iphilgood during the Bachelor thesis at HSR University of Applied Sciences in Rapperswil.

graphhopperrouting's People

Contributors

iphilgood avatar rmnblm avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

hobbesthetige

graphhopperrouting's Issues

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.