Colour map QC events according to their labels.

We take the first label associated with the event (if any) and use
the label's colour for the event marker. We override the colour for
QC events and use a default value for events with no labels or if
the label does not have an associated colour.
This commit is contained in:
D. Berge
2022-05-07 12:07:03 +02:00
parent a5603cf243
commit df13343063

View File

@@ -374,6 +374,7 @@ export default {
} }
} }
], ],
labels: {},
hashMarker: null hashMarker: null
}; };
}, },
@@ -438,17 +439,16 @@ export default {
const data = await this.api([url, {headers: {"Accept": "application/geo+json"}}]); const data = await this.api([url, {headers: {"Accept": "application/geo+json"}}]);
if (data) { if (data) {
function colour(feature) { const colour = (feature) => {
if (feature && feature.properties && feature.properties.type) { if (feature.properties.meta?.qc_id) {
if (feature.properties.type == "qc") { return feature.properties.labels.includes("QCAccepted")
return feature.properties.labels.includes("QCAccepted") ? "lightgray"
? "lightgray" : "green";
: "gray"; } else if (feature.properties.type == "midnight shot") { // FIXME
} else if (feature.properties.type == "midnight shot") { // The above will no longer work. See #223.
return "cyan"; return "cyan";
} else { } else if (feature.properties.labels?.length) {
return "orange"; return this.labels?.[feature.properties.labels[0]]?.view?.colour ?? "orange";
}
} }
return "brown"; return "brown";
} }
@@ -671,6 +671,15 @@ export default {
} }
}, },
async getLabelDefinitions () {
const url = `/project/${this.$route.params.project}/label`;
const labelSet = {};
const labels = await this.api([url]) || [];
labels.forEach( l => labelSet[l.name] = l.data );
this.labels = labelSet;
},
...mapActions(["api"]) ...mapActions(["api"])
}, },
@@ -704,6 +713,8 @@ export default {
} }
}; };
this.getLabelDefinitions(); // No await
layers["Events (QC)"] = L.realtime(this.getEvents(i => i.properties.meta?.qc_id), eventsOptions()); layers["Events (QC)"] = L.realtime(this.getEvents(i => i.properties.meta?.qc_id), eventsOptions());
layers["Events (Other)"] = L.realtime(this.getEvents(i => !i.properties.meta?.qc_id), eventsOptions()); layers["Events (Other)"] = L.realtime(this.getEvents(i => !i.properties.meta?.qc_id), eventsOptions());