-
Notifications
You must be signed in to change notification settings - Fork 15
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
Basic Numeric and Boolean Filter #110
Conversation
@@ -219,6 +231,108 @@ std::vector<vtzero::property> get_properties_vector(vtzero::feature& f) { | |||
return v; | |||
} | |||
|
|||
double convert_to_double(value_type value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ran into type conversion errors when the filter was one type (float) and the parameter value was a different type (int64) so I just cast everything to double here. There is probably a better way to achieve this but I'm not super familiar with boost::variadic.
436046a
to
ce3d12f
Compare
src/vtquery.cpp
Outdated
} | ||
|
||
/// apply filters to a feature | ||
bool filter_feature(vtzero::feature& feature, std::vector<filter_struct> filters) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return true if a feature should be rejected. Maybe it should return false as it didn't pass the filter.
src/vtquery.cpp
Outdated
@@ -308,6 +388,10 @@ struct Worker : Nan::AsyncWorker { | |||
while (auto feature = layer.next_feature()) { | |||
auto original_geometry_type = get_geometry_type(feature); | |||
|
|||
if (filter_enabled && filter_feature(feature, filters)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have filters and the filters say we should filter out this feature, skip to next feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helpful! 👍 Mind adding this as an inline comment?
src/vtquery.cpp
Outdated
} else if (filter.type == eq && feature_bool != filter_bool) { | ||
reject_feature = true; | ||
} | ||
} else if (feature_value.which() != 0 && feature_value.which() != 5 && filter.value.which() != 0 && filter.value.which() != 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be 1 <= .which() <= 4 to indicate numeric types instead of != 0 and != 5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why we can't apply these operations on uint (5) or sint (6) values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was following this and I think the uint and sint get mapped via the boost::variant defined as value_type to uint64_t and int64_t.
The value_type = boost::variant<std::string, float, double, int64_t, uint64_t, bool>;
so the numeric ones are 1-5, unless I'm misunderstanding something.
2937644
to
3a2a4f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CyanRook this is fantastic! I just left a couple comments, and am only requesting changes on the testing front. I'll follow up with a new fixture in mvt-fixtures you can use to add additional tests.
src/vtquery.cpp
Outdated
} else if (filter.type == eq && feature_bool != filter_bool) { | ||
reject_feature = true; | ||
} | ||
} else if (feature_value.which() != 0 && feature_value.which() != 5 && filter.value.which() != 0 && filter.value.which() != 5) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason why we can't apply these operations on uint (5) or sint (6) values?
src/vtquery.cpp
Outdated
@@ -308,6 +388,10 @@ struct Worker : Nan::AsyncWorker { | |||
while (auto feature = layer.next_feature()) { | |||
auto original_geometry_type = get_geometry_type(feature); | |||
|
|||
if (filter_enabled && filter_feature(feature, filters)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helpful! 👍 Mind adding this as an inline comment?
@CyanRook As for the failing ASAN builds, I'll need to take a little bit of time to ramp up into those failures. Will report back soon! |
@mapsam Sounds good. I changed something that seemingly fixed codecov so all thats left is asam but I might have just masked the problem instead of fixing it. |
* Implemented a basic optional filtering mechanism into VTQuery * This allows VTQuery to ignore features that don't match the filters * Enabled filtering for features that pass 'all' or 'any' of the filters. * Remove Node v4/v6 targets * Update to mvt-features to version 3.6.0
76f0328
to
947971d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Basic Filter for VTQuery.
Related Issues
Current Issues