mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-02 08:25:40 +02:00
Remove undocumented command-line options (#361)
* Remove --accumulate-numeric-attributes * Remove join-sqlite, etc. * Remove --accumulate-numeric-attributes from overzoom * Remove --assign-to-bins and --bin-by-id-list * Remove --clip-polygon and --clip-bounding-box * Remove FSL expressions * Update version and changelog
This commit is contained in:
+1
-178
@@ -57,11 +57,6 @@ std::map<std::string, std::string> renames;
|
||||
bool exclude_all = false;
|
||||
bool exclude_all_tile_attributes = false;
|
||||
std::vector<std::string> unidecode_data;
|
||||
std::string join_tile_attribute;
|
||||
std::string join_table_expression;
|
||||
std::string join_table;
|
||||
size_t join_count_limit = 1;
|
||||
std::string attribute_for_id;
|
||||
|
||||
bool want_overzoom = false;
|
||||
int buffer = 5;
|
||||
@@ -79,92 +74,6 @@ struct stats {
|
||||
std::vector<struct strategy> strategies{};
|
||||
};
|
||||
|
||||
// list, per feature in the tile,
|
||||
// of lists of features in the sqlite response,
|
||||
// each of which is a mapping from keys to values
|
||||
std::vector<std::vector<std::map<std::string, mvt_value>>> get_joined_rows(sqlite3 *db, const std::vector<mvt_value> &join_keys) {
|
||||
std::vector<std::vector<std::map<std::string, mvt_value>>> ret;
|
||||
ret.resize(join_keys.size());
|
||||
|
||||
// double quotes for table and column identifiers
|
||||
const char *s = sqlite3_mprintf("select %s, * from \"%w\" where %s in (",
|
||||
join_table_expression.c_str(), join_table.c_str(), join_table_expression.c_str());
|
||||
std::string query = s;
|
||||
sqlite3_free((void *) s);
|
||||
|
||||
std::multimap<std::string, size_t> key_to_row;
|
||||
for (size_t i = 0; i < join_keys.size(); i++) {
|
||||
const mvt_value &v = join_keys[i];
|
||||
|
||||
// single quotes for literals
|
||||
if (v.type == mvt_string) {
|
||||
s = sqlite3_mprintf("'%q'", v.c_str());
|
||||
query += s;
|
||||
sqlite3_free((void *) s);
|
||||
key_to_row.emplace(v.get_string_value(), i);
|
||||
} else {
|
||||
std::string stringified = v.toString();
|
||||
key_to_row.emplace(stringified, i);
|
||||
query += stringified;
|
||||
}
|
||||
|
||||
if (i + 1 < join_keys.size()) {
|
||||
query += ", ";
|
||||
}
|
||||
}
|
||||
|
||||
// this doesn't add a LIMIT to the query because our limit
|
||||
// is per tiled feature, not a limit on the entire query response.
|
||||
query += ");";
|
||||
|
||||
sqlite3_stmt *stmt;
|
||||
if (sqlite3_prepare_v2(db, query.c_str(), -1, &stmt, NULL) != SQLITE_OK) {
|
||||
fprintf(stderr, "sqlite3 query %s failed: %s\n", query.c_str(), sqlite3_errmsg(db));
|
||||
exit(EXIT_SQLITE);
|
||||
}
|
||||
while (sqlite3_step(stmt) == SQLITE_ROW) {
|
||||
int count = sqlite3_column_count(stmt);
|
||||
std::map<std::string, mvt_value> row;
|
||||
|
||||
if (count > 0) {
|
||||
// join key is 0th column of query
|
||||
std::string key = (const char *) sqlite3_column_text(stmt, 0);
|
||||
auto f = key_to_row.equal_range(key);
|
||||
if (f.first == f.second) {
|
||||
fprintf(stderr, "Unexpected join key: %s\n", key.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (auto ff = f.first; ff != f.second; ++ff) {
|
||||
if (ret[ff->second].size() < join_count_limit) {
|
||||
for (int i = 1; i < count; i++) {
|
||||
int type = sqlite3_column_type(stmt, i);
|
||||
mvt_value v;
|
||||
v.type = mvt_null;
|
||||
|
||||
if (type == SQLITE_INTEGER || type == SQLITE_FLOAT) {
|
||||
v = mvt_value(sqlite3_column_double(stmt, i));
|
||||
} else if (type == SQLITE_TEXT || type == SQLITE_BLOB) {
|
||||
v.set_string_value((const char *) sqlite3_column_text(stmt, i));
|
||||
}
|
||||
|
||||
const char *name = sqlite3_column_name(stmt, i);
|
||||
row.emplace(name, v);
|
||||
}
|
||||
|
||||
ret[ff->second].push_back(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sqlite3_finalize(stmt) != SQLITE_OK) {
|
||||
fprintf(stderr, "sqlite3 finalize failed: %s\n", sqlite3_errmsg(db));
|
||||
exit(EXIT_SQLITE);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct arg {
|
||||
std::map<zxy, std::vector<std::string>> inputs{};
|
||||
std::map<zxy, std::string> outputs{};
|
||||
@@ -187,7 +96,7 @@ struct arg {
|
||||
double minlon2, maxlon2;
|
||||
};
|
||||
|
||||
void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<std::string, layermap_entry> &layermap, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, sqlite3 *db, std::set<std::string> &exclude, std::set<std::string> &include, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, int ifmatched, mvt_tile &outtile, json_object *filter, struct arg *a) {
|
||||
void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<std::string, layermap_entry> &layermap, std::vector<std::string> &header, std::map<std::string, std::vector<std::string>> &mapping, sqlite3 * /* db */, std::set<std::string> &exclude, std::set<std::string> &include, std::set<std::string> &keep_layers, std::set<std::string> &remove_layers, int ifmatched, mvt_tile &outtile, json_object *filter, struct arg *a) {
|
||||
mvt_tile tile;
|
||||
int features_added = 0;
|
||||
bool was_compressed;
|
||||
@@ -253,30 +162,6 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::vector<std::map<std::string, mvt_value>>> joined;
|
||||
if (db != NULL) {
|
||||
// collect join keys for sql query
|
||||
|
||||
std::vector<mvt_value> join_keys;
|
||||
join_keys.resize(layer.features.size());
|
||||
|
||||
for (size_t f = 0; f < layer.features.size(); f++) {
|
||||
mvt_feature &feat = layer.features[f];
|
||||
join_keys[f].type = mvt_no_such_key;
|
||||
|
||||
for (size_t t = 0; t + 1 < feat.tags.size(); t += 2) {
|
||||
const std::string &key = layer.keys[feat.tags[t]];
|
||||
if (key == join_tile_attribute) {
|
||||
const mvt_value &val = layer.values[feat.tags[t + 1]];
|
||||
join_keys[f] = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
joined = get_joined_rows(db, join_keys);
|
||||
}
|
||||
|
||||
auto tilestats = layermap.find(layer.name);
|
||||
|
||||
long long minx = LLONG_MAX;
|
||||
@@ -306,47 +191,6 @@ void append_tile(std::string message, int z, unsigned x, unsigned y, std::map<st
|
||||
std::vector<match> matches;
|
||||
bool matched = false;
|
||||
|
||||
// start filling out sql matches
|
||||
|
||||
if (f < joined.size()) {
|
||||
if (joined[f].size() > 0) {
|
||||
matched = true;
|
||||
}
|
||||
|
||||
for (auto const &joined_feature : joined[f]) {
|
||||
match m;
|
||||
m.has_id = feat.has_id;
|
||||
m.id = feat.id;
|
||||
|
||||
if (!exclude_all_tile_attributes) {
|
||||
for (size_t t = 0; t + 1 < feat.tags.size(); t += 2) {
|
||||
const std::string &key = layer.keys[feat.tags[t]];
|
||||
mvt_value &val = layer.values[feat.tags[t + 1]];
|
||||
serial_val sv = mvt_value_to_serial_val(val);
|
||||
|
||||
if (include.count(key) || (!exclude_all && exclude.count(key) == 0 && exclude_attributes.count(key) == 0)) {
|
||||
m.attributes.insert(std::pair<std::string, std::pair<mvt_value, serial_val>>(key, std::pair<mvt_value, serial_val>(val, sv)));
|
||||
m.key_order.push_back(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto const &kv : joined_feature) {
|
||||
if (kv.first == attribute_for_id) {
|
||||
m.has_id = true;
|
||||
m.id = mvt_value_to_long_long(kv.second);
|
||||
} else if (include.count(kv.first) || (!exclude_all && exclude.count(kv.first) == 0 && exclude_attributes.count(kv.first) == 0)) {
|
||||
if (kv.second.type != mvt_null) {
|
||||
m.attributes.insert(std::pair<std::string, std::pair<mvt_value, serial_val>>(kv.first, std::pair<mvt_value, serial_val>(kv.second, mvt_value_to_serial_val(kv.second))));
|
||||
m.key_order.push_back(kv.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
matches.push_back(m);
|
||||
}
|
||||
}
|
||||
|
||||
// look for csv matches and start filling them out
|
||||
|
||||
if (!matched) {
|
||||
@@ -1475,11 +1319,6 @@ int main(int argc, char **argv) {
|
||||
{"rename-layer", required_argument, 0, 'R'},
|
||||
{"read-from", required_argument, 0, 'r'},
|
||||
|
||||
{"join-sqlite", required_argument, 0, '~'},
|
||||
{"join-tile-attribute", required_argument, 0, '~'},
|
||||
{"join-table-expression", required_argument, 0, '~'},
|
||||
{"join-table", required_argument, 0, '~'},
|
||||
{"join-count-limit", required_argument, 0, '~'},
|
||||
{"use-attribute-for-id", required_argument, 0, '~'},
|
||||
|
||||
{"no-tile-size-limit", no_argument, &pk, 1},
|
||||
@@ -1666,24 +1505,8 @@ int main(int argc, char **argv) {
|
||||
max_tilestats_values = atoi(optarg);
|
||||
} else if (strcmp(opt, "unidecode-data") == 0) {
|
||||
unidecode_data = read_unidecode(optarg);
|
||||
} else if (strcmp(opt, "join-sqlite") == 0) {
|
||||
join_sqlite_fname = optarg;
|
||||
if (sqlite3_open(optarg, &db) != SQLITE_OK) {
|
||||
fprintf(stderr, "%s: %s\n", optarg, sqlite3_errmsg(db));
|
||||
exit(EXIT_SQLITE);
|
||||
}
|
||||
} else if (strcmp(opt, "join-table") == 0) {
|
||||
join_table = optarg;
|
||||
} else if (strcmp(opt, "join-table-expression") == 0) {
|
||||
join_table_expression = optarg;
|
||||
} else if (strcmp(opt, "join-tile-attribute") == 0) {
|
||||
join_tile_attribute = optarg;
|
||||
} else if (strcmp(opt, "use-attribute-for-id") == 0) {
|
||||
attribute_for_id = optarg;
|
||||
} else if (strcmp(opt, "exclude-all-tile-attributes") == 0) {
|
||||
exclude_all_tile_attributes = true;
|
||||
} else if (strcmp(opt, "join-count-limit") == 0) {
|
||||
join_count_limit = atoi(optarg);
|
||||
} else {
|
||||
fprintf(stderr, "%s: Unrecognized option --%s\n", argv[0], opt);
|
||||
exit(EXIT_ARGS);
|
||||
|
||||
Reference in New Issue
Block a user