After testing original QGIS Web Client I (QWC) about good year ago, We quickly start to think what on our opinion and experiences is missing or should be different. But we liked the whole project and idea of QGIS Extending some general classes of GeoExt and WMS standard. One drawback could be that QWC is running on old versions of external librariers, but upgrading here it’s not easy task, basically means starting from scratch and migrating certain parts, but that’s a different story. I only update OpenLayers 2.13 to newer version from GitHub and ExtJS 3.4.0 to 126.96.36.199.
So I started searching for various solutions and then integrating them into new client.
Jump directly to the client or read more below.
I set up PostgreSQL database with following relevant tables:
- projects (every qgis project has own record with settings for overview layer, base or external WMS layers)
- users (name, email, password hash and list of projects that user is allowed to use)
- layers (layer settings for using as overview, base or external layers)
2. Additional project settings
I moved all of project related settings from inside the code (search panel, themeswitcher and new settings for layer filtering and geonames search) into separate json file, which should exist beside project qgs file.
3. User authentication
We needed to have QWC and QGIS project data accessed for specific users only. When user is succesfully logged in, all necessary data is stored into PHP session variables and browser is redirected to QWC which initially reads those session variables and stores them into js variables. If there is no session, login window shows up.
It is also possible to enable public access on project (Guest login).
3a. QGIS Server proxy
Latest adition (September 2015) is a proxy PHP script for all requests to QGIS Server. This script serves 2 reasons:
- Caching requests which are static as long as QGIS project (and data) stays the same. This requests are: GetProjectSettings, GetLegendGraphics and GetFeatureInfo when it is used with empty filter (get atributes for all features).
- Calling QGIS Server only for requests from users that are logged in.
So this feature means higher performance and better security. Users have manual control to see and delete cache content if it is changed.
Client (user interface)
4. Layer context menu
Each vector layer from QGIS project has context menu with following options:
- Zoom to layer extent
- Open attribute table
- Export layer to…
- Currently supported formats are SHP, DXF and CSV
- Option for exporting just current bounding box
Displaying attribute table is done using WMS GetFeatureInfo request, the same as when searching on layer with QGIS.SearchPanel. Only filter string is empty in this case.
Of course, this is a problem with large data. So first thing: I switched off Adding geometry to feature response in QGIS Projects properties to significantly reduce returned XML size. It’ s too bad that means for the whole project and not just specific layer.
Another thing is setting feature count limit, which means that you cannot receive all results in case of layers with number of features over your limit. This could be done with adding bounding box to GetFeatureInfo filter, but I think QGIS Server currently doesn’t support that (I read that Geoserver has this option). In this case, you could open attributes for currently visible features on the map, which would be very cool for my opinion.
5. Geolocation button
Simple button for showing your current location with accuracy information. Another click removes marker.
6. Google StreetView integration
With Google StreetView mode enabled, click on the map displays StreetView panel. Marker on the map is syncronising when you rotate view or move positon in StreetView.
7. Layer tree
Legend for visible layers is displayed in layer tree (taken from Customization scripts). Removed button “i” icon for displaying legend and layer properties since this can be added to context menu and legend is already displayed.
8. Minor consolidations
Stuff below is based upon subjective opinion.
- use ExtJS blue theme (just to differ from original QWC)
- GeoExt popup instead of OpenLayers window. This fit’s more into ExtJS application look and feel.
- Buttons and icons (some new, some changed, some removed)
- Layer ordering removed. In general this is cool option, but has to be done with simple drag&drop (which is possible with GeoEXt). Solution here was for my opinion too much for clean and simple user interface.
- Set default Object identification mode to “All layers” since I think this is generally what user expects. I also hide selection for other identification modes.
Try it out
On our GIS Clients page there is a link to demo project with login info.
Certain parts were done using or helping with code from other users: