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

Jorge Gustavo Rocha jgr at di.uminho.pt
Fri Nov 13 01:53:03 PST 2020


Hi,

(It is more a question, than a contribution).

We already have the extent available in the API, for people opening the
projects, with something like:

        project = QgsProject.instance()
        root = project.layerTreeRoot()
        canvas = QgsMapCanvas()
        bridge = QgsLayerTreeMapCanvasBridge(root, canvas)
        project.read(projectpath)
	e = canvas.extent()

If the user just wants to parse the project's xml, it is also there (the
extent and the extent's CRS).

I think Alessandro was asking for this in the server context, like make
it available in QgsServerProjectUtils.

Regards,

Jorge

Às 03:37 de 13/11/20, Nyall Dawson escreveu:
> 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
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> 

J. Gustavo
-- 
Jorge Gustavo Rocha
Departamento de Informática
Universidade do Minho
4710-057 Braga
Gabinete 3.29 (Piso 3)
Tel: +351 253604480
Fax: +351 253604471
Móvel: +351 910333888
skype: nabocudnosor


More information about the QGIS-Developer mailing list