optimized events
This commit is contained in:
@@ -432,6 +432,13 @@ function inferredRole(candidate: MarinePoiCandidate): MarinePoiRole {
|
||||
function officialIds(properties: Record<string, unknown>) {
|
||||
const ids = new Map<string, string>();
|
||||
for (const key of OFFICIAL_ID_KEYS) {
|
||||
// On an OSM waterway way, `lock_name` identifies the lock facility while
|
||||
// `wikidata` commonly still identifies the underlying canal or river.
|
||||
// Treating that waterway ID as a lock ID would split one physical lock into
|
||||
// several events. EuRIS/ISRS identifiers remain authoritative.
|
||||
if (key === "wikidata" && stringValue(properties.lock_name)) {
|
||||
continue;
|
||||
}
|
||||
const value = stringValue(properties[key]);
|
||||
if (value) ids.set(key, value.toLocaleUpperCase("en-US"));
|
||||
}
|
||||
|
||||
@@ -92,6 +92,29 @@ describe("marine POI canonicalization", () => {
|
||||
expect(result).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("does not mistake a waterway Wikidata ID for the lock named by lock_name", () => {
|
||||
const result = canonicalizeMarinePois([
|
||||
lock("lock-node", "Kesselschleuse Emden", 7.2, {
|
||||
wikidata: "Q965772"
|
||||
}),
|
||||
lock("canal-way", "Kesselschleuse Emden", 7.2002, {
|
||||
name: "Fehntjer Tief",
|
||||
lock_name: "Kesselschleuse Emden",
|
||||
wikidata: "Q1401323",
|
||||
phone: "+49 170 8512375"
|
||||
})
|
||||
]);
|
||||
|
||||
expect(result).toHaveLength(1);
|
||||
expect(result[0]).toMatchObject({
|
||||
name: "Kesselschleuse Emden",
|
||||
memberCount: 2,
|
||||
properties: {
|
||||
phone: "+49 170 8512375"
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("assigns an unnamed gate to exactly the nearest anchor without bridging facilities", () => {
|
||||
const result = canonicalizeMarinePois([
|
||||
lock("west", "Schleuse West", 7),
|
||||
|
||||
Reference in New Issue
Block a user