Fix string comparisons in LightCharacteristics Java port - #9
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes incorrect string identity comparisons in the Java port of LightCharacteristics, ensuring category-dependent formatting (e.g., Dir, Aero, (vert), (hor), etc.) correctly applies for non-interned tag strings coming from Planetiler/OSM parsing.
Changes:
- Replaces
==/!=string comparisons with value-based checks (.equals(...)andisEmpty()). - Fixes a substring comparison to use
": ".equals(...)rather than==. - Updates multiple conditional branches so category/type-specific decorations are reliably appended to the encoded light string.
Suppressed comments (1)
data/planetiler/LightCharacteristics.java:129
str += VALMXR += "M";mutates the localVALMXRas a side effect, which is unnecessary and easy to misread (it looks like a bug). Prefer concatenating without modifyingVALMXR.
if (!VALMXR.isEmpty()) {
str += VALMXR += "M";
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+97
to
99
| } else if (!SIGGRP.isEmpty()) { | ||
| str += LITCHR + "(" + SIGGRP + ")"; | ||
| } |
Comment on lines
+72
to
79
| if (!CATLIT.isEmpty() && "fog_signal".equals(type)) { | ||
| str += capitalize(CATLIT) + ": "; | ||
| } | ||
| if (CATLIT == "directional") { | ||
| if ("directional".equals(CATLIT)) { | ||
| str += "Dir"; | ||
| } | ||
| if (CATLIT == "aero" || CATLIT == "air_obstruction") { | ||
| if ("aero".equals(CATLIT) || "air_obstruction".equals(CATLIT)) { | ||
| str += "Aero"; |
Owner
|
thanks for the PR! it's nice to know that this is useful for other projects :) |
Contributor
Author
|
@k-yle 🤝 |
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.
Fixes #8.
This replaces the string identity comparisons (
==/!=) indata/planetiler/LightCharacteristics.javawith value comparisons (.equals()andisEmpty()). In Java==compares object identity, so the category branches (Dir,Aero,(vert),(hor),(Front),(Rear),(Upper),(Lower)) never fire for tag values that come from Planetiler, and these decorations were missing from_lxin the tiles.I verified with the reproduction from the issue: after the change, both interned and non-interned input produce
F.W(vert). The empty-string presence checks are replaced withisEmpty(), so behaviour for absent tags stays the same.