atlas

package
v0.0.0-...-9d57a4f Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

atlas package provides a store that interacts with the database to retrieve geo location information.

Index

Constants

This section is empty.

Variables

View Source
var ErrGeoLocationNotFound = errors.New("geo location not found")

Functions

This section is empty.

Types

type Atlas

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

Atlas represents a geographic location service.

func New

func New() (*Atlas, error)

New creates a new instance of Atlas and initializes the database connection. It returns a pointer to Atlas and an error if the connection fails.

func (*Atlas) GetGeoLocationByPostalCode

func (a *Atlas) GetGeoLocationByPostalCode(ctx context.Context, postalCode string) (*GeoLocation, error)

GetGeoLocationByPostalCode retrieves a GeoLocation struct from the database by postal code. If the GeoLocation is not found, returns ErrGeoLocationNotFound.

type GeoLocation

type GeoLocation struct {
	// ISO country code abbreviation
	CountryCode string `json:"country_code,omitempty"`

	// Postal code or zip code
	PostalCode string `json:"postal_code,omitempty"`

	// Name of the place
	PlaceName string `json:"place_name,omitempty"`

	// First-order administrative division (state, province, region, etc.)
	AdminName1 string `json:"admin_name_1,omitempty"`

	// Code for the first-order administrative division
	AdminCode1 string `json:"admin_code_1,omitempty"`

	// Second-order administrative division (county, district, etc.)
	AdminName2 string `json:"admin_name_2,omitempty"`

	// Code for the second-order administrative division
	AdminCode2 string `json:"admin_code_2,omitempty"`

	// Third-order administrative division (township, municipality, etc.)
	AdminName3 string `json:"admin_name_3,omitempty"`

	// Code for the third-order administrative division
	AdminCode3 string `json:"admin_code_3,omitempty"`

	// Latitude of the location
	Latitude float64 `json:"latitude,omitempty"`

	// Longitude of the location
	Longitude float64 `json:"longitude,omitempty"`

	// Accuracy of the location in meters
	Accuracy int `json:"accuracy,omitempty"`
}

GeoLocation represents a geographical location details

Jump to

Keyboard shortcuts

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