[QGIS-Developer] Storing a copy of map canvas extent in QgsProject (for server)

Nyall Dawson nyall.dawson at gmail.com
Thu Nov 12 19:37:35 PST 2020


On Thu, 12 Nov 2020 at 23:53, Alessandro Pasotti <apasotti at gmail.com> wrote:
>
> Hi,
>
> The new landing page server core API module makes use of the canvas
> extent to determine the initial extent of the map being shown in the
> web gis viewer.
>
> If I'm not mistaken, that value is only available in map canvas and
> it's not available in the server context. My current workaround mimics
> what happens in the desktop when QgsProject::readProject is emitted.
>
> This prevents me from using the server's config (project) cache and
> results in an unnecessary additional project read when the server
> landing page API is accessed for the first time.
>
> I was thinking of storing that value directly in QgsProject instances
> as "initialExtent()" by reading it from the "mapcanvas" xml tag, I'm
> not super-happy with that because that would be a duplication but I
> cannot see another way to access that information without re-reading
> the project.
>
> Any idea or comment before I proceed?

I'm in favour. I think there's other good use cases for this too -
e.g. giving a stable api for qfield/input to open projects at the
correct map extents.

Can you put the new settings in QgsProjectViewSettings? That's the
ideal place for things like this to reside...

Nyall


More information about the QGIS-Developer mailing list