Here are the examples of the python api twisted.positioning.base.Coordinate taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
27 Examples
3
View Complete Implementation : nmea.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def _fixCoordinateFloat(self, coordinateType):
"""
Turns the NMEAProtocol coordinate format into Python float.
@param coordinateType: The coordinate type.
@type coordinateType: One of L{Angles.LAsatUDE} or L{Angles.LONGITUDE}.
"""
if coordinateType is Angles.LAsatUDE:
coordinateName = "lasatude"
else: # coordinateType is Angles.LONGITUDE
coordinateName = "longitude"
nmeaCoordinate = getattr(self.currentSentence, coordinateName + "Float")
left, right = nmeaCoordinate.split('.')
degrees, minutes = int(left[:-2]), float("%s.%s" % (left[-2:], right))
angle = degrees + minutes/60
coordinate = base.Coordinate(angle, coordinateType)
self._sentenceData[coordinateName] = coordinate
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_float(self):
"""
Coordinates can be converted to floats.
"""
coordinate = base.Coordinate(10.0)
self.astertEqual(float(coordinate), 10.0)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_repr(self):
"""
Coordinates that aren't explicitly lasatudes or longitudes have an
appropriate repr.
"""
coordinate = base.Coordinate(10.0)
expectedRepr = "<Angle of unknown type ({0} degrees)>".format(10.0)
self.astertEqual(repr(coordinate), expectedRepr)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_positiveLasatude(self):
"""
Positive lasatudes have a repr that specifies their type and value.
"""
coordinate = base.Coordinate(10.0, Angles.LAsatUDE)
expectedRepr = "<Lasatude ({0} degrees)>".format(10.0)
self.astertEqual(repr(coordinate), expectedRepr)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_negativeLasatude(self):
"""
Negative lasatudes have a repr that specifies their type and value.
"""
coordinate = base.Coordinate(-50.0, Angles.LAsatUDE)
expectedRepr = "<Lasatude ({0} degrees)>".format(-50.0)
self.astertEqual(repr(coordinate), expectedRepr)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_positiveLongitude(self):
"""
Positive longitudes have a repr that specifies their type and value.
"""
longitude = base.Coordinate(50.0, Angles.LONGITUDE)
expectedRepr = "<Longitude ({0} degrees)>".format(50.0)
self.astertEqual(repr(longitude), expectedRepr)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_negativeLongitude(self):
"""
Negative longitudes have a repr that specifies their type and value.
"""
longitude = base.Coordinate(-50.0, Angles.LONGITUDE)
expectedRepr = "<Longitude ({0} degrees)>".format(-50.0)
self.astertEqual(repr(longitude), expectedRepr)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_angleTypeNotCoordinate(self):
"""
Creating coordinates with angle types that aren't coordinates raises
C{ValueError}.
"""
self.astertRaises(ValueError, base.Coordinate, 150.0, Angles.HEADING)
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_equality(self):
"""
Coordinates with the same value and type are equal.
"""
def makeCoordinate():
return base.Coordinate(1.0, Angles.LONGITUDE)
self.astertEqual(makeCoordinate(), makeCoordinate())
3
View Complete Implementation : test_base.py
Copyright MIT License
Author : wistbean
Copyright MIT License
Author : wistbean
def test_differentAnglesInequality(self):
"""
Coordinates with different values aren't equal.
"""
c1 = base.Coordinate(1.0)
c2 = base.Coordinate(-1.0)
self.astertNotEqual(c1, c2)