Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 3abea36
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions python/plugins/processing/algs/grass7/ext/v_net.py
Expand Up @@ -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
Expand Down
Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/algs/grass7/ext/v_net_distance.py
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/processing/algs/grass7/ext/v_net_flow.py
Expand Up @@ -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,
Expand All @@ -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):
Expand Down

0 comments on commit 3abea36

Please sign in to comment.