Skip to content
Draft
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
5 changes: 4 additions & 1 deletion .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ jobs:
matrix:
os:
- ubuntu-22.04
- ubuntu-22.04-arm

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, should we test on ARM everywhere? It's always nice to keep things consistent and who knows where other ARM bugs could be lurking.

- ubuntu-24.04
- ubuntu-24.04-arm
Comment on lines +11 to +12

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, for consistency, let's hold off on adding Ubuntu 24 in this PR, we can add it everywhere as part of testing and rolling out pelias/docker-baseimage#32.

It's much much easier to do Node.js and Ubuntu version upgrades if our github actions files are consistent. Updating them all en masse can be easily done with scripting if they're identical, but then every difference creates extra work.

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 }}'
Expand Down
Binary file modified build/pbf2json.darwin-arm64
Binary file not shown.
Binary file modified build/pbf2json.darwin-x64
Binary file not shown.
Binary file modified build/pbf2json.linux-arm64
Binary file not shown.
Binary file modified build/pbf2json.linux-x64
Binary file not shown.
Binary file modified build/pbf2json.win32-x64
Binary file not shown.
3 changes: 2 additions & 1 deletion compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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';
10 changes: 10 additions & 0 deletions pbf2json.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
14 changes: 13 additions & 1 deletion test/end-to-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();