Пример #1
0
    def __init__(self, points):
        points = utils.clean_points(points)
        if len(points) < 3:
            raise ValueError('polygon must have at least 3 unique vertices')

        self.lons = numpy.array([float(point.longitude) for point in points])
        self.lats = numpy.array([float(point.latitude) for point in points])
        if utils.line_intersects_itself(self.lons, self.lats, closed_shape=1):
            raise ValueError('polygon perimeter intersects itself')

        self._projection = None
        self._polygon2d = None
Пример #2
0
    def __init__(self, points):
        points = utils.clean_points(points)
        if len(points) < 3:
            raise ValueError('polygon must have at least 3 unique vertices')

        self.lons = numpy.array([float(point.longitude) for point in points])
        self.lats = numpy.array([float(point.latitude) for point in points])
        if utils.line_intersects_itself(self.lons, self.lats, closed_shape=1):
            raise ValueError('polygon perimeter intersects itself')

        self._projection = None
        self._polygon2d = None
Пример #3
0
    def __init__(self, points):
        self.points = utils.clean_points(points)

        if len(self.points) < 1:
            raise ValueError("One point needed to create a line!")
Пример #4
0
 def test_close_duplicates(self):
     a, b, c = geo.Point(1e-4, 1e-4), geo.Point(0, 0), geo.Point(1e-6, 1e-6)
     self.assertEqual(utils.clean_points([a, b, c]), [a, b])
Пример #5
0
 def test_exact_duplicates(self):
     a, b, c = geo.Point(1, 2, 3), geo.Point(3, 4, 5), geo.Point(5, 6, 7)
     self.assertEqual(utils.clean_points([a, a, a, b, a, c, c]),
                      [a, b, a, c])
Пример #6
0
    def __init__(self, points):
        self.points = utils.clean_points(points)

        if len(self.points) < 1:
            raise ValueError("One point needed to create a line!")
Пример #7
0
 def test_close_duplicates(self):
     a, b, c = geo.Point(1e-4, 1e-4), geo.Point(0, 0), geo.Point(1e-6, 1e-6)
     self.assertEqual(utils.clean_points([a, b, c]), [a, b])
Пример #8
0
 def test_exact_duplicates(self):
     a, b, c = geo.Point(1, 2, 3), geo.Point(3, 4, 5), geo.Point(5, 6, 7)
     self.assertEqual(utils.clean_points([a, a, a, b, a, c, c]),
                      [a, b, a, c])