Skip to content

Support for kml22gx.xsd extension

Latest

Choose a tag to compare

@urbancamo urbancamo released this 10 Apr 11:05

Release Notes

Bug Fixes

Style classes no longer emit stray default elements on marshal

IconStyle, LineStyle, and LabelStyle previously serialized <scale>, <heading>, and <width> elements even when callers never set them, because the underlying fields were primitive double (always 0.0) and JAXB's defaultValue only applies during unmarshalling. Affected fields have been converted to boxed Double so that unset (null) values are correctly omitted from output.

  • IconStyle.scale, IconStyle.heading
  • LineStyle.width
  • LabelStyle.scale

Breaking change (source-level, mostly benign): getters now return Double and setters/fluent withX(...) methods accept Double. Callers passing double literals (e.g. withWidth(6.0)) remain source-compatible via autoboxing; callers passing integer literals (e.g. withWidth(1)) must add a decimal (withWidth(1.0)). Binary compatibility is broken — downstream jars must be recompiled.

New Features

Icon palette sheet (sprite sheet) support

Added support for the Google gx: extension elements gx:x, gx:y, gx:w, gx:h on the <Icon> element, allowing callers to select a sub-rectangle of a larger sprite sheet image. This unblocks consumption of KML feeds — including some NOAA/NWS weather products and Google Earth sample data — that use sprite-based icon palettes.

iconStyle.createAndSetIcon()
    .withHref("https://example.com/weather-sprites.png")
    .withX(0.0).withY(0.0)
    .withW(138.0).withH(138.0);

Produces:

<Icon>
    <href>https://example.com/weather-sprites.png</href>
    <gx:x>0.0</gx:x>
    <gx:y>0.0</gx:y>
    <gx:w>138.0</gx:w>
    <gx:h>138.0</gx:h>
</Icon>

The new fields are typed Double (nullable) rather than Integer — verified necessary against Google's own libkml golden fixture, which uses floating-point values like 3.2/4.3. The local kml22gx.xsd has been updated to document the four new elements.

Test Coverage

  • IconStyleTest — 11 tests covering unset/explicit/zero scenarios for IconStyle.scale/heading, LineStyle.width, LabelStyle.scale, plus a verbatim reproduction of the reported bug scenario.
  • IconPaletteSheetTest — 5 tests covering defaults, marshal, unmarshal (both integer-form and float-form values), and round-trip.
  • RealWorldNwsFixturesTest — 4 tests parsing real NOAA/WPC KML fixtures (QPF6hr_f00-f06_latest.kml, Day1_psnow_gt_12inches.kml, Day_1_Excessive_Rainfall_Outlook.kml), including a round-trip regression check that confirms no stray <scale>/<heading>/<width> elements get introduced when a real-world file is parsed and re-serialized.
  • New test fixtures: libkml-all-gx.kml (from google/libkml, Apache 2.0, included with attribution header) and a synthetic icon_palette_sheet.kml modeled on the Google KML reference.

Total: 263 tests passing (up from 243).

Housekeeping

  • Removed the unresolvable maven-changelog-plugin reference from pom.xml (plugin last released 2014, no longer resolvable in modern Maven setups; only affected mvn site, which this project doesn't publish).