From 1127605cb71e21117b11cf129ebb830470ea6ac9 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 18:57:21 -0700 Subject: [PATCH 1/9] Auto-loop fix from Dan via Discord. Signed-off-by: Jim Mattson --- processGPX | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/processGPX b/processGPX index f1c3007..d6b7d10 100755 --- a/processGPX +++ b/processGPX @@ -4978,7 +4978,7 @@ for my $file ( @files ) { # - # autoLoop: automatically detrmine if -loop should be invoked + # autoLoop: automatically determine if -loop should be invoked # $autoLoop //= $auto; if ( $autoLoop ) { @@ -4988,9 +4988,15 @@ for my $file ( @files ) { (! defined $cropMax) && (latlngDistance($points->[0], $points->[-1]) < 150) && (@$points > 3) && - (latlngDotProduct($points->[-2], $points->[-1], $points->[0], $points->[1]) > -0.1) + (latlngDotProduct($points->[-2], $points->[-1], $points->[-1], $points->[0]) > -0.1) && + ( + (latlngDotProduct($points->[-2], $points->[-1], $points->[-1], $points->[0]) > -0.1) || + (latlngDotProduct($points->[-2], $points->[-1], $points->[-1], $points->[1]) > -0.1) || + (latlngDotProduct($points->[-2], $points->[0], $points->[0], $points->[1]) > -0.1) || + (latlngDotProduct($points->[-1], $points->[0], $points->[0], $points->[1]) > -0.1) + ) ) { - $isLoop = 1; + $isLoop //= 1; $copyPoint = 0; note("setting -loop\n"); } From e9e3d698e098f7c1a33936463f27a699048bd585 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Tue, 26 Aug 2025 16:22:24 -0700 Subject: [PATCH 2/9] Fix variable scoping error in post-smoothing spline processing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove erroneous 'my' declaration that was shadowing the existing $points variable, preventing the spline processing result from being properly passed to subsequent operations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Co-Authored-By: Jim Mattson --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index d6b7d10..e63274e 100755 --- a/processGPX +++ b/processGPX @@ -5610,7 +5610,7 @@ for my $file ( @files ) { # spline again post-smoothing, if requested if ( ($splineRadians > 0) && (($lSmooth > 1) || ($zSmooth > 0)) ) { note("corner splines, post-smoothing...\n"); - my $points = addSplines(points=> $points, minRadians=> $splineRadians, maxRadians=> $splineMaxRadians, isLoop=> $isLoop, splineType=> "spline", start=> $splineStart, end=> $splineEnd); + $points = addSplines(points=> $points, minRadians=> $splineRadians, maxRadians=> $splineMaxRadians, isLoop=> $isLoop, splineType=> "spline", start=> $splineStart, end=> $splineEnd); } if ( ($arcFitRadians > 0) && (($lSmooth > 1) || ($zSmooth > 0)) ) { From 7d428a5a154d1799a01939411008729caefcf21c Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Fri, 5 Sep 2025 09:10:23 -0700 Subject: [PATCH 3/9] Fix variable name error in doAutoSpacing function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed incorrect variable $i1 to $i2 in modulo operation for loop index handling. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Co-Authored-By: Jim Mattson --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index e63274e..1211713 100755 --- a/processGPX +++ b/processGPX @@ -1606,7 +1606,7 @@ sub doAutoSpacing { $i2 ++; next iLoop if (((! $isLoop) && ($i2 > $#$points)) || ($i2 == $i)); - $i1 %= scalar(@$points); + $i2 %= scalar(@$points); } # determine the angle between the points my $a = latlngAngle($points->[$i1], $points->[$i], $points->[$i2]); From f9efa0ee4446a7bcea857297aa7badd6d16c2b6c Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 07:09:57 -0700 Subject: [PATCH 4/9] Fix variable reference spacing in makeLoop function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove space in "$ sdir" variable reference. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Co-Authored-By: Jim Mattson --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index 1211713..523a461 100755 --- a/processGPX +++ b/processGPX @@ -3910,7 +3910,7 @@ sub makeLoop { # also calculate distance for my $i ( 0 .. $#xs ) { $ys[$i] += $shear * $xs[$i]; - my $x = $ sdir * $xs[$i] + $cdir * $ys[$i]; + my $x = $sdir * $xs[$i] + $cdir * $ys[$i]; my $y = -$cdir * $xs[$i] + $sdir * $ys[$i]; $xs[$i] = $x; $ys[$i] = $y; From 54811f634bcff863f6c317663f3fb0637eb824c7 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 09:17:28 -0700 Subject: [PATCH 5/9] Fix incorrect filehandle reference in join operation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed cut-and-paste error where $fin filehandle was being closed instead of $fjoin when processing joined files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Jim Mattson Co-Authored-By: Claude --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index 523a461..7c87bdb 100755 --- a/processGPX +++ b/processGPX @@ -4918,7 +4918,7 @@ for my $file ( @files ) { $xml2 = <$fjoin>; $/ = $tmp; } - close $fin; + close $fjoin; # Parse GPX from open file my $gpx2 = Geo::Gpx->new( xml => $xml2 ); From c8cda346de07b90e4711334483a2f14b98095e57 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 12:25:57 -0700 Subject: [PATCH 6/9] Fix incorrect hash reference syntax in removeDuplicatePoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed `push @pNew, \%$p;` to `push @pNew, $p;` since $p is already a hash reference. The original syntax was attempting to take a reference to a dereferenced hash. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Jim Mattson Co-Authored-By: Claude --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index 7c87bdb..501fd99 100755 --- a/processGPX +++ b/processGPX @@ -672,7 +672,7 @@ sub removeDuplicatePoints { } if ($i1 == $i) { - push @pNew, \%$p; + push @pNew, $p; } else { # if this is the first point removed, then clean out derived fields From 2452ffa24720710795c6d7ec0e3e74d0d10ce283 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 12:26:23 -0700 Subject: [PATCH 7/9] Fix typo in circuitFromPosition error message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changed "non-poisitive" to "non-positive" in the error message for invalid repeats parameter. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Jim Mattson Co-Authored-By: Claude --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index 501fd99..9c67a98 100755 --- a/processGPX +++ b/processGPX @@ -3236,7 +3236,7 @@ sub circuitFromPosition { $repeats = int($repeats); if ($repeats <= 0) { - warn("CircuitFromPosition called with non-poisitive repeats -- ignoring option.\n"); + warn("CircuitFromPosition called with non-positive repeats -- ignoring option.\n"); return $points; } From 53eace44ebd4ce5c1c3cf20582d4d7bcc82ed832 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 12:46:55 -0700 Subject: [PATCH 8/9] Fix missing loop label in addSplines function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added missing 'iLoop' label to 'next' statement for consistency with other control flow statements in the function. This ensures the next statement affects the correct loop level. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Jim Mattson Co-Authored-By: Claude --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index 9c67a98..76fc2bc 100755 --- a/processGPX +++ b/processGPX @@ -1039,7 +1039,7 @@ sub addSplines { if ($isLoop) { next iLoop if ( ($l <= $j) && ($l >= $k) ); } else { - next if ($l <= $j); + next iLoop if ($l <= $j); } # turn angles From 1b0daefe9a4d6c5c8e28b39e6610da90f6e93422 Mon Sep 17 00:00:00 2001 From: Jim Mattson Date: Sat, 6 Sep 2025 12:49:29 -0700 Subject: [PATCH 9/9] Fix incorrect variable assignment in autoStraighten function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the line segment optimization logic, when shortening from the beginning of the segment, the code should update $i (start index) not $j (end index). Changed $j = $k to $i = $k to match the intended logic of moving the start point forward. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Jim Mattson Co-Authored-By: Claude --- processGPX | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processGPX b/processGPX index 76fc2bc..beba423 100755 --- a/processGPX +++ b/processGPX @@ -3189,7 +3189,7 @@ sub autoStraighten { if ((my $L2 = latlngDistance($points->[$k % @$points], $points->[$j % @$points])) > $minLength) { my ($avg2, $max2, $rms2) = calcDeviationStats( $points, $k, $j ); if ($rms2 * $L < $rms * $L2) { - $j = $k; + $i = $k; $L = $L2; $avg = $avg2; $max = $max2;