/* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include #include #include #include #include #include #include "aidl/android/hardware/gnss/IGnss.h" namespace android { namespace hardware { namespace gnss { namespace common { /** Helper class to parse and store the GNSS fix details information. */ class NmeaFixInfo { private: float altitudeMeters; float bearingDegrees; uint32_t fixId; bool hasGMCRecord; bool hasGGARecord; float hDop; float vDop; float latDeg; float lngDeg; uint32_t satelliteCount; float speedMetersPerSec; int64_t timestamp; public: static std::unique_ptr getLocationFromInputStr(const std::string& inputStr); static std::unique_ptr getAidlLocationFromInputStr( const std::string& inputStr); private: static void splitStr(const std::string& line, const char& delimiter, std::vector& out); static float checkAndConvertToFloat(const std::string& sentence); static int64_t nmeaPartsToTimestamp(const std::string& timeStr, const std::string& dateStr); NmeaFixInfo(); void parseGGALine(const std::vector& sentenceValues); void parseRMCLine(const std::vector& sentenceValues); std::unique_ptr toGnssLocation() const; // Getters float getAltitudeMeters() const; float getBearingAccuracyDegrees() const; float getBearingDegrees() const; uint32_t getFixId() const; float getHorizontalAccuracyMeters() const; float getLatDeg() const; float getLngDeg() const; float getSpeedAccuracyMetersPerSecond() const; float getSpeedMetersPerSec() const; int64_t getTimestamp() const; float getVerticalAccuracyMeters() const; bool isValidFix() const; void reset(); NmeaFixInfo& operator=(const NmeaFixInfo& rhs); }; } // namespace common } // namespace gnss } // namespace hardware } // namespace android