You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java/Janino scripting to replace our interpreter (graphhopper#2209)
* 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 (graphhopper#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 (graphhopper#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]>
*[Turn costs and restrictions](../stable/docs/core/turn-restrictions.md)
215
215
* Country specific routing via SpatialRules
216
-
* The core uses only a few dependencies (hppc, jts and slf4j)
216
+
* The core uses only a few dependencies (hppc, jts, janino and slf4j)
217
217
* Scales from small indoor-sized to world-wide-sized graphs
218
218
* Finds nearest point on street e.g. to get elevation or 'snap to road' or being used as spatial index (see [#1485](https://github.com/graphhopper/graphhopper/pull/1485))
219
219
* Calculates isochrones and [shortest path trees](https://github.com/graphhopper/graphhopper/pull/1577)
// avoid changing the specified CustomModel via deep copy otherwise the server-side CustomModel would be modified (same problem if queryModel would be used as target)
147
+
if (queryModel.isInternal())
148
+
thrownewIllegalArgumentException("CustomModel in query cannot be internal");
149
+
150
+
// avoid changing the specified CustomModel via deep copy otherwise the server-side CustomModel would be
151
+
// modified (same problem if queryModel would be used as target)
138
152
CustomModelmergedCM = newCustomModel(baseModel);
139
-
if (queryModel.maxSpeedFallback != null) {
140
-
if (mergedCM.maxSpeedFallback != null && mergedCM.maxSpeedFallback > queryModel.maxSpeedFallback)
141
-
thrownewIllegalArgumentException("CustomModel in query can only use max_speed_fallback bigger or equal to " + mergedCM.maxSpeedFallback);
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": entry in " + querySuperEntry.getValue() + " must not contain more than one key comparison but contained " + queryComparisonKeys);
if (multiply(queryMap.get(queryComparisonKeys.get(0)), mergedMap.get(mergedComparisonKeys.get(0))) != 0)
221
-
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": currently only blocking comparisons are allowed, but query was " + queryMap.get(queryComparisonKeys.get(0)) + " and server side: " + mergedMap.get(mergedComparisonKeys.get(0)));
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": only use a comparison key with a bigger value than " + comparisonMergedValue + " but was " + comparisonQueryValue);
229
-
} elseif (opChar == '>') {
230
-
if (comparisonMergedValue < comparisonQueryValue)
231
-
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": only use a comparison key with a smaller value than " + comparisonMergedValue + " but was " + comparisonQueryValue);
232
-
} else {
233
-
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": only use a comparison key with < or > as operator but was " + opChar);
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": number in one of the 'comparison' keys for " + querySuperEntry.getKey() + " wasn't parsable: " + queryComparisonKeys + " (" + mergedComparisonKeys + ")");
239
-
}
240
-
} else {
241
-
thrownewIllegalArgumentException(querySuperEntry.getKey() + ": comparison keys must match but did not: " + queryComparisonKeys.get(0) + " vs " + mergedComparisonKeys.get(0));
0 commit comments