Fix: HexagonDrawable 4-arg constructor renders invisible hexagons#1301
Conversation
…psforge#1300) The 4-arg constructor was projecting geographic coordinates through MercatorProjection.project() and feeding the resulting screen-space x/y values into GeomBuilder.points(). Since VectorLayer interprets whatever it receives as lat/lng, the Mercator-projected hexagon landed at a completely wrong map position and was effectively invisible. Fix: remove MercatorProjection.project() call and Point usage, pass point.getLongitude()/point.getLatitude() directly to gb.points(), matching the working 2-arg constructor. Removed unused imports. Add HexagonDrawableTest to the playground, which renders 4 hexagons at distinct European locations and logs vertex coordinates to console, proving all vertices are valid geographic degrees. Co-Authored-By: Claude <noreply@anthropic.com>
Testing on Debian with Intel GPU, it works correctly. Perhaps something with your graphics drivers? |
could be. changing to Keep in mind that the the issue generation, the PR, the fix, all description and report ... is all generated by claude and I have no idea about java. This described fix described above appears to me that it might break some apps, that already implemented a workaround for the hexagon. Im not sure if it is good to roll out this fix |
|
@jhotadhari Thanks for the fix! |
Closes #1300
The bug
HexagonDrawablehas two constructors that build geometry in different coordinate spaces, causing the 4-argument version to render invisible hexagons.The 2-arg constructor correctly uses geographic lat/lng when building the JTS polygon via
GeomBuilder:The 4-arg constructor was projecting through Mercator first and feeding screen-space x/y into
GeomBuilderas if they were lat/lng:Since
VectorLayerlater interprets whatever it receives as geographic coordinates, the Mercator-projected hexagon lands at a completely wrong map position and is effectively invisible.This was the only usage of
MercatorProjectionin the entiregeometriespackage — other style-accepting drawables (CircleDrawable,RectangleDrawable,PolygonDrawable) all pass raw lon/lat directly.The fix
Remove the
MercatorProjection.project()call andPointusage from the 4-arg constructor. Instead, pass geographic coordinates directly toGeomBuilder, matching the 2-arg constructor behavior:Also removed the now-unused
MercatorProjectionandPointimports.Proof
HexagonDrawableTestrenders 4 hexagons at distinct European locations and logs every vertex coordinate. All vertices are valid geographic degrees, confirming the 4-arg constructor now correctly places hexagons at the intended map positions:Before the fix, the 4-arg constructor would have produced Mercator-projected x/y values (on the order of millions) fed into
GeomBuilderas if they were geographic degrees — making those same hexagons land nowhere near the map viewport (effectively invisible).Side note: running the playground test
The playground
build.gradleneeded two temporary tweaks to run the test on Ubuntu 22.04 — neither is part of this PR:implementation project(':vtm-desktop-lwjgl')→':vtm-desktop-lwjgl3'. LWJGL 2's native.soloading hits a glibcld.soassertion on Ubuntu 22.04+. LWJGL 3 has no such issue.mainClass = project.findProperty('mainClassName')so theapplicationplugin picks up the main class from-PmainClassName=on the command line.Run with:
🤖 Generated with Claude Code