routeplanner

package module
v0.0.0-...-bd18ed3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 7 Imported by: 0

README

RoutePlanner Backend

This repository contains code that powers the routeplanner app. The app suggests circular walks or runs based on start location and desired distance.

Motivation

I have been interested in making an app like that for a while since I started running more frequently. I normally use google maps and add multiple destinations to work out a distance of a potential run, but that is rather cumbersome way of doing it. Secondly I thought it would be a good challenge since I would have to figure out how to get suitable map data and then design an algorithm that would produce decent quality circular paths.

Implementation

This service is designed to be used as serverless function hosted on google cloud platform with an API gateway to it.

Map data is retrieved from a public OSM server and this is also the slowest step in the process as it can take a few seconds to download the data. The data is then parsed and routes are calculated. Best 25 results are returned encoded as JSON.

Result

The quality of routes does vary a lot. Some areas especially urban areas with a lot of suitable roads and paths can produce great results. Other times the routes might be hard to navigate due to large number of turns or the fact that they keep going back on themselves. This variability was the main reason to return best 25 as it makes it more likely that some of the suggestions are suitable.

Example of good suggestions:

good routes in knole park

Back in high school I took part in the Knole run which is a 10km cross country run made up of two loops.

Last thing to note is while I tried to eliminate the possibility of roads and paths that are not suitable for pedestrians being used, they still will likely appear sometimes as OSM data is not always complete or up to date in different parts of the world.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OSMToGraph

func OSMToGraph(res overpass.Response) (graph routing.Graph)

osmToGraph takes an overpass Responce object and returns a graph of nodes and edges between them without dead ends.

func RoutePlannerAPI

func RoutePlannerAPI(w http.ResponseWriter, r *http.Request)

Handler function that is invoked by GCP.

Types

type CoordPair

type CoordPair [2]float64

type Request

type Request struct {
	Lat      float64 `schema:"lat,required"`
	Lon      float64 `schema:"lon,required"`
	Distance float64 `schema:"distance,required"`
}

type Responce

type Responce []Route

type Route

type Route struct {
	Path     []CoordPair `json:"path"`
	Distance float64     `json:"distance"`
}

Directories

Path Synopsis
Package overpass provides functions to query a specified overpass api instance and unmarshal the JSON response.
Package overpass provides functions to query a specified overpass api instance and unmarshal the JSON response.
Package routing provides functions to navigate on and process graphs in the context of routeplanner project.
Package routing provides functions to navigate on and process graphs in the context of routeplanner project.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL