def test_offset_calculations(self):
        """Tests the latitude/longitude to y_m/x_m offset calculations."""
        for value in (-2.0, -1.0, 0.0, 1.0, 2.0):
            self.assertAlmostEqual(
                value,
                Telemetry.offset_y_m_to_latitude(
                    Telemetry.latitude_to_m_offset(value)))
            self.assertAlmostEqual(
                value,
                Telemetry.latitude_to_m_offset(
                    Telemetry.offset_y_m_to_latitude(value)))
            for value_2 in (-0.01, 0.0, 0.01):
                self.assertAlmostEqual(
                    value,
                    Telemetry.offset_x_m_to_longitude(
                        Telemetry.longitude_to_m_offset(value, 0.0), value_2))
                self.assertAlmostEqual(
                    value,
                    Telemetry.offset_x_m_to_longitude(
                        Telemetry.longitude_to_m_offset(value, 0.0), value_2))

        rally_parking_lot = (40.020776, -105.248319)
        self.assertAlmostEqual(
            Telemetry.offset_x_m_to_longitude(
                Telemetry.longitude_to_m_offset(rally_parking_lot[1],
                                                rally_parking_lot[0]),
                rally_parking_lot[0]), rally_parking_lot[1])
Пример #2
0
    def test_offset_calculations(self):
        """Tests the latitude/longitude to y_m/x_m offset calculations."""
        for value in (-2.0, -1.0, 0.0, 1.0, 2.0):
            self.assertAlmostEqual(
                value,
                Telemetry.offset_y_m_to_latitude(
                    Telemetry.latitude_to_m_offset(value)
                )
            )
            self.assertAlmostEqual(
                value,
                Telemetry.latitude_to_m_offset(
                    Telemetry.offset_y_m_to_latitude(
                        value
                    )
                )
            )
            for value_2 in (-0.01, 0.0, 0.01):
                self.assertAlmostEqual(
                    value,
                    Telemetry.offset_x_m_to_longitude(
                        Telemetry.longitude_to_m_offset(value, 0.0),
                        value_2
                    )
                )
                self.assertAlmostEqual(
                    value,
                    Telemetry.offset_x_m_to_longitude(
                        Telemetry.longitude_to_m_offset(value, 0.0),
                        value_2
                    )
                )

        rally_parking_lot = (40.020776, -105.248319)
        self.assertAlmostEqual(
            Telemetry.offset_x_m_to_longitude(
                Telemetry.longitude_to_m_offset(
                    rally_parking_lot[1],
                    rally_parking_lot[0]
                ),
                rally_parking_lot[0]
            ),
            rally_parking_lot[1]
        )