补全页显示高德找到的 POI 与类型,类别标出真机用过的

原先没映射出建议的行就是一片空白,可高德其实早就说了「这里是什么」——
「中国邮政 / 生活服务;邮局」「沙县小吃 / 餐饮服务;中餐厅」,
这种信息看着就能判断该填什么。现在多一列「高德参考」把它显示出来。

类别下拉带上中文,并标出哪几种是**真机确实用过**的:
ZCATEGORY_ 那列存的就是这些 MKPOICategory 枚举串,那 12 种导回 rond 一定认得,
其余是 MapKit 支持但你的设备还没用过的,写错只会显示不出类别、不会坏数据。
This commit is contained in:
tamakyi
2026-09-19 16:46:34 +08:00
parent 6c061a0548
commit 9c7e152361
3 changed files with 46 additions and 9 deletions
+27 -6
View File
@@ -20,8 +20,10 @@ import (
// fillupHint 是一次高德查询给出的建议(按地点 id 缓存在内存里,页面重载仍能看到)。
type fillupHint struct {
Act string
Cat string
Act string
Cat string
Type string // 高德给的原始类型(「餐饮服务;咖啡厅」),没映射上时给站长看
Poi string // 最近的 POI 名字,同样只作参考
}
var (
@@ -57,6 +59,8 @@ type FillupRow struct {
ActID int64 // 建议命中现有活动时的 id;0 表示得新建
CatHint string // 建议的类别
Source string // 建议从哪来
AmapType string // 高德给出的类型原文,供人工判断(可能没映射出建议)
AmapPoi string // 高德找到的最近 POI 名字
}
func (r FillupRow) Missing() string {
@@ -75,7 +79,7 @@ type FillupData struct {
Page
Rows []FillupRow
Activities []activityOption // 下拉选项
Categories []string // 类别下拉选项
Categories []fillupCategory // 类别下拉选项
Total int
WithHint int
}
@@ -149,6 +153,7 @@ func (s *Server) fillupRows(ctx context.Context, datasetID int64) ([]FillupRow,
if out[i].NoCat && h.Cat != "" {
out[i].CatHint = h.Cat
}
out[i].AmapType, out[i].AmapPoi = h.Type, h.Poi
}
}
sort.SliceStable(out, func(i, j int) bool {
@@ -212,8 +217,16 @@ func (s *Server) activityOptions(ctx context.Context, datasetID int64) ([]activi
return out, rows.Err()
}
// fillupCategory 是类别下拉的一项。Label 用中文,并标出这一种真机到底用过没有——
// ZCATEGORY_ 那列真机存的就是这些 MKPOICategory 枚举串,写错名字不会损坏数据,
// 但会显示不出类别,所以优先选「真机用过」的那几种。
type fillupCategory struct {
Value string
Label string
}
// fillupCategories 是类别下拉的选项:真机用过的 12 种在前,其余常见 MapKit 类别在后。
func fillupCategories() []string {
func fillupCategories() []fillupCategory {
known := []string{
"MKPOICategoryRestaurant", "MKPOICategoryStore", "MKPOICategoryPublicTransport",
"MKPOICategoryHotel", "MKPOICategoryLandmark", "MKPOICategoryFoodMarket",
@@ -228,7 +241,14 @@ func fillupCategories() []string {
"MKPOICategoryNationalPark", "MKPOICategoryAquarium", "MKPOICategoryAmusementPark",
"MKPOICategoryGasStation", "MKPOICategoryCarRental", "MKPOICategoryMarina",
}
return append(known, extra...)
out := make([]fillupCategory, 0, len(known)+len(extra))
for _, c := range known {
out = append(out, fillupCategory{c, poiName(c) + "(真机用过)"})
}
for _, c := range extra {
out = append(out, fillupCategory{c, poiName(c)})
}
return out
}
// adminFillupApply 执行补全。表单里每行两个字段:
@@ -411,9 +431,10 @@ func (s *Server) adminFillupAmap(w http.ResponseWriter, r *http.Request) {
if n >= fillupAmapBatch {
break
}
_, typ, _, ok := s.amapAround(ctx, row.Lat, row.Lon)
poi, typ, _, ok := s.amapAround(ctx, row.Lat, row.Lon)
var h fillupHint
if ok {
h.Type, h.Poi = typ, poi
h.Act = guessActivityFromAmapType(typ)
h.Cat = guessCategoryFromAmapType(typ)
if h.Act != "" || h.Cat != "" {