Beispiel #1
0
    def test_comment_altitude(self):
        self.assertEqual(util.comment_altitude(0), "/A=000000")

        # top limit
        self.assertEqual(util.comment_altitude(100000000), "/A=999999")
        # bottom limit
        self.assertEqual(util.comment_altitude(-100000000), "/A=-99999")

        self.assertEqual(util.comment_altitude(1.524), "/A=000005")
        self.assertEqual(util.comment_altitude(15.24), "/A=000050")
        self.assertEqual(util.comment_altitude(152.4), "/A=000500")
        self.assertEqual(util.comment_altitude(1524), "/A=005000")
        self.assertEqual(util.comment_altitude(3048), "/A=010000")
        self.assertEqual(util.comment_altitude(6096), "/A=020000")
        self.assertEqual(util.comment_altitude(30480), "/A=100000")
Beispiel #2
0
    def test_comment_altitude(self):
        self.assertEqual(util.comment_altitude(0), "/A=000000")

        # top limit
        self.assertEqual(util.comment_altitude(100000000), "/A=999999")
        # bottom limit
        self.assertEqual(util.comment_altitude(-100000000), "/A=-99999")

        self.assertEqual(util.comment_altitude(1.524), "/A=000005")
        self.assertEqual(util.comment_altitude(15.24), "/A=000050")
        self.assertEqual(util.comment_altitude(152.4), "/A=000500")
        self.assertEqual(util.comment_altitude(1524), "/A=005000")
        self.assertEqual(util.comment_altitude(3048), "/A=010000")
        self.assertEqual(util.comment_altitude(6096), "/A=020000")
        self.assertEqual(util.comment_altitude(30480), "/A=100000")
Beispiel #3
0
    def _serialize_body(self):

        if self.timestamp is None:
            timestamp = ''
        elif isinstance(self.timestamp, str):
            timestamp = self.timestamp
        else:
            timestamp = datetime.utcfromtimestamp(self.timestamp).strftime("%d%H%M") + 'z'

        body = [
            '/' if self.timestamp else '!',  # packet type
            timestamp,
            latitude_to_ddm(self.latitude),
            self.symbol_table,
            longitude_to_ddm(self.longitude),
            self.symbol,
            comment_altitude(self.altitude) if self.altitude is not None else '',
            self.comment,
        ]

        return "".join(body)
Beispiel #4
0
    def _serialize_body(self):

        if self.timestamp is None:
            timestamp = ''
        elif isinstance(self.timestamp, str):
            timestamp = self.timestamp
        else:
            timestamp = datetime.utcfromtimestamp(
                self.timestamp).strftime("%d%H%M") + 'z'

        body = [
            '/' if self.timestamp else '!',  # packet type
            timestamp,
            latitude_to_ddm(self.latitude),
            self.symbol_table,
            longitude_to_ddm(self.longitude),
            self.symbol,
            comment_altitude(self.altitude)
            if self.altitude is not None else '',
            self.comment,
        ]

        return "".join(body)