mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-21 22:46:32 +00:00
fix(places): keep the chain out of the field that means "this place"
toPlaceRecord wrote the brand's Wikidata item into `wikidata`, and getPlaceDetails spreads the record over the OSM details, so for a chain branch picked from the index that value replaced the building's own tag - and nulled a real one when the place had no brand. resolveIdentity reads that field as the place's own identity, so the photo ladder returned the chain's Commons files as pictures of this branch and the description came back as the company's article without the aboutBrand flag. That is precisely the failure WIKI_IDENTITY_TAGS and readBrandIdentity were written to prevent, in their own words: "a chain's logo passed off as a photo of the restaurant would be a plain lie". The item now travels under brand:wikidata, the key OSM uses and readBrandIdentity already reads, and resolveIdentity picks it up from the payload for a place OSM does not know - so a branch still gets the chain's description, flagged as such, and never its logo. The client test also covers trekPlacesArea, the streaming half of readCapped including the size cap, the configured base URL and the nearby defaults, none of which any test reached.
This commit is contained in:
@@ -258,7 +258,12 @@ export function toPlaceRecord(p: TrekPlace): Record<string, unknown> {
|
||||
email: p.contact?.email ?? null,
|
||||
category: p.category ?? null,
|
||||
brand: p.brand?.name ?? null,
|
||||
wikidata: p.brand?.wikidata ?? null,
|
||||
// The chain's Wikidata item, under the key that says so. It must NOT go
|
||||
// into `wikidata`: that field means "the article about this place", and the
|
||||
// enrichment ladder reads it as such — a branch would then be illustrated
|
||||
// with the chain's logo and described as the company, which is the failure
|
||||
// readBrandIdentity and WIKI_IDENTITY_TAGS exist to prevent.
|
||||
'brand:wikidata': p.brand?.wikidata ?? null,
|
||||
source: 'trek-places',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -391,16 +391,21 @@ export class PlaceEnrichmentService {
|
||||
wikidata: fromPayload('wikidata'),
|
||||
wikimedia_commons: fromPayload('wikimedia_commons'),
|
||||
osmTags: null,
|
||||
brand: { wikidata: null, wikipedia: null },
|
||||
// The index knows the chain a branch belongs to and hands it over under
|
||||
// the same key OSM uses. It stays out of the three fields above: those
|
||||
// say "this is the article about this place", and a chain's is not.
|
||||
brand: { wikidata: fromPayload('brand:wikidata'), wikipedia: fromPayload('brand:wikipedia') },
|
||||
};
|
||||
if (carried.wikipedia || carried.wikidata || carried.wikimedia_commons) return carried;
|
||||
|
||||
const resolved = await this.maps.resolveOsmIdentity(req.name, req.lat, req.lng, { lang: req.lang });
|
||||
if (!resolved) return carried;
|
||||
const brand = readBrandIdentity(resolved.tags);
|
||||
return {
|
||||
...readWikiIdentity(resolved.tags),
|
||||
osmTags: resolved.tags,
|
||||
brand: readBrandIdentity(resolved.tags),
|
||||
// OSM first, the carried one when OSM has no brand tag for this object.
|
||||
brand: brand.wikidata || brand.wikipedia ? brand : carried.brand,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user