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

@@ -9,19 +9,39 @@ import (
func Query(q query.QueryMessage) query.IQueryResult {
lang := q.Lang
message := q.Text
var qo *query.QueryObject
var err error
var routeStops *[]query.ISearchable
qr := QueryResult{Lang: lang}
routeStops, err := getRouteStops()
busStops, err := readBusStopsData()
if err != nil {
qr.Error = err
goto qrReturn
}
qo, err = query.MatchKeys(strings.ToUpper(message), routeStops)
routeStops, err = getRouteStops(busStops)
if err != nil {
qr.Error = err
goto qrReturn
}
if q.Text != "" {
qo, err = query.MatchKeys(strings.ToUpper(q.Text), routeStops)
} else if q.Location != nil {
bList := []query.ISearchable{}
for _, b := range *busStops {
bList = append(bList, b)
}
qo, err = query.MatchNearest(*q.Location, &bList, 100, 3)
}
qo.Message = &q
if err != nil {
qr.Error = err
goto qrReturn