location

package
v0.0.0-...-2a68481 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2022 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Location

type Location struct {
	common.Timestamp
	ID              uint    `gorm:"primaryKey"`
	Latitude        float64 `gorm:"column:latitude"`
	Longitude       float64 `gorm:"column:longitude"`
	Name            string  `gorm:"column:name"`
	Description     string  `gorm:"column:description"`
	FullDescription string  `gorm:"column:fullDescription"`
	Altitude        int     `gorm:"column:altitude"`
	Country         string  `gorm:"column:contry"`
	CountryPart     string  `gorm:"column:contryPart"`
	City            string  `gorm:"column:city"`
}

Location describes a location... Just like the name intends

func (*Location) CoordinatesFromRadius

func (l *Location) CoordinatesFromRadius(radius int64) (float64, float64, float64, float64)

CoordinatesFromRadius returns coordinates in the radius arround the location `radius` is in meters returns (lat-north, lat-south, long-west, long-east)

func (Location) TableName

func (Location) TableName() string

type LocationService

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

func (*LocationService) CreateLocation

func (l *LocationService) CreateLocation(location *Location) (uint, error)

CreateLocation Create location

func (*LocationService) GetAllLocations

func (l *LocationService) GetAllLocations() ([]Location, error)

GetAllLocations get all locations

func (*LocationService) GetClosestLocation

func (l *LocationService) GetClosestLocation(latitude float64, longitude float64, treshold int) ([]Location, error)

func (*LocationService) GetLoactionExistance

func (l *LocationService) GetLoactionExistance(ids []uint) (bool, error)

func (*LocationService) GetLocationById

func (l *LocationService) GetLocationById(id uint) (*Location, error)

GetLocationById gets a single location by ID

func (*LocationService) UpdateLocation

func (l *LocationService) UpdateLocation(location *Location) error

UpdateLocation Update location

type Locations

type Locations []Location

func (Locations) OrderByLocation

func (l Locations) OrderByLocation(latitude float64, longitude float64)

type Reader

type Reader interface {
	// GetAllLocations get all locations
	GetAllLocations() ([]Location, error)
	// GetLocationById gets a single location by ID
	GetLocationById(id uint) (*Location, error)
	GetLoactionExistance(ids []uint) (bool, error)
}

type Repo

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

func NewRepository

func NewRepository(context *gorm.DB) (*Repo, error)

NewRepository creates a new repository

func (*Repo) CreateLocation

func (l *Repo) CreateLocation(location *Location) (uint, error)

func (*Repo) GetAllLocations

func (l *Repo) GetAllLocations() ([]Location, error)

func (*Repo) GetClosestLocation

func (l *Repo) GetClosestLocation(latitude_north float64, latitude_south float64, longitude_west float64, longitude_east float64) ([]Location, error)

func (*Repo) GetLoactionExistance

func (l *Repo) GetLoactionExistance(ids []uint) (bool, error)

func (*Repo) GetLocationById

func (l *Repo) GetLocationById(id uint) (*Location, error)

func (*Repo) UpdateLocation

func (l *Repo) UpdateLocation(location *Location) error

type Repository

type Repository interface {
	Reader
	Writer
	GetClosestLocation(latitude_north float64, latitude_south float64, longitude_east float64, longitude_west float64) ([]Location, error)
}

type Service

type Service interface {
	Reader
	Writer
	GetClosestLocation(latitude float64, longitude float64, treshold int) ([]Location, error)
}

func NewService

func NewService(repo Repository) Service

type Writer

type Writer interface {
	// CreateLocation Create location
	CreateLocation(location *Location) (uint, error)
	// UpdateLocation Update location
	UpdateLocation(location *Location) error
}

Jump to

Keyboard shortcuts

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