- getStoreListByCoordinates会先检测第一个坐标会否返回有用店铺,以过滤不支持的城市,相应GetCityCoordinateList返回的第一个坐标是城市中心点
This commit is contained in:
@@ -63,7 +63,14 @@ func GetDistrictCoordinateList(districtCode int, radius, gridWith int) (coordLis
|
||||
if err == nil {
|
||||
if len(districts) > 0 {
|
||||
roundLng, roundLat := GetRound4Radius(districts[0].Lng, districts[0].Lat, gridWith)
|
||||
coordList = getDistrictCoordinateList(districts, radius, gridWith, roundLng, roundLat)
|
||||
tmpCoordList := getDistrictCoordinateList(districts, radius, gridWith, roundLng, roundLat)
|
||||
if len(tmpCoordList) > 0 {
|
||||
coordList = append(coordList, &Coordinate{
|
||||
Lng: districts[0].Lng,
|
||||
Lat: districts[0].Lat,
|
||||
})
|
||||
coordList = append(coordList, tmpCoordList...)
|
||||
}
|
||||
}
|
||||
}
|
||||
return coordList
|
||||
@@ -74,16 +81,32 @@ func GetCityCoordinateList(cityCode int, radius, gridWith int) (coordList []*Coo
|
||||
if err == nil {
|
||||
if len(districts) > 0 {
|
||||
roundLng, roundLat := GetRound4Radius(districts[0].Lng, districts[0].Lat, gridWith)
|
||||
coordList = getDistrictCoordinateList(districts, radius, gridWith, roundLng, roundLat)
|
||||
tmpCoordList := getDistrictCoordinateList(districts, radius, gridWith, roundLng, roundLat)
|
||||
if len(tmpCoordList) > 0 {
|
||||
coordList = append(coordList, &Coordinate{
|
||||
Lng: districts[0].Lng,
|
||||
Lat: districts[0].Lat,
|
||||
})
|
||||
coordList = append(coordList, tmpCoordList...)
|
||||
}
|
||||
}
|
||||
}
|
||||
return coordList
|
||||
}
|
||||
|
||||
func needCheckTown(place *autonavi.District) bool {
|
||||
for _, v := range []string{"街道", "镇"} {
|
||||
if strings.Index(place.Name, v) >= 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func getDistrictCoordinateList(districtList []*autonavi.District, radius, gridWith, roundLng, roundLat int) (coordList []*Coordinate) {
|
||||
coordMap := make(map[int64]*Coordinate)
|
||||
for _, v := range districtList {
|
||||
if (v.Level <= 3 || (v.Level == 4 && strings.Index(v.Name, "街道") >= 0)) && v.Lng != 0 && v.Lat != 0 {
|
||||
if (v.Level <= 3 || (v.Level == 4 && needCheckTown(v))) && v.Lng != 0 && v.Lat != 0 {
|
||||
realRadius := radius
|
||||
if v.Level == 2 {
|
||||
realRadius = 2 * radius
|
||||
|
||||
Reference in New Issue
Block a user