Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Introduce geo::GeoBuf struct, alter geo::Geo struct #21

Closed
frewsxcv opened this issue Mar 9, 2016 · 4 comments
Closed

Proposal: Introduce geo::GeoBuf struct, alter geo::Geo struct #21

frewsxcv opened this issue Mar 9, 2016 · 4 comments

Comments

@frewsxcv
Copy link
Member

frewsxcv commented Mar 9, 2016

Idea

Currently, there exists just geo::Geo, which is a structure containing owned data. I propose we rename this to geo::GeoBuf and introduce a new structure containing borrowed data called geo::Geo. Table of similar analogies:

Owned Borrowed
Vec slice
String str
PathBuf Path
GeoBuf Geo

Reasoning

Currently, if there exists a method centerpoint on Geo, and I want to apply this operation on a Wkt struct (from rust-wkt), I have to convert my Wkt struct to a Geo, and since Geo is owned, this results in memory allocations occurring.

With my proposal above, we would just need to interpret the Wkt struct as the new borrowed Geo, which results in a Geo struct that references the existing data in the Wkt struct, resulting in no new memory allocations.

Implementation

struct Geo will be renamed to struct GeoBuf

struct Geo will be a new struct with borrowed fields. Not too sure how this will look right now, but it's do-able.

Deref<Target=Geo> will be implemented on GeoBuf

@frewsxcv frewsxcv changed the title Proposal: Introduce geo::GeoBuf struct, alter geo::Geo truct Proposal: Introduce geo::GeoBuf struct, alter geo::Geo struct Mar 9, 2016
@frewsxcv
Copy link
Member Author

On second thought, I forgot that we have separate structs for each geometry type (e.g. MultiPoint, Point, etc.). Not sure how that would work...

@frewsxcv
Copy link
Member Author

Another option here: https://gist.github.com/frewsxcv/1f334de4839fefc88a79

@frewsxcv
Copy link
Member Author

frewsxcv commented Nov 1, 2016

This might no longer need to happen if #67 gets resolved.

@kylebarron
Copy link
Member

Just curious, is there still interest in this? Is there a way today to use geo geometries from borrowed data? Or is the thought that in the long term geo traits will hopefully solve this use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
@frewsxcv @kylebarron and others