Skip to content

Commit 4dbf6dd

Browse files
committed
fix: points not draggable after 2010 error
1 parent bd7872b commit 4dbf6dd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ORStools/gui/ORStoolsDialog.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def _linetool_annotate_point(
600600
self, point: QgsPointXY, idx: int, crs: Optional[QgsCoordinateReferenceSystem] = None
601601
) -> QgsAnnotation:
602602
if not crs:
603-
crs = self.canvas.mapSettings().destinationCrs()
603+
crs = QgsProject.instance().crs()
604604

605605
annotation = QgsTextAnnotation()
606606

@@ -612,8 +612,8 @@ def _linetool_annotate_point(
612612

613613
annotation.setFrameSizeMm(QSizeF(8, 5))
614614
annotation.setFrameOffsetFromReferencePointMm(QPointF(1.3, 1.3))
615-
annotation.setMapPosition(point)
616615
annotation.setMapPositionCrs(crs)
616+
annotation.setMapPosition(point)
617617

618618
return QgsMapCanvasAnnotationItem(annotation, self.canvas).annotation()
619619

@@ -760,7 +760,9 @@ def _on_movetool_map_release(self, point, idx):
760760
self._clear_annotations()
761761
else:
762762
self.routing_fromline_list.takeItem(num)
763+
self._reindex_list_items()
763764
self.create_rubber_band()
765+
764766
QMessageBox.warning(
765767
self,
766768
"Please use a different point",
@@ -838,14 +840,17 @@ def _reindex_list_items(self) -> None:
838840
self.routing_fromline_list.clear()
839841
self._clear_annotations()
840842
crs = QgsCoordinateReferenceSystem(f"EPSG:{4326}")
843+
project_crs = self.canvas.mapSettings().destinationCrs()
841844
for idx, x in enumerate(items):
842845
coords = x.split(":")[1]
843846
item = f"Point {idx}:{coords}"
844847
x, y = (float(i) for i in coords.split(", "))
845848
point = QgsPointXY(x, y)
846849

847850
self.routing_fromline_list.addItem(item)
848-
annotation = self._linetool_annotate_point(point, idx, crs)
851+
transform = QgsCoordinateTransform(crs, project_crs, QgsProject.instance())
852+
point = transform.transform(point)
853+
annotation = self._linetool_annotate_point(point, idx)
849854
self.annotations.append(annotation)
850855
self.project.annotationManager().addAnnotation(annotation)
851856
self.create_rubber_band()

0 commit comments

Comments
 (0)