loc_nmea.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* Copyright (c) 2012-2013, 2015-2020 The Linux Foundation. All rights reserved.
  2. *
  3. * Redistribution and use in source and binary forms, with or without
  4. * modification, are permitted provided that the following conditions are
  5. * met:
  6. * * Redistributions of source code must retain the above copyright
  7. * notice, this list of conditions and the following disclaimer.
  8. * * Redistributions in binary form must reproduce the above
  9. * copyright notice, this list of conditions and the following
  10. * disclaimer in the documentation and/or other materials provided
  11. * with the distribution.
  12. * * Neither the name of The Linux Foundation nor the names of its
  13. * contributors may be used to endorse or promote products derived
  14. * from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  17. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  18. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  20. * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  21. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  22. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  23. * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  24. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
  25. * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
  26. * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. *
  28. */
  29. #ifndef LOC_ENG_NMEA_H
  30. #define LOC_ENG_NMEA_H
  31. #include <gps_extended.h>
  32. #include <vector>
  33. #include <string>
  34. #define NMEA_SENTENCE_MAX_LENGTH 200
  35. /** gnss datum type */
  36. #define LOC_GNSS_DATUM_WGS84 0
  37. #define LOC_GNSS_DATUM_PZ90 1
  38. /* len of semi major axis of ref ellips*/
  39. #define MAJA (6378137.0)
  40. /* flattening coef of ref ellipsoid*/
  41. #define FLAT (1.0/298.2572235630)
  42. /* 1st eccentricity squared*/
  43. #define ESQR (FLAT*(2.0 - FLAT))
  44. /*1 minus eccentricity squared*/
  45. #define OMES (1.0 - ESQR)
  46. #define MILARCSEC2RAD (4.848136811095361e-09)
  47. /*semi major axis */
  48. #define C_PZ90A (6378136.0)
  49. /*semi minor axis */
  50. #define C_PZ90B (6356751.3618)
  51. /* Transformation from WGS84 to PZ90
  52. * Cx,Cy,Cz,Rs,Rx,Ry,Rz,C_SYS_A,C_SYS_B*/
  53. const double DatumConstFromWGS84[9] =
  54. {+0.003, +0.001, 0.000, (1.0+(0.000*1E-6)), (-0.019*MILARCSEC2RAD),
  55. (+0.042*MILARCSEC2RAD), (-0.002*MILARCSEC2RAD), C_PZ90A, C_PZ90B};
  56. /** Represents a LTP*/
  57. typedef struct {
  58. double lat;
  59. double lon;
  60. double alt;
  61. } LocLla;
  62. /** Represents a ECEF*/
  63. typedef struct {
  64. double X;
  65. double Y;
  66. double Z;
  67. } LocEcef;
  68. void loc_nmea_config_output_types(GnssNmeaTypesMask enabledNmeaTypes);
  69. void loc_nmea_generate_sv(const GnssSvNotification &svNotify,
  70. std::vector<std::string> &nmeaArraystr);
  71. void loc_nmea_generate_pos(const UlpLocation &location,
  72. const GpsLocationExtended &locationExtended,
  73. const LocationSystemInfo &systemInfo,
  74. unsigned char generate_nmea,
  75. bool custom_gga_fix_quality,
  76. std::vector<std::string> &nmeaArraystr,
  77. int& indexOfGGA,
  78. bool isTagBlockGroupingEnabled);
  79. #define DEBUG_NMEA_MINSIZE 6
  80. #define DEBUG_NMEA_MAXSIZE 4096
  81. inline bool loc_nmea_is_debug(const char* nmea, int length) {
  82. return ((nullptr != nmea) &&
  83. (length >= DEBUG_NMEA_MINSIZE) && (length <= DEBUG_NMEA_MAXSIZE) &&
  84. (nmea[0] == '$') && (nmea[1] == 'P') && (nmea[2] == 'Q') && (nmea[3] == 'W'));
  85. }
  86. #endif // LOC_ENG_NMEA_H