benducke / Network-reconstruction-tools-for-GRASS-GIS

Node-based network model generator for GRASS GIS 7.x (and QGIS 3.x)
GNU General Public License v3.0
4 stars 1 forks source link

v.net.models: Improve performance of node:links consistency checks for option 'initial=' #64

Open benducke opened 1 month ago

benducke commented 1 month ago

Currently, using 'initial=' is not much of a time saver, since the consistency check this triggers takes more time than computing a complete model!

The code to blame is in function check_input() and part of the "initial links map" checks:

if [ -n "${GIS_OPT_INITIAL}" ] ; then
...
fiif [ -n "${GIS_OPT_INITIAL}" ] ; then
...
fi

Following this comment:

# 3. Check that INITIAL AND INPUT links/nodes MATCH. The aim is to prevent users from

... there are three loops that each iterate over all features in the nodes and links input maps.

Replacing all calls to v.db.select with db.select her should make these 4-5 times faster!

In addition, users should be allowed to skip these checks, as they are not strictly required.

The way to handle this properly is already implemented in v.net.stats (same function: check_inpu), which needs to check these two maps for consistency, too.