server

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Distance

func Distance(aLat, aLon, bLat, bLon float64) float64

Distance calculated in km between the given lat/lon coordinates.

func HSin

func HSin(theta float64) float64

HSin haversin(θ) function

Types

type ErrorMessage added in v0.3.0

type ErrorMessage struct {
	Message string
}

type Geo

type Geo struct {
	CountryCode string
	PostalCode  string
	PlaceName   string
	AdminName1  string
	AdminCode1  string
	AdminName2  string
	AdminCode2  string
	AdminName3  string
	AdminCode3  string
	Latitude    float64
	Longitude   float64
}

Geo is the model used to store the geo-information.

type GeoDistance added in v0.3.3

type GeoDistance struct {
	Geo
	Distance float64
}

type GeoSource

type GeoSource interface {
	GetGeoData() ([]Geo, error)
}

GeoSource provides a method to load the Geo data from somewhere.

type Neargo

type Neargo struct {
	// Source can be set to any implementation of GeoSource which defines where
	// the data comes from.
	Source GeoSource
	// contains filtered or unexported fields
}

Neargo is a simple webservice which provides a proximity search by postal code.

func (*Neargo) Init

func (n *Neargo) Init() error

Init has to be called before serving it. It loads and initializes the data using the provided Source.

func (Neargo) ServeHTTP

func (n Neargo) ServeHTTP(res http.ResponseWriter, req *http.Request)

ServeHTTP responds with the found geo data as json based on the passed query parameters.

Jump to

Keyboard shortcuts

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