Beispiel #1
0
 def testSmallDistance(self):
     # Almost 10 meters
     self.assertAlmostEqual(
         geo.earth_distance(
             lat1=46.46338889, lon1=6.51755271,
             lat2=46.46339444, lon2=6.51768333),
         0.010, places=4)
Beispiel #2
0
 def testMediumDistance(self):
     # Almost 1000 meters
     self.assertAlmostEqual(
         geo.earth_distance(
             lat1=46.44307778, lon1=6.44688056,
             lat2=46.44813889, lon2=6.45766932),
         1.000, places=4)
Beispiel #3
0
 def in_radius(self, fix):
     """Checks whether the provided GNSSFix is within the radius"""
     distance = geo.earth_distance(self.lat, self.lon, fix.lat, fix.lon)
     return distance < self.radius
Beispiel #4
0
 def distance_to(self, other):
     """Computes great circle distance in kilometers to another GNSSFix."""
     return geo.earth_distance(self.lat, self.lon, other.lat, other.lon)
Beispiel #5
0
 def testHonoluluToKualaLumpur(self):
     self.assertAlmostEqual(
         geo.earth_distance(
             lat1=21.3, lon1=-157.816667,
             lat2=3.133333, lon2=101.683333),
         10964.740, places=2)
Beispiel #6
0
 def testLondonToNewYork(self):
     self.assertAlmostEqual(
         geo.earth_distance(
             lat1=51.507222, lon1=-0.1275,
             lat2=40.7127, lon2=-74.0059),
         5570.249, places=2)
Beispiel #7
0
 def contains(self, fix):
     if self.minAlt <= fix.alt <= self.maxAlt:
         distance = geo.earth_distance(self.lat, self.lon, fix.lat, fix.lon)
         return distance < self.radius
     return False
Beispiel #8
0
 def in_radius(self, fix):
     """Checks whether the provided GNSSFix is within the radius"""
     distance = geo.earth_distance(self.lat, self.lon, fix.lat, fix.lon)
     return distance < self.radius
Beispiel #9
0
 def distance_to(self, other):
     """Computes great circle distance in kilometers to another GNSSFix."""
     return geo.earth_distance(self.lat, self.lon, other.lat, other.lon)