LuciadRIA (2026.0.05)
    Preparing search index...

    A ShapeProvider maps features from a single model to different geometric representations. It is used by a FeatureLayer.

    A common use case is visualizing the same model on both a geographic map and a Cartesian map.

    For example, a ShapeProvider can display trajectories on a geodetic map in one layer, and the same trajectories on a vertical view map in another layer.

    class TrajectoryShapeProvider extends ShapeProvider {
    constructor() {
    super();
    this.reference = createCartesianReference({
    xUnitOfMeasure: meterUnit,
    yUnitOfMeasure: meterUnit
    });
    }

    provideShape(trajectoryFeature: Feature) {
    const shape = trajectoryFeature.shape as any as Polyline;
    if (!shape || !shape.reference) {
    return null;
    }

    // Creates a cartesian shape for the passed trajectory feature,
    // where the x-coordinates represent the distance along the trajectory, and the y-coordinate represents the altitude of the aircraft at that point.
    const geodesy = createEllipsoidalGeodesy(shape.reference);
    const points: Point[] = [];

    // for each of the points in the original trajectory calculate the distance from the first point using
    // the geodesy instance. This gives us the x-coordinate of the resulting shape
    // The height is directly available in the z-coordinate of the points of the original trajectory
    let distance = 0;
    let point0 = shape.getPoint(0);
    points[0] = createPoint(this.reference, [0, point0.z]);

    for (let i = 0; i < shape.pointCount; i++) {
    const nextPoint = shape.getPoint(i);
    distance += geodesy.distance(point0, nextPoint, LineType.SHORTEST_DISTANCE);
    points.push(createPoint(this.reference, [distance, nextPoint.z]))
    point0 = nextPoint;
    }
    return createPolyline(this.reference, points);
    }
    }

    Example of a ShapeProvider that provides shapes asynchronously:

    class AsyncShapeProvider extends ShapeProvider {
    private readonly shapeCache: Map<string|number, Shape>
    private readonly shapePromise: Map<string|number, Promise<Shape>>;
    constructor() {
    super();
    this.shapeCache = new Map();
    this.shapePromise = new Map();
    }

    provideShape(feature: Feature) {
    const shape = this.shapeCache.get(feature.id);
    if (shape) {
    // Shape was already resolved
    return shape;
    }

    if (!this.shapePromise.get(feature.id)) {
    // Invoke a function that provides shapes asynchronously
    const promiseForShape = getAsyncShape(feature);
    this.shapePromise.set(feature.id, promiseForShape);

    // When the promise is resolved cache the shape and invalidate itself
    promiseForShape.then((shape) => {
    this.shapeCache.set(feature.id, shape);
    this.shapePromise.delete(feature.id);
    // Invalidate self to provide the resolved shape
    this.invalidateById(feature.id);
    });
    }

    // The feature will not be drawn till its shape is resolved
    return null;
    };
    }

    Implements

    Constructors

    Accessors

    • get reference(): CoordinateReference | null

      The reference of the shapes produced by the provideShape method.

      When a ShapeProvider is added to a FeatureLayer and the layer is then attached to a map, LuciadRIA determines whether the shapes can be visualized by matching the shape provider’s reference to the map’s reference.

      This property is optional. If not set, the FeatureLayer assumes that all shapes use the same reference as the associated FeatureModel.

      Returns CoordinateReference | null

    • set reference(reference: CoordinateReference | null): void

      Parameters

      Returns void

    Methods

    • Invalidates the shape of a specific feature.

      Call this method when any state affecting the mapping between a feature and its shape has changed. Doing so ensures that the feature will be repainted with an updated shape during the next map render.

      Parameters

      • feature: Feature

        The feature whose shape should be re-evaluated.

      Returns void

    • Invalidates the shapes of all features.

      Calling this method ensures that all features will be repainted with updated shapes during the next map render.

      Returns void

    • Invalidates the shape of a specific feature by its ID.

      Call this method when any state affecting the mapping between a feature and its shape has changed. Doing so ensures that the feature will be repainted with an updated shape during the next map render.

      Parameters

      Returns void

    • Returns a shape for the given feature. The returned shape must match the declared reference.

      Parameters

      • feature: Feature

        The feature for which to provide a shape.

      Returns Shape | null

      The shape associated with the given feature, or null if no shape is available.

    Events

    • Registers a callback function for the "InvalidateAll" event, that notifies a listener that the all features are invalidated.

      Parameters

      • event: "InvalidateAll"

        Always set to "InvalidateAll" for this event type.

      • callback: () => void

        The callback function to be executed when the event is emitted

      • Optionalcontext: any

        The context in which the function should be invoked.

        "InvalidateAll"

      Returns Handle

      2026.0

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

      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

      • Optionalcontext: any

        The context in which the function should be invoked.

        "Invalidate"

      Returns Handle

      2026.0

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

      Parameters

      • event: "InvalidateById"

        Always set to "InvalidateById" for this event type.

      • callback: (id: FeatureId) => void

        The callback function to be executed when the event is emitted

      • Optionalcontext: any

        The context in which the function should be invoked.

        "InvalidateById"

      Returns Handle

      2026.0