inspect-geometry-district.py 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. import json, collections, re
  2. p='.scratch/cockpit-real-data-wayfinding/verify/artifacts/t67/geom-none.json'
  3. with open(p,encoding='utf-8') as f: d=json.load(f)
  4. feats=d['data']['features']
  5. print('features:', len(feats))
  6. # 1) 是否存在 location / 位置描述类字段
  7. keys=collections.Counter()
  8. for ft in feats: keys.update((ft.get('properties') or {}).keys())
  9. print('property keys:', dict(keys))
  10. # 2) code 前缀分布
  11. pref=collections.Counter()
  12. for ft in feats:
  13. code=str((ft.get('properties') or {}).get('code') or '')
  14. m=re.match(r'^([A-Za-z]{2})', code)
  15. pref[m.group(1) if m else '(none)']+=1
  16. print('code 2-letter prefix:', dict(pref))
  17. # 3) 按 source 分组看前缀
  18. bysrc=collections.defaultdict(collections.Counter)
  19. for ft in feats:
  20. pr=ft.get('properties') or {}
  21. code=str(pr.get('code') or '')
  22. m=re.match(r'^([A-Za-z]{2})', code)
  23. bysrc[pr.get('source')][m.group(1) if m else '(none)']+=1
  24. for k,v in bysrc.items(): print('source', k, dict(v))
  25. # 4) 样例
  26. for ft in feats[:3]:
  27. print('SAMPLE', json.dumps(ft.get('properties'), ensure_ascii=False)[:400])
  28. # 5) 看 name/remark 里是否含 城南/城北/太常
  29. for word in ['城南','城北','太常']:
  30. hits=[ (ft.get('properties') or {}).get('code') for ft in feats if word in json.dumps(ft.get('properties') or {}, ensure_ascii=False)]
  31. print(word, 'appears in', len(hits), 'features; sample codes:', hits[:3])