Skip to content

Commit

Permalink
events map: minor refactoring and reducing clustering amount
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Feb 22, 2024
1 parent 597eb38 commit a90fae5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/webapp/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ async function map_start_promise() {
// define a function to compute dynamically the style for a feature/cluster
let RoadEventsStyle = function (feature) {
const size = feature.get('features').length;
if (size > 1) {
if (size > 10) {
// style for clustered features
return new ol.style.Style({
image: new ol.style.Icon({
Expand Down Expand Up @@ -1449,7 +1449,7 @@ async function map_start_promise() {

// filter Province BZ events for following logic
// https://github.com/noi-techpark/it.bz.opendatahub.analytics/issues/97
if (event.evorigin == "PROVINCE_BZ" && !isVisibleProvinceBZ(event, timestamp)) {
if (event.evorigin == "PROVINCE_BZ" && filterProvinceBZ(event, timestamp)) {
return
}

Expand Down Expand Up @@ -1804,36 +1804,36 @@ function getProvinceBZIcon(subTycodeValue) {
}
}

function isVisibleProvinceBZ(event, now) {
function filterProvinceBZ(event, now) {
const startTs = new Date(event.evstart).getTime()
const endTs = new Date(event.evend).getTime()
const category = event.evcategory;
const last24hours = now - (24 * 60 * 60 * 1000)

// filter out old events, that don't have new code typeCode_subTypeCode
if(!category.includes("_") || category.includes(" | ")){
return false
return true
}
console.log(category);

switch (category) {
case "intralci viabilità in e fuori Alto Adige_chiusura temporanea | Verkehrsbehinderung für Zonen und aus. Südt._kurzfristige oder zeitweilige Sperre":
console.log("pla");
if (endTs === null || endTs === undefined)
return true
return false
console.log("tata");
return now >= startTs && now <= endTs
return !(now >= startTs && now <= endTs)
case "intralci viabilità in e fuori Alto Adige_cantiere | Verkehrsbehinderung für Zonen und aus. Südt._Baustelle":
return now >= startTs && now <= endTs
return !(now >= startTs && now <= endTs)
case "intralci viabilità in e fuori Alto Adige_attenzione | Verkehrsbehinderung für Zonen und aus. Südt._Vorsicht":
case "intralci viabilità in e fuori Alto Adige_caduta frana | Verkehrsbehinderung für Zonen und aus. Südt._Murenabgang und Strassenverlegung":
case "intralci viabilità in e fuori Alto Adige_manifestazione | Verkehrsbehinderung für Zonen und aus. Südt._Veranstaltungen":
case "intralci viabilità in e fuori Alto Adige_senso unico alternato con semafero | Verkehrsbehinderung für Zonen und aus. Südt._Ampelregelung":
return startTs >= last24hours
return startTs <= last24hours
default:
// console.warn("PROVINCE_BZ: No fitler defined for category: " + category)
// return true;
// if (category.includes("Situazione attuale"))
return startTs >= last24hours
return startTs <= last24hours
}
}

0 comments on commit a90fae5

Please sign in to comment.