develop basic APIs / override reverse geolocation

This commit is contained in:
2025-02-12 01:12:13 +08:00
parent 1d27c6ee8a
commit 3e51ab8e3f
38 changed files with 1737 additions and 118 deletions

View File

@@ -0,0 +1,35 @@
package geo_json
import (
"fmt"
"testing"
)
func TestGen(t *testing.T) {
// 假设我们要查询的经纬度为乌鲁木齐
//lat := 43.792818
//lon := 87.617733
lat := 28.19409
lon := 112.982279
// 初始化时加载GeoJSON数据文件
cityRegions, err := LoadGeoJSONFileData(
"E:\\Go_WorkSpace\\schisandra-album-cloud-microservices\\app\\auth\\resources\\geo_json\\world.zh.json",
"E:\\Go_WorkSpace\\schisandra-album-cloud-microservices\\app\\auth\\resources\\geo_json\\china_province.json",
"E:\\Go_WorkSpace\\schisandra-album-cloud-microservices\\app\\auth\\resources\\geo_json\\china_city.json",
)
if err != nil {
fmt.Println("Error reading GeoJSON:", err)
return
}
// 获取城市名称
address, s, s2, err := GetAddress(lat, lon, cityRegions)
if err != nil {
fmt.Println("Error finding city:", err)
}
fmt.Println("Address:", address)
fmt.Println("Province:", s)
fmt.Println("City:", s2)
}