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

Trigger cost-based mode if "cost" attribute is present in map loaded via "initial=" #18

Closed benducke closed 3 years ago

benducke commented 3 years ago

Throughout the code, constructs like this one:

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

... are used to decide whether an operation should be done in cost-based mode instead of Euclidean mode.

Currently, GIS_OPT_COSTMAP is only checked and set on program initialization, when the CLI parameters are parsed. We also need a way to trigger cost-based mode whenever a precomputed links map is given via "initial=", and it contains a valid "cost" field!

The implementation plan for this is already in the source code (ca. line 3514, in main program block):

# TODO: TRIGGER COST-BASED MODE HERE IF "COST" ATTRIBUTE IS PRESENT!
# TODO: 1. Check for presence and type of field "cost".
# TODO: 2. Content completeness of field "cost" must be checker earlier: in check_input!
# TODO  3. "cost" field and contents must be generated adhoc, if it does not exist but "costmap=" is specified!
# TODO: 4. Set global var "COST_MODE" to "TRUE" if appropriate.
# TODO: 5. Only model_complete() must ever read $GIS_OPT_COSTMAP!   
# TODO:    All other tests for $GIS_OPT_COSTMAP must be replaced with $COST_MODE
# TODO: 6. model_complete() must also set COST_MODE as required!
benducke commented 3 years ago

Done. But needs testing now.