geo

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EarthDistance

func EarthDistance(lat1, lng1, lat2, lng2 float64) float64

func FormatCityName

func FormatCityName(city string) string

func FormatCountryName

func FormatCountryName(country string) string

func FormatProvinceName

func FormatProvinceName(province string) string

func GetCountryCodeMap

func GetCountryCodeMap() map[string]string

func GetCountryMap

func GetCountryMap() map[string]Country

func TestCases

func TestCases()

Types

type City

type City struct {
	Location
	Code string `json:"code"`
}

type Country

type Country struct {
	Location
	CountryName string              `json:"countryName,omitempty"`
	CountryCode string              `json:"countryCode,omitempty"`
	Provinces   map[string]Province `json:"provinces"`
	Cities      map[string]City     `json:"cities"`
}

type GeoInfo

type GeoInfo struct {
	/*
		search from ip2region
	*/
	Country  string `json:"country"`
	Region   string `json:"region"`
	Province string `json:"province"`
	City     string `json:"city"`
	ISP      string `json:"isp"`
	/*
		lookup from our countries.json
	*/
	Timezone    string  `json:"timezone"`
	Lng         float64 `json:"lng"`
	Lat         float64 `json:"lat"`
	CountryName string  `json:"countryName"`
	CountryCode string  `json:"countryCode"`
}

func NewGeoFromIp

func NewGeoFromIp(ip string) (geo *GeoInfo)

func NewGeoFromLocation

func NewGeoFromLocation(country, province, city string) *GeoInfo

func (*GeoInfo) CalcDistance

func (geo *GeoInfo) CalcDistance(geo1 *GeoInfo) float64

func (*GeoInfo) GetZoneOffset

func (geo *GeoInfo) GetZoneOffset() (ret int)

func (*GeoInfo) LookupGeoInfo

func (geo *GeoInfo) LookupGeoInfo() bool

type Location

type Location struct {
	Coords   []float64 `json:"coords"`
	Timezone string    `json:"timezone,omitempty"`
}

type Province

type Province struct {
	Location
	Code   string   `json:"code,omitempty"`
	Cities []string `json:"cities"`
}

Jump to

Keyboard shortcuts

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