-
Notifications
You must be signed in to change notification settings - Fork 18
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
[oshdb-filter] discussion for PR #380 refactor oshdb-filter #385
Conversation
- make Filter.class a utility class, replace Filter with FilterExpression - remove intemediate interface/class FilterInternal, RangedFilter - combine ContributionFilters together - combine GeometryFilters together - make negatable geometry/contribution-filter
this test should not fail, because |
Right, this is a major bug/oversight and also does not fulfill the contract defined for the method (see oshdb/oshdb-filter/src/main/java/org/heigit/ohsome/oshdb/filter/FilterExpression.java Lines 37 to 38 in e194364
Right! For contribution/snapshot-based filters this is also true for |
|
||
private Filter() { | ||
// utility class | ||
} |
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.
is this really needed for an abstract class?
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.
No I don't think so, the private constructor is enough, like it is e.ge OSHEntityTimeUtils
. Even sonarlint was complaining why I don't do 😂
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 meant, that the Filter should better not be abstract.
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.
why I don't do
you mean convert the class to an interface?
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.
You are right, that is what sonarlint suggest ("because it is abstract class with only static methods"), but actually what it should be is rule-1118 Utility Class
So wrong here is that this class is abstract.
@@ -12,7 +11,7 @@ | |||
/** | |||
* A filter condition which can be applied to an OSM entity. | |||
*/ | |||
public interface Filter extends FilterExpression { | |||
public abstract class Filter { |
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.
why the change from interface to abstract class?
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.
The change here is actually not to implement FilterExpression
and to keep the Filter as a "sandalone" utility class, as it only provides static methods for creating FilterExpressions
in various forms.
At first glance I dislike this change in this PR. It seemingly unnecessarily destroys the distinction of |
I see what you mean, but the mapReducer.filter(new FilterExpression() {
public FilterExpression negate() {
throw new UnsupportedOperationException();
}
public boolean applyOSM(OSMEntity entity) {
return ...// custom filter logic
}
}); We could solve this, by letting the mapReducer.filter accept only the subtype |
That's true, because we check on the geometry and not actually on the osm it self. But let me bring the same example but add one more assert.
I'm thinking about a query like "type:way and barrier=wall and geometry:polygon" on a contribution endpoint. This could build potentially alot of geometries even if it is clear in the osm filter that this entity never should result in a polygon. I just saw that for this example "barrier=wall", the DefaultTagInterpreter tag this as polygon! Is this intended?
|
Well, OSM constantly changes 😅. A few years ago when I first compiled this polygon tag list, the OSM wiki didn't really mandate tagging
I wouldn't say never since any OSM entity can always have the
I think this is an optimization which only few queries really benefit from and it would make the implementation more complex, because we need to somehow make sure that the same |
Yes: then one couldn't use the method anymore to set non-"primitive" filters with boolean operators (e.g.
I guess a simple "solution" for this would be that the |
This PR is for discussion of some refactoring within the oshdb-filter module. It is based on PR #380
And should provide some suggestion as a starting point for a discussion:
As the
Filter
only adds static methods to theFilterExpression
, we could extract it as a utility class and replace it withFilterExpression
where ever it is referenced as a typeFilterInternal
seem to just provide a default implementation fornegate
which we can pull to theFilterExpression
interface, and removeFilterInternal
we could "pull" some classes like (ChangesetIdFilter|GeometryTypeFilter|ContributorIdFilter)(Equals|EqualsAnyOf|Range) together as they provide just "strategies" for filtering and no concrete class would be necessary. Like ContributionFilter, and GeometryFilter
Wrapping the Contribution Based filters with a Negatable does not work because Negatable "blindly" negate all filter methods also
applyOSM
which for the ContributionTypes should always return true, because of the possible "minor"-versions.We should also take a look over some tests for example:
Should this test not fail? It is a closed ring but it is missing the tags which leads to a "polygon", e.g. building=yes