Options
All
  • Public
  • Public/Protected
  • All
Menu

TrajectoryPainter.

This painter uses the graphics hardware to efficiently switch styling and filtering.

Highlights

  • Property filtering: efficiently filter on propertyColorExpressions.
  • Property styling: efficiently choose and switch colors based on propertyColorExpressions.
  • Time filtering: filter parts of a line based on a timeWindow.
  • Density: overlapping trajectories are automatically painted with more intense color.
  • Trajectory head and trail highlighting: the part of the line close to the current time range end is emphasized, the tail is faded out.

Note that this painter does not allow overriding of paintBody, unlike the usual FeaturePainter. All styling is configured by setting this object's properties.

See also ParameterizedLinePainter for a painter with similar capabilities for more generic line datasets.

Limitations:

  • This painter can only be used on a WebGLMap.
  • This painter cannot be combined with FeaturePainter.density based on a color map. Instead, density is automatically applied using a gradient per color (default and in the expressions).
  • You can only use two different colors in propertyColorExpressions or defaultColor. You can re-use the same color multiple times though. For example, you can have two rules that colors red, two that color green, two that hide elements and a default color green. This limitation exists to allow efficient density using color gradients.
  • This painter does not support labels. You should not override paintLabel.

Hierarchy

Implements

Overview

Constructors

constructor

  • Creates a new TrajectoryPainter.

    Examples

    Specifying filtering and styling based on feature properties

    You can specify simple expressions to determine the visibility and color based on feature properties. Use a null color to hide features.

    // Create a painter, specify that we will filter on "airline" and "destination"
    const trajectoryPainter = new TrajectoryPainter({
      properties: ["airline", "destination"],
      defaultColor: "rgb(255, 255, 255)"
    });
    
    // At runtime, immediately change styling and filtering
    trajectoryPainter.propertyColorExpressions = [
      {property: "destination", value: "Brussels", color: "rgb(255, 0, 0")},  // Destination Brussels = red
      {property: "destination", value: "London", color: "rgb(0, 255, 0")}     // Destination London = green
    ];
    trajectoryPainter.defaultColor = null;                                       // Hide all the rest
    
    // At runtime, immediately change styling and filtering
    trajectoryPainter.propertyColorExpressions = [
      {property: "airline", value: "Brussels Airlines", color: "rgb(255, 0, 0")},  // Brussels Airlines = red
    ];
    trajectoryPainter.defaultColor = "rgb(0, 0, 255)";                                // All the rest = blue

    Specifying per-point time and continuously change time window

    // Create a painter, specify a provider that can calculate time per point of a line
    const trajectoryPainter = new TrajectoryPainter({
      lineWidth: 1,
      timeProvider: function(feature, shape, pointIndex) {
        return feature.properties.timestamps[pointIndex];
      },
      timeWindow: [0, 3600]
    });
    
    // Update the painter when the users updates the time window in the UI (e.g. on slider drag)
    timeSlider.onChange(function(startTime, endTime) {
      trajectoryPainter.timeWindow = [startTime, endTime];
    });

    Parameters

    Returns TrajectoryPainter

Events

on

  • (event: "InvalidateAll", callback: () => void, context?: any): Handle
  • (event: "Invalidate", callback: (feature: Feature) => void, context?: any): Handle
  • (event: "InvalidateById", callback: (id: string | number) => void, context?: any): Handle
  • Registers a callback function for the "InvalidateAll" event, that notifies a listener that the all features are invalidated.

    since

    2020.1

    Parameters

    • event: "InvalidateAll"

      Always set to "InvalidateAll" for this event type.

    • callback: () => void

      The callback function to be executed when the event is emitted

        • (): void
        • Returns void

    • Optional context: any

      The context in which the function should be invoked.

    Returns Handle

  • Registers a callback function for the "Invalidate" event, that notifies a listener that a given feature is invalidated.

    since

    2020.1

    Parameters

    • event: "Invalidate"

      Always set to "Invalidate" for this event type.

    • callback: (feature: Feature) => void

      The callback function to be executed when the event is emitted

    • Optional context: any

      The context in which the function should be invoked.

    Returns Handle

  • Registers a callback function for the "InvalidateById" event, that notifies a listener that a feature with the given id is invalidated.

    since

    2020.1

    Parameters

    • event: "InvalidateById"

      Always set to "InvalidateById" for this event type.

    • callback: (id: string | number) => void

      The callback function to be executed when the event is emitted

        • (id: string | number): void
        • Parameters

          • id: string | number

          Returns void

    • Optional context: any

      The context in which the function should be invoked.

    Returns Handle

Accessors

defaultColor

  • get defaultColor(): string | null
  • set defaultColor(defaultColor: string | null): void

density

  • get density(): null
  • set density(v: null): void

outsideTimeRangeWeight

  • get outsideTimeRangeWeight(): number
  • set outsideTimeRangeWeight(timeWeight: number): void
  • The weight of parts of lines that are outside of the configured time windows.

    Use 0 to completely discard these parts, so that they don't count in the density.

    Use a number > 0 (for example 0.05) to let these parts add to the density. They will form a hazy image of all the lines, whether "active" or not.

    Note that numbers lower than 0.004 are treated as 0 (they map to 0 when representing it as a single byte).

    default

    0.01 (1%)

    Returns number

  • The weight of parts of lines that are outside of the configured time windows.

    Use 0 to completely discard these parts, so that they don't count in the density.

    Use a number > 0 (for example 0.05) to let these parts add to the density. They will form a hazy image of all the lines, whether "active" or not.

    Note that numbers lower than 0.004 are treated as 0 (they map to 0 when representing it as a single byte).

    default

    0.01 (1%)

    Parameters

    • timeWeight: number

    Returns any

propertyColorExpressions

  • An array of objects describing a mapping of property values to colors.

    Each object in the array describes a single entry in the map and has the following structure:

    • property The name of the property as a string.
    • value The value of the property. Can be any type.
    • color The color as a CSS color string, or null to hide features.
    The mapping can be read as: if property x equals value y, use color z. Else if property p equals value v use color c....

    When multiple entries result in a color for a trajectory, the first entry of the possible entries in the array will be used.

    Note that any property used in the expressions must be specified in the constructor parameter TrajectoryPainterConstructorOptions.properties.

    You can only use two different colors in propertyColorExpressions or defaultColor. You can re-use the same color multiple times though.

    default

    [] (no expressions, defaultColor is used)

    Returns PropertyColorExpression[]

  • An array of objects describing a mapping of property values to colors.

    Each object in the array describes a single entry in the map and has the following structure:

    • property The name of the property as a string.
    • value The value of the property. Can be any type.
    • color The color as a CSS color string, or null to hide features.
    The mapping can be read as: if property x equals value y, use color z. Else if property p equals value v use color c....

    When multiple entries result in a color for a trajectory, the first entry of the possible entries in the array will be used.

    Note that any property used in the expressions must be specified in the constructor parameter TrajectoryPainterConstructorOptions.properties.

    You can only use two different colors in propertyColorExpressions or defaultColor. You can re-use the same color multiple times though.

    default

    [] (no expressions, defaultColor is used)

    Parameters

    Returns any

selectionColor

  • get selectionColor(): string | null
  • set selectionColor(selectionColor: string | null): void

timeWindow

  • get timeWindow(): [number, number]
  • set timeWindow(range: [number, number]): void
  • The start / end values for the window of the time filter.

    This setting only has effect if you have set a timeProvider in the constructor.

    This must be an array with two values.

    The end value should be larger than the start value.

    default

    [0, Number.MAX_VALUE]

    Returns [number, number]

  • The start / end values for the window of the time filter.

    This setting only has effect if you have set a timeProvider in the constructor.

    This must be an array with two values.

    The end value should be larger than the start value.

    default

    [0, Number.MAX_VALUE]

    Parameters

    • range: [number, number]

    Returns any

Methods

getDetailLevelScales

  • Returns an array of map scales that determine when this painter should switch from one level-of-detail to the next. This can be used to advertise that this painter supports multiple level-of-details for a given object. The current level-of-detail that is used is determined by the map and is passed back to this FeaturePainter via the state.level property that is passed to the paint methods. The default implementation of this method returns null indicating the level-of-detail is not supported.

    see

    FeaturePainter#paintBody

    see

    FeaturePainter#paintLabel

    A visual example of the relation between the scale switching points and the paint levels. The example uses 3 different switching scales, hence resulting with 4 paint levels.

    // Scale:           1 : 100 000          1 : 10 000            1 : 1000
    // (zoomed out) -------- | ----------------- | ----------------- | -------- (zoomed in)
    //          level 0      |      level 1      |      level 2      |      level 3
    
    getDetailLevelScales(): number[] {
      return [1 / 100000, 1 / 10000, 1 / 1000];
    }

    Parameters

    • Optional layer: FeatureLayer

      the layer for which the detail level scales are being requested

    • Optional map: Map

      the map for which the detail level scales are being requested

    Returns number[] | null

    the switch scales for each level of detail

invalidate

  • Invalidates this painter for a specific feature. Call this method when any state that determines the rendering of a specific feature has been changed. Calling this method refreshes this FeaturePainter's layer and guarantees that paintBody() and paintLabel() will be called for the given feature during the next map render.

    Parameters

    • feature: Feature

      the model feature whose representation has changed

    Returns void

invalidateAll

  • (): void
  • Invalidates this painter for all objects. Call this method when any state that determines the rendering of objects has been changed. Calling this method refreshes the FeaturePainter's layer and guarantees that paintBody() and paintLabel() will be called for all objects in the layer during the next map render.

    Returns void

invalidateById

  • (featureId: string | number): void
  • Invalidates this painter for a specific object by id. Call this method when any state that determines the rendering of a specific object has been changed. Calling this method refreshes this FeaturePainter's layer and guarantees that paintBody() and paintLabel() will be called for the given object during the next map render.

    Parameters

    • featureId: string | number

      The id of the feature. It corresponds to Feature.id.

    Returns void

paintBody

Optional paintBorderBody

  • (): void

Optional paintBorderLabel

  • (): void

Optional paintLabel

  • (): void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method