From bb9c64b38ee1c317f93cad8c7b407b94eecbc791 Mon Sep 17 00:00:00 2001 From: btheado Date: Sun, 28 Jul 2024 08:44:09 -0400 Subject: [PATCH] Fix olc-decode and geopoint latitude and longitude order in the geospatial plugin (#8437) * Reverse latitude and longitude in olc-decode tests to match proper geojson output format * Reverse latitude and longitude in olc-decode to match proper geojson output format * Reverse latitude and longitude in geopoint expected results to match proper geojson format * Reverse latitude and longitude in geolookup expected results to match proper geojson format * Corrected the Oxford to New York distances * Oxford is actually 12 miles closer to New York than Winchester Used calculator at https://www.nhc.noaa.gov/gccalc.shtml to check Reversed latitude and longitude to correct the geojson * Reversed the latitude and longitude turf.point arguments in the geopoint function * Swapped latitude and longitude in geopoint function calls --- .../tiddlers/real-estate-demo/schema.json | 4 ++-- editions/geospatialdemo/tiddlers/ui/geomarker.tid | 6 +++--- plugins/tiddlywiki/geospatial/operators/helper.js | 2 +- plugins/tiddlywiki/geospatial/operators/olc.js | 12 ++++++------ .../geospatial/tests/operators/geodistance.tid | 2 +- .../geospatial/tests/operators/geolookup.tid | 6 +++--- .../geospatial/tests/operators/geonearestpoint.tid | 4 ++-- .../geospatial/tests/operators/geonearestpoint2.tid | 6 +++--- .../geospatial/tests/operators/geopoint.tid | 2 +- .../geospatial/tests/operators/olc-decode.tid | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/editions/geospatialdemo/tiddlers/real-estate-demo/schema.json b/editions/geospatialdemo/tiddlers/real-estate-demo/schema.json index e7decf5a1..31cca45b4 100644 --- a/editions/geospatialdemo/tiddlers/real-estate-demo/schema.json +++ b/editions/geospatialdemo/tiddlers/real-estate-demo/schema.json @@ -16,7 +16,7 @@ {"name": "nearest-volcano", "caption": "Nearest Volcano", "type": "string", "display": "[{$:/geospatialdemo/features/harvard-volcanoes-of-the-world}geonearestpoint]"} ], "variables": { - "coords": "[] :map[geopoint{!!long},{!!lat}]", - "census-data": "[] :map[geopoint{!!long},{!!lat}geolookup{$:/geospatialdemo/features/canada-census-subdivision-millesime}]" + "coords": "[] :map[geopoint{!!lat},{!!long}]", + "census-data": "[] :map[geopoint{!!lat},{!!long}geolookup{$:/geospatialdemo/features/canada-census-subdivision-millesime}]" } } diff --git a/editions/geospatialdemo/tiddlers/ui/geomarker.tid b/editions/geospatialdemo/tiddlers/ui/geomarker.tid index cf561c704..89e9fd950 100644 --- a/editions/geospatialdemo/tiddlers/ui/geomarker.tid +++ b/editions/geospatialdemo/tiddlers/ui/geomarker.tid @@ -73,7 +73,7 @@ title: ui/geomarker !! Distance to other markers <$let - thisLocation={{{ [geopoint{!!long},{!!lat}] }}} + thisLocation={{{ [geopoint{!!lat},{!!long}] }}} >
    <$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoMarker]sort[caption]] -[]"> @@ -81,7 +81,7 @@ title: ui/geomarker <$link><$view field="caption"><$view field="title"/> -- <$let - otherLocation={{{ [geopoint{!!long},{!!lat}] }}} + otherLocation={{{ [geopoint{!!lat},{!!long}] }}} > <$text text={{{ [geodistance,,[miles]fixed[0]] }}}/> miles @@ -93,7 +93,7 @@ title: ui/geomarker !! GeoFeature Lookups <$let - thisLocation={{{ [geopoint{!!long},{!!lat}] }}} + thisLocation={{{ [geopoint{!!lat},{!!long}] }}} >
      <$list filter="[all[shadows+tiddlers]tag[$:/tags/GeoFeature]sort[caption]]"> diff --git a/plugins/tiddlywiki/geospatial/operators/helper.js b/plugins/tiddlywiki/geospatial/operators/helper.js index 744632414..164b1dc86 100644 --- a/plugins/tiddlywiki/geospatial/operators/helper.js +++ b/plugins/tiddlywiki/geospatial/operators/helper.js @@ -18,7 +18,7 @@ exports.geopoint = function(source,operator,options) { var lat = $tw.utils.parseNumber(operator.operands[0] || "0"), long = $tw.utils.parseNumber(operator.operands[1] || "0"), alt = $tw.utils.parseNumber(operator.operands[2] || "0"); - return [JSON.stringify(turf.point([lat,long,alt]))]; + return [JSON.stringify(turf.point([long,lat,alt]))]; }; })(); diff --git a/plugins/tiddlywiki/geospatial/operators/olc.js b/plugins/tiddlywiki/geospatial/operators/olc.js index 93962572f..ee8c34fa5 100644 --- a/plugins/tiddlywiki/geospatial/operators/olc.js +++ b/plugins/tiddlywiki/geospatial/operators/olc.js @@ -27,14 +27,14 @@ exports["olc-decode"] = function(source,operator,options) { obj; if(suffixes.indexOf("bounds") !== -1) { obj = turf.polygon([[ - [olc.latitudeLo, olc.longitudeLo], - [olc.latitudeHi, olc.longitudeLo], - [olc.latitudeHi, olc.longitudeHi], - [olc.latitudeLo, olc.longitudeHi], - [olc.latitudeLo, olc.longitudeLo] + [olc.longitudeLo, olc.latitudeLo], + [olc.longitudeLo, olc.latitudeHi], + [olc.longitudeHi, olc.latitudeHi], + [olc.longitudeHi, olc.latitudeLo], + [olc.longitudeLo, olc.latitudeLo] ]]); } else { - obj = turf.point([olc.latitudeCenter,olc.longitudeCenter]); + obj = turf.point([olc.longitudeCenter,olc.latitudeCenter]); } return [JSON.stringify(obj)]; }; diff --git a/plugins/tiddlywiki/geospatial/tests/operators/geodistance.tid b/plugins/tiddlywiki/geospatial/tests/operators/geodistance.tid index 5ce1f9a50..75d1e9259 100644 --- a/plugins/tiddlywiki/geospatial/tests/operators/geodistance.tid +++ b/plugins/tiddlywiki/geospatial/tests/operators/geodistance.tid @@ -27,4 +27,4 @@ title: Output + title: ExpectedResult -

      5042.67688063485,5042.67688063485,8115.401781788412,72.89828683394038,1.2738016908387275,5042.67688063485

      \ No newline at end of file +

      3406.2115173004354,3406.2115173004354,5481.766068098352,49.241105484826875,0.8604235593111019,3406.2115173004354

      \ No newline at end of file diff --git a/plugins/tiddlywiki/geospatial/tests/operators/geolookup.tid b/plugins/tiddlywiki/geospatial/tests/operators/geolookup.tid index 0a3f709fd..b363a48a2 100644 --- a/plugins/tiddlywiki/geospatial/tests/operators/geolookup.tid +++ b/plugins/tiddlywiki/geospatial/tests/operators/geolookup.tid @@ -22,7 +22,7 @@ type: application/json "type": "Feature", "geometry": { "type": "Point", - "coordinates": [102.0,0.5] + "coordinates": [0.5,102.0] }, "properties": { "animal": "amoeba" @@ -33,7 +33,7 @@ type: application/json "geometry": { "type": "LineString", "coordinates": [ - [102.0,0.0],[103.0,1.0],[104.0,0.0],[105.0,1.0] + [0.0,102.0],[1.0,103.0],[0.0,104.0],[1.0,105.0] ] }, "properties": { @@ -46,7 +46,7 @@ type: application/json "geometry": { "type": "Polygon", "coordinates": [ - [[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]] + [[0.0,100.0],[0.0,101.0],[1.0,101.0],[1.0,100.0],[0.0,100.0]] ] }, "properties": { diff --git a/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint.tid b/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint.tid index e5ada0162..08fc3e023 100644 --- a/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint.tid +++ b/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint.tid @@ -17,7 +17,7 @@ title: Output > <$text text={{{ =[] =[] +[geonearestpointjsonget[id]] }}}/>, -<$text text={{{ =[] =[[Not a point]] +[geonearestpointjsonget[id]] }}}/>, +<$text text={{{ =[] =[[Not a point]] +[geonearestpointjsonget[id]] }}}/>, <$text text={{{ =[[Not a point]] +[geonearestpointjsonget[id]] }}}/> @@ -25,4 +25,4 @@ title: Output + title: ExpectedResult -

      Winchester,Oxford,

      \ No newline at end of file +

      Oxford,Winchester,

      \ No newline at end of file diff --git a/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint2.tid b/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint2.tid index ef20e830b..9cb509ad0 100644 --- a/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint2.tid +++ b/plugins/tiddlywiki/geospatial/tests/operators/geonearestpoint2.tid @@ -22,14 +22,14 @@ title: Output "id": "Oxford", "geometry": { "type": "Point", - "coordinates": [51.751944, -1.257778] + "coordinates": [-1.257778, 51.751944] } },{ "type": "Feature", "id": "Winchester", "geometry": { "type": "Point", - "coordinates": [51.0632, -1.308] + "coordinates": [-1.308, 51.0632] } } ] @@ -42,4 +42,4 @@ title: Output + title: ExpectedResult -

      Winchester

      \ No newline at end of file +

      Oxford

      \ No newline at end of file diff --git a/plugins/tiddlywiki/geospatial/tests/operators/geopoint.tid b/plugins/tiddlywiki/geospatial/tests/operators/geopoint.tid index 1aa00c238..a4096e3c4 100644 --- a/plugins/tiddlywiki/geospatial/tests/operators/geopoint.tid +++ b/plugins/tiddlywiki/geospatial/tests/operators/geopoint.tid @@ -18,4 +18,4 @@ title: Output + title: ExpectedResult -{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[51.751944,-1.257778,0]}}{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[51.751944,-1.257778,0]},"id":"Oxford"}{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[51.751944,-1.257778,2]}} \ No newline at end of file +{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-1.257778,51.751944,0]}}{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-1.257778,51.751944,0]},"id":"Oxford"}{"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-1.257778,51.751944,2]}} \ No newline at end of file diff --git a/plugins/tiddlywiki/geospatial/tests/operators/olc-decode.tid b/plugins/tiddlywiki/geospatial/tests/operators/olc-decode.tid index 7d2d4c027..c13c60855 100644 --- a/plugins/tiddlywiki/geospatial/tests/operators/olc-decode.tid +++ b/plugins/tiddlywiki/geospatial/tests/operators/olc-decode.tid @@ -15,6 +15,6 @@ title: Output + title: ExpectedResult -

      ({"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[51.751875,-1.257875],[51.752,-1.257875],[51.752,-1.25775],[51.751875,-1.25775],[51.751875,-1.257875]]]}}) -({"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[51.7519375,-1.257765625]}}) +

      ({"type":"Feature","properties":{},"geometry":{"type":"Polygon","coordinates":[[[-1.257875,51.751875],[-1.257875,51.752],[-1.25775,51.752],[-1.25775,51.751875],[-1.257875,51.751875]]]}}) +({"type":"Feature","properties":{},"geometry":{"type":"Point","coordinates":[-1.257765625,51.7519375]}})

      \ No newline at end of file