irceline / opendataviewer

A light weight viewer for displaying air quality data throughout Belgium, customisable via URL-parameters
Apache License 2.0
3 stars 1 forks source link

Don't show the forwardHour when time being diplayed is lastupdate #1

Closed opeeters closed 4 years ago

opeeters commented 4 years ago

When the data on the map is the latest data available, it should not be possible to go to the future. I solved this elsewhere with something like this:

var now = moment.utc(lastupdate).format("YYYY-MM-DD[T]HH:mm:ss.SSS[Z]");
var now_orig = moment.utc(lastupdate).format("YYYY-MM-DD[T]HH:mm:ss.SSS[Z]");
if (now_orig === now) {
  document.getElementById('forwardHour').style.display = "none"; 
} else {
  document.getElementById('forwardHour').style.display = "unset"; 
}

And in $('#backHour').click(function() and $('#forwardHour').click(function() something like this:

        lastupdate = moment(lastupdate).subtract('hours', 1);
        now = moment.utc(lastupdate).format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
if (now_orig === now) {
  document.getElementById('forwardHour').style.display = "none"; 
} else {
  document.getElementById('forwardHour').style.display = "unset"; 
}
stevenvdbosch commented 4 years ago

@opeeters done

opeeters commented 4 years ago

All is well for resolution=rioifdm. Something is still going wrong for resolution=rio4x4 and resolution=rio1x1. These maps are already available at about '25 and '30 past the hour. The rioifdm layers are only ready by '54 past the hour..

In the case of e.g. resolution=rio4x4, https://www.irceline.be/air/time_hmean_rio4x4_json.php is correctly fetched, but the WMS calls go to the time as returned by https://www.irceline.be/air/time_hmean_rioifdm_json.php

stevenvdbosch commented 4 years ago

I think i have found what is going on: I think that the issue you are mentioning was already existent in the code (separate from this enhancement), but now you found it (so it's a separate issue). The consequence is that sometimes not the last possible update was shown on the map.

What is happening: The lastupdate format is specified for example as time = "2020-01-09T14:00:00+01:00" but when you call moment(time).toISOString(), (what we do in the _timeformats.js ), moment.js adjusts the zone to +00:00, which turns the clock 1 hour back, which is unwanted in our case.

See: https://jsfiddle.net/htdk5e3w/1/ (i take moment() and then turn it to an ISOString() )

Still reading up on how to solve this.

So i thought i had found it, but i don't think it's that. Could you ellaborate what the problem is? If the .php returns a time of lastupdate, i presume this is the last update right? And this doesn't seem the case? for example, now it is 18u42 and the php for rio4x4 gives 17h +1. Which is not the latestupdate it seems, because the latest update is from 18h +1 no? Maybe i'm wrong, please ellaborate...

By the way: there is no mechanism in the page to update the correct time of latest update. So if that's not present, we have to assume that the first time we get the latest update is the latest update (as long as there is no refresh).

amotl commented 4 years ago

Dear @opeeters and @stevenvdbosch,

regarding the forwardHour button, I have amended the behavior slightly within #7 to disable the button instead of hiding it. This prevents layout changes within the time control so the user does not have to move the mouse to follow the button.

With kind regards, Andreas.

opeeters commented 4 years ago

Thanks @amotl I merged the code into the issue3_refine_region_parameter branch.

stevenvdbosch commented 4 years ago

The added feature for changing the time with the arrow keys and ctrl + shift is a nice addition: But it introduces 3 'problems' if you use the arrow keys,:

  1. the disabling of the forwardHour does not work when using the arrow keys
  2. the map also shifts to the left or right when using the arrow keys
  3. How do people know that you can change the time with those keys? Shouldn't there be some explanation or info popup or so..?
amotl commented 4 years ago

Dear @stevenvdbosch,

  1. I just found this as well. Thanks.
  2. It works for me on Firefox. However, we can well redefine the key codes.
  3. It was really just an evaluation to check whether I could familiarize myself with the codebase and just has prototype character. Feel free to use that feature as you like and add a guideline to the user manual. Most probably, we should put a help icon somewhere which opens an overlay displaying the user manual, right? Unless this is implemented, consider it as a kind of hidden feature where only some people are initiated ;].

With kind regards, Andreas.

stevenvdbosch commented 4 years ago

@amotl I use chrome mainly. In firefox it works indeed

opeeters commented 4 years ago

I added documentation about this to the readme. This is an advanced user feature for the time-being, but I was planning to add some documentation pop-up in the future.