Skip to content

Commit a9daaff

Browse files
committed
wirk with other projections #17
1 parent ff7276c commit a9daaff

File tree

4 files changed

+73
-38
lines changed

4 files changed

+73
-38
lines changed

code/Geo360.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ def unload(self):
8383
# Close server
8484
self.close_server()
8585

86-
def is_running(self):
87-
return self.server_thread and self.server_thread.is_alive()
86+
# def is_running(self):
87+
# return self.server_thread and self.server_thread.is_alive()
8888

8989
def close_server(self):
9090
"""Close Local server"""
@@ -118,15 +118,12 @@ def make_server(self):
118118
print("Serving at port: %s" % self.server.server_address[1])
119119
time.sleep(1)
120120
self.server_thread.start()
121-
# while self.server_thread.is_alive():
122-
# print ("isRunning")
123121
except Exception:
124122
print("Server Error")
125123

126124
def run(self):
127125
"""Run click feature"""
128126
self.found = False
129-
130127
# Check if mapa foto is loaded
131128
lys = self.canvas.layers()
132129
for layer in lys:
@@ -204,6 +201,6 @@ def canvasReleaseEvent(self, event):
204201

205202
layer = found_features[0].mLayer
206203
feature = found_features[0].mFeature
207-
204+
# Zoom To Feature
208205
qgsutils.zoomToFeature(self.canvas, layer, feature.id())
209206
self.parent.ShowViewer(featuresId=feature.id(), layer=layer)

code/Geo360Dialog.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def __init__(self, iface, parent=None, featuresId=None, layer=None):
115115
u"Information: ", u"There is no associated image."
116116
)
117117
self.resetQgsRubberBand()
118-
# time.sleep(1)
119118
self.ChangeUrlViewer(self.DEFAULT_EMPTY)
120119
return
121120

@@ -341,7 +340,13 @@ def setOrientation(self, yaw=None):
341340
"""Set Orientation in the firt time"""
342341
self.bearing = self.selected_features.attribute(config.column_yaw)
343342

344-
self.actualPointDx = self.selected_features.geometry().asPoint()
343+
originalPoint = self.selected_features.geometry().asPoint()
344+
self.actualPointDx = qgsutils.convertProjection(
345+
originalPoint.x(),
346+
originalPoint.y(),
347+
self.layer.crs().authid(),
348+
self.canvas.mapSettings().destinationCrs().authid(),
349+
)
345350

346351
self.actualPointOrientation = QgsRubberBand(
347352
self.iface.mapCanvas(), QgsWkbTypes.LineGeometry
@@ -376,7 +381,14 @@ def setOrientation(self, yaw=None):
376381

377382
def setPosition(self):
378383
"""Set RubberBand Position"""
379-
self.actualPointDx = self.selected_features.geometry().asPoint()
384+
# Transform Point
385+
originalPoint = self.selected_features.geometry().asPoint()
386+
self.actualPointDx = qgsutils.convertProjection(
387+
originalPoint.x(),
388+
originalPoint.y(),
389+
"EPSG:4326",
390+
self.canvas.mapSettings().destinationCrs().authid(),
391+
)
380392

381393
self.positionDx = QgsRubberBand(
382394
self.iface.mapCanvas(), QgsWkbTypes.PointGeometry

code/gui/resources_rc.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@
6767
\xc5\x95\x03\xe8\x2a\xc1\x01\x7b\x25\x38\xe8\x2c\x95\x52\x1f\xfb\
6868
\xfa\x69\x77\x3f\x63\x18\xbb\xce\x9b\x64\x57\x00\x00\x00\x00\x49\
6969
\x45\x4e\x44\xae\x42\x60\x82\
70+
\x00\x00\x01\x12\
71+
\x89\
72+
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
73+
\x00\x00\x20\x00\x00\x00\x20\x08\x03\x00\x00\x00\x44\xa4\x8a\xc6\
74+
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
75+
\x01\x00\x9a\x9c\x18\x00\x00\x00\x36\x50\x4c\x54\x45\x47\x70\x4c\
76+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
77+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
78+
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
79+
\x00\x00\x00\xc0\x47\x62\xd5\x00\x00\x00\x11\x74\x52\x4e\x53\x00\
80+
\x2a\xfd\x05\x16\x11\x38\x34\x50\x1b\x7a\x23\x64\xfa\x4b\x99\x61\
81+
\x99\x3a\xdb\x42\x00\x00\x00\x65\x49\x44\x41\x54\x38\xcb\xed\x93\
82+
\x3b\x12\x80\x20\x0c\x44\x17\x01\x21\xfc\x34\xf7\xbf\xac\x64\x2c\
83+
\xc5\x54\x42\xe5\x6b\x77\x27\x93\xe2\x2d\x30\x1f\xb3\x0b\x7e\x94\
84+
\x84\x4e\x46\x65\x21\x3d\x73\xbf\x49\x50\xc1\xa7\xeb\xd8\xc1\x05\
85+
\x47\x44\x85\xc1\x51\x7b\x20\x2e\x29\x24\xd2\x0a\x94\xf0\xf3\x99\
86+
\x51\x56\x4b\xad\xc1\xd6\xb4\x42\xab\x4b\x84\x29\xdd\x4d\x52\xa4\
87+
\xbd\xb5\x3f\xde\xb5\xcf\x32\x8f\xa0\x0c\x67\x3e\x17\xef\x4b\x04\
88+
\xdc\x58\x70\x72\xb7\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
89+
\x82\
7090
\x00\x00\x01\x94\
7191
\x89\
7292
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
@@ -95,26 +115,6 @@
95115
\xa0\x44\x38\xe6\xaf\x8d\x5a\x01\x76\x4e\x84\x1d\xf0\xb1\xdf\xe4\
96116
\x23\x37\x85\xba\xaa\x94\xb2\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
97117
\x42\x60\x82\
98-
\x00\x00\x01\x12\
99-
\x89\
100-
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
101-
\x00\x00\x20\x00\x00\x00\x20\x08\x03\x00\x00\x00\x44\xa4\x8a\xc6\
102-
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
103-
\x01\x00\x9a\x9c\x18\x00\x00\x00\x36\x50\x4c\x54\x45\x47\x70\x4c\
104-
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
105-
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
106-
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
107-
\x00\x00\x00\xc0\x47\x62\xd5\x00\x00\x00\x11\x74\x52\x4e\x53\x00\
108-
\x2a\xfd\x05\x16\x11\x38\x34\x50\x1b\x7a\x23\x64\xfa\x4b\x99\x61\
109-
\x99\x3a\xdb\x42\x00\x00\x00\x65\x49\x44\x41\x54\x38\xcb\xed\x93\
110-
\x3b\x12\x80\x20\x0c\x44\x17\x01\x21\xfc\x34\xf7\xbf\xac\x64\x2c\
111-
\xc5\x54\x42\xe5\x6b\x77\x27\x93\xe2\x2d\x30\x1f\xb3\x0b\x7e\x94\
112-
\x84\x4e\x46\x65\x21\x3d\x73\xbf\x49\x50\xc1\xa7\xeb\xd8\xc1\x05\
113-
\x47\x44\x85\xc1\x51\x7b\x20\x2e\x29\x24\xd2\x0a\x94\xf0\xf3\x99\
114-
\x51\x56\x4b\xad\xc1\xd6\xb4\x42\xab\x4b\x84\x29\xdd\x4d\x52\xa4\
115-
\xbd\xb5\x3f\xde\xb5\xcf\x32\x8f\xa0\x0c\x67\x3e\x17\xef\x4b\x04\
116-
\xdc\x58\x70\x72\xb7\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
117-
\x82\
118118
"
119119

120120
qt_resource_name = b"\
@@ -136,14 +136,14 @@
136136
\x00\x9e\x33\x47\
137137
\x00\x4e\
138138
\x00\x65\x00\x78\x00\x74\x00\x5f\x00\x41\x00\x72\x00\x72\x00\x6f\x00\x77\x00\x2e\x00\x70\x00\x6e\x00\x67\
139-
\x00\x08\
140-
\x0a\x61\x5a\xa7\
141-
\x00\x69\
142-
\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
143139
\x00\x0f\
144140
\x0e\x0d\xd5\x47\
145141
\x00\x66\
146142
\x00\x75\x00\x6c\x00\x6c\x00\x5f\x00\x73\x00\x63\x00\x72\x00\x65\x00\x65\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
143+
\x00\x08\
144+
\x0a\x61\x5a\xa7\
145+
\x00\x69\
146+
\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
147147
"
148148

149149
qt_resource_struct_v1 = b"\
@@ -152,8 +152,8 @@
152152
\x00\x00\x00\x30\x00\x02\x00\x00\x00\x04\x00\x00\x00\x03\
153153
\x00\x00\x00\x6c\x00\x00\x00\x00\x00\x01\x00\x00\x01\xb1\
154154
\x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
155+
\x00\x00\x00\xb2\x00\x00\x00\x00\x00\x01\x00\x00\x04\x73\
155156
\x00\x00\x00\x8e\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5d\
156-
\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x01\x00\x00\x04\xf5\
157157
"
158158

159159
qt_resource_struct_v2 = b"\
@@ -167,9 +167,9 @@
167167
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
168168
\x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
169169
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
170-
\x00\x00\x00\x8e\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5d\
170+
\x00\x00\x00\xb2\x00\x00\x00\x00\x00\x01\x00\x00\x04\x73\
171171
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
172-
\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x01\x00\x00\x04\xf5\
172+
\x00\x00\x00\x8e\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5d\
173173
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
174174
"
175175

code/utils/qgsutils.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
from qgis.core import Qgis as QGis
88
from qgis.gui import QgsRubberBand
99
from qgis.utils import iface
10-
10+
from qgis.core import (
11+
QgsPointXY,
12+
QgsProject,
13+
QgsCoordinateReferenceSystem,
14+
QgsCoordinateTransform,
15+
QgsRectangle,
16+
)
1117
from EquirectangularViewer.utils.log import log
1218

1319
try:
@@ -17,6 +23,15 @@
1723

1824

1925
class qgsutils(object):
26+
@staticmethod
27+
def convertProjection(x, y, from_crs, to_crs):
28+
"""Convert Coordinates EPSG"""
29+
crsSrc = QgsCoordinateReferenceSystem(from_crs)
30+
crsDest = QgsCoordinateReferenceSystem(to_crs)
31+
xform = QgsCoordinateTransform(crsSrc, crsDest, QgsProject.instance())
32+
pt = xform.transform(QgsPointXY(x, y))
33+
return pt
34+
2035
@staticmethod
2136
def getAttributeFromFeature(feature, columnName):
2237
"""Get Attribute from feature"""
@@ -28,7 +43,18 @@ def zoomToFeature(canvas, layer, ide):
2843
if layer:
2944
for feature in layer.getFeatures():
3045
if feature.id() == ide:
31-
canvas.setExtent(feature.geometry().boundingBox())
46+
# Transform Point
47+
actualPoint = feature.geometry().asPoint()
48+
projPoint = qgsutils.convertProjection(
49+
actualPoint.x(),
50+
actualPoint.y(),
51+
layer.crs().authid(),
52+
canvas.mapSettings().destinationCrs().authid(),
53+
)
54+
x = projPoint.x()
55+
y = projPoint.y()
56+
rect = QgsRectangle(x, y, x, y)
57+
canvas.setExtent(rect)
3258
canvas.refresh()
3359
return True
3460
return False

0 commit comments

Comments
 (0)