Giter Club home page Giter Club logo

geokit-go's Introduction

geokit-go

An assortment of geolocation related tools, all packaged in one easy to use kit. A direct port from http://github.com/MichaelSolati/geokit

Methods

Distance(start *LatLng, end *LatLng, unit *string)(float64, error)

Calculates the distance, in kilometers, between two coordinates.

start and end must be LatLng { Lat: 0, Lng: 0 }.

start := &geokit.LatLng{Lat: 41.3083, Lng: -72.9279};
end := &geokit.LatLng{Lat: -33.8688, Lng: 151.2093};

distance, _ := geokit.Distance(location1, location2, nil); // distance == 16082.811206563834

Hash(coordinates *LatLng, precision *int)(*string, error)

Generates Geohash of coordinates.

coordinates must be LatLng { Lat: 0, Lng: 0 }.

coordinates := &geokit.LatLng{Lat: 41.3083,  Lng: -72.9279};

hash, _ := geokit.Hash(coordinates, nil); // hash == 'drk4urzw2c'

DecodeHash(hash string) (*LatLng, error)

Decodes a Geohash into its Latitude and Longitude as a LatLng.

hash := 'r3gx2f77b';

coordinates, _ := geokit.DecodeHash(hash); // coordinates === &geokit.LatLng{Lat: -33.86881113052368,  Lng: 151.2093186378479}

ValidateCoordinates(coordinates *LatLng) (bool, error)

Validates coordinates and returns a boolean if valid, or throws an error if invalid.

coordinates must be LatLng { lat: 0, lng: 0 }.

coordinates := &geokit.LatLng{Lat: 41.3083,  Lng: -72.9279};

isValid, _ = geokit.ValidateCoordinates(coordinates); // true

ValidateHash(hash string) (bool, error)

Validates a Geohash and returns a boolean if valid, or throws an error if invalid.

hash := 'r3gx2f77b';

isValid = geokit.ValidateHash(hash); // true

geokit-go's People

Contributors

darmie avatar

Stargazers

 avatar

Watchers

 avatar

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.