blob: 9fd9d4f59c0f177858593e340dda656ba2086e14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import osm from "./kodaira-parks-osm.json";
import manual from "./kodaira-parks-manual.json";
// OSMから取得したポリゴンと、QGIS等で手描きしたポリゴンをまとめる。
// 手描き分は kodaira-parks-manual.json に置くことで、npm run osm:update で消えない。
//
// 一覧にないグラウンド(校庭・運動場・pitch・recreation_ground)と、
// 名前のない小規模な地物は地図に出さない。
// 一覧にない公園・緑地のうち、名前のあるものだけを薄い赤で残す。
function isHiddenUnlisted(props: any): boolean {
if (!props || props.matched || props.our_name) return false;
const name = String(props.name || "").trim();
const tag = String(props.leisure || props.landuse || "");
if (!name) return true;
if (/グラウンド|校庭|運動場/.test(name)) return true;
if (tag === "pitch" || tag === "recreation_ground") return true;
return false;
}
const osmFeatures = ((osm as any).features ?? []).filter(
(f: any) => !isHiddenUnlisted(f.properties),
);
const manualFeatures = (manual as any).features ?? [];
// 手入力ポリゴンでOSM側の形を置き換える公園(例: 道路で分かれた公園)。
// QGISの属性 override=true、または import-manual-parks.py の --override-name で付く。
const overrideNames = new Set(
manualFeatures
.filter((f: any) => {
const value = f?.properties?.override;
return value === true || value === 1 || value === "true" || value === "1";
})
.map((f: any) => f?.properties?.our_name)
.filter(Boolean),
);
const features = [
...osmFeatures.filter((f: any) => !overrideNames.has(f.properties?.our_name)),
...manualFeatures,
];
export default { type: "FeatureCollection", features };
|