예제 #1
0
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
예제 #2
0
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
예제 #3
0
    def test_azimuth(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.azimuth(pt1), pt2.azimuth(pt3), places=8)
예제 #4
0
    def test_azimuth(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.azimuth(pt1),
                                   pt2.azimuth(pt3),
                                   places=8)
예제 #5
0
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
예제 #6
0
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
예제 #7
0
    def test_point_azimuth_projected(self):
        """ Verify with:

        printf "0 -1000000\n100000 -900000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s -w6 | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"

        and

        cat <(printf "0 -1000000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s -w6) <(printf "100000 -900000" | proj +proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s -w6) | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"
        """
        point = Point((0.0, -10e5), crs=NSIDCNorth)
        other = Point((1e5, -9e5), crs=NSIDCNorth)
        self.assertAlmostEqual(point.azimuth(other, projected=False), 45.036973, places=6)

        other = Point((1e5, -9e5), crs=NSIDCSouth)
        self.assertAlmostEqual(point.azimuth(other, projected=False), -117.140678, places=6)
        return
예제 #8
0
    def test_point_azimuth3(self):
        """ Verify with:

        printf "0 -1000000\n100000 -900000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"
        """
        point = Point((0.0, -10e5), crs=NSIDCNorth)
        other = Point((1e5, -9e5), crs=NSIDCNorth)
        self.assertAlmostEqual(point.azimuth(other), 45.036973, places=6)
        return
예제 #9
0
    def test_point_azimuth3(self):
        """ Verify with:

        printf "0 -1000000\n100000 -900000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"
        """
        point = Point((0.0, -10e5), crs=NSIDCNorth)
        other = Point((1e5, -9e5), crs=NSIDCNorth)
        self.assertAlmostEqual(point.azimuth(other), 45.036973, places=6)
        return
예제 #10
0
    def test_point_azimuth_projected(self):
        """ Verify with:

        printf "0 -1000000\n100000 -900000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s -w6 | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"

        and

        cat <(printf "0 -1000000" | proj +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s -w6) <(printf "100000 -900000" | proj +proj=stere +lat_0=-90 +lat_ts=-70 +lon_0=0 +k=1 +x_0=0 +y_0=0 +units=m +datum=WGS84 +no_defs -I -s -w6) | tr '\n' ' ' | invgeod +ellps=WGS84 -f "%.6f"
        """
        point = Point((0.0, -10e5), crs=NSIDCNorth)
        other = Point((1e5, -9e5), crs=NSIDCNorth)
        self.assertAlmostEqual(point.azimuth(other, projected=False),
                               45.036973,
                               places=6)

        other = Point((1e5, -9e5), crs=NSIDCSouth)
        self.assertAlmostEqual(point.azimuth(other, projected=False),
                               -117.140678,
                               places=6)
        return
예제 #11
0
    def test_point_azimuth(self):
        point = Point((1.0, 2.0))

        other = Point((2.0, 3.0))
        self.assertEqual(point.azimuth(other), 0.25 * 180)

        other = Point((0.0, 3.0))
        self.assertEqual(point.azimuth(other), -0.25 * 180)

        other = Point((0.0, 1.0))
        self.assertEqual(point.azimuth(other), -0.75 * 180)

        other = Point((2.0, 1.0))
        self.assertEqual(point.azimuth(other), 0.75 * 180)

        other = Point((1.0, 3.0))
        self.assertEqual(point.azimuth(other), 0.0)

        other = Point((1.0, 1.0))
        self.assertEqual(point.azimuth(other), 180.0)
        return
예제 #12
0
    def test_point_azimuth(self):
        point = Point((1.0, 2.0))

        other = Point((2.0, 3.0))
        self.assertEqual(point.azimuth(other), 0.25*180)

        other = Point((0.0, 3.0))
        self.assertEqual(point.azimuth(other), -0.25*180)

        other = Point((0.0, 1.0))
        self.assertEqual(point.azimuth(other), -0.75*180)

        other = Point((2.0, 1.0))
        self.assertEqual(point.azimuth(other), 0.75*180)

        other = Point((1.0, 3.0))
        self.assertEqual(point.azimuth(other), 0.0)

        other = Point((1.0, 1.0))
        self.assertEqual(point.azimuth(other), -180.0)
        return
예제 #13
0
 def test_point_azimuth2(self):
     point = Point((5.0, 2.0))
     other = Point((5.0, 2.0))
     self.assertTrue(np.isnan(point.azimuth(other)))
     return
예제 #14
0
 def test_point_azimuth_nan(self):
     point = Point((5.0, 2.0))
     other = Point((5.0, 2.0))
     self.assertTrue(np.isnan(point.azimuth(other)))
     return