Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class GeoengineRenderer extends Component {
this.orm = useService("orm");
this.view = useService("view");
this.user = useService("user");
this.notification = useService("notification");

// For related model we need to load all the service needed by RelationalModel
this.services = {};
Expand Down Expand Up @@ -749,8 +750,12 @@ export class GeoengineRenderer extends Component {
const fields_to_read = this.getFieldsToRead(vector);
const data = await this.getModelData(vector, fields_to_read);
this.useRelatedModel(vector, layer, data);
const styleInfo = this.styleVectorLayer(vector, data);
this.initLegend(styleInfo, vector);
if (this.checkAttributeFieldUsage(vector, data)) {
const styleInfo = this.styleVectorLayer(vector, data);
if (styleInfo) {
this.initLegend(styleInfo, vector);
}
}
}

async renderVectorLayers() {
Expand Down Expand Up @@ -844,9 +849,13 @@ export class GeoengineRenderer extends Component {
}

styleVectorLayerAndLegend(cfg, data, lv) {
const styleInfo = this.styleVectorLayer(cfg, data);
this.initLegend(styleInfo, cfg);
lv.setStyle(styleInfo.style);
if (this.checkAttributeFieldUsage(cfg, data)) {
const styleInfo = this.styleVectorLayer(cfg, data);
if (styleInfo) {
this.initLegend(styleInfo, cfg);
lv.setStyle(styleInfo.style);
}
}
}

initLegend(styleInfo, cfg) {
Expand Down Expand Up @@ -1248,6 +1257,27 @@ export class GeoengineRenderer extends Component {
var indicator = cfg.attribute_field_id[1];
return data.map((item) => item._values[indicator]);
}

/**
* Check vector Layer Attribute Field is defined
* by view to display proper legends
*/
checkAttributeFieldUsage(cfg, data) {
const indicator_values = this.extractLayerValues(cfg, data);
if (indicator_values.some((item) => typeof item === "undefined")) {
this.notification.add(
this.env._t(
"Customize view to use Attribute Field: " +
cfg.attribute_field_id[1]
),
{
type: "warning",
}
);
return false;
}
return true;
}
}

GeoengineRenderer.template = "base_geoengine.GeoengineRenderer";
Expand Down