Skip to content

Fix string comparisons in LightCharacteristics Java port - #9

Merged
k-yle merged 1 commit into
k-yle:mainfrom
wildsurfer:fix/lx-string-equality
Aug 4, 2026
Merged

Fix string comparisons in LightCharacteristics Java port#9
k-yle merged 1 commit into
k-yle:mainfrom
wildsurfer:fix/lx-string-equality

Conversation

@wildsurfer

@wildsurfer wildsurfer commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #8.

This replaces the string identity comparisons (== / !=) in data/planetiler/LightCharacteristics.java with value comparisons (.equals() and isEmpty()). 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 _lx in 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 with isEmpty(), so behaviour for absent tags stays the same.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(...) and isEmpty()).
  • 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 local VALMXR as a side effect, which is unnecessary and easy to misread (it looks like a bug). Prefer concatenating without modifying VALMXR.
    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";
@k-yle
k-yle merged commit d647322 into k-yle:main Aug 4, 2026
2 checks passed
@k-yle

k-yle commented Aug 4, 2026

Copy link
Copy Markdown
Owner

thanks for the PR! it's nice to know that this is useful for other projects :)

@wildsurfer

Copy link
Copy Markdown
Contributor Author

@k-yle 🤝

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LightCharacteristics.java: string comparisons with == drop Dir/Aero/(vert)/(hor) suffixes for real tag values

3 participants