| 83 | |
| 84 | template<> |
| 85 | StatusWithReason fromString(const std::string& from, |
| 86 | SrsOrderSpec& srsOrder) |
| 87 | { |
| 88 | using namespace las; |
| 89 | |
| 90 | static const std::map<std::string, SrsType> typemap = |
| 91 | { { "wkt2", SrsType::Wkt2 }, |
| 92 | { "wkt1", SrsType::Wkt1 }, |
| 93 | { "projjson", SrsType::Proj }, |
| 94 | { "geotiff", SrsType::Geotiff } }; |
| 95 | |
| 96 | StringList srsTypes = Utils::split2(from, ','); |
| 97 | std::transform(srsTypes.cbegin(), srsTypes.cend(), srsTypes.begin(), |
| 98 | [](std::string s){ Utils::trim(s); return Utils::tolower(s); }); |
| 99 | |
| 100 | for (std::string& stype : srsTypes) |
| 101 | { |
| 102 | auto it = typemap.find(stype); |
| 103 | if (it == typemap.end()) |
| 104 | return { -1, "Invalid SRS type '" + stype + "'. Must be one of 'wkt1', " |
| 105 | "'geotiff', 'wkt' or 'projjson'." }; |
| 106 | SrsType type = it->second; |
| 107 | if (Utils::contains(srsOrder.types, type)) |
| 108 | return { -1, |
| 109 | "Duplicate SRS type '" + stype + "' in 'vlr_srs_order'" }; |
| 110 | srsOrder.types.push_back(type); |
| 111 | } |
| 112 | return true; |
| 113 | } |
| 114 | |
| 115 | template<> |
| 116 | std::string toString(const SrsOrderSpec& srsOrder) |