diff --git a/fiona/_geometry.pyx b/fiona/_geometry.pyx index de651ec9..768b198a 100644 --- a/fiona/_geometry.pyx +++ b/fiona/_geometry.pyx @@ -124,15 +124,19 @@ cdef class GeomBuilder: cdef list _buildCoords(self, void *geom): # Build a coordinate sequence cdef int i + cdef int npoints + cdef list coords = [] + if geom == NULL: raise ValueError("Null geom") npoints = OGR_G_GetPointCount(geom) - coords = [] - for i in range(npoints): - values = [OGR_G_GetX(geom, i), OGR_G_GetY(geom, i)] - if self.ndims > 2: - values.append(OGR_G_GetZ(geom, i)) - coords.append(tuple(values)) + + if self.ndims == 2: + for i in range(npoints): + coords.append((OGR_G_GetX(geom, i), OGR_G_GetY(geom, i))) + else: + for i in range(npoints): + coords.append((OGR_G_GetX(geom, i), OGR_G_GetY(geom, i), OGR_G_GetZ(geom, i))) return coords cdef dict _buildPoint(self, void *geom):