fix(map-gateway): unlock warm layers and local station search
This commit is contained in:
@@ -63,12 +63,13 @@ function normalizeFeature(feature, generatedAt, index) {
|
||||
const identity = nativeId.match(/^(node|way|relation)\/([1-9]\d*)$/);
|
||||
if (!identity) throw new Error(`station_seed_feature_${index}_identity_invalid`);
|
||||
const attributes = compact({
|
||||
name: firstString(properties.name, properties["name:ru"], properties.official_name, properties.loc_name),
|
||||
name: firstString(properties["name:ru"], properties.name, properties.official_name, properties.loc_name),
|
||||
category,
|
||||
network: optionalString(properties.network),
|
||||
operator: optionalString(properties.operator),
|
||||
official_name: optionalString(properties.official_name),
|
||||
local_name: optionalString(properties.loc_name),
|
||||
alternate_names: alternateNames(properties),
|
||||
uic_ref: optionalString(properties.uic_ref),
|
||||
wheelchair: optionalString(properties.wheelchair),
|
||||
});
|
||||
@@ -101,6 +102,28 @@ function optionalString(value) {
|
||||
return normalized && normalized.length <= 256 ? normalized : undefined;
|
||||
}
|
||||
|
||||
function alternateNames(properties) {
|
||||
const primary = firstString(properties["name:ru"], properties.name, properties.official_name, properties.loc_name);
|
||||
const unique = new Map();
|
||||
for (const value of [
|
||||
properties.name,
|
||||
properties["name:ru"],
|
||||
properties["name:en"],
|
||||
properties.official_name,
|
||||
properties.loc_name,
|
||||
properties.short_name,
|
||||
properties.old_name,
|
||||
...String(properties.alt_name || "").split(";"),
|
||||
]) {
|
||||
const normalized = optionalString(value);
|
||||
if (!normalized || normalized.toLocaleLowerCase("ru") === primary?.toLocaleLowerCase("ru")) continue;
|
||||
const key = normalized.toLocaleLowerCase("ru");
|
||||
if (!unique.has(key)) unique.set(key, normalized);
|
||||
}
|
||||
const values = [...unique.values()].slice(0, 16);
|
||||
return values.length ? values : undefined;
|
||||
}
|
||||
|
||||
function compact(value) {
|
||||
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user