Skip to content

Commit

Permalink
docs: fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
oterral committed Feb 13, 2025
1 parent b91b292 commit 5a38609
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/api/RoutingAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface RoutingAPIOptions {
* This class provides convenience methods to use to the [geOps Routing API](https://developer.geops.io/apis/routing).
*
* @example
* import { RoutingAPI } from 'mobility-toolbox-js';
* import { RoutingAPI } from 'mobility-toolbox-js/api';
*
* const api = new RoutingAPI({
* apiKey: [yourApiKey],
Expand Down
27 changes: 18 additions & 9 deletions src/common/utils/RealtimeEngine.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Coordinate } from 'ol/coordinate';

import { FeatureCollection } from 'geojson';
import debounce from 'lodash.debounce';
import throttle from 'lodash.throttle';
Expand All @@ -24,12 +26,9 @@ import {
} from '../../types';
import realtimeDefaultStyle from '../styles/realtimeDefaultStyle';
import { FilterFunction, SortFunction } from '../typedefs';

import * as realtimeConfig from './realtimeConfig';
import renderTrajectories from './renderTrajectories';

import type { Coordinate } from 'ol/coordinate';

export interface RealtimeEngineOptions {
api?: RealtimeAPI;
apiKey?: string;
Expand Down Expand Up @@ -223,8 +222,16 @@ class RealtimeEngine {
this.useRequestAnimationFrame = options.useRequestAnimationFrame || false;
this.useThrottle = options.useThrottle !== false; // the default behavior

this.getViewState = options.getViewState || (() => ({}));
this.shouldRender = options.shouldRender || (() => true);
this.getViewState =
options.getViewState ||
(() => {
return {};
});
this.shouldRender =
options.shouldRender ||
(() => {
return true;
});
this.onRender = options.onRender;
this.onIdle = options.onIdle;
this.onStart = options.onStart;
Expand Down Expand Up @@ -443,7 +450,9 @@ class RealtimeEngine {
return { features: vehicles, type: 'FeatureCollection' };
}

getViewState: () => ViewState = () => ({});
getViewState: () => ViewState = () => {
return {};
};

/**
* Callback on websocket's deleted_vehicles channel events.
Expand Down Expand Up @@ -734,7 +743,6 @@ class RealtimeEngine {
/* @private */
this.mots = this.getMotsByZoom(zoomFloor);
if (this.mots) {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
bbox.push(`mots=${this.mots}`);
}

Expand All @@ -748,7 +756,6 @@ class RealtimeEngine {

if (this.bboxParameters) {
Object.entries(this.bboxParameters).forEach(([key, value]) => {
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
bbox.push(`${key}=${value}`);
});
}
Expand All @@ -757,7 +764,9 @@ class RealtimeEngine {
this.api.bbox = bbox;
}

shouldRender: () => boolean = () => true;
shouldRender: () => boolean = () => {
return true;
};

start() {
this.stop();
Expand Down
5 changes: 3 additions & 2 deletions src/common/utils/realtimeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export const textColors: string[] = [
*/
export const getTypeIndex = (type: RealtimeMot): number => {
if (typeof type === 'string') {
return types.findIndex((t) => t.test(type));
return types.findIndex((t) => {
return t.test(type);
});
}
return type;
};
Expand Down Expand Up @@ -171,7 +173,6 @@ export const getTextSize = (
let i = 0;

while (newText.width > markerSize - 6 && i < maxiter) {
// eslint-disable-next-line no-param-reassign
fontSize -= 0.5;
ctx.font = getTextFont(fontSize, text);
newText = ctx.measureText(text);
Expand Down

0 comments on commit 5a38609

Please sign in to comment.