Open
Conversation
… eventually path details
…erand orders and null comparisons
- Replace CustomWeightingHelper.kvGet(__kv, key, reverse) with edge.getValue(key)
since EdgeIteratorState.getValue() already handles directionality internally
- Remove __kv variable declaration and kvGet helper method
- Handle tag.get() on either side of == / != (e.g. 'lane' == tag.get('cycleway'))
- Support null comparisons: tag.get('lit') == null / != null
- Reject double quotes in expressions; require single quotes for string literals
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
tag.get('cycleway') now compiles to edge.get(this.kv_cycleway_enc) where
kv_cycleway_enc is a KVStorageEncodedValue holding a pre-resolved key index.
This avoids the HashMap lookup in KVStorage.get() on every edge access by
resolving the string key to its internal int index once at init time.
- New KVStorageEncodedValue implements EncodedValue directly (no bits in
edge flags, supports two directions)
- KVStorage: add int-based get(pointer, keyIndex, reverse), reserveKey()
for pre-assigning key indices, and getKeyIndex() for resolution
- EdgeIteratorState: add default get(KVStorageEncodedValue) method falling
back to getValue(name); BaseGraph.EdgeIteratorStateImpl overrides with
the fast int-based path
- ConditionalExpressionVisitor: tag.get replacement now emits
edge.get(this.kv_<field>_enc) instead of edge.getValue("key")
- CustomModelParser: generates KVStorageEncodedValue fields and init code;
adds kvFieldName() to sanitize OSM keys to Java identifiers
- GraphHopper: registers KVStorageEncodedValue per stored tag in
buildEncodingManager; initKVStorageEncodedValues() reserves keys and
sets indices in both import and load paths
- config-example.yml: add default stored_tags with common cycling/walking
tags (cycleway, cycleway:left/right, lit, sidewalk)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the tag.get('xy') syntax with the shorter tag('xy') for
accessing KV-stored OSM tags in custom model expressions.
Add is_forward as a special variable in custom model expressions,
generating `boolean is_forward = !reverse` to expose the edge traversal
direction. This allows directional tag conditions like
`is_forward && tag('cycleway:right') == 'lane'`.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…odelParser; adds only the used kvstorageEnc as variables not all in the EncodingManager which fixes CACHE bug
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.
This is kind of a prototype, but already in good shape to allow arbitrary OSM tags in the custom model via:
{ "priority": [ { "if": "tag('cycleway') == 'lane'", "multiply_by": "2" } ] }Nice if you want to use OSM tags in a custom model but there is no encoded value yet. What about increasing the chance to have a 'lit' on your route? What about preferring sidewalks? Or how to exclude a certain road based on its street? All and a lot more is possible with this :)
However, there might be some downsides compared to encoded values:
==and!=are possible as operator in the custom modelis_forwardto make them meaningful.TODOs:
:and everything, which forces us to use a different syntax (compared to the current one for encoded values) to still keep the parsing simple, i.e. hand most of the parsing over to Janino. The current syntax is still rather short and avoids double escaping and still gives us a robust parsing from Janino as we just have to replace the'with"and no regex or other stuff. Also==only looks like a reference comparison but is usingequalsunder the hood making it more convenient to write.