geobass

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

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

Go to latest
Published: Mar 3, 2019 License: MIT Imports: 5 Imported by: 0

README

geobass

Documentation Go Report Card Build Status Coverage Status Codacy Badge

Very simple db which handle geolocation points by accuracy

Getting started

go get github.com/saromanov/geobass

Examples

In this example, create new db with 11KM of accuracy. It means, that you can get points which is nearly of the stored point, within 11 km

package main

import (
	"fmt"

	"github.com/saromanov/geobass"
)

func main() {
	g := geobass.New(geobass.Range11KM)
	g.Set(geobass.Point{
		Latitude:  40.9887,
		Longitude: 28.7817,
	}, "data")
	fmt.Println(g.Get(geobass.Point{
		Latitude:  40.9858,
		Longitude: 28.7852,
	}))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accuracy

type Accuracy int32

Accuracy specifies accuracy of the distance

const (
	// Range11KM The first decimal place is worth up to 11.1 km
	// eg: 30.1, 50.2
	Range11KM Accuracy = 1 + iota

	// Range1KM The second decimal place is worth up to 1.1 km
	// eg: 30.16, 50.23
	Range1KM

	// Range110M The third decimal place is worth up to 110 m
	// eg: 30.167, 50.231
	Range110M

	// Range11M The fourth decimal place is worth up to 11 m
	// eg: 30.1672, 50.2311
	Range11M

	// Range1M The fifth decimal place is worth up to 1.1 m
	// eg: 30.16722, 50.23118
	Range1M

	// Range11CM The sixth decimal place is worth up to 0.11 m
	// eg: 30.167221, 50.231189
	Range11CM

	// Range11MM The seventh decimal place is worth up to 11 mm
	// eg: 30.1672217, 50.2311896
	Range11MM

	// Range1MM The eighth decimal place is worth up to 1.1 mm
	// eg: 30.16722175, 50.23118962
	Range1MM
)

type GeoBass

type GeoBass struct {
	// contains filtered or unexported fields
}

GeoBass defines app

func New

func New(precision Accuracy) *GeoBass

New provides initialization of the app

func (*GeoBass) Clear

func (c *GeoBass) Clear()

Clear provides removing of the all data

func (*GeoBass) Get

func (c *GeoBass) Get(p Point) (interface{}, error)

Get provides getting object by the point

func (*GeoBass) Set

func (c *GeoBass) Set(p Point, value interface{}) error

Set provides setting to the cache

type Point

type Point struct {
	Latitude  float64
	Longitude float64
}

Point defines point on store

Jump to

Keyboard shortcuts

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