Open tsimonq2 opened 8 years ago
This also applies to the graphs. I have no clue what the units are there.
I agree with the suggestion, a static or dynamic scale bar for the maps would be useful. This can easily be done with leaflet, which the app currently uses to display the tiles.
@tsimonq2 While the legend is easy to add with leaflet, I'm not sure how to generate it. Could you take a look at OWM to see if their API provides a legend/scale for maps - we might not need to generate it?
I'm not sure where to start here, @robinpaulson.
My initial method to do this was to either get a pre-defined legend from OWM (if one exists), or to dynamically generate it. From what I can tell, the first doesn't exist and the second is a bit harder than I'm willing to do at the moment (it would require extracting max and min rgb values from the tiles on screen and then drawing a legend between those extreme values).
In the meantime, I will create a static legend, with sensible values for the min and max. These values will be: Temperature: -40 - +40C Precipitation: 0 - 200mm Wind speed: 0 - 200m/s I took these values from this graph on OWM: https://www.openweathermap.org/weathermap?basemap=map&cities=true&layer=windspeed&lat=-36.87&lon=174.77&zoom=8 It's not perfect, but it's a good start point. Of course, we also need to respect the units chosen in settings.
Aha, I found these:
And more, from: http://openweathermap.org/img/a/PR.png http://openweathermap.org/img/a/RN.png
The source was this github repo: https://github.com/buche/leaflet-openweathermap
Now to check whether that scale corresponds to the scale we get on the weather maps.
Hmm, alternatively, this appears built in to leaflet: https://stackoverflow.com/questions/21307647/leaflet-adding-a-legend-title
Reviewing the issue, I realise part of it is already fixed: the graphs have numbers on the side, the units are whatever you select in the Settings.
It appears this is beyond my leaflet skills for the time being. I've moved it from milestone 1.5 to 2.0; unless I increase my javascript skills, or someone else volunteers to do this, it may well repeatedly get pushed back.
I dont think the graph actually obeys the settings. If I flip from mm to in (or reverse) the scale of the graph does not change.
Hmm, cheers for the update. I will think about this; perhaps the units are only updated when the weather is also updated?
Just checked, and it appears to be stuck on constant mm
Perhaps it needs killing and restarting. Could you check?
@gappleto97 There have been a few updates to the graphs in the last couple of months, I think this is fixed now.
This looks useful too for generating the legend automatically: https://leafletjs.com/examples/choropleth/ and scroll down to the bottom
Aha, generating them on-th-fly: https://openweathermap.org/map_legend
Yup, graphs part is fixed, although I wish that the inches one got marked a bit more granularly. That's getting into nitpicking, though.
I'm more used to snow than rain, so I never realized how crappy inches are as a unit for precipitation until moving to a warmer climate. I wanna say snow is ~10x less dense, so I look at rain numbers and have a lot less context for how big it is, haha
inches one got marked a bit more granularly
it's a valid point, not nitpicking. I won't bore you with the details, but the library we are using for charts (william chart) does not allow higher granularity. We will possibly fix it in the future, fridodeluxe came up with a smart, interesting and only slightly clunky way of getting round another limitation in that library. If you're interested in more detail, check out the long conversation in #331.
No diss to fridodeluxe intended, he's done some excellent work on the charts and elsewhere.
When using the Rain, Temperature, etc. maps, it would be nice to know what the colors mean or have some sort of guide for this. I don't know what those colors mean and they could be misleading.