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

Use mapstructure to decode geometry #188

Open
bastienbc opened this issue Oct 22, 2020 · 1 comment
Open

Use mapstructure to decode geometry #188

bastienbc opened this issue Oct 22, 2020 · 1 comment

Comments

@bastienbc
Copy link

Hi,

I'm using your library to convert some mongodb documents into postgis rows.
The way I do it is simple, with mongodb I decode the bson into a struct with map[string]interface{},
Then I use your library to convert the geojson part into ewkb.

But to do so I have to first use json.Marshal, because the Unmarshal method from geojson needs a json (in bytes) to Unmarshal it.
So it's Bson -> map[string]interface{} -> json -> Geometry

Would it be possible to use mapstructure to encode/decode (using maybe separate functions to not break the API), to prevent this kind of pattern?
It should be pretty simple from my very short experience with mapstructure in the past.

@twpayne
Copy link
Owner

twpayne commented Oct 22, 2020

I would be concerned about the performance overhead of using mapstructure for every conversion, but there's no reason that such code couldn't be included as a separate encoding package and would happily review a PR adding it.

However, if you're doing a one-off conversion from MongoDB to PostGIS, do the extra steps that you have to perform really matter?

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

2 participants