mobility-toolbox-js
Version:
Toolbox for JavaScript applications in the domains of mobility and logistics.
124 lines (123 loc) • 5.56 kB
TypeScript
import { MocoAPI } from '..';
import MaplibreStyleLayer from './MaplibreStyleLayer';
import type { Map } from 'ol';
import type { MocoAPIOptions } from '../../api/MocoAPI';
import type { LineType, MocoExportParameters, PublicationLineGroupType, PublicationStopType, PublicationType, ReasonType } from '../../types';
import type { ServiceConditionGroupEnumeration, SeverityGroupEnumeration, SituationType } from '../../types';
import type { MaplibreStyleLayerOptions } from './MaplibreStyleLayer';
export declare const MOCO_SOURCE_ID = "moco";
export declare const MOCO_MD_LAYER_FILTER = "moco";
export type MocoLayerOptions = {
apiParameters?: MocoExportParameters;
loadAll?: boolean;
publicAt?: Date;
situations?: Partial<SituationType>[];
tenant?: string;
url?: string;
} & MaplibreStyleLayerOptions & Pick<MocoAPIOptions, 'apiKey' | 'tenant' | 'url'>;
export interface MocoNotificationStopPropertiesToRender {
name?: string;
publicationStopId?: PublicationStopType['id'];
}
export interface MocoNotificationLinePropertiesToRender {
hasIcon?: PublicationLineGroupType['hasIcon'];
line?: LineType;
mot?: PublicationLineGroupType['mot'];
name?: string;
}
export interface MocoNotificationSituationPropertiesToRender {
publicationId?: PublicationType['id'];
situationId?: SituationType['id'];
}
/**
* This type contains the properties used by the style to render the situation.
* The extended properties are there to avoid having to request the API again when
* displaying details for this feature.
*/
export type MocoNotificationFeaturePropertiesToRender = {
geometry?: undefined;
graph: string;
isAffected: boolean;
isPublished: boolean;
reasonCategoryImageName: string;
reasons?: ReasonType[];
serviceConditionGroup: ServiceConditionGroupEnumeration;
severityGroup: SeverityGroupEnumeration;
} & (MocoNotificationLinePropertiesToRender | MocoNotificationStopPropertiesToRender) & MocoNotificationSituationPropertiesToRender;
export type MocoNotificationFeatureToRender = GeoJSON.Feature<GeoJSON.LineString | GeoJSON.Point, MocoNotificationFeaturePropertiesToRender>;
export type MocoNotificationFeatureCollectionToRender = GeoJSON.FeatureCollection<GeoJSON.LineString | GeoJSON.Point, MocoNotificationFeaturePropertiesToRender>;
/**
* An OpenLayers layer able to display data from the [geOps MOCO API](https://geops.com/de/solution/disruption-information).
*
* @example
* import { MaplibreLayer, MaplibreStyleLayer } from 'mobility-toolbox-js/ol';
*
* const maplibreLayer = new MaplibreLayer({
* apiKey: 'yourApiKey',
* });
*
* const layer = new MocoLayer({
* apiKey: 'yourApiKey',
* maplibreLayer: maplibreLayer,
* // publicAt: new Date(),
* // loadAll: true,
* // notifications: undefined,
* // tenant: "geopstest",
* // url: 'https://moco.geops.io'
* });
*
* @see <a href="/example/ol-maplibre-style-layer">OpenLayers MaplibreStyle layer example</a>
* @extends {MaplibreStyleLayer}
* @private
*/
declare class MocoLayer extends MaplibreStyleLayer {
#private;
get api(): MocoAPI;
set api(value: MocoAPI);
get apiKey(): string | undefined;
set apiKey(value: string);
get apiParameters(): MocoExportParameters | undefined;
set apiParameters(value: MocoExportParameters);
get loadAll(): boolean;
set loadAll(value: boolean);
set publicAt(value: Date);
get publicAt(): Date;
set situations(value: Partial<SituationType>[]);
get situations(): Partial<SituationType>[] | undefined;
get tenant(): string | undefined;
set tenant(value: string);
get url(): string | undefined;
set url(value: string);
get useGraphs(): boolean;
/**
* Constructor.
*
* @param {Object} options
* @param {string} options.apiKey Access key for [geOps APIs](https://developer.geops.io/).
* @param {string} [options.apiParameters] The url parameters to be included in the MOCO API request.
* @param {boolean} [options.loadAll=true] If true, all active and published notifications will be loaded, otherwise only the notifications set in 'notifications' will be displayed.
* @param {boolean} [options.useGraphs=false] If true, only the notifications using the current graphs for the current zoom level will be passed to the maplibre source.
* @param {MocoNotification[]} [options.notifications] The notifications to display. If not set and loadAll is true, all active and published notifications will be loaded.
* @param {string} [options.publicAt] The date to filter notifications. If not set, the current date is used.
* @param {string} [options.tenant] The SSO config to use to get notifications from.
* @param {string} [options.url] The URL of the [geOps MOCO API](https://geops.com/de/solution/disruption-information).
* @public
*/
constructor(options: MocoLayerOptions);
attachToMap(map: Map): void;
detachFromMap(): void;
getDataByGraph(data: MocoNotificationFeatureCollectionToRender): MocoNotificationFeatureCollectionToRender;
/**
* This functions load situations from backend depending on the current graph mapping in the style metadata.
* @returns
*/
loadData(): Promise<SituationType[] | undefined>;
onLoad(): void;
onZoomEnd(): void;
/**
* This function updates the GeoJSON source data, with the current situations available in this.situations.
* @returns
*/
updateData(): Promise<boolean | undefined>;
}
export default MocoLayer;