Skip to content

Commit

Permalink
feat: drop shapely dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Jul 29, 2024
1 parent f6cdb5c commit 91ac0da
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions ORStools/gui/ORStoolsDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"""

import json
import math
import os
from typing import Optional

Expand Down Expand Up @@ -60,7 +61,6 @@
QDialogButtonBox,
QWidget,
)
from shapely import Point

from ORStools import (
RESOURCE_PREFIX,
Expand Down Expand Up @@ -605,16 +605,21 @@ def change_cursor_on_hover(self, pos):
QApplication.restoreOverrideCursor()

def check_annotation_hover(self, pos):
click = Point(pos.x(), pos.y())
click = [pos.x(), pos.y()]
dists = {}
for i, anno in enumerate(self.annotations):
x, y = anno.mapPosition()
mapcanvas = self._iface.mapCanvas()
point = mapcanvas.getCoordinateTransform().transform(x, y) # die ist es
p = Point(point.x(), point.y())
dist = click.distance(p)
if dist > 0:
dists[dist] = anno
p = [point.x(), point.y()]

distance = 0.0
for i in range(len(click)):
distance += (click[i] - p[i]) ** 2
distance = math.sqrt(distance)

if distance > 0:
dists[distance] = anno
if dists and min(dists) < self.click_dist:
idx = dists[min(dists)]
return idx
Expand Down

0 comments on commit 91ac0da

Please sign in to comment.