geodex

package
v0.0.0-...-b6406c2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidGUID

func IsValidGUID(val string) bool

IsValidGUID returns true if the value might be a valid fort GUID

Types

type BOQCell

type BOQCell struct {
	Stops []*BOQStop `json:"stops"`
}

BOQCell are the values from the outer dict that BookOfQuests returns

type BOQDB

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

BOQDB is a read-only wrapper for a Book Of Quests stops JSON.

func NewBOQDB

func NewBOQDB(files []string, output chan *BOQCell, cancel chan bool) (db *BOQDB, err error)

NewBOQDB returns a ready-to-use BOQDB object

func (*BOQDB) Run

func (db *BOQDB) Run() (err error)

Run parses all files

type BOQGeometry

type BOQGeometry struct {
	Type        string    `json:"type"`
	Coordinates []float64 `json:"coordinates"`
}

BOQGeometry always is a Point with Lat/Lon here

type BOQStop

type BOQStop struct {
	Name      string      `json:"name"`
	IsPortal  bool        `json:"portal"`
	IsGym     bool        `json:"gym"`
	IsStop    bool        `json:"stop"`
	Timestamp int64       `json:"ts"`
	S2Level20 string      `json:"s2l20"`
	Location  BOQGeometry `json:"loc"`
}

BOQStop has name and location for POIs

type DiskDB

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

DiskDB stores fort info like names

func NewDiskDB

func NewDiskDB(basePath *string) (db *DiskDB)

NewDiskDB returns a ready-to-use DiskDB object

func (*DiskDB) Drop

func (db *DiskDB) Drop() error

Drop deletes the whole db

func (*DiskDB) GetFort

func (db *DiskDB) GetFort(GUID string) (f *Fort, err error)

GetFort returns the fort's info from the db

func (*DiskDB) MergeFort

func (db *DiskDB) MergeFort(f *Fort) (err error)

MergeFort copies new values to an existing fort, or created a fort if it doesn't exist

func (*DiskDB) SaveFort

func (db *DiskDB) SaveFort(f *Fort) (err error)

SaveFort saves the fort's info in the db

type Fort

type Fort struct {
	GUID      *string  `json:"guid"` // mandatory
	Latitude  float64  `json:"latitude"`
	Longitude float64  `json:"longitude"`
	Name      *string  `json:"name,omitempty"` // optional
	Type      FortType `json:"type"`
}

Fort is the data structure for our tile38 table

func (*Fort) GetName

func (f *Fort) GetName() string

GetName returns the fort's name if set, "<Type>:<GUID>" string otherwise

func (*Fort) Location

func (f *Fort) Location() *pogo.Location

Location returns the fort's position as a Location object

func (*Fort) ToString

func (f *Fort) ToString() string

ToString returns all the fort's fields in a string

type FortType

type FortType int

FortType says if a fort is a portal, gym, or pokestop

const (
	FortTypePortal FortType = iota
	FortTypeGym
	FortTypeStop
)

yup

func (FortType) ToString

func (t FortType) ToString() (s string)

ToString returns the fort type in human-readable form

type GeoDex

type GeoDex struct {
	Disk *DiskDB
	Tile *TDB
}

GeoDex is the wrapper that should be used when using an already initialized DB

func NewGeoDex

func NewGeoDex(ddbBasePath, tdbHostname, tdbPassword string) (gd *GeoDex, err error)

NewGeoDex connects to Tile38 DB and sets up diskv ready to supply fort info

func (*GeoDex) LookupFortNear

func (gd *GeoDex) LookupFortNear(point pogo.Location, radiusM float64) (f *Fort, err error)

LookupFortNear get the nearest fort within the radius and resolves its name

type Gym

type Gym struct {
	GUID      *string `db:"gym_id"`
	Latitude  float64 `db:"latitude"`
	Longitude float64 `db:"longitude"`
	Name      *string `db:"name"`
}

Gym matches MAD's gym table joined with gymdetails

func (*Gym) ToFort

func (p *Gym) ToFort() *Fort

ToFort returns a Fort for TDB

func (*Gym) ToString

func (p *Gym) ToString() string

ToString returns human-readable gym info

type MADGymScanner

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

MADGymScanner reads gyms from MAD

func (*MADGymScanner) Close

func (m *MADGymScanner) Close()

Close closes the scanner

func (*MADGymScanner) Next

func (m *MADGymScanner) Next() bool

Next prepares to read the next row

func (*MADGymScanner) ScanGym

func (m *MADGymScanner) ScanGym() (f Gym, err error)

ScanGym returns the next row as a Pokestop

type MADPokestopScanner

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

MADPokestopScanner reads pokestops from MAD

func (*MADPokestopScanner) Close

func (m *MADPokestopScanner) Close()

Close closes the scanner

func (*MADPokestopScanner) Next

func (m *MADPokestopScanner) Next() bool

Next prepares to read the next row

func (*MADPokestopScanner) ScanPokestop

func (m *MADPokestopScanner) ScanPokestop() (f Pokestop, err error)

ScanPokestop returns the next row as a Pokestop

type Pokestop

type Pokestop struct {
	GUID      *string `db:"pokestop_id"`
	Latitude  float64 `db:"latitude"`
	Longitude float64 `db:"longitude"`
	Name      *string `db:"name"`
}

Pokestop matches MAD's pokestop table

func (*Pokestop) ToFort

func (p *Pokestop) ToFort() *Fort

ToFort returns a Fort for TDB

func (*Pokestop) ToString

func (p *Pokestop) ToString() string

ToString returns human-readable pokestop info

type SQLDB

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

SQLDB connects to MAD's MariaDB to get pokestops and gyms

func NewSQLDB

func NewSQLDB(hostname, database, username, password string) (db *SQLDB, err error)

NewSQLDB returns a usable MAD db object

func (*SQLDB) Close

func (sdb *SQLDB) Close()

Close closes the database connection

func (*SQLDB) GetGymName

func (sdb *SQLDB) GetGymName(GUID string) (name string, err error)

GetGymName gets the gym's name from MAD's DB

func (*SQLDB) GetPokestopName

func (sdb *SQLDB) GetPokestopName(GUID string) (name string, err error)

GetPokestopName gets the pokestop's name from MAD's DB

func (*SQLDB) GetVersion

func (sdb *SQLDB) GetVersion() (version string, err error)

GetVersion gets the mysql server version

func (*SQLDB) NewMADGymScanner

func (sdb *SQLDB) NewMADGymScanner() (m *MADGymScanner, err error)

NewMADGymScanner sets up the scanner

func (*SQLDB) NewMADPokestopScanner

func (sdb *SQLDB) NewMADPokestopScanner() (m *MADPokestopScanner, err error)

NewMADPokestopScanner sets up the scanner

type TDB

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

TDB is the silphtelescope geodex connection

func NewTDB

func NewTDB(hostname, password string) (db *TDB, err error)

NewTDB returns a usable silpht db object

func (*TDB) Close

func (tdb *TDB) Close()

Close closes the database connection

func (*TDB) Drop

func (tdb *TDB) Drop() (err error)

Drop deletes the whole fort database

func (*TDB) GetNearestFort

func (tdb *TDB) GetNearestFort(point pogo.Location, radiusM float64) (f *Fort, err error)

GetNearestFort looks in the given radius (in meters) around the point for the nearest Fort

func (*TDB) InsertFort

func (tdb *TDB) InsertFort(f *Fort) (err error)

InsertFort adds the fort to the db

Jump to

Keyboard shortcuts

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