orbisgis / cts

Projection library in Java
GNU Lesser General Public License v3.0
49 stars 15 forks source link

Memory leak with example coordinate conversion #120

Closed robo-w closed 2 years ago

robo-w commented 5 years ago

A conversion of coordinates following the example in https://github.com/orbisgis/cts/wiki/4.-Apply-a-coordinate-transformation leads to a memory leak of org.cts.IdentifiableComponent#registry.

If multiple coordinate conversions with the same source and target CRS are generated, the org.cts.op.CoordinateOperation is generated again, although the matching operations already exist. This leads to a growing HashMap.

Options for a fix:

Example: Convert multiple coordinates from British National Grid (EPSG:27700) to GPS (EPSG:4326). After each run with the code from the example, following operations are added: image

Especially the operations like "degree to radian" would be nice if they are re-used, if they have the same parameters.

ebocher commented 4 years ago

Thanks for the comments. Sure the documentation must be improved. Feel free to contribute. About reusing the CoordinateOperation object checks this class https://github.com/orbisgis/h2gis/blob/master/h2gis-functions/src/main/java/org/h2gis/functions/spatial/crs/ST_Transform.java

mukoki commented 4 years ago

1 - Would be nice to give an example of CoordinateOperation re-use in chapter 4 of the wiki. 2 - Cache implementation as in ST_Transform could be done in CoordinateOperationFactory, but I think it is fine to let the user implement it the way he wants.