Пример #1
0
 def __getitem__(self, index):
     "Returns the Point at the given index."
     if index >= 0 and index < self.point_count:
         x, y, z = c_double(), c_double(), c_double()
         capi.get_point(self.ptr, index, byref(x), byref(y), byref(z))
         dim = self.coord_dim
         if dim == 1:
             return (x.value,)
         elif dim == 2:
             return (x.value, y.value)
         elif dim == 3:
             return (x.value, y.value, z.value)
     else:
         raise OGRIndexError('index out of range: %s' % str(index))
 def __getitem__(self, index):
     "Return the Point at the given index."
     if 0 <= index < self.point_count:
         x, y, z = c_double(), c_double(), c_double()
         capi.get_point(self.ptr, index, byref(x), byref(y), byref(z))
         dim = self.coord_dim
         if dim == 1:
             return (x.value,)
         elif dim == 2:
             return (x.value, y.value)
         elif dim == 3:
             return (x.value, y.value, z.value)
     else:
         raise IndexError('Index out of range when accessing points of a line string: %s.' % index)
Пример #3
0
 def __getitem__(self, index):
     "Returns the Point at the given index."
     if index >= 0 and index < self.point_count:
         x, y, z = c_double(), c_double(), c_double()
         capi.get_point(self.ptr, index, byref(x), byref(y), byref(z))
         dim = self.coord_dim
         if dim == 1:
             return (x.value, )
         elif dim == 2:
             return (x.value, y.value)
         elif dim == 3:
             return (x.value, y.value, z.value)
     else:
         raise OGRIndexError('index out of range: %s' % str(index))
Пример #4
0
            return (self.x, self.y, self.z)
    coords = tuple


class LineString(OGRGeometry):

    def __getitem__(self, index):
<<<<<<< HEAD
        "Returns the Point at the given index."
        if index >= 0 and index < self.point_count:
=======
        "Return the Point at the given index."
        if 0 <= index < self.point_count:
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
            x, y, z = c_double(), c_double(), c_double()
            capi.get_point(self.ptr, index, byref(x), byref(y), byref(z))
            dim = self.coord_dim
            if dim == 1:
                return (x.value,)
            elif dim == 2:
                return (x.value, y.value)
            elif dim == 3:
                return (x.value, y.value, z.value)
        else:
<<<<<<< HEAD
            raise OGRIndexError('index out of range: %s' % str(index))

    def __iter__(self):
        "Iterates over each point in the LineString."
        for i in range(self.point_count):
            yield self[i]