Can now accept location

This commit is contained in:
2026-03-08 15:38:28 +08:00
parent 912f9fd0ad
commit 33a7c04e09
12 changed files with 286 additions and 148 deletions

View File

@@ -1,40 +1,52 @@
package kmb
import (
i18n "github.com/tgckpg/golifehk/i18n"
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 `json:"stop"`
Latitude float64 `json:"lat,string"`
Longtitude float64 `json:"long,string"`
Name_en string `json:"name_en"`
Name_tc string `json:"name_tc"`
Name_sc string `json:"name_sc"`
BusStopId string
// Routes[ Route ][ Direction ]
Routes *[] *RouteStop
// Routes[ Route ][ Direction ]
Routes *[]*RouteStop
i18n.Generics
i18n.Generics
query.GeoLocation
}
type BusStops struct {
Type string `json:"type"`
Version string `json:"version"`
DateCreated string `json:"generated_timestamp"`
BusStops [] *BusStop `json:"data"`
type BusStopsJson struct {
Type string `json:"type"`
Version string `json:"version"`
DateCreated string `json:"generated_timestamp"`
BusStops []*BusStopJson `json:"data"`
}
func ( this *BusStop ) Reload() {
i18n_Name := map[string] string{}
i18n_Name["en"] = this.Name_en
i18n_Name["zh-Hant"] = this.Name_tc
searchData := [] *string{}
searchData = append( searchData, &this.Name_en )
searchData = append( searchData, &this.Name_tc )
this.Name = &i18n_Name
this.Key = &this.BusStopId
this.SearchData = &searchData
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
}