Skip to content

Commit

Permalink
Gonna get it right this time
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Sep 6, 2024
1 parent 8232993 commit 2b54558
Show file tree
Hide file tree
Showing 10 changed files with 3,642 additions and 19 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-decode tests/pbf/0-0-0-pop-2-0-1.pbf.out 2 0 1 > tests/pbf/0-0-0-pop-2-0-1.pbf.out.json.check
cmp tests/pbf/0-0-0-pop-2-0-1.pbf.out.json.check tests/pbf/0-0-0-pop-2-0-1.pbf.out.json
rm tests/pbf/0-0-0-pop-2-0-1.pbf.out tests/pbf/0-0-0-pop-2-0-1.pbf.out.json.check
./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-1-1-0.pbf.out --assign-to-bins tests/pbf/h3-1-1-0.geojson tests/pbf/0-0-0.pbf 1/1/0 1/1/0
./tippecanoe-decode tests/pbf/0-0-0-pop-1-1-0.pbf.out 1 1 0 > tests/pbf/0-0-0-pop-1-1-0.pbf.out.json.check
cmp tests/pbf/0-0-0-pop-1-1-0.pbf.out.json.check tests/pbf/0-0-0-pop-1-1-0.pbf.out.json
rm tests/pbf/0-0-0-pop-1-1-0.pbf.out tests/pbf/0-0-0-pop-1-1-0.pbf.out.json.check
./tippecanoe-overzoom -o tests/pbf/0-0-0-pop-0-0-0.pbf.out --assign-to-bins tests/pbf/h3-0-0-0.geojson tests/pbf/0-0-0.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-pop-0-0-0.pbf.out 0 0 0 > tests/pbf/0-0-0-pop-0-0-0.pbf.out.json.check
cmp tests/pbf/0-0-0-pop-0-0-0.pbf.out.json.check tests/pbf/0-0-0-pop-0-0-0.pbf.out.json
rm tests/pbf/0-0-0-pop-0-0-0.pbf.out tests/pbf/0-0-0-pop-0-0-0.pbf.out.json.check

join-test: tippecanoe tippecanoe-decode tile-join
./tippecanoe -q -f -z12 -o tests/join-population/tabblock_06001420.mbtiles -YALAND10:'Land area' -L'{"file": "tests/join-population/tabblock_06001420.json", "description": "population"}'
Expand Down
2 changes: 1 addition & 1 deletion overzoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ int main(int argc, char **argv) {
exit(EXIT_OPEN);
}

bins = parse_layers(f, nz, nx, ny, 1LL << detail);
bins = parse_layers(f, nz, nx, ny, 1LL << detail, true);
fclose(f);
}

Expand Down
2 changes: 1 addition & 1 deletion plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ std::vector<mvt_layer> parse_layers(int fd, int z, unsigned x, unsigned y, std::
exit(EXIT_OPEN);
}

std::vector<mvt_layer> out = parse_layers(f, z, x, y, extent);
std::vector<mvt_layer> out = parse_layers(f, z, x, y, extent, true);

if (fclose(f) != 0) {
perror("fclose postfilter output");
Expand Down
32 changes: 16 additions & 16 deletions read_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ static std::vector<mvt_geometry> to_feature(drawvec &geom) {
return out;
}

std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int extent) {
std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int extent, bool fix_longitudes) {
std::map<std::string, mvt_layer> ret;
std::shared_ptr<std::string> tile_stringpool = std::make_shared<std::string>();

Expand Down Expand Up @@ -282,26 +282,26 @@ std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int
dv = fix_polygon(dv, false, false);
}

if (z > 0) {
// handle longitude wraparound
//
// this is supposed to be data for a single tile,
// so any jump from the left hand side of the world
// to the right side, or vice versa, is unexpected,
// so move it to the other side.
//
// (unless this is z0, in which case it is still
// reasonable to have a big, world-spanning polygon,
// and I'm not sure what to do about that.)
// handle longitude wraparound
//
// this is supposed to be data for a single tile,
// so any jump from the left hand side of the world
// to the right side, or vice versa, is unexpected,
// so move it to the other side.
//
// (unless this is z0, in which case it is still
// reasonable to have a big, world-spanning polygon,
// and I'm not sure what to do about that.)

if (fix_longitudes) {
for (size_t i = 0; i < dv.size(); i++) {
if (i > 0) {
if ((dv[0].x < (1LL << 31)) &&
(dv[i].x > (1LL << 31))) {
if ((dv[0].x < (1LL << 30)) &&
(dv[i].x > 3 * (1LL << 30))) {
dv[i].x -= 1LL << 32;
}
if ((dv[0].x > (1LL << 31)) &&
(dv[i].x < (1LL << 31))) {
if ((dv[0].x > 3 * (1LL << 30)) &&
(dv[i].x < (1LL << 30))) {
dv[i].x += 1LL << 32;
}
}
Expand Down
2 changes: 1 addition & 1 deletion read_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ extern int mb_geometry[GEOM_TYPES];

void json_context(json_object *j);
void parse_geometry(int t, json_object *j, drawvec &out, int op, const char *fname, int line, json_object *feature);
std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int extent);
std::vector<mvt_layer> parse_layers(FILE *fp, int z, unsigned x, unsigned y, int extent, bool fix_longitudes);

serial_val stringify_value(json_object *value, const char *reading, int line, json_object *feature);
217 changes: 217 additions & 0 deletions tests/pbf/0-0-0-pop-0-0-0.pbf.out.json

Large diffs are not rendered by default.

3,395 changes: 3,395 additions & 0 deletions tests/pbf/0-0-0-pop-1-1-0.pbf.out.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/pbf/h3-0-0-0.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/pbf/h3-1-0-0.geojson

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/pbf/h3-1-1-0.geojson

Large diffs are not rendered by default.

0 comments on commit 2b54558

Please sign in to comment.