Skip to content

Commit

Permalink
In _transform_geom finally clean up all allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
sgillies committed Jan 1, 2025
1 parent 8491f03 commit a8309f7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Bug fixes:
- A more information exception is now raised by JSONField.get() when the value
cannot be decoded (#1463).

Changes:

- Python coordinate sequence construction has been improved, translating to
better performance in reading Fiona Features from datasets (#1462).

1.10.1 (2024-09-16)
-------------------

Expand Down
39 changes: 20 additions & 19 deletions fiona/_transform.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -160,25 +160,26 @@ def _transform_geom(src_crs, dst_crs, geom, antimeridian_cutting, antimeridian_o

factory = new OGRGeometryFactory()

if isinstance(geom, Geometry):
out_geom = recursive_round(
_transform_single_geom(geom, factory, transform, options), precision)
else:
out_geom = [
recursive_round(
_transform_single_geom(single_geom, factory, transform, options),
precision,
)
for single_geom in geom
]

OCTDestroyCoordinateTransformation(transform)

if options != NULL:
_csl.CSLDestroy(options)

OSRRelease(src)
OSRRelease(dst)
try:
if isinstance(geom, Geometry):
out_geom = recursive_round(
_transform_single_geom(geom, factory, transform, options), precision)
else:
out_geom = [
recursive_round(
_transform_single_geom(single_geom, factory, transform, options),
precision,
)
for single_geom in geom
]

finally:
del factory
OCTDestroyCoordinateTransformation(transform)
if options != NULL:
_csl.CSLDestroy(options)
OSRRelease(src)
OSRRelease(dst)

return out_geom

Expand Down

0 comments on commit a8309f7

Please sign in to comment.