penguin/golifehk

@golifehk bot in Telegram

datasources/kmb/BusStop.go

raw ยท 1128 bytes

package kmb

import (
	i18n "github.com/tgckpg/golifehk/i18n"
	query "github.com/tgckpg/golifehk/query"
)

type BusStopJson struct {
	BusStopId string  `json:"stop"`
	Latitude  float64 `json:"lat,string"`
	Longitude float64 `json:"long,string"`
	Name_en   string  `json:"name_en"`
	Name_tc   string  `json:"name_tc"`
	Name_sc   string  `json:"name_sc"`
}

type BusStop struct {
	BusStopId string

	// Routes[ Route ][ Direction ]
	Routes *[]*RouteStop

	i18n.Generics
	query.GeoLocation
}

type BusStopsJson struct {
	Type        string         `json:"type"`
	Version     string         `json:"version"`
	DateCreated string         `json:"generated_timestamp"`
	BusStops    []*BusStopJson `json:"data"`
}

func (b BusStop) Register(registers map[string]struct{}) bool {
	if _, ok := registers[b.BusStopId]; ok {
		return false
	}
	registers[b.BusStopId] = struct{}{}
	return true
}

func (this *BusStop) Reload() {
	searchData := []*string{}
	searchData = append(searchData, &this.BusStopId)

	for _, v := range *this.Name {
		searchData = append(searchData, &v)
	}

	this.Key = &this.BusStopId
	this.SearchData = &searchData
}