geosolutions-it/geonode

Implement new thumbnail creation service

Closed this issue · 8 comments

The current creation of thumbnails for layers and maps is quite a mess, and the following points are especially problematic:

  • there are multiple implementations of thumbnail rendering of layers. At least the following two are implemented:
  • both layer_thumbnail and map_thumbnail use the pritng Geoserver module for the actaul rendering. This module is stale and quite a black box. Probably this code reflects the module that we're bundling inside the Geoserver build for GeoNode
  • the creation of the thumbnail for a map apparently takes different paths in case the thumbnail is generated from the Django template pages or from the "Save" action inside the GeoNode MapStore client. Different thumbnails (different zoom level and positioning) are generated for the two cases

We want to move away from the pritng module and implement the rendering inside a cleaner backend Python module, with a clear and unqiue interface that will be adopted by any client method. This module could become the basis for the replacement of the printing module too.

This module will be in charge of:

  • receiving a configuration for the map to be rendered (list of layers, bbox, dimensions, etc.)
  • generating the requests (WM(T)S, TMS) to obtain the images for each layer
  • composing the final rendered image

Notice that part of the heavy work (calculation of tiles, URL for tile requests, etc.) is already done on the Python side.

Several helper libraries already exist for Python for composiion of images, ranging from general purpose like Pillow to domain centric as Mapnik.
The backend lib will be selected after having clarified the detaild of the requirements.

@simboss please add any comment to the desciprion above. More details will be added after the invetigation from @bieganowski will be completed.

@ElenaGallo the mechanism underlying the creation of the thumbnails have been rewritten from scratch. We need to test it (on master demo) thoroughly, all over the places and situations where thumbnails are being created / updated:

  • creation of new resources, in particular layers and maps
  • update of thumbnail from the metadata wizard form
  • update of thumbnail through Edit -> (thumbnail) Set
  • update of thumbnail through Edit -> (thumbnail) Upload

In case expand the tests spreadsheets.

@afabiani should we also test it for the importlayers and updatelayers commands?

@giohappy I updated the spreadsheet with the new tests done on the thumbs and the following tests fail:

1_ Opening the metadata wizard, the thumbnail options are not displayed correctly for a moment
thumb1

How to Reproduce

  • Login as admin
  • Click on Data > Layers
  • Select a layer > Click on Editing Tools
  • Click on Wizard under column Metadata

Current Result
The thumbnail options are not displayed correctly for a moment

2_ By saving the map, for the first time, it should be possible to upload a thumb
(as it already happens with stories)
thumb2

How to Reproduce

  • Login as admin
  • Click on Maps > Create Map
  • From Options menu select Catalog > Add a layer
  • From Options menu select Save as
  • Insert a thumbnails and a Name
  • Click on Save as
  • Go back to Maps list

Current Result
The new saved map does not have the thumb loaded

@ElenaGallo the first glitch is not related to this work.
@bieganowski please check the second one.

ok, the issue is there and in fact is quite simple - the logic inherited from the original implementation expects a thumbnail name to have .png extension. Loading any other file format, even with overwrite=False (as in the case of Maps creation), causes regeneration of the thumbnail, since the generation script doesn't recognize the thumbnail.

edit: Issue is more complicated than initially expected - a race occurs between passed thumbnail storing and async thumbnail generation. Most likely due to the order of functions called in django-mapstore-adapter

@bieganowski what about the upload done from the resource edit window's "Upload" button? Does it follow a different path?

image

@giohappy indeed, this one does not use mapstore at all, it targets upload_thumbnail endpoint from geonode.base app, so it does not trigger thumbnail creation at all

issue created in the upstrem: GeoNode#7114