Branch data Line data Source code
1 : : /* 2 : : * ----------------- BEGIN LICENSE BLOCK --------------------------------- 3 : : * 4 : : * Copyright (C) 2018-2020 Intel Corporation 5 : : * 6 : : * SPDX-License-Identifier: MIT 7 : : * 8 : : * ----------------- END LICENSE BLOCK ----------------------------------- 9 : : */ 10 : : 11 : : /** 12 : : * Generated file 13 : : * @file 14 : : * 15 : : * Generator Version : 11.0.0-1997 16 : : */ 17 : : 18 : : #pragma once 19 : : 20 : : #include <cmath> 21 : : #include <iostream> 22 : : #include <limits> 23 : : #include <sstream> 24 : : #include <stdexcept> 25 : : #include "spdlog/fmt/ostr.h" 26 : : #include "spdlog/spdlog.h" 27 : : /*! 28 : : * @brief namespace ad 29 : : */ 30 : : namespace ad { 31 : : /*! 32 : : * @brief namespace map 33 : : */ 34 : : namespace map { 35 : : /*! 36 : : * @brief namespace point 37 : : * 38 : : * Handling geographic positions in different coordinate systems 39 : : */ 40 : : namespace point { 41 : : 42 : : /*! 43 : : * \brief Define to indicate whether throwing exceptions is enabled 44 : : */ 45 : : #define AD_MAP_POINT_LATITUDE_THROWS_EXCEPTION 1 46 : : 47 : : #if SAFE_DATATYPES_EXPLICIT_CONVERSION 48 : : /*! 49 : : * \brief Enable/Disable explicit conversion. Currently set to "only explicit conversion". 50 : : */ 51 : : #define _AD_MAP_POINT_LATITUDE_EXPLICIT_CONVERSION_ explicit 52 : : #else 53 : : /*! 54 : : * \brief Enable/Disable explicit conversion. Currently set to "implicit conversion allowed". 55 : : */ 56 : : #define _AD_MAP_POINT_LATITUDE_EXPLICIT_CONVERSION_ 57 : : #endif 58 : : 59 : : /*! 60 : : * \brief DataType Latitude 61 : : * 62 : : * WGS-84 Latitude 63 : : * The unit is: Degree 64 : : */ 65 : : class Latitude 66 : : { 67 : : public: 68 : : /*! 69 : : * \brief constant defining the minimum valid Latitude value (used in isValid()) 70 : : */ 71 : : static const double cMinValue; 72 : : 73 : : /*! 74 : : * \brief constant defining the maximum valid Latitude value (used in isValid()) 75 : : */ 76 : : static const double cMaxValue; 77 : : 78 : : /*! 79 : : * \brief constant defining the assumed Latitude value accuracy 80 : : * (used in comparison operator==(), operator!=()) 81 : : */ 82 : : static const double cPrecisionValue; 83 : : 84 : : /*! 85 : : * \brief default constructor 86 : : * 87 : : * The default value of Latitude is: 88 : : * std::numeric_limits<double>::quiet_NaN() 89 : : */ 90 : 15 : Latitude() 91 : 15 : : mLatitude(std::numeric_limits<double>::quiet_NaN()) 92 : : { 93 : 15 : } 94 : : 95 : : /*! 96 : : * \brief standard constructor 97 : : * 98 : : * \note \ref \_AD_MAP_POINT_LATITUDE_EXPLICIT_CONVERSION\_ defines, if only an explicit conversion is allowed. 99 : : */ 100 : 3291618 : _AD_MAP_POINT_LATITUDE_EXPLICIT_CONVERSION_ Latitude(double const iLatitude) 101 : 3291618 : : mLatitude(iLatitude) 102 : : { 103 : 3291618 : } 104 : : 105 : : /*! 106 : : * \brief standard copy constructor 107 : : */ 108 : : Latitude(const Latitude &other) = default; 109 : : 110 : : /*! 111 : : * \brief standard move constructor 112 : : */ 113 : : Latitude(Latitude &&other) = default; 114 : : 115 : : /** 116 : : * \brief standard assignment operator 117 : : * 118 : : * \param[in] other Other Latitude 119 : : * 120 : : * \returns Reference to this Latitude. 121 : : */ 122 : : Latitude &operator=(const Latitude &other) = default; 123 : : 124 : : /** 125 : : * \brief standard move operator 126 : : * 127 : : * \param[in] other Other Latitude 128 : : * 129 : : * \returns Reference to this Latitude. 130 : : */ 131 : : Latitude &operator=(Latitude &&other) = default; 132 : : 133 : : /** 134 : : * \brief standard comparison operator 135 : : * 136 : : * \param[in] other Other Latitude 137 : : * 138 : : * \returns \c true if both Latitude are valid and can be taken as numerically equal 139 : : */ 140 : 138 : bool operator==(const Latitude &other) const 141 : : { 142 : 138 : ensureValid(); 143 : 136 : other.ensureValid(); 144 : 134 : return std::fabs(mLatitude - other.mLatitude) < cPrecisionValue; 145 : : } 146 : : 147 : : /** 148 : : * \brief standard comparison operator 149 : : * 150 : : * \param[in] other Other Latitude. 151 : : * 152 : : * \returns \c true if one of the Latitude is not valid or they can be taken as numerically different 153 : : */ 154 : 15 : bool operator!=(const Latitude &other) const 155 : : { 156 : 15 : return !operator==(other); 157 : : } 158 : : 159 : : /** 160 : : * \brief standard comparison operator 161 : : * 162 : : * \param[in] other Other Latitude. 163 : : * 164 : : * \returns \c true if both Latitude are valid and 165 : : * this Latitude is strictly numerically greater than other. 166 : : * \note the precision of Latitude is considered 167 : : */ 168 : 7 : bool operator>(const Latitude &other) const 169 : : { 170 : 7 : ensureValid(); 171 : 6 : other.ensureValid(); 172 [ + + + + ]: 5 : return (mLatitude > other.mLatitude) && operator!=(other); 173 : : } 174 : : 175 : : /** 176 : : * \brief standard comparison operator 177 : : * 178 : : * \param[in] other Other Latitude. 179 : : * 180 : : * \returns \c true if both Latitude are valid and 181 : : * this Latitude is strictly numerically smaller than other. 182 : : * \note the precision of Latitude is considered 183 : : */ 184 : 8 : bool operator<(const Latitude &other) const 185 : : { 186 : 8 : ensureValid(); 187 : 7 : other.ensureValid(); 188 [ + + + + ]: 6 : return (mLatitude < other.mLatitude) && operator!=(other); 189 : : } 190 : : 191 : : /** 192 : : * \brief standard comparison operator 193 : : * 194 : : * \param[in] other Other Latitude. 195 : : * 196 : : * \returns \c true if both Latitude are valid and 197 : : * this Latitude is numerically greater than other. 198 : : * \note the precision of Latitude is considered 199 : : */ 200 : 7 : bool operator>=(const Latitude &other) const 201 : : { 202 : 7 : ensureValid(); 203 : 6 : other.ensureValid(); 204 [ + + + + ]: 5 : return ((mLatitude > other.mLatitude) || operator==(other)); 205 : : } 206 : : 207 : : /** 208 : : * \brief standard comparison operator 209 : : * 210 : : * \param[in] other Other Latitude 211 : : * 212 : : * \returns \c true if both Latitude are valid and 213 : : * this Latitude is numerically smaller than other. 214 : : * \note the precision of Latitude is considered 215 : : */ 216 : 2306301 : bool operator<=(const Latitude &other) const 217 : : { 218 : 2306301 : ensureValid(); 219 : 2306300 : other.ensureValid(); 220 [ + + + + ]: 2306299 : return ((mLatitude < other.mLatitude) || operator==(other)); 221 : : } 222 : : 223 : : /** 224 : : * \brief standard arithmetic operator 225 : : * 226 : : * \param[in] other Other Latitude 227 : : * 228 : : * \returns Result of arithmetic operation. 229 : : * 230 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 231 : : * the operation is not valid 232 : : */ 233 : 6 : Latitude operator+(const Latitude &other) const 234 : : { 235 [ + + ]: 6 : ensureValid(); 236 [ + + ]: 5 : other.ensureValid(); 237 : 4 : Latitude const result(mLatitude + other.mLatitude); 238 [ + + ]: 4 : result.ensureValid(); 239 : 3 : return result; 240 : : } 241 : : 242 : : /** 243 : : * \brief standard arithmetic operator 244 : : * 245 : : * \param[in] other Other Latitude 246 : : * 247 : : * \returns Result of arithmetic operation. 248 : : * 249 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 250 : : * the operation is not valid 251 : : */ 252 : 4 : Latitude &operator+=(const Latitude &other) 253 : : { 254 : 4 : ensureValid(); 255 : 3 : other.ensureValid(); 256 : 2 : mLatitude += other.mLatitude; 257 : 2 : ensureValid(); 258 : 1 : return *this; 259 : : } 260 : : 261 : : /** 262 : : * \brief standard arithmetic operator 263 : : * 264 : : * \param[in] other Other Latitude 265 : : * 266 : : * \returns Result of arithmetic operation. 267 : : * 268 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 269 : : * the operation is not valid 270 : : */ 271 : 10 : Latitude operator-(const Latitude &other) const 272 : : { 273 [ + + ]: 10 : ensureValid(); 274 [ + + ]: 9 : other.ensureValid(); 275 : 8 : Latitude const result(mLatitude - other.mLatitude); 276 [ + + ]: 8 : result.ensureValid(); 277 : 7 : return result; 278 : : } 279 : : 280 : : /** 281 : : * \brief standard arithmetic operator 282 : : * 283 : : * \param[in] other Other Latitude 284 : : * 285 : : * \returns Result of arithmetic operation. 286 : : * 287 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 288 : : * the operation is not valid 289 : : */ 290 : 4 : Latitude operator-=(const Latitude &other) 291 : : { 292 : 4 : ensureValid(); 293 : 3 : other.ensureValid(); 294 : 2 : mLatitude -= other.mLatitude; 295 : 2 : ensureValid(); 296 : 1 : return *this; 297 : : } 298 : : 299 : : /** 300 : : * \brief standard arithmetic operator 301 : : * 302 : : * \param[in] scalar Scalar double value 303 : : * 304 : : * \returns Result of arithmetic operation. 305 : : * 306 : : * \note throws a std::out_of_range exception if \c value or the result of 307 : : * the operation is not valid 308 : : */ 309 : 8 : Latitude operator*(const double &scalar) const 310 : : { 311 [ + + ]: 8 : ensureValid(); 312 : 7 : Latitude const result(mLatitude * scalar); 313 [ + + ]: 7 : result.ensureValid(); 314 : 6 : return result; 315 : : } 316 : : 317 : : /** 318 : : * \brief standard arithmetic operator 319 : : * 320 : : * \param[in] scalar Scalar double value 321 : : * 322 : : * \returns Result of arithmetic operation. 323 : : * 324 : : * \note throws a std::out_of_range exception if this or the result of 325 : : * the operation is not valid or other is zero 326 : : */ 327 : 5 : Latitude operator/(const double &scalar) const 328 : : { 329 : 5 : Latitude const scalarLatitude(scalar); 330 [ + + ]: 5 : Latitude const result(operator/(scalarLatitude)); 331 [ + + ]: 2 : result.ensureValid(); 332 : 1 : return result; 333 : : } 334 : : 335 : : /** 336 : : * \brief standard arithmetic operator 337 : : * 338 : : * \param[in] other Other Latitude 339 : : * 340 : : * \returns Result of arithmetic operation. 341 : : * 342 : : * \note throws a std::out_of_range exception if one of the two operands or the result of 343 : : * the operation is not valid or other is zero 344 : : * \note since Latitude is a type with physical unit, the division results in the dimensionless type. 345 : : */ 346 : 9 : double operator/(const Latitude &other) const 347 : : { 348 : 9 : ensureValid(); 349 : 7 : other.ensureValidNonZero(); 350 : 3 : double const result = mLatitude / other.mLatitude; 351 : 3 : return result; 352 : : } 353 : : 354 : : /** 355 : : * \brief standard arithmetic operator 356 : : * 357 : : * \returns Result of arithmetic operation. 358 : : * 359 : : * \note throws a std::out_of_range exception if this or the result of 360 : : * the operation is not valid 361 : : */ 362 : 2 : Latitude operator-() const 363 : : { 364 [ + + ]: 2 : ensureValid(); 365 : 1 : Latitude const result(-mLatitude); 366 : 1 : result.ensureValid(); // LCOV_EXCL_BR_LINE Some types do not throw an exception 367 : 1 : return result; 368 : : } 369 : : 370 : : /*! 371 : : * \brief conversion to base type: double 372 : : * 373 : : * \note the conversion to the base type removes the physical unit. 374 : : * \ref \_AD_MAP_POINT_LATITUDE_EXPLICIT_CONVERSION\_ defines, if only explicit calls are allowed. 375 : : */ 376 : 485680 : _AD_MAP_POINT_LATITUDE_EXPLICIT_CONVERSION_ operator double() const 377 : : { 378 : 485680 : return mLatitude; 379 : : } 380 : : 381 : : /*! 382 : : * \returns \c true if the Latitude in a valid range 383 : : * 384 : : * An Latitude value is defined to be valid if: 385 : : * - It is normal or zero (see std::fpclassify()) 386 : : * - \ref cMinValue <= value <= \ref cMaxValue 387 : : */ 388 : 5189598 : bool isValid() const 389 : : { 390 : 5189598 : auto const valueClass = std::fpclassify(mLatitude); 391 [ + + + - ]: 5189598 : return ((valueClass == FP_NORMAL) || (valueClass == FP_ZERO)) && (cMinValue <= mLatitude) 392 [ + + + - ]: 10379176 : && (mLatitude <= cMaxValue); 393 : : } 394 : : 395 : : /*! 396 : : * \brief ensure that the Latitude is valid 397 : : * 398 : : * Throws an std::out_of_range() exception if the Latitude 399 : : * in not valid (i.e. isValid() returns false) 400 : : */ 401 : 4613011 : void ensureValid() const 402 : : { 403 [ + + ]: 4613011 : if (!isValid()) 404 : : { 405 : 34 : spdlog::info("ensureValid(::ad::map::point::Latitude)>> {} value out of range", *this); // LCOV_EXCL_BR_LINE 406 : : #if (AD_MAP_POINT_LATITUDE_THROWS_EXCEPTION == 1) 407 : 34 : throw std::out_of_range("Latitude value out of range"); // LCOV_EXCL_BR_LINE 408 : : #endif 409 : : } 410 : 4612977 : } 411 : : 412 : : /*! 413 : : * \brief ensure that the Latitude is valid and non zero 414 : : * 415 : : * Throws an std::out_of_range() exception if the Latitude 416 : : * in not valid or zero (i.e. isValid() returns false) 417 : : */ 418 : 9 : void ensureValidNonZero() const 419 : : { 420 : 9 : ensureValid(); 421 : 6 : if (operator==(Latitude(0.))) // LCOV_EXCL_BR_LINE 422 : : { 423 : 3 : spdlog::info("ensureValid(::ad::map::point::Latitude)>> {} value is zero", *this); // LCOV_EXCL_BR_LINE 424 : : #if (AD_MAP_POINT_LATITUDE_THROWS_EXCEPTION == 1) 425 : 3 : throw std::out_of_range("Latitude value is zero"); // LCOV_EXCL_BR_LINE 426 : : #endif 427 : : } 428 : 3 : } 429 : : 430 : : /*! 431 : : * \brief get minimum valid Latitude (i.e. \ref cMinValue) 432 : : */ 433 : 576577 : static Latitude getMin() 434 : : { 435 : 576577 : return Latitude(cMinValue); 436 : : } 437 : : 438 : : /*! 439 : : * \brief get maximum valid Latitude (i.e. \ref cMaxValue) 440 : : */ 441 : 576577 : static Latitude getMax() 442 : : { 443 : 576577 : return Latitude(cMaxValue); 444 : : } 445 : : 446 : : /*! 447 : : * \brief get assumed accuracy of Latitude (i.e. \ref cPrecisionValue) 448 : : */ 449 : 3 : static Latitude getPrecision() 450 : : { 451 : 3 : return Latitude(cPrecisionValue); 452 : : } 453 : : 454 : : private: 455 : : /*! 456 : : * \brief the actual value of the type 457 : : */ 458 : : double mLatitude; 459 : : }; 460 : : 461 : : } // namespace point 462 : : } // namespace map 463 : : } // namespace ad 464 : : /** 465 : : * \brief standard arithmetic operator 466 : : * 467 : : * \param[in] other Other Latitude as double value 468 : : * \param[in] value Latitude value 469 : : * 470 : : * \returns Result of arithmetic operation. 471 : : * 472 : : * \note throws a std::out_of_range exception if \c value or the result of 473 : : * the operation is not valid 474 : : */ 475 : 5 : inline ::ad::map::point::Latitude operator*(const double &other, ::ad::map::point::Latitude const &value) 476 : : { 477 : 5 : return value.operator*(other); 478 : : } 479 : : 480 : : /*! 481 : : * \brief namespace std 482 : : */ 483 : : namespace std { 484 : : 485 : : /*! 486 : : * \brief overload of the std::fabs for Latitude 487 : : */ 488 : 7 : inline ::ad::map::point::Latitude fabs(const ::ad::map::point::Latitude other) 489 : : { 490 : 7 : ::ad::map::point::Latitude const result(std::fabs(static_cast<double>(other))); 491 : 7 : return result; 492 : : } 493 : : 494 : : /*! 495 : : * \brief specialization of the std::numeric_limits for Latitude 496 : : * 497 : : * Derived from std::numeric_limits<double> with overloaded functions: 498 : : * std::numeric_limits<Latitude>::lowest() (\see Latitude::getMin()) 499 : : * std::numeric_limits<Latitude>::max() (\see Latitude::getMax()) 500 : : * std::numeric_limits<Latitude>::epsilon() (\see Latitude::getPrecision()) 501 : : */ 502 : : template <> class numeric_limits<::ad::map::point::Latitude> : public numeric_limits<double> 503 : : { 504 : : public: 505 : : /*! 506 : : * \see std::numeric_limits::lowest() 507 : : */ 508 : 576575 : static inline ::ad::map::point::Latitude lowest() 509 : : { 510 : 576575 : return ::ad::map::point::Latitude::getMin(); 511 : : } 512 : : /*! 513 : : * \see std::numeric_limits::max() 514 : : */ 515 : 576575 : static inline ::ad::map::point::Latitude max() 516 : : { 517 : 576575 : return ::ad::map::point::Latitude::getMax(); 518 : : } 519 : : 520 : : /*! 521 : : * \see std::numeric_limits::epsilon() 522 : : */ 523 : 1 : static inline ::ad::map::point::Latitude epsilon() 524 : : { 525 : 1 : return ::ad::map::point::Latitude::getPrecision(); 526 : : } 527 : : }; 528 : : 529 : : } // namespace std 530 : : 531 : : /*! 532 : : * \brief protect the definition of functions from duplicates by typedef usage within other data types 533 : : */ 534 : : #ifndef GEN_GUARD_AD_MAP_POINT_LATITUDE 535 : : #define GEN_GUARD_AD_MAP_POINT_LATITUDE 536 : : /*! 537 : : * @brief namespace ad 538 : : */ 539 : : namespace ad { 540 : : /*! 541 : : * @brief namespace map 542 : : */ 543 : : namespace map { 544 : : /*! 545 : : * @brief namespace point 546 : : * 547 : : * Handling geographic positions in different coordinate systems 548 : : */ 549 : : namespace point { 550 : : 551 : : /** 552 : : * \brief standard ostream operator 553 : : * 554 : : * \param[in] os The output stream to write to 555 : : * \param[in] _value Latitude value 556 : : * 557 : : * \returns The stream object. 558 : : * 559 : : */ 560 : 104 : inline std::ostream &operator<<(std::ostream &os, Latitude const &_value) 561 : : { 562 : 104 : return os << double(_value); 563 : : } 564 : : 565 : : } // namespace point 566 : : } // namespace map 567 : : } // namespace ad 568 : : 569 : : namespace std { 570 : : /*! 571 : : * \brief overload of the std::to_string for Latitude 572 : : */ 573 : : inline std::string to_string(::ad::map::point::Latitude const &value) 574 : : { 575 : : return to_string(static_cast<double>(value)); 576 : : } 577 : : } // namespace std 578 : : #endif // GEN_GUARD_AD_MAP_POINT_LATITUDE