Input Geojson and utilize Dijkstra's formula to provide the best route between two sets of coordinates

Golang GeoJson Dijkstra

Golang GeoJson Dijkstra utilizes GeoJson Feature Collections to find the best the shortest route between two points.

Installation

Use go get.

go get github.com/pitchinnate/golangGeojsonDijkstra

Then import the validator package into your own code.

import "github.com/pitchinnate/golangGeojsonDijkstra"

Requirements

Must pass in valid GeoJson FeatureCollection that has a collection of GeoJson Feature's. Everything but Features that have a geometry.type equal to LineString are ignored. Also, currently it is required that all LineString features must only have two coordinates. This may be improved later.

Usage

Pass into coordinate arrays and a precision. Coordinate arrays should be in the following format [longitude, latitude] as that corresponds to [x,y]. Precision is how accurate it rounds the latitude and longitude coordinates to. So if you pass in a coordinate of -84.396535122 with a precision of 0.00001 it will round that off to -84.39654. This is important when connections between lines are made.

featureCollection.FindPath(Position, Position, precision)

Example

featureCollection := FeatureCollection{
    Type: "FeatureCollection",
    Features: []Feature{
        Feature{Type: "Feature", Geometry: Geometry{Type: "LineString", Coordinates: []Position{Position{-84.396535, 33.792487}, Position{-84.396535, 33.792578}}}},
        Feature{Type: "Feature", Geometry: Geometry{Type: "LineString", Coordinates: []Position{Position{-84.396536, 33.79281}, Position{-84.396535, 33.792578}}}},
        Feature{Type: "Feature", Geometry: Geometry{Type: "LineString", Coordinates: []Position{Position{-84.396536, 33.79281}, Position{-84.396536, 33.792908}}}},
        Feature{Type: "Feature", Geometry: Geometry{Type: "LineString", Coordinates: []Position{Position{-84.396863, 33.792908}, Position{-84.396536, 33.792908}}}},
        Feature{Type: "Feature", Geometry: Geometry{Type: "LineString", Coordinates: []Position{Position{-84.396537, 33.792996}, Position{-84.396536, 33.792908}}}},
        Feature{Type: "Feature", Geometry: Geometry{Type: "LineString", Coordinates: []Position{Position{-84.396213, 33.792908}, Position{-84.396536, 33.792908}}}},
    },
}
path, distance, err := featureCollection.FindPath(Position{-84.396863, 33.792908}, Position{-84.396535, 33.792578}, 0.00001)

// path should come back as an array of coordinates
// [[-84.39654,33.79258],[-84.39654,33.79281],[-84.39654,33.79291],[-84.39686,33.79291]]
// distance should come back as a float64 measure of how far you traveled (in meters)

License

Distributed under GNU GENERAL PUBLIC LICENSE, please see license file within the code for more details.

Owner
Nate
VP of Software Engineering @ Smartlink Ventures
Nate
Similar Resources

Takes a list of poker hands for two players in STDIN and scores them

Poker Hand Sorter Takes a list of poker hands for two players in STDIN and scores them. Returns the number of hands won by each player. Prerequisites

Jan 16, 2022

Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar

Collect stars by solving puzzles. Two puzzles will be made available on each day in the Advent calendar; the second puzzle is unlocked when you complete the first. Each puzzle grants one star.

Dec 6, 2021

The Webhooks Listener-Plugin library consists of two component libraries written in GoLang

The Webhooks Listener-Plugin library consists of two component libraries written in GoLang: WebHook Listener Libraries and Plugin (Event Consumer) Libraries.

Feb 3, 2022

DSV Parallel Processor takes input files and query specification via a spec file

DSV Parallel Processor Spec file DSV Parallel Processor takes input files and query specification via a spec file (conventionally named "spec.toml").

Oct 9, 2021

Works with HashiCorp HCL. Allows to append the input file with blocks and attributes from the template file

About hclmergetool Works with HashiCorp HCL. Allows to append the input file with blocks and attributes from the template file Installation Binary Rel

Feb 6, 2022

The best censorship API.

censor-api The best censorship API. Why choose this API? High quality. It could filter all sensitive words around the world. High performance. It coul

Nov 21, 2022

Best-effort CPU-local sharded values for Go

Best-effort CPU-local sharded values for Go

percpu Percpu is a Go package to support best-effort CPU-local sharded values. This package is something of an experiment. See Go issue #18802 for dis

Nov 9, 2022

Golang service boilerplate using best practices

go-boilerplate Golang service boilerplate using best practices. Responsibility: Register (CRUD) and Login Users with JWT. Dependencies Gin-Gonic Swagg

May 11, 2022

Fishfindr - An application that is being developed to help me figure out the best places to fish based on my catch history

fishfindr Fishfindr is an application that is being developed to help me figure out the best places to fish based on my catch history. The front-end p

Feb 10, 2022
A ocilloscope writen in GO. Supported serial input, portaudio input.

A ocilloscope writen in GO. Supported serial input, portaudio input.

Oct 23, 2021
Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data.

gountries Inspired by the countries gem for ruby. Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO

Dec 22, 2022
A collection of route planning algorithms for road networks.

route-planning A collection of route planning algorithms for road networks. This collection contains different route planning techniques from a lectur

Jan 29, 2022
Reads Sets and Deletes a key from Redis cache

Reads Sets and Deletes a key from Redis cache

Nov 2, 2021
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Dec 2, 2021
Jan 4, 2022
other glyph sets for high-dpi 1-bit monochrome

hd1b_other other glyph sets for high-dpi 1-bit monochrome Currently included glyph sets: Hangul (Korean): U+1100..U+11FF, U+3131..U+318E, U+AC00..U+D7

Aug 29, 2022
Script that sets your nzxt kraken temps based on cpu temps on linux

liquidctl-cpu-temp Script that monitors cpu temps and sets cpu cooler temps according to entered fan/pump curves. Only tested on NZXT kraken z63 requi

Nov 16, 2021
optwdl: Helpful word sets for solving Wordle puzzles

optwdl: Helpful word sets for solving Wordle puzzles. Wordle gives you 6 tries to identify a 5 letter word. I decided to look for sets of 5 words that

Jan 24, 2022
Day-1 is apart of my 6 days of Christmas challenge where i write in two new languages everyday, and make something weird out of it.

Day-1 is apart of my 6 days of Christmas challenge where i write in two new languages everyday, and make something weird out of it. today was a HTTP server written with PostGreSQL using Golang, R, and shell script read more

Dec 21, 2021