mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-22 10:10:49 +00:00
Make sure features with the same clipid also have matching attributes
This commit is contained in:
parent
e2b7040339
commit
c1590ef6a1
21
decode.cpp
21
decode.cpp
@ -231,10 +231,31 @@ std::vector<mvt_feature> handle(std::string message, int z, unsigned x, unsigned
|
||||
return pending;
|
||||
}
|
||||
|
||||
struct by_clipid {
|
||||
bool operator()(const mvt_feature &a, const mvt_feature &b) {
|
||||
return a.clipid < b.clipid;
|
||||
}
|
||||
};
|
||||
|
||||
void handle_split(std::vector<mvt_feature> todo) {
|
||||
if (todo.size() > 0) {
|
||||
printf("doing partial feature\n");
|
||||
}
|
||||
|
||||
std::sort(todo.begin(), todo.end(), by_clipid());
|
||||
|
||||
for (size_t i = 1; i < todo.size(); i++) {
|
||||
if (todo[i - 1].clipid > todo[i].clipid) {
|
||||
fprintf(stderr, "Internal error: failed to sort by clipid\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if (todo[i - 1].clipid == todo[i].clipid) {
|
||||
if (todo[i - 1].intern_tags != todo[i].intern_tags) {
|
||||
fprintf(stderr, "Feature clipids match but attributes don't\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void decode(char *fname, int z, unsigned x, unsigned y, std::set<std::string> const &to_decode, bool pipeline, bool stats) {
|
||||
|
18
mvt.cpp
18
mvt.cpp
@ -447,6 +447,24 @@ bool mvt_value::operator<(const mvt_value &o) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mvt_value::operator==(const mvt_value &o) const {
|
||||
if (type != o.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((type == mvt_string && string_value == o.string_value) ||
|
||||
(type == mvt_float && numeric_value.float_value == o.numeric_value.float_value) ||
|
||||
(type == mvt_double && numeric_value.double_value == o.numeric_value.double_value) ||
|
||||
(type == mvt_int && numeric_value.int_value == o.numeric_value.int_value) ||
|
||||
(type == mvt_uint && numeric_value.uint_value == o.numeric_value.uint_value) ||
|
||||
(type == mvt_sint && numeric_value.sint_value == o.numeric_value.sint_value) ||
|
||||
(type == mvt_bool && numeric_value.bool_value == o.numeric_value.bool_value)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string quote(std::string const &s) {
|
||||
std::string buf;
|
||||
|
||||
|
2
mvt.hpp
2
mvt.hpp
@ -95,6 +95,8 @@ struct mvt_value {
|
||||
this->string_value = "";
|
||||
this->numeric_value.double_value = 0;
|
||||
}
|
||||
|
||||
bool operator==(const mvt_value &o) const;
|
||||
};
|
||||
|
||||
struct mvt_layer {
|
||||
|
@ -227,18 +227,18 @@ void json_writer::adds(std::string const &str) {
|
||||
}
|
||||
|
||||
static void aprintf(std::string *buf, const char *format, ...) {
|
||||
va_list ap;
|
||||
char *tmp;
|
||||
va_list ap;
|
||||
char *tmp;
|
||||
|
||||
va_start(ap, format);
|
||||
if (vasprintf(&tmp, format, ap) < 0) {
|
||||
fprintf(stderr, "memory allocation failure\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
va_end(ap);
|
||||
va_start(ap, format);
|
||||
if (vasprintf(&tmp, format, ap) < 0) {
|
||||
fprintf(stderr, "memory allocation failure\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
buf->append(tmp, strlen(tmp));
|
||||
free(tmp);
|
||||
buf->append(tmp, strlen(tmp));
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
struct lonlat {
|
||||
|
Loading…
x
Reference in New Issue
Block a user