[Qgis-developer] Bug in PAL labelling over the dateline
Marco Hugentobler
marco.hugentobler at sourcepole.ch
Wed Oct 6 07:50:51 EDT 2010
Hi Jeremy
Wouldn't it be easiest to, in pal.cpp, just ignore layers that are already
there instead of throwing an exception? And the same could be done for
features crossing the dateline in pal/layer.cpp:239
If the label initialisation would be done in QgsMapRenderer, it would be
necessary to change the layer interface to pass additional attribute indices
to fetch (e.g. necessary in case of data defined label settings).
Regards,
Marco
>Am Mittwoch, 6. Oktober 2010, um 08.03:58 schrieb Jeremy Palmer:
>Hi All,
>
>I've discovered a label rendering bug for geographic vectors layer when the
>mapcanvas bound spans the dateline. To replicate this do the following:
>
>1) Add a vector layer with a geographic coordinate system, preferably one
that already spans the dateline. I have attached a simple Shapefile.
>2) Enable PAL labelling on this layer.
>3) Turn on OTF projections. Make sure you use a coordinate system that will
>work for data over the dateline. I used EPSG:2193 for the attached Shapefile.
>4) Zoom to a projected extent that will ensure that layer will span +/- 180
>dateline.
>
>This should raise a generic exception that is caught by QGIS, which leaves
>the application in state that is not usable. This exception is actually a re-
>throw of PalException::LayerExists.
>
>At this stage I have debugged the application and determined this:
>
>* When otf transformed are enabled, layer is has a geographic coordinate
>system and the canvas extents span the dateline two separate render operation
>will be initiated by QgsMapRenderer. See lines 475-419 in qgsmaprenderer.cpp
>
>* Within the QgsMapRenderer::Render method the labelling engine is
>initialised, calls are made to the layer to draw the data, the labels are
>rendered and finally the labelling engine is cleaned up.
>
>* Within the layer draw method the labelling engine prepares the layer for
>labelling i.e rendererContext.labelingEngine()->prepareLayer(...). In the
>context of the PAL label engine this sets the layer up for label rendering
>and adds metadata about the layer to the PAL object. i.e. Pal::addLayer(...)
>
>* You can not add a duplicate layer to the PAL object otherwise it will throw
>a PalException::LayerExists exception. See line 186 of pal.cpp.
>
>From a simplistic point of view it seems to me that preparation of the label
>engine should occur within the QgsMapRenderer::Render method and not deeper
>down in the layer draw methods. I see that in the layer draw methods call the
>labelingEngine::prepareLayer() to determine if labelling is required and
>which fields are required for the data select. It seems that this information
>could be associated with the QgsRenderContext and set within
>QgsMapRenderer::Render() then and accessed within the layer draw.
>
>Can someone please comment on this?
>
>Thanks heaps,
>Jeremy
--
Dr. Marco Hugentobler
Sourcepole - Linux & Open Source Solutions
Webereistrasse 66, 8134 Adliswil, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee
More information about the Qgis-developer
mailing list