Skip to content

Commit

Permalink
Getting closer to getting antimeridian-crossing polygons right
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Sep 10, 2024
1 parent cd466e6 commit dbe4965
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 79 deletions.
10 changes: 6 additions & 4 deletions read_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,6 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int

drawvec dv;
parse_geometry(t, coordinates, dv, VT_MOVETO, "Filter output", jp->line, j);
if (mb_geometry[t] == VT_POLYGON) {
dv = fix_polygon(dv, false, false);
}

// handle longitude wraparound
//
Expand All @@ -289,7 +286,7 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
// to the right edge, or vice versa, is unexpected,
// so move it to the other side.

if (fix_longitudes) {
if (fix_longitudes && mb_geometry[t] == VT_POLYGON) {
const long long quarter_world = 1LL << 30;
const long long world = 1LL << 32;

Expand Down Expand Up @@ -332,6 +329,10 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
}
}

if (mb_geometry[t] == VT_POLYGON) {
dv = fix_polygon(dv, false, false);
}

// Offset and scale geometry from global to tile

for (size_t i = 0; i < dv.size(); i++) {
Expand All @@ -351,6 +352,7 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
// on the other side of the world
dv = clean_or_clip_poly(dv, z, 256, true, false);
if (dv.size() < 3) {
// printf("%s\n", json_stringify(j));
dv.clear();
}
}
Expand Down
Loading

0 comments on commit dbe4965

Please sign in to comment.