Esempio n. 1
0
 def test_to_npoints_lonlat(self):
     line = Line([(0, 40), (120, 40)], crs=LonLatWGS84)
     points = line.to_npoints(20)
     ans = [
         Point(v, crs=LonLatWGS84) for v in
         [(0, 40), (4.006549675732082,
                    43.200316625343305), (8.44359845345209,
                                          46.2434129228378),
          (13.382442375999254,
           49.09308515921458), (18.894149336762318, 51.705248417290484),
          (25.03918819127435,
           54.027440893063556), (31.85052685770255, 55.99968253476488),
          (39.31083346558522,
           57.55771841446013), (47.329401349484314, 58.6395037346357),
          (55.7308352362257,
           59.194673757153645), (64.26916476377436, 59.19467375715364),
          (72.67059865051574,
           58.639503734635674), (80.68916653441482, 57.557718414460105),
          (88.14947314229748,
           55.999682534764844), (94.96081180872568, 54.02744089306352),
          (101.10585066323772,
           51.705248417290456), (106.61755762400078, 49.09308515921457),
          (111.55640154654793,
           46.24341292283779), (115.99345032426793,
                                43.2003166253433), (120, 40)]
     ]
     for a, b in zip(points, ans):
         self.assertPointAlmostEqual(a, b)
     return
Esempio n. 2
0
 def test_to_npoints_cartesian(self):
     line = Line([(0.0, 0.0), (1.0, 2.0), (3.0, -2.0), (4.0, -1.0),
                  (4.0, 3.0), (3.0, 2.0)])
     points = line.to_npoints(20)
     ans = [
         Point(v) for v in
         [(0.0,
           0.0), (0.318619234003536,
                  0.637238468007072), (0.637238468007072,
                                       1.274476936014144),
          (0.9558577020106079,
           1.9117154040212159), (
               1.274476936014144,
               1.4510461279717122), (1.59309617001768, 0.8138076599646402),
          (1.911715404021216,
           0.17656919195756826), (2.230334638024752, -0.4606692760495037),
          (2.5489538720282883,
           -1.0979077440565757), (2.867573106031824, -1.7351462120636478),
          (3.294395938694146,
           -1.7056040613058538), (3.7981771815888177, -1.2018228184111823),
          (4.0, -0.5729663008226373), (
              4.0, 0.13948796534818164), (
                  4.0, 0.8519422315190006), (
                      4.0, 1.5643964976898195), (4.0, 2.2768507638606383),
          (4.0, 2.989305030031457), (3.5037812428946715,
                                     2.503781242894671), (3.0, 2.0)]
     ]
     for a, b in zip(points, ans):
         self.assertPointAlmostEqual(a, b)
     return
Esempio n. 3
0
 def test_to_npoints_lonlat(self):
     line = Line([(0, 40), (120, 40)], crs=LonLatWGS84)
     points = line.to_npoints(20)
     ans = [Point(v, crs=LonLatWGS84) for v in [(0, 40),
                               (4.006549675732082, 43.200316625343305),
                               (8.44359845345209, 46.2434129228378),
                               (13.382442375999254, 49.09308515921458),
                               (18.894149336762318, 51.705248417290484),
                               (25.03918819127435, 54.027440893063556),
                               (31.85052685770255, 55.99968253476488),
                               (39.31083346558522, 57.55771841446013),
                               (47.329401349484314, 58.6395037346357),
                               (55.7308352362257, 59.194673757153645),
                               (64.26916476377436, 59.19467375715364),
                               (72.67059865051574, 58.639503734635674),
                               (80.68916653441482, 57.557718414460105),
                               (88.14947314229748, 55.999682534764844),
                               (94.96081180872568, 54.02744089306352),
                               (101.10585066323772, 51.705248417290456),
                               (106.61755762400078, 49.09308515921457),
                               (111.55640154654793, 46.24341292283779),
                               (115.99345032426793, 43.2003166253433),
                               (120, 40)]]
     for a,b in zip(points, ans):
         self.assertPointAlmostEqual(a, b)
     return
Esempio n. 4
0
 def test_to_npoints_cartesian(self):
     line = Line([(0.0, 0.0), (1.0, 2.0), (3.0, -2.0), (4.0, -1.0),
                  (4.0, 3.0), (3.0, 2.0)])
     points = line.to_npoints(20)
     ans = [Point(v) for v in [(0.0, 0.0),
                               (0.318619234003536, 0.637238468007072),
                               (0.637238468007072, 1.274476936014144),
                               (0.9558577020106079, 1.9117154040212159),
                               (1.274476936014144, 1.4510461279717122),
                               (1.59309617001768, 0.8138076599646402),
                               (1.911715404021216, 0.17656919195756826),
                               (2.230334638024752, -0.4606692760495037),
                               (2.5489538720282883, -1.0979077440565757),
                               (2.867573106031824, -1.7351462120636478),
                               (3.294395938694146, -1.7056040613058538),
                               (3.7981771815888177, -1.2018228184111823),
                               (4.0, -0.5729663008226373),
                               (4.0, 0.13948796534818164),
                               (4.0, 0.8519422315190006),
                               (4.0, 1.5643964976898195),
                               (4.0, 2.2768507638606383),
                               (4.0, 2.989305030031457),
                               (3.5037812428946715, 2.503781242894671),
                               (3.0, 2.0)]]
     for a,b in zip(points, ans):
         self.assertPointAlmostEqual(a, b)
     return
Esempio n. 5
0
    def test_to_npoints_lonlat_precision(self):

        line = Line([(-20.247017, 79.683933), (-20.0993, 79.887917),
            (-19.13705, 80.048567), (-18.680467, 80.089333), (-17.451917,
                80.14405), (-16.913233, 80.02715), (-16.631367, 80.022933),
            (-16.194067, 80.0168), (-15.915983, 80.020267), (-15.7763,
                80.021283)], crs=LonLatWGS84)

        for n in range(2, 30):
            self.assertEqual(len(line.to_npoints(n)), n)
        return
Esempio n. 6
0
    def test_to_npoints_lonlat_precision(self):

        line = Line([(-20.247017, 79.683933), (-20.0993, 79.887917),
            (-19.13705, 80.048567), (-18.680467, 80.089333), (-17.451917,
                80.14405), (-16.913233, 80.02715), (-16.631367, 80.022933),
            (-16.194067, 80.0168), (-15.915983, 80.020267), (-15.7763,
                80.021283)], crs=LonLatWGS84)

        for n in range(2, 30):
            self.assertEqual(len(line.to_npoints(n)), n)
        return