Skip to content

Commit

Permalink
fix: points not draggable after 2010 error
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Nov 12, 2024
1 parent bd7872b commit 4dbf6dd
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ def _linetool_annotate_point(
self, point: QgsPointXY, idx: int, crs: Optional[QgsCoordinateReferenceSystem] = None
) -> QgsAnnotation:
if not crs:
crs = self.canvas.mapSettings().destinationCrs()
crs = QgsProject.instance().crs()

annotation = QgsTextAnnotation()

Expand All @@ -612,8 +612,8 @@ def _linetool_annotate_point(

annotation.setFrameSizeMm(QSizeF(8, 5))
annotation.setFrameOffsetFromReferencePointMm(QPointF(1.3, 1.3))
annotation.setMapPosition(point)
annotation.setMapPositionCrs(crs)
annotation.setMapPosition(point)

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

Expand Down Expand Up @@ -760,7 +760,9 @@ def _on_movetool_map_release(self, point, idx):
self._clear_annotations()
else:
self.routing_fromline_list.takeItem(num)
self._reindex_list_items()
self.create_rubber_band()

QMessageBox.warning(
self,
"Please use a different point",
Expand Down Expand Up @@ -838,14 +840,17 @@ def _reindex_list_items(self) -> None:
self.routing_fromline_list.clear()
self._clear_annotations()
crs = QgsCoordinateReferenceSystem(f"EPSG:{4326}")
project_crs = self.canvas.mapSettings().destinationCrs()
for idx, x in enumerate(items):
coords = x.split(":")[1]
item = f"Point {idx}:{coords}"
x, y = (float(i) for i in coords.split(", "))
point = QgsPointXY(x, y)

self.routing_fromline_list.addItem(item)
annotation = self._linetool_annotate_point(point, idx, crs)
transform = QgsCoordinateTransform(crs, project_crs, QgsProject.instance())
point = transform.transform(point)
annotation = self._linetool_annotate_point(point, idx)
self.annotations.append(annotation)
self.project.annotationManager().addAnnotation(annotation)
self.create_rubber_band()
Expand Down

0 comments on commit 4dbf6dd

Please sign in to comment.