geo

package
v0.0.0-...-111d394 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2018 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LocateAll

func LocateAll(ctx context.Context, locater *Locater, unlocated []*models.GeoLoc) []error

LocateAll asynchronously locates all provided GeoLocs. And returns any errors that occur. An empty array on success.

Types

type GeoCache

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

GeoCache caches GeoLoc models retrieved from the database

func NewGeoCache

func NewGeoCache() *GeoCache

NewGeoCache constructs a new GeoCache object

func (GeoCache) Get

func (c GeoCache) Get(raw string) (*models.GeoLoc, error)

Get retrieves a GeoCache model with the provided raw value. This model will be populated with the raw and ID field only. An error is returned if one occurs, or nil on success.

func (GeoCache) InsertIfNew

func (c GeoCache) InsertIfNew(raw string) (*models.GeoLoc, error)

InsertIfNew inserts the GeoLoc model into the database if it does not exist. The ID of the model in the database will be set in the GeoLoc.ID field. An error is returned if one occurs, nil on success.

type Locater

type Locater struct{}

Locater uses the Google Maps API to determine exactly where new GeoLoc models are in the world

func NewLocater

func NewLocater() *Locater

NewLocater creates a new Locater instance

func (Locater) Locate

func (l Locater) Locate(ctx context.Context, loc *models.GeoLoc) error

Locate determines where a GeoLoc model resides on the map. Determining bounds and lat long. An error is returned if one occurs, or nil on success.

A context must be provided to manage the GAPI request's running.

If the GeoLoc provided is indicates the location is unknown, the method returns immediately.

func (Locater) LocateAsync

func (l Locater) LocateAsync(ctx context.Context, errs chan error,
	locs chan *models.GeoLoc, loc *models.GeoLoc)

LocateAsync wraps the Locate method with asynchronous logic. Passing errors through a provided channel, and recording finsihed work via a locs channel.

Jump to

Keyboard shortcuts

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