Lift ndim check out of loop. (#3273)

This updates the code to reflect recent Fiona changes.
This commit is contained in:
Ryan Grout 2024-12-06 12:57:48 -07:00 committed by GitHub
parent a156d1aeb3
commit bea623a5af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -506,15 +506,17 @@ cdef class GeomBuilder:
cdef _buildCoords(self, OGRGeometryH geom):
# Build a coordinate sequence
cdef int i
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
cpdef _buildPoint(self):