Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into tile-join-sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed Dec 5, 2024
2 parents 0ae73c1 + bdfb06c commit eab74d4
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.72.0

* Add --clip-polygon-file and --feature-filter-file options to tippecanoe-overzoom

# 2.71.0

* Add --clip-bounding-box and --clip-polygon options to tippecanoe-overzoom
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-decode tests/pbf/0-0-0-pop-expr.pbf 0 0 0 > tests/pbf/0-0-0-pop-expr.pbf.json.check
cmp tests/pbf/0-0-0-pop-expr.pbf.json.check tests/pbf/0-0-0-pop-expr.pbf.json
rm tests/pbf/0-0-0-pop-expr.pbf tests/pbf/0-0-0-pop-expr.pbf.json.check
# Same filter test, but reading the filter from a file
./tippecanoe-overzoom -y NAME -J tests/pbf/scalerank-0-filter.json -o tests/pbf/0-0-0-pop-expr.pbf tests/pbf/0-0-0-pop.pbf 0/0/0 0/0/0
./tippecanoe-decode tests/pbf/0-0-0-pop-expr.pbf 0 0 0 > tests/pbf/0-0-0-pop-expr.pbf.json.check
cmp tests/pbf/0-0-0-pop-expr.pbf.json.check tests/pbf/0-0-0-pop-expr.pbf.json
rm tests/pbf/0-0-0-pop-expr.pbf tests/pbf/0-0-0-pop-expr.pbf.json.check
# Filtering with multiplier
# 243 features in the source tile tests/pbf/0-0-0-pop.pbf
# 8 features survive into the output, from 9 clusters of 30
Expand Down Expand Up @@ -382,6 +387,11 @@ overzoom-test: tippecanoe-overzoom
./tippecanoe-decode tests/pbf/bin-11-327-791-ids-clip.pbf.out 11 327 791 > tests/pbf/bin-11-327-791-ids-clip.pbf.out.json.check
cmp tests/pbf/bin-11-327-791-ids-clip.pbf.out.json.check tests/pbf/bin-11-327-791-ids-clip.pbf.out.json
rm tests/pbf/bin-11-327-791-ids-clip.pbf.out.json.check tests/pbf/bin-11-327-791-ids-clip.pbf.out
# Binning by id, clipping by polygon from file
./tippecanoe-overzoom -o tests/pbf/bin-11-327-791-ids-clip.pbf.out --clip-polygon-file=tests/pbf/clip-poly.json --assign-to-bins tests/pbf/sf-zips.json --bin-by-id-list bin-ids tests/pbf/yearbuilt.pbf 11/327/791 11/327/791
./tippecanoe-decode tests/pbf/bin-11-327-791-ids-clip.pbf.out 11 327 791 > tests/pbf/bin-11-327-791-ids-clip.pbf.out.json.check
cmp tests/pbf/bin-11-327-791-ids-clip.pbf.out.json.check tests/pbf/bin-11-327-791-ids-clip.pbf.out.json
rm tests/pbf/bin-11-327-791-ids-clip.pbf.out.json.check tests/pbf/bin-11-327-791-ids-clip.pbf.out
# Binning by id, attribute stripping
# Note that it still works even if we exclude the ID that we are binning by
./tippecanoe-overzoom -yZCTA5CE10 -ytippecanoe:count -o tests/pbf/bin-11-327-791-ids-zip.pbf.out --assign-to-bins tests/pbf/sf-zips.json --bin-by-id-list bin-ids tests/pbf/yearbuilt.pbf 11/327/791 11/327/791
Expand Down
32 changes: 32 additions & 0 deletions overzoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ void usage(char **argv) {
exit(EXIT_FAILURE);
}

std::string read_json_file(const char *fname) {
std::string out;

FILE *f = fopen(fname, "r");
if (f == NULL) {
perror(optarg);
exit(EXIT_OPEN);
}

char buf[2000];
size_t nread;
while ((nread = fread(buf, sizeof(char), 2000, f)) != 0) {
out += std::string(buf, nread);
}

fclose(f);

return out;
}

int main(int argc, char **argv) {
int i;
const char *outtile = NULL;
Expand All @@ -60,6 +80,7 @@ int main(int argc, char **argv) {
{"output", required_argument, 0, 'o'},
{"filter-points-multiplier", no_argument, 0, 'm'},
{"feature-filter", required_argument, 0, 'j'},
{"feature-filter-file", required_argument, 0, 'J'},
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
{"accumulate-attribute", required_argument, 0, 'E'},
{"unidecode-data", required_argument, 0, 'u' & 0x1F},
Expand All @@ -72,6 +93,7 @@ int main(int argc, char **argv) {
{"no-tile-compression", no_argument, 0, 'd' & 0x1F},
{"clip-bounding-box", required_argument, 0, 'k' & 0x1F},
{"clip-polygon", required_argument, 0, 'l' & 0x1F},
{"clip-polygon-file", required_argument, 0, 'm' & 0x1F},

{0, 0, 0, 0},
};
Expand Down Expand Up @@ -122,6 +144,10 @@ int main(int argc, char **argv) {
filter = optarg;
break;

case 'J':
filter = read_json_file(optarg);
break;

case 'o' & 0x1F:
preserve_input_order = true;
break;
Expand Down Expand Up @@ -181,6 +207,12 @@ int main(int argc, char **argv) {
break;
}

case 'm' & 0x1F: {
clipbbox clip = parse_clip_poly(read_json_file(optarg));
clipbboxes.push_back(clip);
break;
}

default:
fprintf(stderr, "Unrecognized flag -%c\n", i);
usage(argv);
Expand Down
1 change: 1 addition & 0 deletions tests/pbf/clip-poly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"coordinates":[[[-122.4527379,37.8128815],[-122.4598853,37.7834743],[-122.4280914,37.7959397],[-122.4527379,37.8128815]]],"type":"Polygon"}
1 change: 1 addition & 0 deletions tests/pbf/scalerank-0-filter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"*":["SCALERANK","eq",0]}
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.71.0"
#define VERSION "v2.72.0"

#endif

0 comments on commit eab74d4

Please sign in to comment.