geolocation

package module
v0.0.0-...-79345d6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MIT Imports: 13 Imported by: 1

README

geo-location

Build Status | codecov | Go Report Card | GoDoc

A simple location finder.

Support for

Search Reverse

If i miss something or you have something interesting, please be part of this project. Let me know! My contact is at the end.

Dependecy Management

Dep

Project dependencies are managed using Dep. Read more about Dep.

  • Install dependencies: dep ensure
  • Update dependencies: dep ensure -update
Go
go get github.com/joaosoft/geo-location

Usage

This examples are available in the project at geo-location/examples

var geo, _ = geolocation.NewGeoLocation()

func main() {

	// document create
	fmt.Println(":: SEARCH BY: STREET")
	search("rua particular de monsanto")

	fmt.Println(":: REVERSE BY: LATITUDE/LONGITUDE")
	reverse(41.1718238, -8.6186277)
}

func search(street string) {
	result, err := geo.NewSearch().
		Street(street).
		Search()

	if err != nil {
		panic(err)
	} else {
		fmt.Printf("\nsearch by street %s: %s\n", street, result[0].Name)
	}
}

func reverse(latitude float64, longitude float64) {
	result, err := geo.NewSearch().
		Latitude(latitude).
		Longitude(longitude).
		Reverse()

	if err != nil {
		panic(err)
	} else {
		fmt.Printf("\nsearch by latitude %f, longitude: %f: %s\n", latitude, longitude, result[0].Name)
	}
}

Known issues

Follow me at

Facebook: https://www.facebook.com/joaosoft

LinkedIn: https://www.linkedin.com/in/jo%C3%A3o-ribeiro-b2775438/

If you have something to add, please let me know joaosoft@gmail.com

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Road          string `json:"road"`
	Neighbourhood string `json:"neighbourhood"`
	Suburb        string `json:"suburb"`
	City          string `json:"city"`
	StateDistrict string `json:"state_district"`
	State         string `json:"state"`
	Postcode      string `json:"postcode"`
	Country       string `json:"country"`
	CountryCode2A string `json:"country_code_2a"`
	CountryCode3A string `json:"county_code_3a"`
}

type AppConfig

type AppConfig struct {
	GeoLocation *GeoLocationConfig `json:"geo-location"`
}

AppConfig ...

type GeoLocation

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

func NewGeoLocation

func NewGeoLocation(options ...GeoLocationOption) (*GeoLocation, error)

NewGeoLocation ...

func (*GeoLocation) NewSearch

func (e *GeoLocation) NewSearch() *SearchService

func (*GeoLocation) Reconfigure

func (g *GeoLocation) Reconfigure(options ...GeoLocationOption)

Reconfigure ...

type GeoLocationConfig

type GeoLocationConfig struct {
	Log struct {
		Level string `json:"level"`
	} `json:"log"`
	Api string `json:"api"`
}

GeoLocationConfig ...

type GeoLocationOption

type GeoLocationOption func(g *GeoLocation)

GeoLocationOption ...

func WithConfiguration

func WithConfiguration(config *GeoLocationConfig) GeoLocationOption

WithConfiguration ...

func WithLogLevel

func WithLogLevel(level logger.Level) GeoLocationOption

WithLogLevel ...

func WithLogger

func WithLogger(logger logger.ILogger) GeoLocationOption

WithLogger ...

func WithManager

func WithManager(mgr *manager.Manager) GeoLocationOption

WithManager ...

type Place

type Place struct {
	Latitude    float64  `json:"latitude"`
	Longitude   float64  `json:"longitude"`
	Name        string   `json:"name"`
	Category    string   `json:"category"`
	Type        string   `json:"type"`
	Importance  float64  `json:"importance"`
	PlaceRank   int      `json:"place_rank"`
	BoundingBox []string `json:"bounding_box"`
	AddressType string   `json:"address_type,omitempty"`
	Address     *Address `json:"address,omitempty"`
}

type SearchResponse

type SearchResponse []*Place

type SearchService

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

func (*SearchService) Body

func (e *SearchService) Body(body []byte) *SearchService

func (*SearchService) City

func (e *SearchService) City(city string) *SearchService

func (*SearchService) Country

func (e *SearchService) Country(country string) *SearchService

func (*SearchService) CountryCodes

func (e *SearchService) CountryCodes(countryCodes ...string) *SearchService

func (*SearchService) Latitude

func (e *SearchService) Latitude(latitude float64) *SearchService

func (*SearchService) Limit

func (e *SearchService) Limit(limit int) *SearchService

func (*SearchService) Longitude

func (e *SearchService) Longitude(longitude float64) *SearchService

func (*SearchService) PostalCode

func (e *SearchService) PostalCode(postalCode string) *SearchService

func (*SearchService) Query

func (e *SearchService) Query(query string) *SearchService

func (*SearchService) Reverse

func (e *SearchService) Reverse() (SearchResponse, error)

func (*SearchService) Search

func (e *SearchService) Search() (SearchResponse, error)

func (*SearchService) State

func (e *SearchService) State(state string) *SearchService

func (*SearchService) Street

func (e *SearchService) Street(street string) *SearchService

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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