mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 16:35:40 +02:00
Reviving multi-source-tile overzoom: the overzoom.cpp side
This commit is contained in:
@@ -284,6 +284,16 @@ overzoom-test: tippecanoe-overzoom
|
||||
./tippecanoe-decode tests/pbf/11-327-791-out.pbf 11 327 791 > tests/pbf/11-327-791-out.json
|
||||
cmp tests/pbf/11-327-791.json tests/pbf/11-327-791-out.json
|
||||
rm tests/pbf/11-327-791.json tests/pbf/11-327-791-out.json tests/pbf/11-327-791-out.pbf
|
||||
# Basic operation, multiple input form
|
||||
./tippecanoe-overzoom -o tests/pbf/13-1310-3166.pbf -t 13/1310/3166 tests/pbf/11-327-791.pbf 11/327/791
|
||||
./tippecanoe-decode tests/pbf/13-1310-3166.pbf 13 1310 3166 > tests/pbf/13-1310-3166.pbf.json.check
|
||||
cmp tests/pbf/13-1310-3166.pbf.json.check tests/pbf/13-1310-3166.pbf.json
|
||||
rm tests/pbf/13-1310-3166.pbf tests/pbf/13-1310-3166.pbf.json.check
|
||||
# Multiple inputs
|
||||
./tippecanoe-overzoom -o tests/pbf/13-1310-3166-ne.pbf -t 13/1310/3166 tests/pbf/11-327-791.pbf 11/327/791 tests/pbf/0-0-0.pbf 0/0/0
|
||||
./tippecanoe-decode tests/pbf/13-1310-3166-ne.pbf 13 1310 3166 > tests/pbf/13-1310-3166-ne.pbf.json.check
|
||||
cmp tests/pbf/13-1310-3166-ne.pbf.json.check tests/pbf/13-1310-3166-ne.pbf.json
|
||||
rm tests/pbf/13-1310-3166-ne.pbf tests/pbf/13-1310-3166-ne.pbf.json.check
|
||||
# Different detail and buffer, and attribute stripping
|
||||
./tippecanoe-overzoom -d8 -b30 -y NAME -y name -y scalerank -o tests/pbf/13-1310-3166-8-30.pbf tests/pbf/11-327-791.pbf 11/327/791 13/1310/3166
|
||||
./tippecanoe-decode tests/pbf/13-1310-3166-8-30.pbf 13 1310 3166 > tests/pbf/13-1310-3166-8-30.pbf.json.check
|
||||
|
||||
+77
-37
@@ -26,13 +26,18 @@ std::set<std::string> keep;
|
||||
void usage(char **argv) {
|
||||
fprintf(stderr, "Usage: %s -o newtile.pbf.gz tile.pbf.gz oz/ox/oy nz/nx/ny\n", argv[0]);
|
||||
fprintf(stderr, "to create tile nz/nx/ny from tile oz/ox/oy\n");
|
||||
fprintf(stderr, "Usage: %s -o newtile.pbf.gz -t nz/nx/ny tile.pbf.gz oz/ox/oy tile2.pbf.gz oz2/ox2/oy2\n", argv[0]);
|
||||
fprintf(stderr, "to create tile nz/nx/ny from tiles oz/ox/oy and oz2/ox2/oy2\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int i;
|
||||
const char *outtile = NULL;
|
||||
const char *outfile = NULL;
|
||||
|
||||
std::vector<input_tile> sources;
|
||||
|
||||
struct option long_options[] = {
|
||||
{"include", required_argument, 0, 'y'},
|
||||
{"full-detail", required_argument, 0, 'd'},
|
||||
@@ -43,6 +48,7 @@ int main(int argc, char **argv) {
|
||||
{"preserve-input-order", no_argument, 0, 'o' & 0x1F},
|
||||
{"accumulate-attribute", required_argument, 0, 'E'},
|
||||
{"unidecode-data", required_argument, 0, 'u' & 0x1F},
|
||||
{"source-tile", required_argument, 0, 't'},
|
||||
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
@@ -97,32 +103,71 @@ int main(int argc, char **argv) {
|
||||
unidecode_data = read_unidecode(optarg);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
outtile = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unrecognized flag -%c\n", i);
|
||||
usage(argv);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc - optind != 3) {
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
if (outfile == NULL) {
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
const char *infile = argv[optind + 0];
|
||||
|
||||
int oz, ox, oy;
|
||||
if (sscanf(argv[optind + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) {
|
||||
fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 1]);
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
std::vector<input_tile> its;
|
||||
int nz, nx, ny;
|
||||
if (sscanf(argv[optind + 2], "%d/%d/%d", &nz, &nx, &ny) != 3) {
|
||||
fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 2]);
|
||||
usage(argv);
|
||||
|
||||
if (outtile == NULL) { // single input
|
||||
if (argc - optind != 3) {
|
||||
fprintf(stderr, "Wrong number of arguments\n");
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
const char *infile = argv[optind + 0];
|
||||
|
||||
int oz, ox, oy;
|
||||
if (sscanf(argv[optind + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) {
|
||||
fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 1]);
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
if (sscanf(argv[optind + 2], "%d/%d/%d", &nz, &nx, &ny) != 3) {
|
||||
fprintf(stderr, "%s: not in z/x/y form\n", argv[optind + 2]);
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
input_tile s;
|
||||
s.tile = infile;
|
||||
s.z = oz;
|
||||
s.x = ox;
|
||||
s.y = oy;
|
||||
|
||||
sources.push_back(s);
|
||||
} else { // multiple inputs
|
||||
if ((argc - optind) % 2 != 0) {
|
||||
fprintf(stderr, "Unpaired arguments\n");
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
if (sscanf(outtile, "%d/%d/%d", &nz, &nx, &ny) != 3) {
|
||||
fprintf(stderr, "%s: not in z/x/y form\n", outtile);
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
for (i = optind; i + 1 < argc; i += 2) {
|
||||
int oz, ox, oy;
|
||||
if (sscanf(argv[i + 1], "%d/%d/%d", &oz, &ox, &oy) != 3) {
|
||||
fprintf(stderr, "%s: not in z/x/y form\n", argv[i + 1]);
|
||||
usage(argv);
|
||||
}
|
||||
|
||||
input_tile s;
|
||||
s.tile = argv[i];
|
||||
s.z = oz;
|
||||
s.x = ox;
|
||||
s.y = oy;
|
||||
|
||||
sources.push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
json_object *json_filter = NULL;
|
||||
@@ -130,34 +175,29 @@ int main(int argc, char **argv) {
|
||||
json_filter = parse_filter(filter.c_str());
|
||||
}
|
||||
|
||||
std::string out;
|
||||
{
|
||||
FILE *fi = fopen(infile, "rb");
|
||||
if (fi == NULL) {
|
||||
perror(infile);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (auto const &s : sources) {
|
||||
std::string tile;
|
||||
char buf[1000];
|
||||
int len;
|
||||
|
||||
while ((len = fread(buf, sizeof(char), 1000, fi)) > 0) {
|
||||
FILE *f = fopen(s.tile.c_str(), "rb");
|
||||
if (f == NULL) {
|
||||
perror(s.tile.c_str());
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
while ((len = fread(buf, sizeof(char), 1000, f)) > 0) {
|
||||
tile.append(std::string(buf, len));
|
||||
}
|
||||
fclose(fi);
|
||||
fclose(f);
|
||||
|
||||
std::vector<input_tile> tv;
|
||||
input_tile t;
|
||||
input_tile t = s;
|
||||
t.tile = std::move(tile);
|
||||
t.z = oz;
|
||||
t.x = ox;
|
||||
t.y = oy;
|
||||
tv.push_back(std::move(t));
|
||||
|
||||
out = overzoom(tv, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data);
|
||||
its.push_back(std::move(t));
|
||||
}
|
||||
|
||||
std::string out = overzoom(its, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data);
|
||||
|
||||
FILE *f = fopen(outfile, "wb");
|
||||
if (f == NULL) {
|
||||
perror(outfile);
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
{ "type": "FeatureCollection", "properties": { "zoom": 13, "x": 1310, "y": 3166 }, "features": [
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_land", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "featurecla": "Land", "scalerank": 0, "min_zoom": 0 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.387760, 37.788760 ], [ -122.387094, 37.778754 ], [ -122.386837, 37.778517 ], [ -122.386837, 37.752665 ], [ -122.432499, 37.752665 ], [ -122.432499, 37.788760 ], [ -122.387760, 37.788760 ] ] ] } }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_populated_places", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "SCALERANK": 1, "NATSCALE": 300, "LABELRANK": 1, "FEATURECLA": "Populated place", "NAME": "San Francisco", "NAMEALT": "San Francisco-Oakland", "NAMEASCII": "San Francisco", "ADM0CAP": 0, "WORLDCITY": 1, "MEGACITY": 1, "SOV0NAME": "United States", "SOV_A3": "USA", "ADM0NAME": "United States of America", "ADM0_A3": "USA", "ADM1NAME": "California", "ISO_A2": "US", "LATITUDE": 37.769196, "LONGITUDE": -122.417169, "POP_MAX": 3450000, "POP_MIN": 732072, "POP_OTHER": 27400, "RANK_MAX": 12, "RANK_MIN": 11, "MEGANAME": "San Francisco-Oakland", "LS_NAME": "San Francisco1", "MAX_POP10": 988636, "MAX_POP20": 1130999, "MAX_POP50": 1371285, "MAX_POP300": 4561697, "MAX_POP310": 4561697, "MAX_NATSCA": 300, "MIN_AREAKM": 218, "MAX_AREAKM": 1748, "MIN_AREAMI": 84, "MAX_AREAMI": 675, "MIN_PERKM": 126, "MAX_PERKM": 755, "MIN_PERMI": 78, "MAX_PERMI": 469, "MIN_BBXMIN": -122.516667, "MAX_BBXMIN": -122.516667, "MIN_BBXMAX": -122.358333, "MAX_BBXMAX": -121.733333, "MIN_BBYMIN": 37.191667, "MAX_BBYMIN": 37.575, "MIN_BBYMAX": 37.816667, "MAX_BBYMAX": 38.041667, "MEAN_BBXC": -122.301354, "MEAN_BBYC": 37.622288, "TIMEZONE": "America/Los_Angeles", "UN_FID": 570, "POP1950": 1855, "POP1955": 2021, "POP1960": 2200, "POP1965": 2361, "POP1970": 2529, "POP1975": 2590, "POP1980": 2656, "POP1985": 2805, "POP1990": 2961, "POP1995": 3095, "POP2000": 3236, "POP2005": 3387, "POP2010": 3450, "POP2015": 3544, "POP2020": 3684, "POP2025": 3803, "POP2050": 3898, "MIN_ZOOM": 2.7, "WIKIDATAID": "Q62", "WOF_ID": 85922583, "CAPALT": 0, "NAME_EN": "San Francisco", "NAME_DE": "San Francisco", "NAME_ES": "San Francisco", "NAME_FR": "San Francisco", "NAME_PT": "São Francisco", "NAME_RU": "Сан-Франциско", "NAME_ZH": "旧金山", "NAME_AR": "سان فرانسيسكو", "NAME_BN": "সান ফ্রান্সিস্কো", "NAME_EL": "Σαν Φρανσίσκο", "NAME_HI": "सैन फ्रांसिस्को", "NAME_HU": "San Francisco", "NAME_ID": "San Francisco", "NAME_IT": "San Francisco", "NAME_JA": "サンフランシスコ", "NAME_KO": "샌프란시스코", "NAME_NL": "San Francisco", "NAME_PL": "San Francisco", "NAME_SV": "San Francisco", "NAME_TR": "San Francisco", "NAME_VI": "San Francisco", "NE_ID": 1159151479, "NAME_FA": "سان فرانسیسکو", "NAME_HE": "סן פרנסיסקו", "NAME_UK": "Сан-Франциско", "NAME_UR": "سان فرانسسکو", "NAME_ZHT": "舊金山", "GEONAMESID": 5391959 }, "geometry": { "type": "Point", "coordinates": [ -122.399583, 37.784249 ] } }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_roads", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "scalerank": 4, "featurecla": "Road", "type": "Major Highway", "sov_a3": "USA", "edited": "New in version 2.0.0", "name": "101", "question": 0, "length_km": 11, "toll": 0, "ne_part": "ne_1d4_original", "labelrank": 0, "ignore": 0, "add": 0, "rwdb_rd_id": 0, "orig_fid": 0, "uident": 118705, "continent": "North America", "expressway": 1, "level": "Federal", "min_zoom": 4, "min_label": 7 }, "geometry": { "type": "LineString", "coordinates": [ [ -122.407351, 37.767933 ], [ -122.412586, 37.781841 ], [ -122.419496, 37.788760 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "scalerank": 3, "featurecla": "Road", "type": "Major Highway", "sov_a3": "USA", "edited": "New in version 2.0.0", "name": "80", "question": 0, "length_km": 14, "toll": 1, "ne_part": "ne_1d4_original", "labelrank": 0, "ignore": 0, "add": 0, "rwdb_rd_id": 0, "orig_fid": 0, "uident": 311505, "continent": "North America", "expressway": 1, "level": "Interstate", "min_zoom": 3, "min_label": 6 }, "geometry": { "type": "LineString", "coordinates": [ [ -122.407351, 37.767933 ], [ -122.388253, 37.785300 ], [ -122.386837, 37.786453 ] ] } }
|
||||
,
|
||||
{ "type": "Feature", "properties": { "scalerank": 4, "featurecla": "Road", "type": "Major Highway", "sov_a3": "USA", "edited": "New in version 2.0.0", "name": "280", "question": 0, "length_km": 52, "toll": 0, "ne_part": "ne_1d4_original", "labelrank": 0, "ignore": 0, "add": 0, "rwdb_rd_id": 0, "orig_fid": 0, "uident": 124805, "continent": "North America", "expressway": 1, "level": "Interstate", "min_zoom": 4, "min_label": 7 }, "geometry": { "type": "LineString", "coordinates": [ [ -122.405677, 37.752665 ], [ -122.407351, 37.767933 ] ] } }
|
||||
] }
|
||||
,
|
||||
{ "type": "FeatureCollection", "properties": { "layer": "ne_10m_admin_0_countries", "version": 2, "extent": 4096 }, "features": [
|
||||
{ "type": "Feature", "properties": { "featurecla": "Admin-0 country", "scalerank": 0, "LABELRANK": 2, "SOVEREIGNT": "United States of America", "SOV_A3": "US1", "ADM0_DIF": 1, "LEVEL": 2, "TYPE": "Country", "TLC": "1", "ADMIN": "United States of America", "ADM0_A3": "USA", "GEOU_DIF": 0, "GEOUNIT": "United States of America", "GU_A3": "USA", "SU_DIF": 0, "SUBUNIT": "United States", "SU_A3": "USA", "BRK_DIFF": 0, "NAME": "United States of America", "NAME_LONG": "United States", "BRK_A3": "USA", "BRK_NAME": "United States", "ABBREV": "U.S.A.", "POSTAL": "US", "FORMAL_EN": "United States of America", "NAME_CIAWF": "United States", "NAME_SORT": "United States of America", "MAPCOLOR7": 4, "MAPCOLOR8": 5, "MAPCOLOR9": 1, "MAPCOLOR13": 1, "POP_EST": 328239523, "POP_RANK": 17, "POP_YEAR": 2019, "GDP_MD": 21433226, "GDP_YEAR": 2019, "ECONOMY": "1. Developed region: G7", "INCOME_GRP": "1. High income: OECD", "FIPS_10": "US", "ISO_A2": "US", "ISO_A2_EH": "US", "ISO_A3": "USA", "ISO_A3_EH": "USA", "ISO_N3": "840", "ISO_N3_EH": "840", "UN_A3": "840", "WB_A2": "US", "WB_A3": "USA", "WOE_ID": 23424977, "WOE_ID_EH": 23424977, "WOE_NOTE": "Exact WOE match as country", "ADM0_ISO": "USA", "ADM0_TLC": "USA", "ADM0_A3_US": "USA", "ADM0_A3_FR": "USA", "ADM0_A3_RU": "USA", "ADM0_A3_ES": "USA", "ADM0_A3_CN": "USA", "ADM0_A3_TW": "USA", "ADM0_A3_IN": "USA", "ADM0_A3_NP": "USA", "ADM0_A3_PK": "USA", "ADM0_A3_DE": "USA", "ADM0_A3_GB": "USA", "ADM0_A3_BR": "USA", "ADM0_A3_IL": "USA", "ADM0_A3_PS": "USA", "ADM0_A3_SA": "USA", "ADM0_A3_EG": "USA", "ADM0_A3_MA": "USA", "ADM0_A3_PT": "USA", "ADM0_A3_AR": "USA", "ADM0_A3_JP": "USA", "ADM0_A3_KO": "USA", "ADM0_A3_VN": "USA", "ADM0_A3_TR": "USA", "ADM0_A3_ID": "USA", "ADM0_A3_PL": "USA", "ADM0_A3_GR": "USA", "ADM0_A3_IT": "USA", "ADM0_A3_NL": "USA", "ADM0_A3_SE": "USA", "ADM0_A3_BD": "USA", "ADM0_A3_UA": "USA", "ADM0_A3_UN": -99, "ADM0_A3_WB": -99, "CONTINENT": "North America", "REGION_UN": "Americas", "SUBREGION": "Northern America", "REGION_WB": "North America", "NAME_LEN": 24, "LONG_LEN": 13, "ABBREV_LEN": 6, "TINY": -99, "HOMEPART": 1, "MIN_ZOOM": 0, "MIN_LABEL": 1.7, "MAX_LABEL": 5.7, "LABEL_X": -97.482602, "LABEL_Y": 39.538479, "NE_ID": 1159321369, "WIKIDATAID": "Q30", "NAME_AR": "الولايات المتحدة", "NAME_BN": "মার্কিন যুক্তরাষ্ট্র", "NAME_DE": "Vereinigte Staaten", "NAME_EN": "United States of America", "NAME_ES": "Estados Unidos", "NAME_FA": "ایالات متحده آمریکا", "NAME_FR": "États-Unis", "NAME_EL": "Ηνωμένες Πολιτείες Αμερικής", "NAME_HE": "ארצות הברית", "NAME_HI": "संयुक्त राज्य अमेरिका", "NAME_HU": "Amerikai Egyesült Államok", "NAME_ID": "Amerika Serikat", "NAME_IT": "Stati Uniti d'America", "NAME_JA": "アメリカ合衆国", "NAME_KO": "미국", "NAME_NL": "Verenigde Staten van Amerika", "NAME_PL": "Stany Zjednoczone", "NAME_PT": "Estados Unidos", "NAME_RU": "США", "NAME_SV": "USA", "NAME_TR": "Amerika Birleşik Devletleri", "NAME_UK": "Сполучені Штати Америки", "NAME_UR": "ریاستہائے متحدہ امریکا", "NAME_VI": "Hoa Kỳ", "NAME_ZH": "美国", "NAME_ZHT": "美國", "FCLASS_ISO": "Admin-0 country", "FCLASS_TLC": "Admin-0 country" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -122.432499, 37.788081 ], [ -122.386837, 37.788081 ], [ -122.386837, 37.752665 ], [ -122.432499, 37.752665 ], [ -122.432499, 37.788081 ] ] ] } }
|
||||
] }
|
||||
] }
|
||||
Reference in New Issue
Block a user