mobility-toolbox-js 2.0.0-beta.60 → 2.0.0-beta.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"realtimeDefaultStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeDefaultStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAMrB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WACnB,MAAM,UACN,MAAM,SACP,MAAM,2CAmBd,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UACtB,MAAM,QACP,MAAM,YACF,MAAM,QACV,MAAM,cACA,MAAM,sBACC,MAAM,eACb,MAAM,2CAuBnB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,UACN,MAAM,SACP,MAAM,aACF,OAAO,WACT,OAAO,cACJ,MAAM,2CAiCnB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAClB,MAAM,UACJ,MAAM,YACJ,MAAM,aACL,MAAM,eACJ,MAAM,aACR,OAAO,cACN,MAAM,2CAmCnB,CAAC;AAKF;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,EAAE,qBA8M3B,CAAC;AACF,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"realtimeDefaultStyle.d.ts","sourceRoot":"","sources":["../../../src/common/styles/realtimeDefaultStyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAKV,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAMrB;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,WACnB,MAAM,UACN,MAAM,SACP,MAAM,2CAmBd,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,UACtB,MAAM,QACP,MAAM,YACF,MAAM,QACV,MAAM,cACA,MAAM,sBACC,MAAM,eACb,MAAM,2CAuBnB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,UACN,MAAM,SACP,MAAM,aACF,OAAO,WACT,OAAO,cACJ,MAAM,2CAiCnB,CAAC;AAKF;;;;GAIG;AACH,eAAO,MAAM,aAAa,SAClB,MAAM,UACJ,MAAM,YACJ,MAAM,aACL,MAAM,eACJ,MAAM,aACR,OAAO,cACN,MAAM,2CAmCnB,CAAC;AAKF;;;;;;;GAOG;AACH,QAAA,MAAM,oBAAoB,EAAE,qBAiN3B,CAAC;AACF,eAAe,oBAAoB,CAAC"}
@@ -140,7 +140,7 @@ const cache = {};
140
140
  * @return a canvas
141
141
  */
142
142
  const realtimeDefaultStyle = (trajectory, viewState, options) => {
143
- const { hoverVehicleId, selectedVehicleId, useDelayStyle, delayOutlineColor = '#000', delayDisplay = 300000, getRadius = () => 0, getBgColor = () => '#000', getDelayColor = () => '#000', getDelayText = () => null, getTextColor = () => '#000', getTextSize = () => 0, } = options;
143
+ const { hoverVehicleId, selectedVehicleId, useDelayStyle, delayOutlineColor = '#000', delayDisplay = 300000, getRadius = () => 0, getBgColor = () => '#000', getDelayColor = () => '#000', getDelayText = () => null, getTextColor = () => '#000', getTextSize = () => 0, getMaxRadiusForText = () => 10, getMaxRadiusForStrokeAndDelay = () => 7, } = options;
144
144
  const { zoom, pixelRatio = 1 } = viewState;
145
145
  let { type } = trajectory.properties;
146
146
  const { train_id: id, line, delay, state, operator_provides_realtime_journey: operatorProvidesRealtime, } = trajectory.properties;
@@ -166,13 +166,13 @@ const realtimeDefaultStyle = (trajectory, viewState, options) => {
166
166
  const selected = !!(selectedVehicleId && selectedVehicleId === id);
167
167
  // Calcul the radius of the circle
168
168
  let radius = getRadius(type, z) * pixelRatio;
169
- const isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
169
+ const isDisplayStrokeAndDelay = radius >= getMaxRadiusForStrokeAndDelay() * pixelRatio;
170
170
  if (hover || selected) {
171
171
  radius = isDisplayStrokeAndDelay
172
172
  ? radius + 5 * pixelRatio
173
173
  : 14 * pixelRatio;
174
174
  }
175
- const mustDrawText = radius > 10 * pixelRatio;
175
+ const isDisplayText = radius > getMaxRadiusForText() * pixelRatio;
176
176
  // Optimize the cache key, very important in high zoom level
177
177
  let key = `${radius}${hover}${selected}${cancelled}${delay}`;
178
178
  if (useDelayStyle) {
@@ -181,7 +181,7 @@ const realtimeDefaultStyle = (trajectory, viewState, options) => {
181
181
  else {
182
182
  key += `${type}${color}`;
183
183
  }
184
- if (mustDrawText) {
184
+ if (isDisplayText) {
185
185
  key += `${name}${textColor}`;
186
186
  }
187
187
  if (!cache[key]) {
@@ -239,7 +239,7 @@ const realtimeDefaultStyle = (trajectory, viewState, options) => {
239
239
  ctx.drawImage(circle, 0, 0);
240
240
  }
241
241
  // Draw text in the circle
242
- if (mustDrawText && ctx) {
242
+ if (isDisplayText && ctx) {
243
243
  const fontSize = Math.max(radius, 10);
244
244
  const textSize = getTextSize(ctx, markerSize, name, fontSize);
245
245
  const textColor2 = !useDelayStyle
package/mbt.js CHANGED
@@ -36187,7 +36187,9 @@ uniform ${i3} ${o3} u_${a3};
36187
36187
  getDelayColor: getDelayColor2 = () => "#000",
36188
36188
  getDelayText: getDelayText2 = () => null,
36189
36189
  getTextColor: getTextColor2 = () => "#000",
36190
- getTextSize: getTextSize2 = () => 0
36190
+ getTextSize: getTextSize2 = () => 0,
36191
+ getMaxRadiusForText = () => 10,
36192
+ getMaxRadiusForStrokeAndDelay = () => 7
36191
36193
  } = options;
36192
36194
  const { zoom, pixelRatio = 1 } = viewState;
36193
36195
  let { type } = trajectory.properties;
@@ -36219,18 +36221,18 @@ uniform ${i3} ${o3} u_${a3};
36219
36221
  const hover = !!(hoverVehicleId && hoverVehicleId === id);
36220
36222
  const selected = !!(selectedVehicleId && selectedVehicleId === id);
36221
36223
  let radius = getRadius2(type, z) * pixelRatio;
36222
- const isDisplayStrokeAndDelay = radius >= 7 * pixelRatio;
36224
+ const isDisplayStrokeAndDelay = radius >= getMaxRadiusForStrokeAndDelay() * pixelRatio;
36223
36225
  if (hover || selected) {
36224
36226
  radius = isDisplayStrokeAndDelay ? radius + 5 * pixelRatio : 14 * pixelRatio;
36225
36227
  }
36226
- const mustDrawText = radius > 10 * pixelRatio;
36228
+ const isDisplayText = radius > getMaxRadiusForText() * pixelRatio;
36227
36229
  let key = `${radius}${hover}${selected}${cancelled}${delay}`;
36228
36230
  if (useDelayStyle) {
36229
36231
  key += `${operatorProvidesRealtime}`;
36230
36232
  } else {
36231
36233
  key += `${type}${color}`;
36232
36234
  }
36233
- if (mustDrawText) {
36235
+ if (isDisplayText) {
36234
36236
  key += `${name}${textColor}`;
36235
36237
  }
36236
36238
  if (!cache2[key]) {
@@ -36277,7 +36279,7 @@ uniform ${i3} ${o3} u_${a3};
36277
36279
  if (circle) {
36278
36280
  ctx.drawImage(circle, 0, 0);
36279
36281
  }
36280
- if (mustDrawText && ctx) {
36282
+ if (isDisplayText && ctx) {
36281
36283
  const fontSize = Math.max(radius, 10);
36282
36284
  const textSize = getTextSize2(ctx, markerSize, name, fontSize);
36283
36285
  const textColor2 = !useDelayStyle ? textColor || getTextColor2(type) : "#000000";