Add the very end of processing, v.net.models spends a lot of time updating statistics and storing them in the attribute table of the nodes output map. These statistics are commonly useful, but they needlessly add to computing times when generating experimental models. This, it would be better to move this functionality into v.net.stats.
The affected code is in a loop toward the very end of the script:;
g.message -i "Writing output nodes map:"
# Start looping through nodes by user-defined key
get_primary_keys "${GIS_OPT_NODES}"
step=1 # For progress reporting
for key in ${PRIMARY_KEYS} ; do
...
done
The current code has some deficiencies that would be easy to fix:
There is a special case (at the very top of the loop) for model type 'attsim', but the metric computed for this case seems to be the same as that being computed for the general case ('let num_links=${from_links}+${to_links}'), immediately below.
Conversely, the generic case for computing the number of incoming and outgoing links per node is a bit wasteful: Instead of counting both separately, using separate SELECT statements, their combined total could be counted with using OR in SQL clause.
The subnet statistics, consisting of variables 'subnet_nodes', 'subnet_links', 'subnet_len' and 'subnet_cost' are never used. It is questionable whether any of them are useful, because (a) they are seem to be superseded by other stats (that do actually get written into attribute fields), and (b) they get reset to '0' before the main loop starts, i.e. they are in fact global counters(?).
Implementation in v.net.stats:
Add '-n'ode statistics flag.
Create necessary fields if they are missing.
If the fields are already present: throw error, if type is wrong.
Compute statistics and upload them into attribute table of 'nodes=' map (layer 1).
Add the very end of processing, v.net.models spends a lot of time updating statistics and storing them in the attribute table of the nodes output map. These statistics are commonly useful, but they needlessly add to computing times when generating experimental models. This, it would be better to move this functionality into v.net.stats.
The affected code is in a loop toward the very end of the script:;
The current code has some deficiencies that would be easy to fix:
Implementation in v.net.stats: