87 lines
2.7 KiB
Go
87 lines
2.7 KiB
Go
package catalogs
|
||
|
||
import (
|
||
"encoding/json"
|
||
"os"
|
||
"path/filepath"
|
||
"sync"
|
||
)
|
||
|
||
var _ = json.RawMessage{}
|
||
var _ = sync.Mutex{}
|
||
var _ = os.ReadFile
|
||
var _ = filepath.Join
|
||
|
||
//
|
||
// 真实路口表 —— 用来填 AetherAIInitData.Intersections
|
||
// (元素类型 ClientTrafficIntersectionInitInfo)。
|
||
// ★★ 数据源(2026-09-28):补丁和工具/DUMPS/readable_world_dump_4229938_final.zip
|
||
// - 路口 id:04_WORLD_JSON/full_json/vfc_1286_e106_*.json → interInfos[].intersection
|
||
// (ZebraConnector.json 里**只有坐标没有 id**,以前就是查错了这份才误判"造不出来")
|
||
// - ZoneIndex:03_ZONEGRAPHS/vfc_1286_e108_*.json(车辆图,2246 zone / 14171 lane)
|
||
// 筛 tagNames 含 "Intersection" 的 zone(1020 个),按
|
||
// lanesBegin..lanesEnd 建「车道 → zone」映射,
|
||
// 再把路口的 connectedSegment(车道 handle,Handle == Index)投进去。
|
||
// 生成脚本产出 167 条(主城 181 个 interInfos 中 14 个的车道没落在 Intersection zone 内,已剔除)。
|
||
//
|
||
const (
|
||
IntersectionCatalog4229938_RelativePath string = "Drmk.Server/Drmk.App/data/intersections.csv"
|
||
IntersectionCatalog4229938_ProbeRelativePath string = "Drmk.Server/Drmk.App/data/intersections_probe.csv"
|
||
)
|
||
|
||
var (
|
||
IntersectionCatalog4229938_cacheLock sync.RWMutex
|
||
IntersectionCatalog4229938_cached = false
|
||
IntersectionCatalog4229938_entries []any
|
||
)
|
||
|
||
// LoadIntersectionCatalog4229938 loads catalog records from client config directory
|
||
func LoadIntersectionCatalog4229938(configDir string) ([]any, error) {
|
||
IntersectionCatalog4229938_cacheLock.RLock()
|
||
if IntersectionCatalog4229938_cached {
|
||
defer IntersectionCatalog4229938_cacheLock.RUnlock()
|
||
return IntersectionCatalog4229938_entries, nil
|
||
}
|
||
IntersectionCatalog4229938_cacheLock.RUnlock()
|
||
|
||
IntersectionCatalog4229938_cacheLock.Lock()
|
||
defer IntersectionCatalog4229938_cacheLock.Unlock()
|
||
if IntersectionCatalog4229938_cached { return IntersectionCatalog4229938_entries, nil }
|
||
|
||
filePath := filepath.Join(configDir, "IntersectionCatalog.json.json")
|
||
data, err := os.ReadFile(filePath)
|
||
if err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
var raw struct {
|
||
Records []json.RawMessage `json:"records"`
|
||
}
|
||
if err := json.Unmarshal(data, &raw); err != nil {
|
||
return nil, err
|
||
}
|
||
|
||
var result []any
|
||
for _, item := range raw.Records {
|
||
var m map[string]any
|
||
if err := json.Unmarshal(item, &m); err == nil {
|
||
result = append(result, m)
|
||
}
|
||
}
|
||
|
||
IntersectionCatalog4229938_entries = result
|
||
IntersectionCatalog4229938_cached = true
|
||
return result, nil
|
||
}
|
||
|
||
func IntersectionCatalog4229938_LoadFile(projectRelative string) []IntersectionRow {
|
||
// Catalog helper IntersectionCatalog4229938_LoadFile
|
||
return nil
|
||
}
|
||
|
||
type IntersectionRow struct {
|
||
InstanceId uint64 `json:"instanceId"`
|
||
ZoneIndex int32 `json:"zoneIndex"`
|
||
}
|
||
|