Skip to content

fix: render blue dot fallback for point features without SIDC#113

Open
axel-krapotke wants to merge 1 commit intomainfrom
fix/live-data-source-default-symbol
Open

fix: render blue dot fallback for point features without SIDC#113
axel-krapotke wants to merge 1 commit intomainfrom
fix/live-data-source-default-symbol

Conversation

@axel-krapotke
Copy link
Copy Markdown
Contributor

Problem

Point features arriving via the ODIN LiveDataSource (implemented as SSEVectorSource) were not visible on the map when the incoming GeoJSON carried neither an sidc property nor a custom svg property — even though data was clearly flowing.

Root cause

In src/renderer/ol/style/symbol.js, the style spec for point features was built unconditionally as:

return [{
  id: 'style:2525c/symbol',
  'symbol-code': sidc,
  'symbol-modifiers': modifiers
}]

When sidc is missing, symbol-code becomes undefined. The style spec then flows into styleFactory.makeImage (src/renderer/ol/style/styleFactory.js:188-195):

const makeImage = props => {
  if (props['icon-image']) return makeCanvasIcon(props)
  else if (props['circle-radius']) return makeCircle(props)
  else if (props['shape-radius']) return makeShape(props)
  else if (props['symbol-code']) return makeSymbol(props)
  else if (props['icon-url']) return makeIcon(props)
  else return null
}

None of the branches match, makeImage returns null, and the resulting ol.style.Style has no image. The feature is attached to the source but renders as nothing on the map.

Missing SIDCs are a legitimate case for live data feeds, so filtering the feature out is not acceptable — we want at least a locatable marker.

Fix

In symbol.js, when neither svg nor sidc is present, return a fallback blue dot style spec that uses the existing circle-* props already supported by makeCircle:

if (!sidc) {
  return [{
    id: 'style:default/bluedot',
    'circle-radius': 6,
    'circle-fill-color': 'rgba(51,153,204,1)',
    'circle-line-color': '#ffffff',
    'circle-line-width': 1.5
  }]
}

This mirrors OpenLayers' canonical default point style and keeps such features visible without needing new registry entries (unknown IDs pass inline props through — see styleRegistry.js:192).

Line/Polygon features without SIDC are unaffected — shape.js already falls back to a black default stroke.

Test plan

  • Push GeoJSON Point features via the LiveDataSource with an sidc property → military symbol renders as before
  • Push GeoJSON Point features via the LiveDataSource with a svg property → custom SVG renders as before
  • Push GeoJSON Point features via the LiveDataSource without sidc and without svg → blue dot appears at the feature location
  • Push GeoJSON LineString/Polygon features without sidc → still render with default black stroke

Point features arriving via LiveDataSource (SSEVectorSource) that carry
neither an SIDC nor a custom SVG produced a Style with symbol-code set
to undefined. In styleFactory.makeImage none of the branches matched,
so the feature was rendered without an image and stayed invisible.

Return a blue dot style spec in that case so the feature is locatable
on the map.
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.

1 participant