Skip to content
Permalink
Browse files

Transparently reproject source points in algs

  • Loading branch information
nyalldawson committed Sep 24, 2017
1 parent e1eef7e commit 6efcc2fe8617599bda2fd6c18ba1ec120bf18275
@@ -35,6 +35,7 @@
QgsUnitTypes,
QgsFeature,
QgsFeatureSink,
QgsFeatureRequest,
QgsGeometry,
QgsFields,
QgsField,
@@ -163,7 +163,7 @@ def displayName(self):

def processAlgorithm(self, parameters, context, feedback):
network = self.parameterAsSource(parameters, self.INPUT, context)
startPoint = self.parameterAsPoint(parameters, self.START_POINT, context)
startPoint = self.parameterAsPoint(parameters, self.START_POINT, context, network.sourceCrs())
strategy = self.parameterAsEnum(parameters, self.STRATEGY, context)
travelCost = self.parameterAsDouble(parameters, self.TRAVEL_COST, context)

@@ -34,6 +34,7 @@
from qgis.core import (QgsWkbTypes,
QgsUnitTypes,
QgsFeature,
QgsFeatureRequest,
QgsFeatureSink,
QgsGeometry,
QgsFields,
@@ -158,7 +159,7 @@ def displayName(self):
def processAlgorithm(self, parameters, context, feedback):
network = self.parameterAsSource(parameters, self.INPUT, context)
startPoints = self.parameterAsSource(parameters, self.START_POINTS, context)
endPoint = self.parameterAsPoint(parameters, self.END_POINT, context)
endPoint = self.parameterAsPoint(parameters, self.END_POINT, context, network.sourceCrs())
strategy = self.parameterAsEnum(parameters, self.STRATEGY, context)

directionFieldName = self.parameterAsString(parameters, self.DIRECTION_FIELD, context)
@@ -157,7 +157,7 @@ def displayName(self):

def processAlgorithm(self, parameters, context, feedback):
network = self.parameterAsSource(parameters, self.INPUT, context)
startPoint = self.parameterAsPoint(parameters, self.START_POINT, context)
startPoint = self.parameterAsPoint(parameters, self.START_POINT, context, network.sourceCrs())
endPoints = self.parameterAsSource(parameters, self.END_POINTS, context)
strategy = self.parameterAsEnum(parameters, self.STRATEGY, context)

@@ -160,8 +160,8 @@ def displayName(self):

def processAlgorithm(self, parameters, context, feedback):
network = self.parameterAsSource(parameters, self.INPUT, context)
startPoint = self.parameterAsPoint(parameters, self.START_POINT, context)
endPoint = self.parameterAsPoint(parameters, self.END_POINT, context)
startPoint = self.parameterAsPoint(parameters, self.START_POINT, context, network.sourceCrs())
endPoint = self.parameterAsPoint(parameters, self.END_POINT, context, network.sourceCrs())
strategy = self.parameterAsEnum(parameters, self.STRATEGY, context)

directionFieldName = self.parameterAsString(parameters, self.DIRECTION_FIELD, context)
@@ -28,6 +28,9 @@

import os

from qgis.core import (QgsProject,
QgsReferencedPointXY,
QgsPointXY)
from qgis.PyQt import uic

from qgis.utils import iface
@@ -48,6 +51,7 @@ def __init__(self, dialog, default=None):
self.btnSelect.clicked.connect(self.selectOnCanvas)

self.dialog = dialog
self.crs = QgsProject.instance().crs()

if iface is not None:
canvas = iface.mapCanvas()
@@ -76,6 +80,7 @@ def selectOnCanvas(self):

def updatePoint(self, point, button):
s = '{},{}'.format(point.x(), point.y())
self.crs = QgsProject.instance().crs()

self.leText.setText(s)
canvas = iface.mapCanvas()
@@ -86,7 +91,15 @@ def updatePoint(self, point, button):

def getValue(self):
if str(self.leText.text()).strip() != '':
return str(self.leText.text())
try:
parts = self.leText.text().split(',')
parts = [float(p) for p in parts]
r = QgsReferencedPointXY(QgsPointXY(parts[0], parts[1]),
self.crs)
return r

except:
return str(self.leText.text())
else:
return None

0 comments on commit 6efcc2f

Please sign in to comment.
You can’t perform that action at this time.