mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
[processing] snap points to network by default (fix #19904)
Kudos to Pedro Venâncio for finding solution for this bug
This commit is contained in:
parent
c3819e88dc
commit
3abea36000
@ -58,12 +58,12 @@ def incorporatePoints(alg, parameters, context, feedback, pointLayerName='points
|
||||
threshold = alg.parameterAsDouble(parameters, 'threshold', context)
|
||||
|
||||
# Create the v.net connect command for point layer integration
|
||||
command = u"v.net input={} points={} output={} operation=connect threshold={}".format(
|
||||
command = 'v.net -s input={} points={} output={} operation=connect threshold={}'.format(
|
||||
lineLayer, pointLayer, intLayer, threshold)
|
||||
alg.commands.append(command)
|
||||
|
||||
# Connect the point layer database to the layer 2 of the network
|
||||
command = u"v.db.connect -o map={} table={} layer=2".format(intLayer, pointLayer)
|
||||
command = 'v.db.connect -o map={} table={} layer=2'.format(intLayer, pointLayer)
|
||||
alg.commands.append(command)
|
||||
|
||||
# remove undesired parameters
|
||||
|
@ -30,14 +30,14 @@ from .v_net import incorporatePoints, variableOutput
|
||||
|
||||
def checkParameterValuesBeforeExecuting(alg, parameters, context):
|
||||
""" Verify if we have the right parameters """
|
||||
params = [u'where', u'cats']
|
||||
params = ['where', 'cats']
|
||||
values = []
|
||||
for param in params:
|
||||
for i in range(1, 3):
|
||||
values.append(
|
||||
alg.parameterAsString(
|
||||
parameters,
|
||||
u'set{}_{}'.format(i, param),
|
||||
'set{}_{}'.format(i, param),
|
||||
context
|
||||
)
|
||||
)
|
||||
@ -45,7 +45,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
|
||||
if (values[0] or values[2]) and (values[1] or values[3]):
|
||||
return True, None
|
||||
|
||||
return False, alg.tr("You need to set at least setX_where or setX_cats parameters for each set!")
|
||||
return False, alg.tr('You need to set at least setX_where or setX_cats parameters for each set!')
|
||||
|
||||
|
||||
def processCommand(alg, parameters, context, feedback):
|
||||
|
@ -48,20 +48,20 @@ def processCommand(alg, parameters, context, feedback):
|
||||
threshold = alg.parameterAsDouble(parameters, 'threshold', context)
|
||||
|
||||
# Create the v.net connect command for from_layer integration
|
||||
command = u"v.net input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=2".format(
|
||||
command = 'v.net -s input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=2'.format(
|
||||
lineLayer, fromLayer, intLayer, threshold)
|
||||
alg.commands.append(command)
|
||||
|
||||
# Do it again with to_layer
|
||||
command = u"v.net input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=3".format(
|
||||
command = 'v.net -s input={} points={} output={} operation=connect threshold={} arc_layer=1 node_layer=3'.format(
|
||||
intLayer, toLayer, netLayer, threshold)
|
||||
alg.commands.append(command)
|
||||
|
||||
# Connect the point layer database to the layer 2 of the network
|
||||
command = u"v.db.connect -o map={} table={} layer=2".format(netLayer, fromLayer)
|
||||
command = 'v.db.connect -o map={} table={} layer=2'.format(netLayer, fromLayer)
|
||||
alg.commands.append(command)
|
||||
|
||||
command = u"v.db.connect -o map={} table={} layer=3".format(netLayer, toLayer)
|
||||
command = 'v.db.connect -o map={} table={} layer=3'.format(netLayer, toLayer)
|
||||
alg.commands.append(command)
|
||||
|
||||
# remove undesired parameters
|
||||
|
@ -31,10 +31,10 @@ from .v_net import incorporatePoints, variableOutput
|
||||
|
||||
def checkParameterValuesBeforeExecuting(alg, parameters, context):
|
||||
""" Verify if we have the right parameters """
|
||||
params = [u'where', u'cats']
|
||||
params = ['where', 'cats']
|
||||
values = []
|
||||
for param in params:
|
||||
for i in [u'source', u'sink']:
|
||||
for i in ['source', 'sink']:
|
||||
values.append(
|
||||
alg.parameterAsString(
|
||||
parameters,
|
||||
@ -46,7 +46,7 @@ def checkParameterValuesBeforeExecuting(alg, parameters, context):
|
||||
if (values[0] or values[2]) and (values[1] or values[3]):
|
||||
return True, None
|
||||
|
||||
return False, alg.tr("You need to set at least source/sink_where or source/sink_cats parameters for each set!")
|
||||
return False, alg.tr('You need to set at least source/sink_where or source/sink_cats parameters for each set!')
|
||||
|
||||
|
||||
def processCommand(alg, parameters, context, feedback):
|
||||
|
Loading…
x
Reference in New Issue
Block a user