mirror of
https://github.com/felt/tippecanoe.git
synced 2026-10-05 18:05:42 +02:00
Fix a bunch of compiler warnings
This commit is contained in:
+27
-25
@@ -1,6 +1,3 @@
|
|||||||
// for vasprintf() on Linux
|
|
||||||
#define _GNU_SOURCE
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.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) {
|
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();
|
const char *key = layer.keys(feat.tags(t)).c_str();
|
||||||
mapnik::vector::tile_value const &val = layer.values(feat.tags(t + 1));
|
mapnik::vector::tile_value const &val = layer.values(feat.tags(t + 1));
|
||||||
char *value;
|
char *value;
|
||||||
int type;
|
int type = -1;
|
||||||
|
|
||||||
if (val.has_string_value()) {
|
if (val.has_string_value()) {
|
||||||
value = strdup(val.string_value().c_str());
|
value = strdup(val.string_value().c_str());
|
||||||
type = VT_STRING;
|
type = VT_STRING;
|
||||||
} else if (val.has_int_value()) {
|
} else if (val.has_int_value()) {
|
||||||
asprintf(&value, "%lld", val.int_value());
|
if (asprintf(&value, "%lld", (long long) val.int_value()) >= 0) {
|
||||||
type = VT_NUMBER;
|
type = VT_NUMBER;
|
||||||
|
}
|
||||||
} else if (val.has_double_value()) {
|
} else if (val.has_double_value()) {
|
||||||
asprintf(&value, "%g", val.double_value());
|
if (asprintf(&value, "%g", val.double_value()) >= 0) {
|
||||||
type = VT_NUMBER;
|
type = VT_NUMBER;
|
||||||
|
}
|
||||||
} else if (val.has_float_value()) {
|
} else if (val.has_float_value()) {
|
||||||
asprintf(&value, "%g", val.float_value());
|
if (asprintf(&value, "%g", val.float_value()) >= 0) {
|
||||||
type = VT_NUMBER;
|
type = VT_NUMBER;
|
||||||
|
}
|
||||||
} else if (val.has_bool_value()) {
|
} else if (val.has_bool_value()) {
|
||||||
asprintf(&value, "%s", val.bool_value() ? "true" : "false");
|
if (asprintf(&value, "%s", val.bool_value() ? "true" : "false") >= 0) {
|
||||||
type = VT_BOOLEAN;
|
type = VT_BOOLEAN;
|
||||||
|
}
|
||||||
} else if (val.has_sint_value()) {
|
} else if (val.has_sint_value()) {
|
||||||
asprintf(&value, "%lld", val.sint_value());
|
if (asprintf(&value, "%lld", (long long) val.sint_value()) >= 0) {
|
||||||
type = VT_NUMBER;
|
type = VT_NUMBER;
|
||||||
|
}
|
||||||
} else if (val.has_uint_value()) {
|
} else if (val.has_uint_value()) {
|
||||||
asprintf(&value, "%llu", val.uint_value());
|
if (asprintf(&value, "%llu", (long long) val.uint_value()) >= 0) {
|
||||||
type = VT_NUMBER;
|
type = VT_NUMBER;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (type < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_pooled(&((*file_keys)[ll]), key, type)) {
|
if (!is_pooled(&((*file_keys)[ll]), key, type)) {
|
||||||
pool(&((*file_keys)[ll]), strdup(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()) {
|
if (ii != mapping.end()) {
|
||||||
std::vector<std::string> fields = ii->second;
|
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 joinkey = header[i];
|
||||||
std::string joinval = fields[i];
|
std::string joinval = fields[i];
|
||||||
int type = VT_STRING;
|
int type = VT_STRING;
|
||||||
@@ -395,7 +397,7 @@ std::vector<std::string> split(char *s) {
|
|||||||
|
|
||||||
std::string dequote(std::string s) {
|
std::string dequote(std::string s) {
|
||||||
std::string out;
|
std::string out;
|
||||||
int i;
|
unsigned i;
|
||||||
for (i = 0; i < s.size(); i++) {
|
for (i = 0; i < s.size(); i++) {
|
||||||
if (s[i] == '"') {
|
if (s[i] == '"') {
|
||||||
if (i + 1 < s.size() && s[i + 1] == '"') {
|
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)) {
|
if (fgets(s, MAXLINE, f)) {
|
||||||
header = split(s);
|
header = split(s);
|
||||||
|
|
||||||
for (int i = 0; i < header.size(); i++) {
|
for (unsigned i = 0; i < header.size(); i++) {
|
||||||
header[i] = dequote(header[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]);
|
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());
|
// printf("putting %s\n", line[0].c_str());
|
||||||
mapping.insert(std::pair<std::string, std::vector<std::string> >(line[0], line));
|
mapping.insert(std::pair<std::string, std::vector<std::string> >(line[0], line));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user