mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-02-22 02:06:38 +00:00
Fix a bunch of compiler warnings
This commit is contained in:
parent
529c9aedc9
commit
88b9750959
52
tile-join.cc
52
tile-join.cc
@ -1,6 +1,3 @@
|
||||
// for vasprintf() on Linux
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -160,41 +157,46 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi
|
||||
}
|
||||
|
||||
for (int t = 0; t + 1 < feat.tags_size(); t += 2) {
|
||||
if (feat.tags(t) >= layer.keys_size() || feat.tags(t + 1) >= layer.values_size()) {
|
||||
printf("out of range: %d=%d\n", feat.tags(t), feat.tags(t + 1));
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *key = layer.keys(feat.tags(t)).c_str();
|
||||
mapnik::vector::tile_value const &val = layer.values(feat.tags(t + 1));
|
||||
char *value;
|
||||
int type;
|
||||
int type = -1;
|
||||
|
||||
if (val.has_string_value()) {
|
||||
value = strdup(val.string_value().c_str());
|
||||
type = VT_STRING;
|
||||
} else if (val.has_int_value()) {
|
||||
asprintf(&value, "%lld", val.int_value());
|
||||
type = VT_NUMBER;
|
||||
if (asprintf(&value, "%lld", (long long) val.int_value()) >= 0) {
|
||||
type = VT_NUMBER;
|
||||
}
|
||||
} else if (val.has_double_value()) {
|
||||
asprintf(&value, "%g", val.double_value());
|
||||
type = VT_NUMBER;
|
||||
if (asprintf(&value, "%g", val.double_value()) >= 0) {
|
||||
type = VT_NUMBER;
|
||||
}
|
||||
} else if (val.has_float_value()) {
|
||||
asprintf(&value, "%g", val.float_value());
|
||||
type = VT_NUMBER;
|
||||
if (asprintf(&value, "%g", val.float_value()) >= 0) {
|
||||
type = VT_NUMBER;
|
||||
}
|
||||
} else if (val.has_bool_value()) {
|
||||
asprintf(&value, "%s", val.bool_value() ? "true" : "false");
|
||||
type = VT_BOOLEAN;
|
||||
if (asprintf(&value, "%s", val.bool_value() ? "true" : "false") >= 0) {
|
||||
type = VT_BOOLEAN;
|
||||
}
|
||||
} else if (val.has_sint_value()) {
|
||||
asprintf(&value, "%lld", val.sint_value());
|
||||
type = VT_NUMBER;
|
||||
if (asprintf(&value, "%lld", (long long) val.sint_value()) >= 0) {
|
||||
type = VT_NUMBER;
|
||||
}
|
||||
} else if (val.has_uint_value()) {
|
||||
asprintf(&value, "%llu", val.uint_value());
|
||||
type = VT_NUMBER;
|
||||
if (asprintf(&value, "%llu", (long long) val.uint_value()) >= 0) {
|
||||
type = VT_NUMBER;
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!is_pooled(&((*file_keys)[ll]), key, type)) {
|
||||
pool(&((*file_keys)[ll]), strdup(key), type);
|
||||
}
|
||||
@ -222,7 +224,7 @@ void handle(std::string message, int z, unsigned x, unsigned y, struct pool **fi
|
||||
if (ii != mapping.end()) {
|
||||
std::vector<std::string> fields = ii->second;
|
||||
|
||||
for (int i = 1; i < fields.size(); i++) {
|
||||
for (unsigned i = 1; i < fields.size(); i++) {
|
||||
std::string joinkey = header[i];
|
||||
std::string joinval = fields[i];
|
||||
int type = VT_STRING;
|
||||
@ -395,7 +397,7 @@ std::vector<std::string> split(char *s) {
|
||||
|
||||
std::string dequote(std::string s) {
|
||||
std::string out;
|
||||
int i;
|
||||
unsigned i;
|
||||
for (i = 0; i < s.size(); i++) {
|
||||
if (s[i] == '"') {
|
||||
if (i + 1 < s.size() && s[i + 1] == '"') {
|
||||
@ -419,7 +421,7 @@ void readcsv(char *fn, std::vector<std::string> &header, std::map<std::string, s
|
||||
if (fgets(s, MAXLINE, f)) {
|
||||
header = split(s);
|
||||
|
||||
for (int i = 0; i < header.size(); i++) {
|
||||
for (unsigned i = 0; i < header.size(); i++) {
|
||||
header[i] = dequote(header[i]);
|
||||
}
|
||||
}
|
||||
@ -429,7 +431,7 @@ void readcsv(char *fn, std::vector<std::string> &header, std::map<std::string, s
|
||||
line[0] = dequote(line[0]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < line.size() && i < header.size(); i++) {
|
||||
for (unsigned i = 0; i < line.size() && i < header.size(); i++) {
|
||||
// printf("putting %s\n", line[0].c_str());
|
||||
mapping.insert(std::pair<std::string, std::vector<std::string> >(line[0], line));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user