| 88 | } |
| 89 | |
| 90 | void ReprojectionFilter::prepared(PointTableRef table) |
| 91 | { |
| 92 | |
| 93 | // convert string args to integers and throw if |
| 94 | // we can't |
| 95 | auto convert = [] (const std::vector<std::string>& in) |
| 96 | { |
| 97 | std::vector<int> output; |
| 98 | for (auto& str: in) |
| 99 | { |
| 100 | try |
| 101 | { |
| 102 | output.push_back(std::stoi(str)); |
| 103 | } catch (std::invalid_argument&) |
| 104 | { |
| 105 | throw pdal_error("Unable to convert axis ordering to integer"); |
| 106 | } |
| 107 | |
| 108 | } |
| 109 | return output; |
| 110 | |
| 111 | }; |
| 112 | |
| 113 | // Check that the sorted vector is 1,2 or 1,2,3 |
| 114 | auto check = [this] (const std::vector<int>& in) |
| 115 | { |
| 116 | auto test = in; |
| 117 | std::sort(test.begin(), test.end()); |
| 118 | if (test.size() > 3) |
| 119 | throwError("Axis ordering vector is too long"); |
| 120 | if (test.at(0) != 1 && test.at(1) != 2) |
| 121 | throwError("Axis ordering is invalid"); |
| 122 | if (test.size() > 2) |
| 123 | if (test.at(2) != 3) |
| 124 | throwError("Axis ordering for 3rd dimension is invalid"); |
| 125 | |
| 126 | }; |
| 127 | |
| 128 | if (m_inAxisOrderingArg.size()) |
| 129 | { |
| 130 | m_inAxisOrdering = convert(m_inAxisOrderingArg); |
| 131 | check(m_inAxisOrdering); |
| 132 | } |
| 133 | |
| 134 | if (m_outAxisOrderingArg.size()) |
| 135 | { |
| 136 | m_outAxisOrdering = convert(m_outAxisOrderingArg); |
| 137 | check(m_outAxisOrdering); |
| 138 | } |
| 139 | |
| 140 | } |
| 141 | |
| 142 | void ReprojectionFilter::createTransform(const SpatialReference& srsSRS) |
| 143 | { |