Skip to content

Commit

Permalink
Add edge code and snap points to the closest node in network (#166)
Browse files Browse the repository at this point in the history
Optionally, instead of ending in somewhere in the segment, the network travel ends at the start or end node
of a segment (whichever is the closest).

To support the snapping based on distance, each segment now has explicit total cost (distance), so Segment and SegmentView need to be classes, not just a using. The generic classes are called edge geometry and edge geometry view.

Having the total cost (distance) for segment available allows the travel function to not iterate over a segment when its cost
is lower than the remaining distance (cost) to travel (spend).

This contains only the changes in the network itself and it add an item to the config. The kernel does not know about snapping (it doesn't need to).

* Segment cost as a property to set and as a total or per cell
* References for readability instead of pair members in node matrix creation
* Read CSV header to determine cost column presence
* Add test for edge-variable cost (failing for now)
* Advance to next node even when loop continues sooner (fix)
* Use only half of start and end cell when counting cost for a segment
* Use index to move within segment (changes results)
* Methods to get last, first, nth element
* Compute cell from distance in segment
* Ensure that segment has at least two cells
* Add snap to config
* Test segment (geometry) and view directly, make them separate classes
  • Loading branch information
wenzeslaus committed Apr 4, 2022
1 parent 0b2f3e6 commit dfe55ef
Show file tree
Hide file tree
Showing 6 changed files with 578 additions and 28 deletions.
1 change: 1 addition & 0 deletions include/pops/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class Config
std::string anthro_direction;
double network_min_distance{0};
double network_max_distance{0};
bool network_snap{false}; ///< Snap resulting location to closest node in network
double anthro_kappa{0};
double shape{1.0};
// Treatments
Expand Down
Loading

0 comments on commit dfe55ef

Please sign in to comment.