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

switch from many parameters in constructor to a single Options struct #21

Merged
merged 1 commit into from
Dec 7, 2015

Conversation

mikemorris
Copy link
Contributor

semver major, fixes #20

/cc @mourner @jfirebaugh @incanus

@incanus
Copy link
Contributor

incanus commented Dec 2, 2015

👍, especially the abstraction of extent and buffer.

@mourner
Copy link
Member

mourner commented Dec 2, 2015

Looks great.

I'd suggest mirroring the JS version API though, with features as the first flat required argument and optional object for all the rest options.

BTW what's the reason to keep the API 2-step with first doing convertFeatures on GeoJSON data and then passing the converted features to constructor, instead of one step like in the JS version?

@mikemorris
Copy link
Contributor Author

I'd suggest mirroring the JS version API though, with features as the first flat required argument and optional object for all the rest options.

Sounds good, will change this. 👍

BTW what's the reason to keep the API 2-step with first doing convertFeatures on GeoJSON data and then passing the converted features to constructor, instead of one step like in the JS version?

Not sure, I'm not too familiar with either version to be honest.

@mourner
Copy link
Member

mourner commented Dec 2, 2015

@incanus do you know?

@mikemorris
Copy link
Contributor Author

@jfirebaugh Is there an easy fix for initializer lists in GCC?

../test/test_full.cpp:21:55: error: no matching function for call to ‘mapbox::util::geojsonvt::GeoJSONVT::GeoJSONVT(<brace-enclosed initializer list>)’
                         .indexMaxPoints = maxPoints } };
                                                       ^
../test/test_full.cpp:21:55: note: candidate is:
In file included from ../test/test_full.cpp:4:0:
../include/mapbox/geojsonvt/geojsonvt.hpp:33:5: note: mapbox::util::geojsonvt::GeoJSONVT::GeoJSONVT(mapbox::util::geojsonvt::Options)
     GeoJSONVT(Options);
     ^
../include/mapbox/geojsonvt/geojsonvt.hpp:33:5: note:   no known conversion for argument 1 from ‘<brace-enclosed initializer list>’ to ‘mapbox::util::geojsonvt::Options’

@jfirebaugh
Copy link
Contributor

That's designated initializer syntax, and it's a C99 feature. As far as I know there's no portable way to use it in C++. You'll have to write it out manually:

    Options options;
    options.features = features;
    options.maxZoom = 14;
    options.indexMaxZoom = maxZoom;
    options.indexMaxPoints = maxPoints;
    GeoJSONVT index(options);

@incanus
Copy link
Contributor

incanus commented Dec 2, 2015

BTW what's the reason to keep the API 2-step with first doing convertFeatures on GeoJSON data and then passing the converted features to constructor, instead of one step like in the JS version?

Hmm, interesting, and I didn't do it in the intermediary Swift port:

https://github.com/mapbox/geojsonvt.swift/blob/bc44007a3baf7d26734e108e5d05079d037f39cd/geojsonvt/geojsonvt/geojsonvt.swift

I think this was related to something in the original shape annotations implementation (https://github.com/mapbox/mapbox-gl-native/pull/1655/files) like needing to convert first, but not necessarily tile until a later point.

@mikemorris mikemorris force-pushed the 20-configurable-options branch from 2c32527 to 80e1230 Compare December 2, 2015 23:08
@mourner
Copy link
Member

mourner commented Dec 2, 2015

I think this was related to something in the original shape annotations implementation

@incanus can we ditch the step now so that it mirrors the JS API?

@incanus
Copy link
Contributor

incanus commented Dec 3, 2015 via email

indexMaxPoints(indexMaxPoints_),
solidChildren(solidChildren_),
tolerance(tolerance_) {
GeoJSONVT::GeoJSONVT(std::vector<ProjectedFeature> features_, Options options)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not store an Options object directly into the GeoJSONVT object rather than exploding it into its parts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that seems like it would work well.

@mikemorris
Copy link
Contributor Author

@mourner @kkaefer Is it valuable to keep convertFeatures as a public static method for performance testing?

@mourner
Copy link
Member

mourner commented Dec 5, 2015

@mikemorris doesn't matter much, I think this is good to merge.

@kkaefer
Copy link
Member

kkaefer commented Dec 6, 2015

@mikemorris let's make it private; we should add more detailed benchmarking to the internals of geojson-vt-cpp anyway if the need arises to optimize.

- move convertFeatures from public static to private member function
- private Options var on GeoJSONVT class
@mikemorris mikemorris force-pushed the 20-configurable-options branch from 25ab258 to d0d81a6 Compare December 7, 2015 20:10
@mikemorris
Copy link
Contributor Author

Rebased and squashed, this should be good to merge (and tag v3.0 - is breaking from JS versions an issue here @mourner?) once Travis passes.

@mourner
Copy link
Member

mourner commented Dec 7, 2015

and tag v3.0 - is breaking from JS versions an issue here @mourner?

Not sure what's the best practice is, but worth noting that we diverged the API anyway even though the version was mirrored, so we probably have to break the version mirroring here, even if it's not wanted. @jfirebaugh what do you think?

@jfirebaugh
Copy link
Contributor

I think it's fine to version js and cpp independently.

mikemorris added a commit that referenced this pull request Dec 7, 2015
switch from many parameters in constructor to a single Options struct
@mikemorris mikemorris merged commit ea92425 into master Dec 7, 2015
@mikemorris mikemorris deleted the 20-configurable-options branch December 7, 2015 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make all parameters configurable
5 participants