Skip to content

Commit

Permalink
wirk with other projections #17
Browse files Browse the repository at this point in the history
  • Loading branch information
All4Gis committed Jul 16, 2021
1 parent ff7276c commit a9daaff
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 38 deletions.
9 changes: 3 additions & 6 deletions code/Geo360.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def unload(self):
# Close server
self.close_server()

def is_running(self):
return self.server_thread and self.server_thread.is_alive()
# def is_running(self):
# return self.server_thread and self.server_thread.is_alive()

def close_server(self):
"""Close Local server"""
Expand Down Expand Up @@ -118,15 +118,12 @@ def make_server(self):
print("Serving at port: %s" % self.server.server_address[1])
time.sleep(1)
self.server_thread.start()
# while self.server_thread.is_alive():
# print ("isRunning")
except Exception:
print("Server Error")

def run(self):
"""Run click feature"""
self.found = False

# Check if mapa foto is loaded
lys = self.canvas.layers()
for layer in lys:
Expand Down Expand Up @@ -204,6 +201,6 @@ def canvasReleaseEvent(self, event):

layer = found_features[0].mLayer
feature = found_features[0].mFeature

# Zoom To Feature
qgsutils.zoomToFeature(self.canvas, layer, feature.id())
self.parent.ShowViewer(featuresId=feature.id(), layer=layer)
18 changes: 15 additions & 3 deletions code/Geo360Dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ def __init__(self, iface, parent=None, featuresId=None, layer=None):
u"Information: ", u"There is no associated image."
)
self.resetQgsRubberBand()
# time.sleep(1)
self.ChangeUrlViewer(self.DEFAULT_EMPTY)
return

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

self.actualPointDx = self.selected_features.geometry().asPoint()
originalPoint = self.selected_features.geometry().asPoint()
self.actualPointDx = qgsutils.convertProjection(
originalPoint.x(),
originalPoint.y(),
self.layer.crs().authid(),
self.canvas.mapSettings().destinationCrs().authid(),
)

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

def setPosition(self):
"""Set RubberBand Position"""
self.actualPointDx = self.selected_features.geometry().asPoint()
# Transform Point
originalPoint = self.selected_features.geometry().asPoint()
self.actualPointDx = qgsutils.convertProjection(
originalPoint.x(),
originalPoint.y(),
"EPSG:4326",
self.canvas.mapSettings().destinationCrs().authid(),
)

self.positionDx = QgsRubberBand(
self.iface.mapCanvas(), QgsWkbTypes.PointGeometry
Expand Down
54 changes: 27 additions & 27 deletions code/gui/resources_rc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,26 @@
\xc5\x95\x03\xe8\x2a\xc1\x01\x7b\x25\x38\xe8\x2c\x95\x52\x1f\xfb\
\xfa\x69\x77\x3f\x63\x18\xbb\xce\x9b\x64\x57\x00\x00\x00\x00\x49\
\x45\x4e\x44\xae\x42\x60\x82\
\x00\x00\x01\x12\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x03\x00\x00\x00\x44\xa4\x8a\xc6\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x00\x36\x50\x4c\x54\x45\x47\x70\x4c\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\xc0\x47\x62\xd5\x00\x00\x00\x11\x74\x52\x4e\x53\x00\
\x2a\xfd\x05\x16\x11\x38\x34\x50\x1b\x7a\x23\x64\xfa\x4b\x99\x61\
\x99\x3a\xdb\x42\x00\x00\x00\x65\x49\x44\x41\x54\x38\xcb\xed\x93\
\x3b\x12\x80\x20\x0c\x44\x17\x01\x21\xfc\x34\xf7\xbf\xac\x64\x2c\
\xc5\x54\x42\xe5\x6b\x77\x27\x93\xe2\x2d\x30\x1f\xb3\x0b\x7e\x94\
\x84\x4e\x46\x65\x21\x3d\x73\xbf\x49\x50\xc1\xa7\xeb\xd8\xc1\x05\
\x47\x44\x85\xc1\x51\x7b\x20\x2e\x29\x24\xd2\x0a\x94\xf0\xf3\x99\
\x51\x56\x4b\xad\xc1\xd6\xb4\x42\xab\x4b\x84\x29\xdd\x4d\x52\xa4\
\xbd\xb5\x3f\xde\xb5\xcf\x32\x8f\xa0\x0c\x67\x3e\x17\xef\x4b\x04\
\xdc\x58\x70\x72\xb7\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
\x00\x00\x01\x94\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
Expand Down Expand Up @@ -95,26 +115,6 @@
\xa0\x44\x38\xe6\xaf\x8d\x5a\x01\x76\x4e\x84\x1d\xf0\xb1\xdf\xe4\
\x23\x37\x85\xba\xaa\x94\xb2\x00\x00\x00\x00\x49\x45\x4e\x44\xae\
\x42\x60\x82\
\x00\x00\x01\x12\
\x89\
\x50\x4e\x47\x0d\x0a\x1a\x0a\x00\x00\x00\x0d\x49\x48\x44\x52\x00\
\x00\x00\x20\x00\x00\x00\x20\x08\x03\x00\x00\x00\x44\xa4\x8a\xc6\
\x00\x00\x00\x09\x70\x48\x59\x73\x00\x00\x0b\x13\x00\x00\x0b\x13\
\x01\x00\x9a\x9c\x18\x00\x00\x00\x36\x50\x4c\x54\x45\x47\x70\x4c\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\
\x00\x00\x00\xc0\x47\x62\xd5\x00\x00\x00\x11\x74\x52\x4e\x53\x00\
\x2a\xfd\x05\x16\x11\x38\x34\x50\x1b\x7a\x23\x64\xfa\x4b\x99\x61\
\x99\x3a\xdb\x42\x00\x00\x00\x65\x49\x44\x41\x54\x38\xcb\xed\x93\
\x3b\x12\x80\x20\x0c\x44\x17\x01\x21\xfc\x34\xf7\xbf\xac\x64\x2c\
\xc5\x54\x42\xe5\x6b\x77\x27\x93\xe2\x2d\x30\x1f\xb3\x0b\x7e\x94\
\x84\x4e\x46\x65\x21\x3d\x73\xbf\x49\x50\xc1\xa7\xeb\xd8\xc1\x05\
\x47\x44\x85\xc1\x51\x7b\x20\x2e\x29\x24\xd2\x0a\x94\xf0\xf3\x99\
\x51\x56\x4b\xad\xc1\xd6\xb4\x42\xab\x4b\x84\x29\xdd\x4d\x52\xa4\
\xbd\xb5\x3f\xde\xb5\xcf\x32\x8f\xa0\x0c\x67\x3e\x17\xef\x4b\x04\
\xdc\x58\x70\x72\xb7\x00\x00\x00\x00\x49\x45\x4e\x44\xae\x42\x60\
\x82\
"

qt_resource_name = b"\
Expand All @@ -136,14 +136,14 @@
\x00\x9e\x33\x47\
\x00\x4e\
\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\
\x00\x08\
\x0a\x61\x5a\xa7\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
\x00\x0f\
\x0e\x0d\xd5\x47\
\x00\x66\
\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\
\x00\x08\
\x0a\x61\x5a\xa7\
\x00\x69\
\x00\x63\x00\x6f\x00\x6e\x00\x2e\x00\x70\x00\x6e\x00\x67\
"

qt_resource_struct_v1 = b"\
Expand All @@ -152,8 +152,8 @@
\x00\x00\x00\x30\x00\x02\x00\x00\x00\x04\x00\x00\x00\x03\
\x00\x00\x00\x6c\x00\x00\x00\x00\x00\x01\x00\x00\x01\xb1\
\x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x00\xb2\x00\x00\x00\x00\x00\x01\x00\x00\x04\x73\
\x00\x00\x00\x8e\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5d\
\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x01\x00\x00\x04\xf5\
"

qt_resource_struct_v2 = b"\
Expand All @@ -167,9 +167,9 @@
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
\x00\x00\x00\x42\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
\x00\x00\x00\x8e\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5d\
\x00\x00\x00\xb2\x00\x00\x00\x00\x00\x01\x00\x00\x04\x73\
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
\x00\x00\x00\xa4\x00\x00\x00\x00\x00\x01\x00\x00\x04\xf5\
\x00\x00\x00\x8e\x00\x00\x00\x00\x00\x01\x00\x00\x03\x5d\
\x00\x00\x01\x7a\x7a\x92\xe5\xb0\
"

Expand Down
30 changes: 28 additions & 2 deletions code/utils/qgsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@
from qgis.core import Qgis as QGis
from qgis.gui import QgsRubberBand
from qgis.utils import iface

from qgis.core import (
QgsPointXY,
QgsProject,
QgsCoordinateReferenceSystem,
QgsCoordinateTransform,
QgsRectangle,
)
from EquirectangularViewer.utils.log import log

try:
Expand All @@ -17,6 +23,15 @@


class qgsutils(object):
@staticmethod
def convertProjection(x, y, from_crs, to_crs):
"""Convert Coordinates EPSG"""
crsSrc = QgsCoordinateReferenceSystem(from_crs)
crsDest = QgsCoordinateReferenceSystem(to_crs)
xform = QgsCoordinateTransform(crsSrc, crsDest, QgsProject.instance())
pt = xform.transform(QgsPointXY(x, y))
return pt

@staticmethod
def getAttributeFromFeature(feature, columnName):
"""Get Attribute from feature"""
Expand All @@ -28,7 +43,18 @@ def zoomToFeature(canvas, layer, ide):
if layer:
for feature in layer.getFeatures():
if feature.id() == ide:
canvas.setExtent(feature.geometry().boundingBox())
# Transform Point
actualPoint = feature.geometry().asPoint()
projPoint = qgsutils.convertProjection(
actualPoint.x(),
actualPoint.y(),
layer.crs().authid(),
canvas.mapSettings().destinationCrs().authid(),
)
x = projPoint.x()
y = projPoint.y()
rect = QgsRectangle(x, y, x, y)
canvas.setExtent(rect)
canvas.refresh()
return True
return False
Expand Down

0 comments on commit a9daaff

Please sign in to comment.