Repository navigation
Custom weighting helper cleanup - #2211
Merged
Merged
Conversation
karussell
reviewed
Dec 14, 2020
|
|
||
| @FunctionalInterface | ||
| public interface EdgeToDoubleMapping { | ||
| double apply(EdgeIteratorState edge, boolean reverse); |
Member
There was a problem hiding this comment.
In current master this is named EdgeToValueEntry and getValue but the class name you have is better, unsure about apply :D
Member
Author
There was a problem hiding this comment.
java.util.Function calls it apply, but honestly this never sounded very intuitive to me either. Maybe call it get like java.util.Supplier? Or map? Don't know really.
karussell
approved these changes
Dec 14, 2020
Member
Author
|
After merging this maybe we can migrate some tests from |
easbar
marked this pull request as ready for review
December 14, 2020 12:03
karussell
added a commit
that referenced
this pull request
Jan 19, 2021
* basic test with janino passing * move janino scripting to safe whitelisted approach * create a class to add encoded values on the fly but limit user input to expression * compilation unit via overwriting getValue method safely * minor fix regarding ClassName * ensure it is not called twice * separate parsing of condition and number * CustomWeighting: ensure Map is ordered (#2162) * CustomWeighting: ensure Map is ordered * minor * cleaner junit5 assertThrows * one more assertThrow * change expression from factor multiplication to if-then-elseif-else and make speed factor working too * replace catch all with true and make max_speed working * no need to parse value which is always a number * use global max speed * minor cleanup and fix regarding sharedEV * found a way to avoid Unparser.unparse * use scripting in CustomWeighting. This revealed: we need if and if-else-if clauses and maybe a different variable initialization * reduce max speed and fix priority bug * cosmetics * minor truck.yml tweaks * adapt benchmarks * a bit more details in exception * see perf with ugly caching hack * revert and see bench * workaround bug with import conflict (two imports for enum 'NO') * inject class for constants, avoid static imports that can easily collide * special case of RouteNetwork for bike * introduce thread-safe caching; minor restructuring * reduce code duplication in ScriptHelper * move code out of ScriptHelper and rename it to ExpressionBuilder * less recursion for more clear protection * further cleanup and improved naming * adapt CustomModel.merge to scripting and throw exception if query-CustomModel contains factors >1 * improved docs about custom model * adapted docs to new format * removed CustomWeightingOld and all related classes * minor fixes * make debugging possible; every dynamic class has a different name now; fix two issues in source code creation (RoadClass->EncodedValue and import JsonFeature) * improve caching: remove oldest accessed entry, instead oldest inserted * introduce cache to keep certain classes in cache forever * try perf with disabled cache to see CH numbers again * Revert "try perf with disabled cache to see CH numbers again" This reverts commit 85c9743. * make it possible to disable dyn cache; clarify about the static cache which is populated via checkProfilesConsistency * allow multiple first_match and make names of encoded values even stricter * non-shared EncodedValue is too complex due to '.' we should use '$' or '__' * use non-shared encoded values * test again without cache * call in-area method only when necessary, improves speed where pre-conditional checks are done like road_class!=PRIMARY && in_area_custom1 * make area names stricter * already consider parts of the pull request reviews * Custom weighting helper cleanup (#2211) * Chain CustomWeighting constructors, use static creator method * CustomWeighting no longer depends on CustomWeightingHelper * Extract parameter object for CustomWeighting * Use SpeedAndAccessProvider interface, add ExpressionBuilderTest * Change apply -> get * More fine-grained usage of try statement * revert DEFAULT to true * docs: remove confusing statement * better name for subclass * no need for the extra line in test * simple max_speed_fallback handling, still explicit * migrate to if-then notation * fix benchmarks for if-then notation * made Clause methods shorter * introduce different Op * merge speed_factor and max_speed into speed via introduced 'multiply with' and 'limit to' operators; cleanup * further simplify custom model: remove max_speed_fallback * bug fix * docs: adapt to know notation * multiply with -> by * minor cleanup * support for StringEncodedValue * UI fixes for new format; make isSharedEncodedValues method private again * bug fix for findMaxSpeed calculation * test perf: disable cache for comparison * test perf: again * enable cache to permanently store internal Weighting classes * uhm, test perf: without cache but push separately * Revert "uhm, test perf: without cache but push separately" This reverts commit 6bb9fd0. * minor improvements * removed SpeedAndAccessProvider * make sure that the internal cache will never be too big * fix package of JaninoCustomWeightingHelperSubclass * rename ExpressionBuilder to CustomModelParser * made CustomModelParser parser public and move create method to it from CustomWeighting * comment regarding internal cache method * create -> createWeighting * move CustomModel to different package to hide useInternalCache methods * limit size of the whole script, not single expressions * Rename CustomModelParser#create etc. * minor * rename internal and throw exception if found in query * fix contentString * Improve profiles.md * Fix road_surface->surface and else: "" -> else: null * Explain how to use else statement in JSON * Fix GH maps example * Warn instead of error in case the edge distance of very long edges differs from way geometry length (cherry picked from commit dfee21c) * rename * error message e.g. in case of encoded value wasn't added * distanceInfluence: use default value only if not initialized * less cryptic error message Co-authored-by: Andi <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here I tried separating the custom model parsing from the custom weighting creation a bit, such that e.g. we can test extracting speeds and priorities from the custom model definition without creating a
CustomWeighting.Follow-up of this comment: https://github.com/graphhopper/graphhopper/pull/2209/files#r541899846