Skip to content

Commit

Permalink
fix: correct setting of center coordinate
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Feb 13, 2024
1 parent fd02394 commit 1c199b4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,12 @@ def option_chosen(name, lineEdit):
lineEdit.setText("")

e = self._iface.mapCanvas().extent()
lat = e.xMinimum() + (e.yMaximum() - e.xMinimum()) / 2
sourceCrs = QgsCoordinateReferenceSystem(3857)
destCrs = QgsCoordinateReferenceSystem(4326)
lat = e.yMinimum() + (e.yMaximum() - e.yMinimum()) / 2
lon = e.xMinimum() + (e.xMaximum() - e.xMinimum()) / 2
sourceCrs = self._iface.mapCanvas().mapSettings().destinationCrs()
destCrs = QgsCoordinateReferenceSystem.fromEpsgId(4326)
tr = QgsCoordinateTransform(sourceCrs, destCrs, QgsProject.instance())
middle = tr.transform(QgsPointXY(0, lat))
middle = tr.transform(QgsPointXY(lon, lat))

url = f"https://api.openrouteservice.org/geocode/autocomplete?api_key={api_key}&text={lineEdit.text()}&sources=geonames&focus.point.lat={middle.y()}&focus.point.lon={middle.x()}"
request = QgsBlockingNetworkRequest()
Expand Down Expand Up @@ -685,7 +686,7 @@ def _reindex_list_items(self):
]
self.routing_fromline_list.clear()
self._clear_annotations()
crs = QgsCoordinateReferenceSystem("EPSG:4326")
crs = QgsCoordinateReferenceSystem.fromEpsgId("EPSG:4326")
for idx, x in enumerate(items):
coords = x.split(":")[1]
item = f"Point {idx}:{coords}"
Expand Down

0 comments on commit 1c199b4

Please sign in to comment.