<commit_before>"""
Created on 10 Jan 2017

@author: <NAME> (<EMAIL>)

https://www.nmea.org
https://en.wikipedia.org/wiki/NMEA_0183

reference coordinate systems:
https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84
https://en.wikipedia.org/wiki/PZ-90
"""

from collections import OrderedDict
from numbers import Number

from scs_core.data.datum import Datum
from scs_core.data.json import JSONable
from scs_core.position.position import Position


# --------------------------------------------------------------------------------------------------------------------

class GPSDatum(JSONable):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    @classmethod
    def construct_from_jdict(cls, jdict):
        if not jdict:
            return None

        pos = Position.construct_from_jdict(jdict.get('pos'))
        elv = jdict.get('elv')

        quality = jdict.get('qual')

        return GPSDatum(pos, elv, quality)


    @classmethod
    def construct_from_gga(cls, gga):
        if gga is None:
            return None

        pos = Position.construct_from_gga(gga)
        elv = None if gga.alt is None else round(gga.alt)

        quality = gga.quality

        return GPSDatum(pos, elv, quality)


    @classmethod
    def construct_null(cls):
        return GPSDatum(Position(None, None), None, 0)


    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, pos, elv, quality):
        """
        Constructor
        """
        self.__pos = pos                            # Position
        self.__elv = Datum.float(elv, 1)            # metres above mean sea level

        self.__quality = Datum.int(quality)         # 0 to 6 (?)


    # ----------------------------------------------------------------------------------------------------------------
    # Support for averaging...<commit_msg>GPSMonitor now returns null datum instead of None.<commit_after>"""
Created on 10 Jan 2017

@author: <NAME> (<EMAIL>.com)

https://www.nmea.org
https://en.wikipedia.org/wiki/NMEA_0183

reference coordinate systems:
https://en.wikipedia.org/wiki/World_Geodetic_System#WGS84
https://en.wikipedia.org/wiki/PZ-90
"""

from collections import OrderedDict
from numbers import Number

from scs_core.data.datum import Datum
from scs_core.data.json import JSONable
from scs_core.position.position import Position


# --------------------------------------------------------------------------------------------------------------------

class GPSDatum(JSONable):
    """
    classdocs
    """

    # ----------------------------------------------------------------------------------------------------------------

    @classmethod
    def construct_from_jdict(cls, jdict):
        if not jdict:
            return None

        pos = Position.construct_from_jdict(jdict.get('pos'))
        elv = jdict.get('elv')

        quality = jdict.get('qual')

        return GPSDatum(pos, elv, quality)


    @classmethod
    def construct_from_gga(cls, gga):
        if gga is None:
            return None

        pos = Position.construct_from_gga(gga)
        elv = None if gga.alt is None else round(gga.alt)

        quality = gga.quality

        return GPSDatum(pos, elv, quality)


    @classmethod
    def null_datum(cls):
        return GPSDatum(Position(None, None), None, 0)


    # ----------------------------------------------------------------------------------------------------------------

    def __init__(self, pos, elv, quality):
        """
        Constructor
        """
        self.__pos = pos                            # Position
        self.__elv = Datum.float(elv, 1)            # metres above mean sea level

        self.__quality = Datum.int(quality)         # 0 to 6 (?)


    # ----------------------------------------------------------------------------------------------------------------
    # Support for averaging...
{'fraction_non_alphanumeric': 0.3048750309329374, 'fraction_numerical': 0.008908685968819599, 'mean_word_length': 1.1661307609860665, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1766896', 'n_tokens_mistral': 1066, 'n_tokens_neox': 985, 'n_words': 240}