diff --git a/.github/workflows/_test.yml b/.github/workflows/_test.yml index 19ef195..605079d 100644 --- a/.github/workflows/_test.yml +++ b/.github/workflows/_test.yml @@ -7,9 +7,12 @@ jobs: matrix: os: - ubuntu-22.04 + - ubuntu-22.04-arm + - ubuntu-24.04 + - ubuntu-24.04-arm node-version: [ 20.x, 22.x, 24.x ] go-version: - - 1.16.x + - 1.16.x steps: - uses: actions/checkout@v4 - name: 'Install node.js ${{ matrix.node-version }}' diff --git a/build/pbf2json.darwin-arm64 b/build/pbf2json.darwin-arm64 index a62b1b5..a20becf 100755 Binary files a/build/pbf2json.darwin-arm64 and b/build/pbf2json.darwin-arm64 differ diff --git a/build/pbf2json.darwin-x64 b/build/pbf2json.darwin-x64 index 0cb7ed2..36b813e 100755 Binary files a/build/pbf2json.darwin-x64 and b/build/pbf2json.darwin-x64 differ diff --git a/build/pbf2json.linux-arm64 b/build/pbf2json.linux-arm64 index d4aa019..3417ab3 100755 Binary files a/build/pbf2json.linux-arm64 and b/build/pbf2json.linux-arm64 differ diff --git a/build/pbf2json.linux-x64 b/build/pbf2json.linux-x64 index 98d049e..497b011 100755 Binary files a/build/pbf2json.linux-x64 and b/build/pbf2json.linux-x64 differ diff --git a/build/pbf2json.win32-x64 b/build/pbf2json.win32-x64 index c917eb8..e5facc5 100755 Binary files a/build/pbf2json.win32-x64 and b/build/pbf2json.win32-x64 differ diff --git a/compile.sh b/compile.sh index a8063ef..110f214 100755 --- a/compile.sh +++ b/compile.sh @@ -74,4 +74,5 @@ assert $?; chmod +x pbf2json.exe; mv pbf2json.exe build/pbf2json.win32-x64; check 'build/pbf2json.win32-x64' 'PE32+ executable (console) x86-64'; -compress 'build/pbf2json.win32-x64'; +# UPX disabled for windows +# compress 'build/pbf2json.win32-x64'; diff --git a/pbf2json.go b/pbf2json.go index b06533c..a347611 100644 --- a/pbf2json.go +++ b/pbf2json.go @@ -729,5 +729,15 @@ func computeCentroidAndBounds(latlons []map[string]string) (map[string]string, * centroid["lat"] = strconv.FormatFloat(compute.Lat(), 'f', 7, 64) centroid["lon"] = strconv.FormatFloat(compute.Lng(), 'f', 7, 64) + // normalize negative zero + // note: this can occur for non-zero values such as -8.481315557654037e-18 + // and may vary across CPU architectures + if centroid["lat"] == "-0.0000000" { + centroid["lat"] = "0.0000000" + } + if centroid["lon"] == "-0.0000000" { + centroid["lon"] = "0.0000000" + } + return centroid, points.Bound() } diff --git a/test/end-to-end.js b/test/end-to-end.js index 8156c62..dba9026 100644 --- a/test/end-to-end.js +++ b/test/end-to-end.js @@ -71,10 +71,22 @@ var deepEqual = function(a, b) { if(Object.keys(a).length !== Object.keys(b).length){ return false; } for(var i in a) { if( !b.hasOwnProperty(i) ){ return false; } - if( deep.diff(a[i], b[i]) ){ return false; } + // centroid values vary slightly between CPU architecture + let prefilter; + if( a[i].hasOwnProperty('centroid') && b[i].hasOwnProperty('centroid') ) { + if (!equal(a[i].centroid.lat, b[i].centroid.lat, 1e-6)) { return false; } + if (!equal(a[i].centroid.lon, b[i].centroid.lon, 1e-6)) { return false; } + prefilter = (_path, key) => key === 'centroid'; // skip centroid field for the diff + } + if( deep.diff(a[i], b[i], prefilter) ){ return false; } } return true; }; +// ensure two numbers are equal within a threshold +function equal(a, b, delta = 0.0) { + return Math.abs(parseFloat(a) - parseFloat(b)) <= delta; +} + // run each test synchronously next();