Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/commands/match.ts
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ async function matchLines(outFile, params, lines, flags) {
matcher.searchRadius = flags['search-radius'];

matcher.snapIntersections = flags['snap-intersections'];
matcher.snapIntersectionsRadius = flags['snap-intersections-radius'];

var matchedLines:turfHelpers.Feature<turfHelpers.LineString>[] = [];
var unmatchedLines:turfHelpers.Feature<turfHelpers.LineString>[] = [];
Expand Down
13 changes: 7 additions & 6 deletions src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ export class Graph {
// options
searchRadius = DEFAULT_SEARCH_RADIUS;
snapIntersections = false;
snapIntersectionsRadius = DEFAULT_SEARCH_RADIUS;
useHMM = true;
useDirect = true;
includeStreetnames = true;
Expand Down Expand Up @@ -1011,20 +1012,20 @@ export class Graph {
var segment = bestPathCandidate.segments[i];

// adding fudge factor for decimal precision issues
if(segment.section[0] < segment.section[1] + this.searchRadius && segment.section[1] <= segment.referenceLength + this.searchRadius && segment.section[0] + this.searchRadius >= 0) {
if(segment.section[0] < segment.section[1] + this.snapIntersectionsRadius && segment.section[1] <= segment.referenceLength + this.searchRadius && segment.section[0] + this.snapIntersectionsRadius >= 0) {

if(this.snapIntersections && (totalPathLength > this.searchRadius)) {
if(this.snapIntersections && (totalPathLength > this.snapIntersectionsRadius)) {

if(i == 0 && segment.referenceLength - segment.section[0] < this.searchRadius)
if(i == 0 && segment.referenceLength - segment.section[0] < this.snapIntersectionsRadius)
continue;

if(i == 0 && segment.section[0] < this.searchRadius)
if(i == 0 && segment.section[0] < this.snapIntersectionsRadius)
segment.section[0] = 0;

if(i == bestPathCandidate.segments.length -1 && segment.section[1] < this.searchRadius)
if(i == bestPathCandidate.segments.length -1 && segment.section[1] < this.snapIntersectionsRadius)
continue;

if(i == bestPathCandidate.segments.length -1 && segment.referenceLength - segment.section[1] < this.searchRadius)
if(i == bestPathCandidate.segments.length -1 && segment.referenceLength - segment.section[1] < this.snapIntersectionsRadius)
segment.section[1] = segment.referenceLength;

if( i > 0 && i < bestPathCandidate.segments.length -1) {
Expand Down