使用腾讯地图,百度和高德不在使用

This commit is contained in:
邹宗楠
2024-07-31 11:09:07 +08:00
parent d6e1893671
commit 4cf9001c9a
20 changed files with 287 additions and 212 deletions

View File

@@ -1,10 +1,11 @@
package ditu
import (
"git.rosy.net.cn/baseapi/platformapi/tencent_map"
"git.rosy.net.cn/jx-callback/business/model/dao"
"math"
"strings"
"git.rosy.net.cn/baseapi/platformapi/autonavi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils"
"git.rosy.net.cn/jx-callback/globals/api"
@@ -76,12 +77,11 @@ func GetDistrictCoordinateList(districtCode int, radius, gridWith int) (coordLis
}
func GetCityCoordinateList(cityCode int, radius, gridWith int) (coordList []*Coordinate) {
//place, err := dao.GetPlaces(dao.GetDB(), []int{cityCode})
//if err != nil {
// return nil
//}
//level+1
districts, err := api.AutonaviAPI.GetDistricts(2, utils.Int2Str(cityCode))
place, err := dao.GetPlaces(dao.GetDB(), []int{cityCode})
if err != nil {
return nil
}
districts, err := api.TencentMapAPI.GetDistricts(2, utils.Int2Str(cityCode), int(place[0].Level+1))
if err == nil {
if len(districts) > 0 {
roundLng, roundLat := GetRound4Radius(districts[0].Lng, districts[0].Lat, gridWith)
@@ -98,7 +98,7 @@ func GetCityCoordinateList(cityCode int, radius, gridWith int) (coordList []*Coo
return coordList
}
func needCheckTown(place *autonavi.District) bool {
func needCheckTown(place *tencent_map.District) bool {
for _, v := range []string{"街道", "镇"} {
if strings.Index(place.Name, v) >= 0 {
return true
@@ -107,7 +107,7 @@ func needCheckTown(place *autonavi.District) bool {
return false
}
func getDistrictCoordinateList(districtList []*autonavi.District, radius, gridWith, roundLng, roundLat int) (coordList []*Coordinate) {
func getDistrictCoordinateList(districtList []*tencent_map.District, radius, gridWith, roundLng, roundLat int) (coordList []*Coordinate) {
coordMap := make(map[int64]*Coordinate)
for _, v := range districtList {
if (v.Level <= 3 || (v.Level == 4 && needCheckTown(v))) && v.Lng != 0 && v.Lat != 0 {
@@ -131,3 +131,29 @@ func getDistrictCoordinateList(districtList []*autonavi.District, radius, gridWi
}
return coordList
}
// 老版本
//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 && needCheckTown(v))) && v.Lng != 0 && v.Lat != 0 {
// realRadius := radius
// if v.Level == 2 {
// realRadius = 2 * radius
// } else if v.Level == 2 {
// realRadius = radius / 2
// }
// tmpCoordList := GetGridsFromCoordinate(v.Lng, v.Lat, realRadius, roundLng, roundLat)
// if v.Level <= 3 {
// tmpCoordList = append(tmpCoordList, getDistrictCoordinateList(v.Districts, radius, gridWith, roundLng, roundLat)...)
// }
// for _, coord := range tmpCoordList {
// coordMap[coord.GetMapKey()] = coord
// }
// }
// }
// for _, coord := range coordMap {
// coordList = append(coordList, coord)
// }
// return coordList
//}