Skip to content

Commit

Permalink
Only detect longitude wraparound within each ring. (#150)
Browse files Browse the repository at this point in the history
* Only detect longitude wraparound within each ring.

Between rings it's OK to jump around from one side of the world
to the other.

* Add test

* Update changelog
  • Loading branch information
e-n-f authored Oct 17, 2023
1 parent 0ca1408 commit e1c665b
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.35.0

* Fix a bug in --detect-longitude-wraparound when there are multiple rings

# 2.34.1

* Further improvements to tile-join speed
Expand Down
27 changes: 16 additions & 11 deletions serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,19 +325,24 @@ static long long scale_geometry(struct serialization_state *sst, long long *bbox
long long y = geom[i].y;

if (additional[A_DETECT_WRAPAROUND]) {
x += offset;
if (has_prev) {
if (x - prev > (1LL << 31)) {
offset -= 1LL << 32;
x -= 1LL << 32;
} else if (prev - x > (1LL << 31)) {
offset += 1LL << 32;
x += 1LL << 32;
if (geom[i].op == VT_LINETO) {
x += offset;
if (has_prev) {
if (x - prev > (1LL << 31)) {
offset -= 1LL << 32;
x -= 1LL << 32;
} else if (prev - x > (1LL << 31)) {
offset += 1LL << 32;
x += 1LL << 32;
}
}
}

has_prev = true;
prev = x;
has_prev = true;
prev = x;
} else {
offset = 0;
prev = x;
}
}

if (x < bbox[0]) {
Expand Down
1 change: 1 addition & 0 deletions tests/bathymetry-6000/in.json

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions tests/bathymetry-6000/out/-z0_--detect-longitude-wraparound.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion version.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef VERSION_HPP
#define VERSION_HPP

#define VERSION "v2.34.1"
#define VERSION "v2.35.0"

#endif

0 comments on commit e1c665b

Please sign in to comment.