a
This commit is contained in:
@@ -436,7 +436,7 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl
|
|||||||
SELECT SQL_CALC_FOUND_ROWS *
|
SELECT SQL_CALC_FOUND_ROWS *
|
||||||
`
|
`
|
||||||
if distanceFlag {
|
if distanceFlag {
|
||||||
sql += `, ROUND(POWER((POWER(longitude-?,2))+(POWER(latitude-?,2)),1/2)) distance2`
|
sql += `, getDistance(?, ?, longitude, latitude) distance`
|
||||||
sqlParams = append(sqlParams, lng, lat)
|
sqlParams = append(sqlParams, lng, lat)
|
||||||
}
|
}
|
||||||
sql += `
|
sql += `
|
||||||
@@ -457,9 +457,9 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl
|
|||||||
}
|
}
|
||||||
if sortType != 0 {
|
if sortType != 0 {
|
||||||
if sortType == 1 {
|
if sortType == 1 {
|
||||||
sql += " ORDER BY distance2"
|
sql += " ORDER BY distance"
|
||||||
} else if sortType == -1 {
|
} else if sortType == -1 {
|
||||||
sql += " ORDER BY distance2 DESC"
|
sql += " ORDER BY distance DESC"
|
||||||
} else if sortType == 2 {
|
} else if sortType == 2 {
|
||||||
sql += " ORDER BY star_num"
|
sql += " ORDER BY star_num"
|
||||||
} else if sortType == -2 {
|
} else if sortType == -2 {
|
||||||
@@ -474,18 +474,18 @@ func GetStationInfoList(db *DaoDB, stationName string, cityCode int, lat, lng fl
|
|||||||
if err = GetRows(db, &stations, sql, sqlParams...); err == nil {
|
if err = GetRows(db, &stations, sql, sqlParams...); err == nil {
|
||||||
pagedInfo = &model.PagedInfo{
|
pagedInfo = &model.PagedInfo{
|
||||||
TotalCount: GetLastTotalRowCount(db),
|
TotalCount: GetLastTotalRowCount(db),
|
||||||
// Data: stations,
|
Data: stations,
|
||||||
}
|
}
|
||||||
for _, v := range stations {
|
// for _, v := range stations {
|
||||||
var distance float64
|
// var distance float64
|
||||||
if v.Longitude != 0 && v.Latitude != 0 {
|
// if v.Longitude != 0 && v.Latitude != 0 {
|
||||||
distance = jxutils.EarthDistance(lng, lat, v.Longitude, v.Latitude)
|
// distance = jxutils.EarthDistance(lng, lat, v.Longitude, v.Latitude)
|
||||||
} else {
|
// } else {
|
||||||
distance = 0
|
// distance = 0
|
||||||
}
|
// }
|
||||||
v.Distance = distance
|
// v.Distance = distance
|
||||||
}
|
// }
|
||||||
pagedInfo.Data = stations
|
// pagedInfo.Data = stations
|
||||||
}
|
}
|
||||||
return pagedInfo, err
|
return pagedInfo, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user