{"action":"created","issue":{"url":"https://api.github.com/repos/georust/rust-gdal/issues/4","labels_url":"https://api.github.com/repos/georust/rust-gdal/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/georust/rust-gdal/issues/4/comments","events_url":"https://api.github.com/repos/georust/rust-gdal/issues/4/events","html_url":"https://github.com/georust/rust-gdal/issues/4","id":55810276,"number":4,"title":"Borrowed vs. owned geometries","user":{"login":"mgax","id":27617,"avatar_url":"https://avatars.githubusercontent.com/u/27617?v=3","gravatar_id":"","url":"https://api.github.com/users/mgax","html_url":"https://github.com/mgax","followers_url":"https://api.github.com/users/mgax/followers","following_url":"https://api.github.com/users/mgax/following{/other_user}","gists_url":"https://api.github.com/users/mgax/gists{/gist_id}","starred_url":"https://api.github.com/users/mgax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgax/subscriptions","organizations_url":"https://api.github.com/users/mgax/orgs","repos_url":"https://api.github.com/users/mgax/repos","events_url":"https://api.github.com/users/mgax/events{/privacy}","received_events_url":"https://api.github.com/users/mgax/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-01-28T20:24:45Z","updated_at":"2015-01-29T15:22:40Z","closed_at":null,"body":"The [OGR C API](http://www.gdal.org/ogr__api_8h.html) has two ways of accessing geometries:\r\n\r\n* take a geometry pointer from a feature using `OGR_F_GetGeometryRef`, and you're not supposed to modify or deallocate it,\r\n* clone the above geometry, or create one from scratch e.g. using `OGR_G_CreateFromWkt`, and you can modify it, and you're responsible for deallocating; you can also pass ownership back to OGR by attaching it to a feature, using `OGR_F_SetGeometryDirectly`.\r\n\r\nIn both cases, you have a pointer to `OGRGeometryH`. We should support operations on both, e.g. transforming them to JSON or WKT, and it makes sense to share the implementation.\r\n\r\nA naive approach would be to always copy geometries, and only work with owned geometries from Rust, but that seems wasteful. But I'm probably implementing this initially, to have a working API.\r\n\r\nAnother option is to create different types for owned and borrowed geometries and share the implementation by a common trait. I've experimented with this in the [feature-geometry branch](https://github.com/georust/rust-gdal/compare/feature-geometry).\r\n\r\nA third option is to have an owned geometry type, which wraps a borrowed geometry type, similar to `String` and `str`.\r\n\r\n@georust/core, any input is much appreciated :)"},"comment":{"url":"https://api.github.com/repos/georust/rust-gdal/issues/comments/72042354","html_url":"https://github.com/georust/rust-gdal/issues/4#issuecomment-72042354","issue_url":"https://api.github.com/repos/georust/rust-gdal/issues/4","id":72042354,"user":{"login":"sunng87","id":221942,"avatar_url":"https://avatars.githubusercontent.com/u/221942?v=3","gravatar_id":"","url":"https://api.github.com/users/sunng87","html_url":"https://github.com/sunng87","followers_url":"https://api.github.com/users/sunng87/followers","following_url":"https://api.github.com/users/sunng87/following{/other_user}","gists_url":"https://api.github.com/users/sunng87/gists{/gist_id}","starred_url":"https://api.github.com/users/sunng87/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunng87/subscriptions","organizations_url":"https://api.github.com/users/sunng87/orgs","repos_url":"https://api.github.com/users/sunng87/repos","events_url":"https://api.github.com/users/sunng87/events{/privacy}","received_events_url":"https://api.github.com/users/sunng87/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T15:22:40Z","updated_at":"2015-01-29T15:22:40Z","body":"For now we cannot avoid some package specific types. I think it's OK to keep these types and export them publicly. (Perhaps in a `raw` module?) \r\n\r\nWe only need to provide To/From traits and impls to convert them into our geo types for integration."}}