def test_split_line(self):
     start = Coordinates(13.0, 52.0)
     middle = Coordinates(13.1, 52.0)
     end = Coordinates(13.1, 52.1)
     line = LineString([Point(*start), Point(*middle), Point(*end)])
     length = distance(start, middle) + distance(middle, end)
     (first, second) = split_line(line, 0.0)
     self.assertIsNone(first)
     self.assertEqual(second, line)
     (first, second) = split_line(line, 1.0 * length)
     self.assertIsNone(second)
     self.assertEqual(first, line)
     (first, second) = split_line(line, 0.5 * length)
     self.assertAlmostEqual(first.length + second.length, line.length)
 def test_distance_4(self):
     "Compare a WGS84 distance near prime Meridian to an expected value"
     geo1 = Coordinates(-0.0000886, 51.462934)
     geo2 = Coordinates(0.000097, 51.4629935)
     dist = distance(geo1, geo2)
     # Compare that to what Spatialite says
     self.assertAlmostEqual(14.50, dist, delta=0.05)
 def test_distance_3(self):
     "Compare a WGS84 distance to an expected value"
     geo1 = Coordinates(19.3644325, 51.796037)
     geo2 = Coordinates(19.3642027, 51.7957296)
     dist = distance(geo1, geo2)
     # Compare that to what Spatialite says
     self.assertAlmostEqual(37.7, dist, delta=0.05)
 def test_distance_1(self):
     "Compare a WGS84 distance to an expected value"
     geo1 = Coordinates(4.9091286, 52.3773181)
     geo2 = Coordinates(13.4622487, 52.4952885)
     dist = distance(geo1, geo2)
     # Compare that to what google maps says (579.3 km)
     self.assertAlmostEqual(dist, 579_530, delta=3000)
 def test_projection_and_angle(self):
     "Test re-projecting existing point"
     geo1 = Coordinates(13.41, 52.525)
     geo2 = Coordinates(13.414, 52.525)
     dist = distance(geo1, geo2)
     angle = bearing(geo1, geo2)
     geo3 = extrapolate(geo1, dist, angle)
     self.assertAlmostEqual(geo2.lon, geo3.lon)
     self.assertAlmostEqual(geo2.lat, geo3.lat)
 def test_point_along_path(self):
     "Test point projection along path"
     path = [
         Coordinates(0.0, 0.0),
         Coordinates(0.0, 1.0),
         Coordinates(0.0, 2.0)
     ]
     part_lengths = [
         distance(path[i], path[i + 1]) for i in range(len(path) - 1)
     ]
     length = sum(part_lengths)
     projected = interpolate(path, 0.75 * length)
     self.assertAlmostEqual(projected.lon, 0.0, places=3)
     self.assertAlmostEqual(projected.lat, 1.5, places=3)
Exemple #7
0
 def length(self) -> float:
     "Return distance between star and end node"
     return distance(self.start_node.coord, self.end_node.coord)
 def test_distance_2(self):
     "Compare a WGS84 distance to an expected value"
     geo1 = Coordinates(13.1759576, 52.4218989)
     geo2 = Coordinates(13.147999, 52.4515114)
     dist = distance(geo1, geo2)
     self.assertAlmostEqual(3800, dist, delta=10)