Skip to content
Permalink
Browse files

[processing] snap points to network by default (fix #19904)

Kudos to Pedro Venâncio for finding solution for this bug
  • Loading branch information
alexbruy committed Jan 31, 2019
1 parent c3819e8 commit 3abea3600024c4d329403e7462a47af4db503339
@@ -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,22 +30,22 @@

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
)
)

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 @@

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):

0 comments on commit 3abea36

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