Guest User

Untitled

a guest
Jul 30th, 2025
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1.  
  2. Component.onCompleted: {
  3. iface.addItemToPluginsToolbar(pluginButton)
  4.  
  5. pointHandler.registerHandler("species_plugin", (point, type, interactionType) => {
  6. if (interactionType === "clicked") {
  7. let tl = mapCanvas.mapSettings.screenToCoordinate(Qt.point(point.x - 4, point.y - 4))
  8. let br = mapCanvas.mapSettings.screenToCoordinate(Qt.point(point.x + 4, point.y + 4))
  9.  
  10. let expression = "intersects(geom_from_wkt('POLYGON(("+tl.x+" "+tl.y+", "+br.x+" "+tl.y+", "+br.x+" "+br.y+", "+tl.x+" "+br.y+", "+tl.x+" "+tl.y+"))'), $geometry)"
  11. let it = LayerUtils.createFeatureIteratorFromExpression(qgisProject.mapLayersByName("plots")[0], expression)
  12. if (it.hasNext()) {
  13. const feature = it.next()
  14. console.log(feature.id)
  15. }
  16. }
  17. return false;
  18. });
  19. }
  20.  
  21. Component.onDestruction: {
  22. pointHandler.deregisterHandler("species_plugin");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment