TransWikia.com

How to detect snapping event while editing layer in QGIS? (For custom topological control)

Geographic Information Systems Asked by Leon Powałka on February 20, 2021

QGIS 3.14 – plugin. I have a requirement to draw lines which must start and end snapped to point geometries of another layer. I need to be able to detect a vertex snap event while drawing linear geometries so I can know whether the line feature is snapped to a feature from the point layer and if it is then I need to have the id of the snapped feature.

I managed to create my own SnappingMapTool derived from QgsMapToolEmitPoint. My custom tool does exactly the logic I need – it detects a snap event and gives me the snapped layer and feature identifiers.

The problem is QGIS replaces my MapTool with its own whenever I start drawing geometries. How do I somehow access or override the snapping event while drawing geometries? I need to check if the edited/created lines have their ends snapped to a point layer.

How it works at the moment – you can see in the console when the MapTool gets replaced.
enter image description here

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP