kartoza / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
http://geonode.org/
GNU General Public License v3.0
8 stars 17 forks source link

Thumbnails should be of standard size across backends #497

Closed NyakudyaA closed 5 years ago

NyakudyaA commented 5 years ago

Problem

When using QGIS Server vs Geoserver backend the thumbnails generated are of different dimensions.

We need to decide which approach is better.

Example of the same layer uploaded in the different backends QGIS -Server Backend qgsi-server

Geoserver Backend layer-4370ae3a-c61c-11e8-9590-027bd5c50f8c-thumb

Solutions

gubuntu commented 5 years ago

For QGIS I originally wanted layer aspect ratio to be maintained while being forced to fit into a standard sized div, and to always have a basemap. I don't like how Geoserver thumbnails are squashed.

However, the guys implemented nice thumbnails maintaining aspect ratio, but not in a fixed div. So as an enhancement definitely use our QGIS approach, but in a fixed div.

To do this all that needs to be done is to add the div dimensions to the thumbnail WMS request. i.e. full extent of layer with div dimensions for image size.

lucernae commented 5 years ago

We do this by allowing the user to set the thumbnail extent themselves when they want it to be square like the map (But it doesn't seem to work now). The default thumbnail is still like that.

If we want a fixed div, i don't know how to make the extent square. do we have global projection where the unit is in meters?

gubuntu commented 5 years ago
  1. you don't need to worry about projections as I've explained before. You just make a request with the bounding box you want and the image size in pixels you want returned and WMS does the rest. You should get a perfectly sized image for the target div with the gis layer in the right proportions.

  2. where can the user set the thumbnail extent?

gubuntu commented 5 years ago

should be resolved by #517

lucernae commented 5 years ago

@gubuntu I explained this over and over again for 1 :D.

you don't need to worry about projections as I've explained before. You just make a request with the bounding box you want and the image size in pixels you want returned and WMS does the rest. You should get a perfectly sized image for the target div with the gis layer in the right proportions.

Let's say the layer have non square extent, if we request the thumbnails as it is with that extent with square image size in pixels, QGIS WMS will return the correct image size, but since it needs to fit that extent, the image is squashed. This is our first implementation years ago. The size is perfect square but the proportions is not.

What we do now is use the proportion of the extent, calculate linear distance of vertical and horizontal length of the extent using GEOS, and calculate the aspect ratios. We then use the same aspect ratios for the image size in pixel. QGIS will return the requested size and in correct proportions. We can take the image into GeoNode square div and center aligned it. But you don't want this, right? Because you want all extent to be included in the square div. If the div is square, some portion of the extent will be cut off.

What I need now is how to make that extent square in meters/flat unit. If I just make it square in EPSG:4326, it's not going to be proportional near the poles? If you can suggest me what projection to use (meters/flat for any location in the world), I can project the extent to that, make it square, then transform back to EPSG:4326 for the WMS request.

where can the user set the thumbnail extent?

Zoom to location you want in Layer Detail view, then click Set Thumbnail button. It will use map extent.

gubuntu commented 5 years ago

this isn't difficult and we have some thumbnails that were done correctly. In any case the current implementation is all over the place.

it shouldn't need GEOS or projection libraries

  1. use the 3857 bbox of the layer (which is global in meters)
  2. which is greater, h or w? a. if bbox h is greater, match that to the fixed height of the div as your image height parameter a. if bbox w is greater, match that to the fixed width of the div as your image width parameter
  3. use the aspect ratio of the bbox to solve for the missing image dimension.
  4. centre the image horizontally and vertically in the div without stretching it to fit

you should be able to specify just width or height and let the WMS figure the other one out based on the aspect ratio of the bbox but QGIS fails if you don't supply both.

boney-bun commented 5 years ago

even the geoserver's thumbnail seems to be squashed for the non-square extent as in the OP.

let me try @gubuntu's suggestion on my machine first.

lucernae commented 5 years ago

Ok, the key is here @boney-bun

  1. use the 3857 bbox of the layer (which is global in meters)

Just operate using 3857 when doing the scaling calculation. If this is in meters, then we're done. The original GeoNode image ratio is 200x150 pixel.

Just scale the new bbox using that ratios

gubuntu commented 5 years ago

our GeoNode QGIS server is now using the standard GeoNode div for thumbnails