2

I am making an application and I want to access a lot of weather data.

Now I want to use the SQL View option to let the WMS layer know which timestamp to use and then it shows me all the data from that moment on a map.

Only I want to be able to do this for all the data in my database. I want my end-user to be able to enter the date they want to see. I want them to see a timeslider for that day AND an extra option which lets them type in a date and then that data will be shown in the application.

Is this possible?

(The data is in a PostGIS database, the application is written in HTML, JSON and JavaScript, is working with npm and OpenLayers and running on Tomcat.)

9
  • you could use the WMS TIME dimension and avoid using an SQL view altogether
    – Ian Turton
    Commented Dec 6, 2018 at 12:49
  • I am now thinking it might be possible to make a timeslider with the TIME dimension for a day and then with the SQL View the user can select a datetime so that the application will show a timeslider for that day. But does the TIME dimension have an option for a timeslider, because I have not yet found that. I have seen you can access multiple timestamps, but nothing about a slider yet. Do you know anything about that?
    – Trisha
    Commented Dec 6, 2018 at 13:04
  • the capabilities will give you a valid range or list of times that you use to create the timeslider from.
    – Ian Turton
    Commented Dec 6, 2018 at 14:01
  • I have been searching for about the entire day, but I can't seem to find anything about making a good timeslider that helps me. You seem to know how it works, do you maybe know where I can find some good info about it? I have made a time dimension and this works fine in my layer preview when I add &time=.. to my url. But I am just lost in how to make this into a timeslider. Could you give a nudge in the right way? I can't find any good examples either. Nothing to tie the time dimension and a time slider together so to say.
    – Trisha
    Commented Dec 12, 2018 at 15:44
  • github.com/metno/openlayers-timeslider should do what you need
    – Ian Turton
    Commented Dec 12, 2018 at 15:46

1 Answer 1

2

You can use dynamic parameters in Geoserver SQL Views to include the user's date/time settings to your database query.

See https://docs.geoserver.org/stable/en/user/data/database/sqlview.html#parameterizing-sql-views or https://geoserver.geo-solutions.it/edu/en/adding_data/add_sqllayers.html ("Creating a parametric SQL view").

5
  • Thanks I am trying this now. I have so far made a SQL View and added my own parameter (called chosen_datetime). I have given it a default value, but when I try to change the paramvalue via the URL it does not work. I am not sure what to enter in the 'Validation Regular Expression' when adding the new parameter for the datetime in the SQL View. Maybe I am doing something wrong there? This is the URL I typed in the browser: '....'openlayers&viewparams=chosen_timestamp:2018-10-14T08:00:00Z
    – Trisha
    Commented Dec 6, 2018 at 13:10
  • The error I get is: java.io.IOExceptionInvalid value for parameter chosen_timestamp
    – Trisha
    Commented Dec 6, 2018 at 13:11
  • The Validation Regular Expression defines the pattern the parameter has to pass (important for security reasons). Only for testing purposes you can set it to .* and thereby allow every value.
    – Mesa
    Commented Dec 6, 2018 at 13:32
  • Thanks! I changed it (for testing purposes, will change it again after I read more about it and know the right expression to enter), but still am getting the same error. Is there something wrong about the way I am putting the date in the url? In the view (default value) I did: 2018-10-18 08:00:00, and that worked. I have now tried almost every timestamp format I can think of, but it still won't work.
    – Trisha
    Commented Dec 6, 2018 at 13:52
  • Figured it out. Something was wrong with the SRID-settings. Thanks so much for the help!
    – Trisha
    Commented Dec 6, 2018 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.