| 154 | |
| 155 | template<> |
| 156 | StatusWithReason fromString(const std::string& from, |
| 157 | SrsOrderSpec& srsOrder) |
| 158 | { |
| 159 | using namespace las; |
| 160 | |
| 161 | static const std::map<std::string, SrsType> typemap = |
| 162 | { { "wkt2", SrsType::Wkt2 }, |
| 163 | { "wkt1", SrsType::Wkt1 }, |
| 164 | { "projjson", SrsType::Proj } }; |
| 165 | |
| 166 | StringList srsTypes = Utils::split2(from, ','); |
| 167 | std::transform(srsTypes.cbegin(), srsTypes.cend(), srsTypes.begin(), |
| 168 | [](std::string s){ Utils::trim(s); return Utils::tolower(s); }); |
| 169 | |
| 170 | for (std::string& stype : srsTypes) |
| 171 | { |
| 172 | auto it = typemap.find(stype); |
| 173 | if (it == typemap.end()) |
| 174 | return { -1, "Invalid SRS type '" + stype + "'. Must be one of 'wkt1', " |
| 175 | "'wkt' or 'projjson'." }; |
| 176 | SrsType type = it->second; |
| 177 | if (Utils::contains(srsOrder.types, type)) |
| 178 | return { -1, |
| 179 | "Duplicate SRS type '" + stype + "' in 'vlr_srs_order'" }; |
| 180 | srsOrder.types.push_back(type); |
| 181 | } |
| 182 | return true; |
| 183 | } |
| 184 | |
| 185 | template<> |
| 186 | std::string toString(const SrsOrderSpec& srsOrder) |