Fix bug where metatagging would not fully calculate in some cases
This commit is contained in:
parent
27a43fdbe0
commit
65470cbac5
8 changed files with 34 additions and 20 deletions
|
@ -353,20 +353,21 @@ export default class FeaturePipeline {
|
||||||
|
|
||||||
private applyMetaTags(src: FeatureSourceForLayer) {
|
private applyMetaTags(src: FeatureSourceForLayer) {
|
||||||
const self = this
|
const self = this
|
||||||
console.debug("Applying metatagging onto ", src.name)
|
|
||||||
window.setTimeout(
|
window.setTimeout(
|
||||||
() => {
|
() => {
|
||||||
|
console.debug("Applying metatagging onto ", src.name)
|
||||||
|
const layerDef = src.layer.layerDef;
|
||||||
MetaTagging.addMetatags(
|
MetaTagging.addMetatags(
|
||||||
src.features.data,
|
src.features.data,
|
||||||
{
|
{
|
||||||
memberships: this.relationTracker,
|
memberships: this.relationTracker,
|
||||||
getFeaturesWithin: (layerId, bbox: BBox) => self.GetFeaturesWithin(layerId, bbox)
|
getFeaturesWithin: (layerId, bbox: BBox) => self.GetFeaturesWithin(layerId, bbox)
|
||||||
},
|
},
|
||||||
src.layer.layerDef,
|
layerDef,
|
||||||
{
|
{
|
||||||
includeDates: true,
|
includeDates: true,
|
||||||
// We assume that the non-dated metatags are already set by the cache generator
|
// We assume that the non-dated metatags are already set by the cache generator
|
||||||
includeNonDates: !src.layer.layerDef.source.isOsmCacheLayer
|
includeNonDates: layerDef.source.geojsonSource === undefined || !layerDef.source.isOsmCacheLayer
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
|
@ -61,7 +61,15 @@ export default class MetaTagging {
|
||||||
// All keys are already defined, we probably already ran this one
|
// All keys are already defined, we probably already ran this one
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
somethingChanged = somethingChanged || metatag.applyMetaTagsOnFeature(feature, freshness)
|
const newValueAdded = metatag.applyMetaTagsOnFeature(feature, freshness)
|
||||||
|
/* Note that the expression:
|
||||||
|
* `somethingChanged = newValueAdded || metatag.applyMetaTagsOnFeature(feature, freshness)`
|
||||||
|
* Is WRONG
|
||||||
|
*
|
||||||
|
* IF something changed is `true` due to an earlier run, it will short-circuit and _not_ evaluate the right hand of the OR,
|
||||||
|
* thus not running an update!
|
||||||
|
*/
|
||||||
|
somethingChanged = newValueAdded || somethingChanged
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not calculate metatag for ", metatag.keys.join(","), ":", e, e.stack)
|
console.error("Could not calculate metatag for ", metatag.keys.join(","), ":", e, e.stack)
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,14 +146,14 @@ export default class SimpleMetaTagger {
|
||||||
private static country = new SimpleMetaTagger(
|
private static country = new SimpleMetaTagger(
|
||||||
{
|
{
|
||||||
keys: ["_country"],
|
keys: ["_country"],
|
||||||
doc: "The country code of the property (with latlon2country)"
|
doc: "The country code of the property (with latlon2country)",
|
||||||
|
includesDates: false
|
||||||
},
|
},
|
||||||
feature => {
|
((feature, _) => {
|
||||||
|
|
||||||
let centerPoint: any = GeoOperations.centerpoint(feature);
|
let centerPoint: any = GeoOperations.centerpoint(feature);
|
||||||
const lat = centerPoint.geometry.coordinates[1];
|
const lat = centerPoint.geometry.coordinates[1];
|
||||||
const lon = centerPoint.geometry.coordinates[0];
|
const lon = centerPoint.geometry.coordinates[0];
|
||||||
|
|
||||||
SimpleMetaTagger.coder?.GetCountryCodeFor(lon, lat, (countries: string[]) => {
|
SimpleMetaTagger.coder?.GetCountryCodeFor(lon, lat, (countries: string[]) => {
|
||||||
try {
|
try {
|
||||||
const oldCountry = feature.properties["_country"];
|
const oldCountry = feature.properties["_country"];
|
||||||
|
@ -167,7 +167,7 @@ export default class SimpleMetaTagger {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return false;
|
return false;
|
||||||
}
|
})
|
||||||
)
|
)
|
||||||
private static isOpen = new SimpleMetaTagger(
|
private static isOpen = new SimpleMetaTagger(
|
||||||
{
|
{
|
||||||
|
|
|
@ -118,7 +118,7 @@ export default class MinimapImplementation extends BaseUIElement implements Mini
|
||||||
self.InitMap();
|
self.InitMap();
|
||||||
self.leafletMap?.data?.invalidateSize()
|
self.leafletMap?.data?.invalidateSize()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not construct a minimap:", e)
|
console.warn("Could not construct a minimap:", e)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ export default class UserBadge extends Toggle {
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
this.SetClass("shadow rounded-full h-min overflow-hidden block w-max")
|
this.SetClass("shadow rounded-full h-min overflow-hidden block w-full md:w-max")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1062,12 +1062,6 @@ video {
|
||||||
width: min-content;
|
width: min-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
.w-max {
|
|
||||||
width: -webkit-max-content;
|
|
||||||
width: -moz-max-content;
|
|
||||||
width: max-content;
|
|
||||||
}
|
|
||||||
|
|
||||||
.w-6 {
|
.w-6 {
|
||||||
width: 1.5rem;
|
width: 1.5rem;
|
||||||
}
|
}
|
||||||
|
@ -1076,6 +1070,12 @@ video {
|
||||||
width: 50%;
|
width: 50%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.w-max {
|
||||||
|
width: -webkit-max-content;
|
||||||
|
width: -moz-max-content;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
.min-w-min {
|
.min-w-min {
|
||||||
min-width: -webkit-min-content;
|
min-width: -webkit-min-content;
|
||||||
min-width: -moz-min-content;
|
min-width: -moz-min-content;
|
||||||
|
@ -2339,6 +2339,12 @@ li::marker {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.md\:w-max {
|
||||||
|
width: -webkit-max-content;
|
||||||
|
width: -moz-max-content;
|
||||||
|
width: max-content;
|
||||||
|
}
|
||||||
|
|
||||||
.md\:grid-flow-row {
|
.md\:grid-flow-row {
|
||||||
grid-auto-flow: row;
|
grid-auto-flow: row;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
clear: right;
|
clear: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wikipedia-article svg, img {
|
.wikipedia-article svg, .wikipedia-article img {
|
||||||
width: unset;
|
width: unset;
|
||||||
height: unset;
|
height: unset;
|
||||||
display: unset;
|
display: unset;
|
||||||
|
|
3
index.ts
3
index.ts
|
@ -19,8 +19,7 @@ import SimpleMetaTagger from "./Logic/SimpleMetaTagger";
|
||||||
MinimapImplementation.initialize()
|
MinimapImplementation.initialize()
|
||||||
// Workaround for a stupid crash: inject some functions which would give stupid circular dependencies or crash the other nodejs scripts
|
// Workaround for a stupid crash: inject some functions which would give stupid circular dependencies or crash the other nodejs scripts
|
||||||
ValidatedTextField.bestLayerAt = (location, layerPref) => AvailableBaseLayers.SelectBestLayerAccordingTo(location, layerPref)
|
ValidatedTextField.bestLayerAt = (location, layerPref) => AvailableBaseLayers.SelectBestLayerAccordingTo(location, layerPref)
|
||||||
|
SimpleMetaTagger.coder = new CountryCoder("https://pietervdvn.github.io/latlon2country/");
|
||||||
SimpleMetaTagger.coder = new CountryCoder("https://pietervdvn.github.io/latlon2country/");
|
|
||||||
|
|
||||||
let defaultLayout = ""
|
let defaultLayout = ""
|
||||||
// --------------------- Special actions based on the parameters -----------------
|
// --------------------- Special actions based on the parameters -----------------
|
||||||
|
|
Loading…
Reference in a new issue