@cond Doxygen_Suppress
| 181 | |
| 182 | //! @cond Doxygen_Suppress |
| 183 | void UnitOfMeasure::_exportToWKT( |
| 184 | WKTFormatter *formatter, |
| 185 | const std::string &unitType) const // throw(FormattingException) |
| 186 | { |
| 187 | const bool isWKT2 = formatter->version() == WKTFormatter::Version::WKT2; |
| 188 | |
| 189 | const auto l_type = type(); |
| 190 | if (!unitType.empty()) { |
| 191 | formatter->startNode(unitType, !codeSpace().empty()); |
| 192 | } else if (formatter->forceUNITKeyword() && l_type != Type::PARAMETRIC) { |
| 193 | formatter->startNode(WKTConstants::UNIT, !codeSpace().empty()); |
| 194 | } else { |
| 195 | if (isWKT2 && l_type == Type::LINEAR) { |
| 196 | formatter->startNode(WKTConstants::LENGTHUNIT, |
| 197 | !codeSpace().empty()); |
| 198 | } else if (isWKT2 && l_type == Type::ANGULAR) { |
| 199 | formatter->startNode(WKTConstants::ANGLEUNIT, !codeSpace().empty()); |
| 200 | } else if (isWKT2 && l_type == Type::SCALE) { |
| 201 | formatter->startNode(WKTConstants::SCALEUNIT, !codeSpace().empty()); |
| 202 | } else if (isWKT2 && l_type == Type::TIME) { |
| 203 | formatter->startNode(WKTConstants::TIMEUNIT, !codeSpace().empty()); |
| 204 | } else if (isWKT2 && l_type == Type::PARAMETRIC) { |
| 205 | formatter->startNode(WKTConstants::PARAMETRICUNIT, |
| 206 | !codeSpace().empty()); |
| 207 | } else { |
| 208 | formatter->startNode(WKTConstants::UNIT, !codeSpace().empty()); |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | { |
| 213 | const auto &l_name = name(); |
| 214 | const bool esri = formatter->useESRIDialect(); |
| 215 | if (esri) { |
| 216 | if (ci_equal(l_name, "degree")) { |
| 217 | formatter->addQuotedString("Degree"); |
| 218 | } else if (ci_equal(l_name, "grad")) { |
| 219 | formatter->addQuotedString("Grad"); |
| 220 | } else if (ci_equal(l_name, "metre")) { |
| 221 | formatter->addQuotedString("Meter"); |
| 222 | } else { |
| 223 | formatter->addQuotedString(l_name); |
| 224 | } |
| 225 | } else { |
| 226 | formatter->addQuotedString(l_name); |
| 227 | } |
| 228 | const auto &factor = conversionToSI(); |
| 229 | if (!isWKT2 || l_type != Type::TIME || factor != 0.0) { |
| 230 | // Some TIMEUNIT do not have a conversion factor |
| 231 | formatter->add(factor); |
| 232 | } |
| 233 | if (!codeSpace().empty() && formatter->outputId()) { |
| 234 | formatter->startNode( |
| 235 | isWKT2 ? WKTConstants::ID : WKTConstants::AUTHORITY, false); |
| 236 | formatter->addQuotedString(codeSpace()); |
| 237 | const auto &l_code = code(); |
| 238 | if (isWKT2) { |
| 239 | try { |
| 240 | (void)std::stoi(l_code); |
no test coverage detected