Skip to content

Commit

Permalink
Only detect longitude wraparound within each ring.
Browse files Browse the repository at this point in the history
Between rings it's OK to jump around from one side of the world
to the other.
  • Loading branch information
e-n-f committed Oct 6, 2023
1 parent 0ca1408 commit 4d423c6
Showing 1 changed file with 16 additions and 11 deletions.
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

0 comments on commit 4d423c6

Please sign in to comment.