Skip to content

Handle null orientation explicitly in generateVehicleIcon #449

Description

@aaronbrethorst

Context

In PR #383, toDirection() was updated to return null for non-finite inputs (NaN, Infinity, null, undefined, etc.). The caller in src/lib/MapHelpers/generateVehicleIcon.js:26 (getDirectionFromOrientation(toDirection(orientation))) relies on JavaScript's implicit null → 0 coercion to default to the "north" icon when orientation data is missing.

Suggestion

Add an explicit null check in createVehicleIconSvg so that when toDirection returns null, the vehicle icon is rendered without a directional arrow (or with a clearly "unknown direction" state) rather than silently defaulting to north.

This is cosmetic — the current behavior matches what happened before the refactor (NaN also defaulted to north) — but an explicit check would be cleaner and prevent confusion for future maintainers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions