From 1b1be9f872d871143feb5a1d9fce2f01f300abc9 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Wed, 29 Nov 2017 16:44:55 -0800 Subject: [PATCH] Also trim .geobuf from layer names --- main.cpp | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/main.cpp b/main.cpp index a16b4b4..a06a8b9 100644 --- a/main.cpp +++ b/main.cpp @@ -1140,18 +1140,29 @@ int read_input(std::vector &sources, char *fname, int maxzoom, int minzo std::string trunc = std::string(use); // Trim .json or .mbtiles from the name - ssize_t cp; - cp = trunc.find(".json"); - if (cp >= 0 && (size_t) cp + 5 == trunc.size()) { - trunc = trunc.substr(0, cp); - } - cp = trunc.find(".geojson"); - if (cp >= 0 && (size_t) cp + 8 == trunc.size()) { - trunc = trunc.substr(0, cp); - } - cp = trunc.find(".mbtiles"); - if (cp >= 0 && (size_t) cp + 8 == trunc.size()) { - trunc = trunc.substr(0, cp); + while (true) { + ssize_t cp; + cp = trunc.find(".json"); + if (cp >= 0 && (size_t) cp + 5 == trunc.size()) { + trunc = trunc.substr(0, cp); + continue; + } + cp = trunc.find(".geojson"); + if (cp >= 0 && (size_t) cp + 8 == trunc.size()) { + trunc = trunc.substr(0, cp); + continue; + } + cp = trunc.find(".geobuf"); + if (cp >= 0 && (size_t) cp + 7 == trunc.size()) { + trunc = trunc.substr(0, cp); + continue; + } + cp = trunc.find(".mbtiles"); + if (cp >= 0 && (size_t) cp + 8 == trunc.size()) { + trunc = trunc.substr(0, cp); + continue; + } + break; } // Trim out characters that can't be part of selector