Can now accept location
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user