Add the ability to specify the file format with -L{"format":"…"}

This commit is contained in:
Eric Fischer
2018-07-17 14:57:56 -07:00
parent 07ab900393
commit 3cb09d0e2a
5 changed files with 38 additions and 13 deletions
+15 -7
View File
@@ -10,10 +10,16 @@
#include "milo/dtoa_milo.h"
void parse_geocsv(std::vector<struct serialization_state> &sst, std::string fname, int layer, std::string layername) {
FILE *f = fopen(fname.c_str(), "r");
if (f == NULL) {
perror(fname.c_str());
exit(EXIT_FAILURE);
FILE *f;
if (fname.size() == 0) {
f = stdin;
} else {
f = fopen(fname.c_str(), "r");
if (f == NULL) {
perror(fname.c_str());
exit(EXIT_FAILURE);
}
}
std::string s;
@@ -120,8 +126,10 @@ void parse_geocsv(std::vector<struct serialization_state> &sst, std::string fnam
serialize_feature(&sst[0], sf);
}
if (fclose(f) != 0) {
perror("fclose");
exit(EXIT_FAILURE);
if (fname.size() != 0) {
if (fclose(f) != 0) {
perror("fclose");
exit(EXIT_FAILURE);
}
}
}