class TestGeometryProj(unittest.TestCase): def setUp(self): self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84) self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84) self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84) return def test_greatcircle(self): d1 = self.vancouver.distance(self.ottawa) d2 = self.vancouver.distance(self.whitehorse) d3 = self.whitehorse.distance(self.ottawa) d4 = self.whitehorse.distance(self.vancouver) self.assertTrue(abs(d1 - 3549030.70541) < 1e-5) self.assertTrue(abs(d2 - 1483327.53922) < 1e-5) self.assertTrue(abs(d3 - 4151366.88185) < 1e-5) self.assertTrue(abs(d4 - 1483327.53922) < 1e-5) return def test_azimuth_lonlat(self): """ Verify with echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f" """ az1 = self.vancouver.azimuth(self.ottawa) az2 = self.vancouver.azimuth(self.whitehorse) self.assertAlmostEqual(az1, 78.483344, places=6) self.assertAlmostEqual(az2, -26.135827, places=6) return def test_walk_lonlat(self): start = Point((-132.14, 54.01), crs=LonLatWGS84) dest = start.walk(5440.0, 106.8) self.assertAlmostEqual(dest.x, -132.0605910876) self.assertAlmostEqual(dest.y, 53.99584742821) return
class TestGeometryProj(unittest.TestCase): def setUp(self): self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84) self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84) self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84) return def test_greatcircle(self): d1 = self.vancouver.distance(self.ottawa) d2 = self.vancouver.distance(self.whitehorse) d3 = self.whitehorse.distance(self.ottawa) d4 = self.whitehorse.distance(self.vancouver) self.assertTrue(abs(d1 - 3549030.70541) < 1e-5) self.assertTrue(abs(d2 - 1483327.53922) < 1e-5) self.assertTrue(abs(d3 - 4151366.88185) < 1e-5) self.assertTrue(abs(d4 - 1483327.53922) < 1e-5) return def test_azimuth_lonlat(self): """ Verify with echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f" """ az1 = self.vancouver.azimuth(self.ottawa) az2 = self.vancouver.azimuth(self.whitehorse) self.assertAlmostEqual(az1, 78.483344, places=6) self.assertAlmostEqual(az2, -26.135827, places=6) return def test_walk_lonlat(self): start = Point((-132.14, 54.01), crs=LonLatWGS84) dest = start.walk(5440.0, 106.8) self.assertAlmostEqual(dest.x, -132.0605910876) self.assertAlmostEqual(dest.y, 53.99584742821) return
def test_distance(self): for crs in (SphericalEarth, LonLatWGS84): pt0 = Point((0.0, 0.0), crs=crs) pt1 = Point((-1.0, 1.0), crs=crs) pt2 = Point((-179.5, 0.0), crs=crs) pt3 = Point((179.5, 1.0), crs=crs) self.assertAlmostEqual(pt0.distance(pt1), pt2.distance(pt3), places=8)
def test_distance(self): for crs in (SphericalEarth, LonLatWGS84): pt0 = Point((0.0, 0.0), crs=crs) pt1 = Point((-1.0, 1.0), crs=crs) pt2 = Point((-179.5, 0.0), crs=crs) pt3 = Point((179.5, 1.0), crs=crs) self.assertAlmostEqual(pt0.distance(pt1), pt2.distance(pt3), places=8)
class TestGeometryProj(unittest.TestCase): def setUp(self): self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84) self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84) self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84) return def test_greatcircle(self): d1 = self.vancouver.distance(self.ottawa) d2 = self.vancouver.distance(self.whitehorse) d3 = self.whitehorse.distance(self.ottawa) d4 = self.whitehorse.distance(self.vancouver) self.assertAlmostEqual(d1, 3549030.70541, places=5) self.assertAlmostEqual(d2, 1483327.53922, places=5) self.assertAlmostEqual(d3, 4151366.88185, places=5) self.assertAlmostEqual(d4, 1483327.53922, places=5) return def test_greatcircle_projected(self): van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) d1 = van.distance(ott, projected=False) d2 = van.distance(whi, projected=False) d3 = whi.distance(ott, projected=False) d4 = whi.distance(van, projected=False) self.assertAlmostEqual(d1, 3549030.70541, places=3) self.assertAlmostEqual(d2, 1483327.53922, places=3) self.assertAlmostEqual(d3, 4151366.88185, places=3) self.assertAlmostEqual(d4, 1483327.53922, places=3) return def test_azimuth_lonlat(self): """ Verify with echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f" """ az1 = self.vancouver.azimuth(self.ottawa) az2 = self.vancouver.azimuth(self.whitehorse) self.assertAlmostEqual(az1, 78.483344, places=6) self.assertAlmostEqual(az2, -26.135827, places=6) return def test_walk_lonlat(self): start = Point((-132.14, 54.01), crs=LonLatWGS84) dest = start.walk(5440.0, 106.8) self.assertAlmostEqual(dest.x, -132.0605910876) self.assertAlmostEqual(dest.y, 53.99584742821) return
def test_greatcircle_projected(self): van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) d1 = van.distance(ott, projected=False) d2 = van.distance(whi, projected=False) d3 = whi.distance(ott, projected=False) d4 = whi.distance(van, projected=False) self.assertAlmostEqual(d1, 3549030.70541, places=3) self.assertAlmostEqual(d2, 1483327.53922, places=3) self.assertAlmostEqual(d3, 4151366.88185, places=3) self.assertAlmostEqual(d4, 1483327.53922, places=3) return
class TestGeometryProj(unittest.TestCase): def setUp(self): self.vancouver = Point((-123.1, 49.25), crs=LonLatWGS84) self.ottawa = Point((-75.69, 45.42), crs=LonLatWGS84) self.whitehorse = Point((-135.05, 60.72), crs=LonLatWGS84) return def test_greatcircle(self): d1 = self.vancouver.distance(self.ottawa) d2 = self.vancouver.distance(self.whitehorse) d3 = self.whitehorse.distance(self.ottawa) d4 = self.whitehorse.distance(self.vancouver) self.assertAlmostEqual(d1, 3549030.70541, places=5) self.assertAlmostEqual(d2, 1483327.53922, places=5) self.assertAlmostEqual(d3, 4151366.88185, places=5) self.assertAlmostEqual(d4, 1483327.53922, places=5) return def test_greatcircle_projected(self): van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) d1 = van.distance(ott, projected=False) d2 = van.distance(whi, projected=False) d3 = whi.distance(ott, projected=False) d4 = whi.distance(van, projected=False) self.assertAlmostEqual(d1, 3549030.70541, places=3) self.assertAlmostEqual(d2, 1483327.53922, places=3) self.assertAlmostEqual(d3, 4151366.88185, places=3) self.assertAlmostEqual(d4, 1483327.53922, places=3) return def test_azimuth_lonlat(self): """ Verify with echo "49.25dN 123.1dW 45.42dW 75.69dW" | invgeod +ellps=WGS84 -f "%.6f" """ az1 = self.vancouver.azimuth(self.ottawa) az2 = self.vancouver.azimuth(self.whitehorse) self.assertAlmostEqual(az1, 78.483344, places=6) self.assertAlmostEqual(az2, -26.135827, places=6) return def test_walk_lonlat(self): start = Point((-132.14, 54.01), crs=LonLatWGS84) dest = start.walk(5440.0, 106.8) self.assertAlmostEqual(dest.x, -132.0605910876) self.assertAlmostEqual(dest.y, 53.99584742821) return
def test_greatcircle_projected(self): van = Point(self.vancouver.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) whi = Point(self.whitehorse.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) ott = Point(self.ottawa.vertex(GallPetersEqualArea), crs=GallPetersEqualArea) d1 = van.distance(ott, projected=False) d2 = van.distance(whi, projected=False) d3 = whi.distance(ott, projected=False) d4 = whi.distance(van, projected=False) self.assertAlmostEqual(d1, 3549030.70541, places=3) self.assertAlmostEqual(d2, 1483327.53922, places=3) self.assertAlmostEqual(d3, 4151366.88185, places=3) self.assertAlmostEqual(d4, 1483327.53922, places=3) return