Closed agnessa closed 6 years ago
I don't think the BC issue is about context layers. It's about the choropleth layers (data served by get_nodes
), and if looking at the issue I'm not sure what are the next steps to be taken.
As for context layers:
layergroupids
values)(maybe @tiagojsag can disambiguate)
(corrected a missing link in the original message)
I might have linked to the wrong BC task, the description in this one is very vague; but Tiago did mention to me representing the contextual layers in the db, and the fact that we might have a different layer source for different years. I hope he can clarify, especially about the layergroupids
.
Worth precising that the call to the CARTO API whenever we want to change or add a context layer is not avoidable. We could go through the pain of moving this to the backend, as well as the legend data structure we discussed, but I'm not sure it's ideal.
Fair enough. So for the time being I'll assume we only want to store the links between contexts + years + layer ids. Are the layer ids the textual identifiers under name
in the json? Could I assume that e.g. when we have another contextual layer for Brazil protected areas for different years, it would need to have a different name
!= brazil_protected
?
Or even more broadly, should that name be unique across contexts?
It's never a question we had to ask ourselves as there were only context layers for Brazil, not dependant on the year selected.
So for the time being I'll assume we only want to store the links between contexts + years + layer ids. Are the layer ids the textual identifiers under name in the json? Could I assume that e.g. when we have another contextual layer for Brazil protected areas for different years, it would need to have a different name != brazil_protected?
Yes to all of that.
Ok, a few things we will have:
Where we return year-specific data we have two choices on how to handle "all years" - either a null
to denote all, or a list of all years. What's better for FE @nerik ?
Here's a proposal for a JSON mock (for a given country-commodity context). I hope it'll help.
context_layers: [
{
is_default: true,
title: 'Brazil biomes',
id: 'brazil_biomes',
tooltip: 'Brazil biomes lorem ipsum blabla',
carto_layers: [
{ id: 'brazil_biomes', year_span: null }
]
},
{
title: 'Land cover',
id: 'landcover',
tooltip: 'Land cover lorem ipsum blabla',
carto_layers: [
{ id: 'landcover_2015', year_span: [2015] },
{ id: 'landcover_2014', year_span: [2014] }
]
},
{
title: 'Water scarcity',
id: 'water',
tooltip: 'Water scarcity lorem ipsum blabla',
carto_layers: [
{ id: 'water_2014_2015', year_span: [2014, 2015] }
]
}
]
This should cover the 3 use cases I can think of:
Thanks, for the comment, amended the original comment.
carto_layers
might be better than years
, as it represents what it actually is in the end result.
looks good. Just a couple of heads up:
you will always get a isDefault value, true or false.
no problem
the root element probably should be named "data" to match every other API call we have.
I was not aware that would be on a separated endpoint, but ok, fine. I guess this endpoint will take a context id as parameter.
Also, I realised an id was also needed on each object of the array, so I added that to the mock.
ah, you want to load this in the get_contexts? yeah, makes sense, I just assumed it would be a separate call, for no good reason, now that I think about it
"moved" to the new repo, closing
I believe we now want to store the list of contextual layers in the database, at least that's what I understand is implied here.
While most of the attributes from this json can be used verbatim as database columns, I struggle to break down the legend property into a representation that would allow the frontend to generate the html, as storing html in the database is not a great option. So far I managed to isolate these properties that seem relevant:
legend_type
(e.g. custom, choropleth)legend_colours
- array of hex colourslegend_labels
- array of labelsWould that be enough to generate the legend? I notice that sometimes the
<li>
element has abkg
class and sometimes not; I'm not sure why that is but if it is important, how best to represent it?One more question:
forceZoom
is so far undefined for all, will it be used in the future or can it be left out? Is this meant to be an integer or boolean?