Skip to content

Commit dfe55ef

Browse files
authored
Add edge code and snap points to the closest node in network (#166)
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
1 parent 0b2f3e6 commit dfe55ef

File tree

6 files changed

+578
-28
lines changed

6 files changed

+578
-28
lines changed

include/pops/config.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class Config
7373
std::string anthro_direction;
7474
double network_min_distance{0};
7575
double network_max_distance{0};
76+
bool network_snap{false}; ///< Snap resulting location to closest node in network
7677
double anthro_kappa{0};
7778
double shape{1.0};
7879
// Treatments

0 commit comments

Comments
 (0)