From 05ca6921e8732242aca19691936d980bca5b2c04 Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:17:36 -0500 Subject: [PATCH 1/5] GeofenceGenerator: do not edit the feature when downloading Download dropped the closing point and rotated the rings of the feature itself, so a second download of the same water body used a different origin and gave a different file, and the popup point count dropped. Work on a copy of each ring. --- GeofenceGenerator/GeofenceGenerator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/GeofenceGenerator/GeofenceGenerator.js b/GeofenceGenerator/GeofenceGenerator.js index e1540436..14c9ac1e 100644 --- a/GeofenceGenerator/GeofenceGenerator.js +++ b/GeofenceGenerator/GeofenceGenerator.js @@ -230,7 +230,8 @@ async function generate_fence(feature, name) { // Convert to cartesian const cartesian = { x: new Array(len), y: new Array(len) } for (let i = 0; i Date: Sun, 22 Nov 2026 11:17:36 -0500 Subject: [PATCH 2/5] GeofenceGenerator: replace every slash in the file name String replace only changed the first / and the first \, so names with more than one still reached the file name. --- GeofenceGenerator/GeofenceGenerator.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GeofenceGenerator/GeofenceGenerator.js b/GeofenceGenerator/GeofenceGenerator.js index 14c9ac1e..4b328aee 100644 --- a/GeofenceGenerator/GeofenceGenerator.js +++ b/GeofenceGenerator/GeofenceGenerator.js @@ -260,8 +260,8 @@ async function generate_fence(feature, name) { // Save to file // sanitize name for use in file - name = name.replace('/', '_') - name = name.replace('\\', '_') + name = name.replaceAll('/', '_') + name = name.replaceAll('\\', '_') let text = 'QGC WPL 110\n' let points = 1 From ea313b7fef7a8e05dd9831012d7b58f41c005a85 Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:17:36 -0500 Subject: [PATCH 3/5] GeofenceGenerator: skip features that are not polygons when cropping turf.intersect throws on a LineString (an unclosed water way), which stopped the crop at that feature and left the later ones off the map. These features are never displayed, so skip them. --- GeofenceGenerator/GeofenceGenerator.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GeofenceGenerator/GeofenceGenerator.js b/GeofenceGenerator/GeofenceGenerator.js index 4b328aee..bd99eca1 100644 --- a/GeofenceGenerator/GeofenceGenerator.js +++ b/GeofenceGenerator/GeofenceGenerator.js @@ -154,6 +154,10 @@ function apply_crop() { // Apply to all features const crop_JSON = crop_polygon.toGeoJSON() for (const feature of features) { + if ((feature.geometry.type != "Polygon") && (feature.geometry.type != "MultiPolygon")) { + // Only polygons can be cropped, the others are not displayed + continue + } const cropped = turf.intersect(feature, crop_JSON) if (cropped != null) { cropped.id = feature.id, From 5eeb8d486548dbafe2ae103e22da8a8db150df57 Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:17:36 -0500 Subject: [PATCH 4/5] GeofenceGenerator: clear the features when starting a search The map was cleared at the start of a search but the features were not, so after a failed search Crop brought the previous results back. --- GeofenceGenerator/GeofenceGenerator.js | 1 + 1 file changed, 1 insertion(+) diff --git a/GeofenceGenerator/GeofenceGenerator.js b/GeofenceGenerator/GeofenceGenerator.js index bd99eca1..a8546f5f 100644 --- a/GeofenceGenerator/GeofenceGenerator.js +++ b/GeofenceGenerator/GeofenceGenerator.js @@ -25,6 +25,7 @@ async function request() { polygons[i].remove() } polygons = [] + features = [] // Remove crop polygon and enable button its button if (crop_polygon != null) { From e7f7ab66f0a726de51ba14b4321bf233dc757c0d Mon Sep 17 00:00:00 2001 From: j-w9 <295470691+j-w9@users.noreply.github.com> Date: Sun, 22 Nov 2026 11:17:36 -0500 Subject: [PATCH 5/5] GeofenceGenerator: wrap_180 below -180 JS remainder keeps the sign of the dividend, so angles below -180 were not wrapped (-270 stayed -270). This is reached by longitude differences across the antimeridian. --- GeofenceGenerator/GeofenceGenerator.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/GeofenceGenerator/GeofenceGenerator.js b/GeofenceGenerator/GeofenceGenerator.js index a8546f5f..79e4cbfd 100644 --- a/GeofenceGenerator/GeofenceGenerator.js +++ b/GeofenceGenerator/GeofenceGenerator.js @@ -301,7 +301,12 @@ async function generate_fence(feature, name) { } function wrap_180(angle) { - return ((angle + 180) % 360) - 180; + // JS remainder keeps the sign of the dividend, so shift negative results up + let wrapped = (angle + 180) % 360 + if (wrapped < 0) { + wrapped += 360 + } + return wrapped - 180; } function longitude_scale(lat) {