-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Result layers #38
Comments
Please find current version in @4lm, If you want to start implementation of result checking (disable layers and show a message in the layer list if no results are available yet), check out this js function where I try to obtain results and disable HCs when I get null. You may wanna use the same logic here (needs to be fired when result panel is clicked).. I'll add a list of required charts today afternoon. |
Hi @nesnoj, thanks for the infos on the result_visualization branch, I already merged it with the branch I work on (feature/layers-in-results). Works fine - no conflicts!
I had a look at the function getSimulationResults() and spotted some challenges I would like to discuss with you a possible solution I came up with. The logic of
My problem: the popup charts data will come from the result models. Right now it's dummy data in the result models and in the future it shall be real data. @nesnoj, so doing nothing in the case of "data is NOT null" is the right thing to do - right? I will now implement the first part of the new JS function, we than can discuss about the second part in the function ... |
Depends on what do you mean by "nothing" ;). The note above the layer list "Das Szenario wurde verändert..." should be removed and the layers be clickable.
The detail view should return null if results are unavailable, it is not supposed to get clicked anyway.. |
Some more logic for the result layer list we just talked about: Event: results panel click
yes -> Actions:
no -> Actions:
Event: activation of region choropleth layer
Event: scenario change
We should discuss this prior to implementation to have in in line with some concepts/event listeners for other sim/result-related stuff. I.e. I would use JS events to check for results similar to |
Another important task: As those tasks will take some time to implement and test, I do not plan to have it finished by tomorrow. I'm currently trying to feed the results to the model by modifying the queryset, it works but needs some tricks. I'll never use the django-geojson package again.. |
this allows to load result layers on demand instead at statup
I gave it a start: Note: You can toggle the spinner visibility by firing toggleSpinnerVisibility() |
@nesnoj, I had a closer look at f22a9c8 (concerning Getting the layer data via REST endpoint(s) as an AJAX call would be much better suited for our use case IMO. What do you think? Or am I missing something? Edit: Yes, we get most of the layer data via JSON endpoints and AJAX calls, but the info which endoints to use comes via rendered context and some other data as well, like style and choropleth data as JSON, directly put into the JS via context render. |
Like you say, the context is static and is fed on page load, this is ok as the layer metadata always remain the same. But the actual dynamic data is taken from the serial view endpoint. I do not get why is it not possible to fire the AJAX call on result panel click and add the layers subsequently. No reload required, right? I agree that we got heaps of template tags and I'd like to have it replaced (also to be able to move this stuff out of map init). But...you know.. |
Yes, you are right I think! I see this working, if we create a clone of the function |
Mmhh, not as easy as I tought, because main_map_init it's doing a double Rittberger: The template tag My next move now will be to see if I can obtain map and options somehow ... Edit: found it in the window object, will see if I just can use it, stay tuned 😄 |
List of layers Erneuerbare Energien (EE)
Energiebedarf
(list is not complete yet) Additional feature: Show delta in layer After quick search this can might be done using leaflet's
Nice-to-have: The delta could be included in the popup like "[Gemeindename]: [Wert] (dies entspricht einer Änderung gegenüber dem status quo von XX)" Not sure if this interferes with the existing entities/popups/tooltips, could you please check whether this is possible and affordable? |
Hi @nesnoj, I had a look at the endpoint To implement all the results layers (with the municipalities data) mentioned above I simply would replicate the steps done for the region layers ... in a later step we then can see how to fill them with the appropriate data (maybe we have to refactor some code for this, but in the end the structure of the code shouldn't change that much, so I think we can go this route) ... |
Yepp, no progress yet, please go on with the replication as far as possible. |
by using django's never_cache decorator for dispatch methods
* this view modifies GeoJSONResponse by adding a custom feature property * uses dummy proxy model ResultLayerModel to prevent separate result layer models * feature data (DataFrame) is obtained using Result.get_layer_results()
used by new result layer serial view GeoJSONResultLayerData
instead of passing model_name and custom_property via init it's is now taken from subclass attribute
…SONResultLayerData #38 as django-geojson's GeoJSONLayerView cannot be used here. Explanation: at serialization time the queryset must be a django QuerySet to have the 'id' included in the features (feature id needed for popup url). If a list of Datasets is provided (which results from adding an additional (virtual) column/property), it's not. But there's no way of having the id included in the GeoJSON without adjusting django-geojson. so
Hint: It's more efficient and idiomatic to use aggregation functions instead of loops as Django performs 1 SQL query for each dataset so in this example we have 80 (!) queries. That sounds like some load for the DB server.
PS: Still 4 queries... with Django's F() object one could even reduce it to have only one.. |
Thanks for the hint, you are right, 80 queries is way to much ... may plan was to first code a solution and optimize later. But your suggestion (aggregation function) is good and easy to implement, I will refactor the given code and use it form now on for new code ... if we need even more performance later on, we can look into Django's F() object in another refactor round, for now I would go with aggregation functions ... |
Currently on hold, might be implemented later, see branch |
There shall be layers with popups and chorolpethmaps that show results. For the work on this, I created a new branch "
layers-in-results
": https://github.com/rl-institut/WAM_APP_stemp_abw/tree/feature/layers-in-resultsParts needed for this (@nesnoj, following list could be useful for you):
Important: right now we use dummy data in the models, this has to change, by using data from the results!
@nesnoj, further infos I need for my work:
Something like this: #22 (comment)
The text was updated successfully, but these errors were encountered: