namazu-ts 0.34.2 → 1.1.1

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.
Files changed (68) hide show
  1. package/README.md +1 -0
  2. package/dist/browser/assets/leg_contour.png +0 -0
  3. package/dist/browser/index.js +140 -69
  4. package/dist/client.d.ts +0 -1
  5. package/dist/node/assets/leg_contour.png +0 -0
  6. package/dist/node/index.js +140 -69
  7. package/dist/sismomap.d.ts +18 -6
  8. package/dist/types.d.ts +37 -5
  9. package/docs/assets/navigation.js +1 -1
  10. package/docs/assets/search.js +1 -1
  11. package/docs/classes/SismoMap.html +11 -9
  12. package/docs/enums/NamazuLayers.html +3 -2
  13. package/docs/enums/NamazuSource.html +3 -2
  14. package/docs/enums/SortType.html +2 -2
  15. package/docs/index.html +1 -0
  16. package/docs/modules.html +1 -1
  17. package/docs/types/Answer.html +2 -2
  18. package/docs/types/CleanedEventQueryOptions.html +1 -1
  19. package/docs/types/ContourFeature.html +4 -0
  20. package/docs/types/ContourGeoJSON.html +6 -0
  21. package/docs/types/EventCity.html +2 -2
  22. package/docs/types/EventFeature.html +2 -2
  23. package/docs/types/EventGeoJSON.html +2 -2
  24. package/docs/types/EventGeoJSONProperties.html +2 -2
  25. package/docs/types/EventGeojsonDescriptionProperty.html +2 -2
  26. package/docs/types/EventPhases.html +1 -1
  27. package/docs/types/EventQueryOptions.html +2 -2
  28. package/docs/types/EventTestimony.html +2 -2
  29. package/docs/types/EventTestimonyGeoJSON.html +2 -2
  30. package/docs/types/FDSNQueryOptions.html +2 -2
  31. package/docs/types/FilterQuery.html +2 -2
  32. package/docs/types/Form.html +2 -2
  33. package/docs/types/FormCity.html +2 -2
  34. package/docs/types/GeoJSON.html +1 -1
  35. package/docs/types/Intensity.html +2 -2
  36. package/docs/types/IntensityGeoJSON.html +2 -2
  37. package/docs/types/Magnitude.html +2 -2
  38. package/docs/types/NamazuEvent.html +2 -2
  39. package/docs/types/Origin.html +2 -2
  40. package/docs/types/{InfosPhase.html → Phase.html} +2 -2
  41. package/docs/types/Quality.html +2 -2
  42. package/docs/types/Question.html +2 -2
  43. package/docs/types/QuestionChoice.html +2 -2
  44. package/docs/types/QuestionCondition.html +1 -1
  45. package/docs/types/QuestionGroup.html +2 -2
  46. package/docs/types/Station.html +2 -2
  47. package/docs/types/StationFeature.html +1 -1
  48. package/docs/types/StationGeoJSON.html +2 -2
  49. package/docs/types/Street.html +2 -2
  50. package/docs/types/Survey.html +2 -2
  51. package/docs/types/Testimony.html +2 -2
  52. package/docs/types/Uncertainty.html +2 -2
  53. package/docs/types/Zone.html +2 -2
  54. package/docs/types/ZoneDesc.html +2 -2
  55. package/docs/types/Zones.html +2 -2
  56. package/docs/variables/EventRadius.html +1 -1
  57. package/docs/variables/EventTypes.html +1 -0
  58. package/docs/variables/IntensitiesColors.html +1 -1
  59. package/docs/variables/Intervals.html +1 -1
  60. package/docs/variables/MagnitudesColors.html +1 -1
  61. package/docs/variables/PossibleEvents.html +1 -1
  62. package/docs/variables/SortFilters.html +1 -1
  63. package/docs/variables/ZoneNames.html +1 -1
  64. package/package.json +1 -1
  65. package/src/client.ts +5 -53
  66. package/src/sismomap.ts +135 -25
  67. package/src/types.ts +86 -3
  68. package/docs/variables/eventTypes.html +0 -1
package/README.md CHANGED
@@ -20,6 +20,7 @@ Types you can find in the sources :
20
20
  - NamazuSource.STATIONS => StationGeoJSON
21
21
  - NamazuSource.EVENTS => EventGeoJSON<T> field has a few common properties but if you want specific fields, you gotta cast it to EventGeoJSONProperties or NamazuEvent depending on the context
22
22
  - NamazuSource.POPUP => Not really a source, it's just used as a placeholder for sismap._descPopup that contains maplibre.Popup
23
+ - NamazuSource.CONTOURS => ContoursGeoJSON
23
24
  ___
24
25
 
25
26
  ## Small example
@@ -30167,6 +30167,7 @@ var NamazuLayers;
30167
30167
  NamazuLayers2["EVENTS"] = "events";
30168
30168
  NamazuLayers2["INTENSITIES"] = "intensities";
30169
30169
  NamazuLayers2["TESTIMONIES"] = "testimonies";
30170
+ NamazuLayers2["CONTOURS"] = "int_contours";
30170
30171
  })(NamazuLayers ||= {});
30171
30172
  var NamazuSource;
30172
30173
  ((NamazuSource2) => {
@@ -30177,6 +30178,7 @@ var NamazuSource;
30177
30178
  NamazuSource2["STATIONS"] = "stations";
30178
30179
  NamazuSource2["EVENTS"] = "events";
30179
30180
  NamazuSource2["POPUP"] = "popup";
30181
+ NamazuSource2["CONTOURS"] = "int_contours";
30180
30182
  })(NamazuSource ||= {});
30181
30183
  var PossibleEvents = [
30182
30184
  "event",
@@ -30323,6 +30325,54 @@ var Intervals = new Map([
30323
30325
  ],
30324
30326
  ["inf", ["all", [">=", ["get", "magnitude"], 6]]]
30325
30327
  ]);
30328
+ var EventTypes = new Map([
30329
+ ["accidental explosion", "explosion accidentelle"],
30330
+ ["acoustic noise", "bruit acoustique"],
30331
+ ["anthropogenic event", "évènement anthropique"],
30332
+ ["avalanche", "avalanche"],
30333
+ ["blasting levee", "digue de dynamitage"],
30334
+ ["boat crash", "accident de bateau"],
30335
+ ["building collapse", "effondrement de bâtiment"],
30336
+ ["cavity collapse", "effondrement de la cavité"],
30337
+ ["chemical explosion", "explosion chimique"],
30338
+ ["collapse", "effondrement"],
30339
+ ["controlled explosion", "explosion contrôlée"],
30340
+ ["crash", "accident"],
30341
+ ["debris avalanche", "avalanche de débris"],
30342
+ ["earthquake", "tremblement de terre"],
30343
+ ["event", "évènement"],
30344
+ ["experimental explosion", "explosion expérimentale"],
30345
+ ["explosion", "explosion"],
30346
+ ["fluid extraction", "extraction de fluide"],
30347
+ ["fluid injection", "injection de fluide"],
30348
+ ["hydroacoustic event", "évènement hydroacoustique"],
30349
+ ["ice quake", "tremblement de glace"],
30350
+ ["induced", "induit"],
30351
+ ["industrial explosion", "explosion industrielle"],
30352
+ ["landslide", "glissement de terrain"],
30353
+ ["meteorite", "météorite"],
30354
+ ["mine collapse", "effondrement de mine"],
30355
+ ["mining explosion", "explosion de mine"],
30356
+ ["not existing", "inexistant"],
30357
+ ["not locatable", "non localisable"],
30358
+ ["not reported", "non reporté"],
30359
+ ["nuclear explosion", "explosion nucléaire"],
30360
+ ["other event", "autre événement"],
30361
+ ["outside of network interest", "en dehors de la zone d'intérêt"],
30362
+ ["plane crash", "crash d'avion"],
30363
+ ["quarry blast", "tir de carrière"],
30364
+ ["reservoir loading", "chargement de réservoir"],
30365
+ ["road cut", "coupe de route"],
30366
+ ["rock burst", "éclat de roche"],
30367
+ ["rockslide", "éboulement"],
30368
+ ["slide", "glissement"],
30369
+ ["snow avalanche", "avalanche de neige"],
30370
+ ["sonic blast", "effet de souffle"],
30371
+ ["sonic boom", "détonation supersonique"],
30372
+ ["thunder", "tonnerre"],
30373
+ ["train crash", "crash de train"],
30374
+ ["volcanic eruption", "éruption volcanique"]
30375
+ ]);
30326
30376
 
30327
30377
  // node_modules/@turf/helpers/dist/esm/index.js
30328
30378
  var earthRadius = 6371008.8;
@@ -30799,7 +30849,7 @@ class Client {
30799
30849
  return `${date.getDay().toString().padStart(2, "0")}/${date.getMonth().toString().padStart(2, "0")}/${date.getFullYear().toString().padStart(2, "0")}`;
30800
30850
  }
30801
30851
  translateEventType(eventType) {
30802
- return eventTypes.get(eventType) || "Évènement";
30852
+ return EventTypes.get(eventType) || "Évènement";
30803
30853
  }
30804
30854
  buildQuery(url, options) {
30805
30855
  return {
@@ -31030,54 +31080,6 @@ class Client {
31030
31080
  return this.apiCall(url);
31031
31081
  }
31032
31082
  }
31033
- var eventTypes = new Map([
31034
- ["accidental explosion", "explosion accidentelle"],
31035
- ["acoustic noise", "bruit acoustique"],
31036
- ["anthropogenic event", "évènement anthropique"],
31037
- ["avalanche", "avalanche"],
31038
- ["blasting levee", "digue de dynamitage"],
31039
- ["boat crash", "accident de bateau"],
31040
- ["building collapse", "effondrement de bâtiment"],
31041
- ["cavity collapse", "effondrement de la cavité"],
31042
- ["chemical explosion", "explosion chimique"],
31043
- ["collapse", "effondrement"],
31044
- ["controlled explosion", "explosion contrôlée"],
31045
- ["crash", "accident"],
31046
- ["debris avalanche", "avalanche de débris"],
31047
- ["earthquake", "tremblement de terre"],
31048
- ["event", "évènement"],
31049
- ["experimental explosion", "explosion expérimentale"],
31050
- ["explosion", "explosion"],
31051
- ["fluid extraction", "extraction de fluide"],
31052
- ["fluid injection", "injection de fluide"],
31053
- ["hydroacoustic event", "évènement hydroacoustique"],
31054
- ["ice quake", "tremblement de glace"],
31055
- ["induced", "induit"],
31056
- ["industrial explosion", "explosion industrielle"],
31057
- ["landslide", "glissement de terrain"],
31058
- ["meteorite", "météorite"],
31059
- ["mine collapse", "effondrement de mine"],
31060
- ["mining explosion", "explosion de mine"],
31061
- ["not existing", "inexistant"],
31062
- ["not locatable", "non localisable"],
31063
- ["not reported", "non reporté"],
31064
- ["nuclear explosion", "explosion nucléaire"],
31065
- ["other event", "autre événement"],
31066
- ["outside of network interest", "en dehors de la zone d'intérêt"],
31067
- ["plane crash", "crash d'avion"],
31068
- ["quarry blast", "tir de carrière"],
31069
- ["reservoir loading", "chargement de réservoir"],
31070
- ["road cut", "coupe de route"],
31071
- ["rock burst", "éclat de roche"],
31072
- ["rockslide", "éboulement"],
31073
- ["slide", "glissement"],
31074
- ["snow avalanche", "avalanche de neige"],
31075
- ["sonic blast", "effet de souffle"],
31076
- ["sonic boom", "détonation supersonique"],
31077
- ["thunder", "tonnerre"],
31078
- ["train crash", "crash de train"],
31079
- ["volcanic eruption", "éruption volcanique"]
31080
- ]);
31081
31083
  // src/sismomap.ts
31082
31084
  var import_maplibre_gl2 = __toESM(require_maplibre_gl(), 1);
31083
31085
  class SismoMap {
@@ -31125,6 +31127,7 @@ class SismoMap {
31125
31127
  scale._container.style.display = "none";
31126
31128
  scale._container.id = "scale";
31127
31129
  this.addMagLegend(legendClasses);
31130
+ this.addContourLegend(legendClasses);
31128
31131
  this.addIntensityLegend(lang, legendClasses);
31129
31132
  map.dragRotate.disable();
31130
31133
  map.once("load", () => {
@@ -31153,6 +31156,7 @@ class SismoMap {
31153
31156
  map.addSource("intensities" /* INTENSITIES */, structuredClone(emptySrc));
31154
31157
  map.addSource("testimonies" /* TESTIMONIES */, structuredClone(emptySrc));
31155
31158
  map.addSource("stations" /* STATIONS */, structuredClone(emptySrc));
31159
+ map.addSource("int_contours" /* CONTOURS */, structuredClone(emptySrc));
31156
31160
  map.addSource("ligne" /* LINE */, {
31157
31161
  type: "geojson",
31158
31162
  data: {
@@ -31183,6 +31187,15 @@ class SismoMap {
31183
31187
  "fill-opacity": 0.8
31184
31188
  }
31185
31189
  });
31190
+ map.addLayer({
31191
+ id: "int_contours" /* CONTOURS */,
31192
+ source: "int_contours" /* CONTOURS */,
31193
+ type: "line",
31194
+ paint: {
31195
+ "line-color": ["get", "color"],
31196
+ "line-width": ["*", 2, ["get", "weight"]]
31197
+ }
31198
+ });
31186
31199
  map.addLayer({
31187
31200
  id: "testimonies" /* TESTIMONIES */,
31188
31201
  source: "testimonies" /* TESTIMONIES */,
@@ -31257,6 +31270,10 @@ class SismoMap {
31257
31270
  const [lng, lat] = feature.geometry.coordinates;
31258
31271
  this._descPopups[0].setLngLat([lng, lat]).setHTML(text[lang]).addTo(map);
31259
31272
  this._descPopups[0].getElement().style.color = "black";
31273
+ this._descPopups[0].getElement().style.pointerEvents = "none !important";
31274
+ this._descPopups[0].getElement().querySelectorAll("*").forEach((el) => {
31275
+ el.style.pointerEvents = "none";
31276
+ });
31260
31277
  }
31261
31278
  });
31262
31279
  map.on("mouseleave", title, () => {
@@ -31313,7 +31330,7 @@ class SismoMap {
31313
31330
  };
31314
31331
  break;
31315
31332
  }
31316
- case "ligne": {
31333
+ case "ligne" /* LINE */: {
31317
31334
  data = {
31318
31335
  type: "Feature",
31319
31336
  geometry: {
@@ -31323,6 +31340,7 @@ class SismoMap {
31323
31340
  };
31324
31341
  break;
31325
31342
  }
31343
+ case "int_contours" /* CONTOURS */:
31326
31344
  case "intensities" /* INTENSITIES */:
31327
31345
  case "testimonies" /* TESTIMONIES */:
31328
31346
  case "stations" /* STATIONS */:
@@ -31350,7 +31368,7 @@ class SismoMap {
31350
31368
  src.setData(data);
31351
31369
  }
31352
31370
  }
31353
- setShowDescription(enabled) {
31371
+ showPopup(enabled) {
31354
31372
  this._showDescription = enabled;
31355
31373
  }
31356
31374
  setDebug(mode) {
@@ -31447,6 +31465,18 @@ class SismoMap {
31447
31465
  clear
31448
31466
  });
31449
31467
  }
31468
+ displayContours({
31469
+ contours,
31470
+ moveView = false,
31471
+ clear = false
31472
+ }) {
31473
+ this.displayGeoJSON({
31474
+ geojson: contours,
31475
+ sourceName: "int_contours" /* CONTOURS */,
31476
+ moveView,
31477
+ clear
31478
+ });
31479
+ }
31450
31480
  displayEvents({
31451
31481
  events,
31452
31482
  moveView = true,
@@ -31505,9 +31535,15 @@ class SismoMap {
31505
31535
  upd();
31506
31536
  }
31507
31537
  centerView(geojson) {
31508
- if (geojson.features.length === 1) {
31509
- const lng = geojson.features[0].geometry.coordinates[0];
31510
- const lat = geojson.features[0].geometry.coordinates[1];
31538
+ if (geojson.features.length === 0) {
31539
+ console.warn("Trying to center on an empty geojson, ignoring.");
31540
+ return;
31541
+ }
31542
+ const coord1 = geojson.features[0].geometry.coordinates[0];
31543
+ const coord2 = geojson.features[0].geometry.coordinates[1];
31544
+ if (geojson.features.length === 1 && typeof coord1 === "number" && typeof coord2 === "number") {
31545
+ const lng = coord1;
31546
+ const lat = coord2;
31511
31547
  this.map.flyTo({ center: [lng, lat], zoom: 6 });
31512
31548
  } else {
31513
31549
  const bounds = bbox(geojson);
@@ -31556,11 +31592,11 @@ class SismoMap {
31556
31592
  !this.map.isMoving() && this.map.easeTo({ center, duration: 1000, easing: (n) => n });
31557
31593
  }
31558
31594
  }
31559
- displayScale() {
31595
+ showScale(enabled) {
31560
31596
  function handle() {
31561
31597
  const legend = document.getElementById("scale");
31562
31598
  if (legend != null) {
31563
- legend.style.display = "block";
31599
+ legend.style.display = enabled ? "block" : "none";
31564
31600
  }
31565
31601
  }
31566
31602
  if (this.map.loaded() || this._usable) {
@@ -31569,11 +31605,11 @@ class SismoMap {
31569
31605
  this.map.once("load", handle);
31570
31606
  }
31571
31607
  }
31572
- hideScale() {
31608
+ showMagLegend(enabled) {
31573
31609
  function handle() {
31574
- const legend = document.getElementById("scale");
31610
+ const legend = document.getElementById("maglegend");
31575
31611
  if (legend != null) {
31576
- legend.style.display = "none";
31612
+ legend.style.display = enabled ? "block" : "none";
31577
31613
  }
31578
31614
  }
31579
31615
  if (this.map.loaded() || this._usable) {
@@ -31582,9 +31618,9 @@ class SismoMap {
31582
31618
  this.map.once("load", handle);
31583
31619
  }
31584
31620
  }
31585
- showMagLegend(enabled) {
31621
+ showContourLegend(enabled) {
31586
31622
  function handle() {
31587
- const legend = document.getElementById("maglegend");
31623
+ const legend = document.getElementById("contlegend");
31588
31624
  if (legend != null) {
31589
31625
  legend.style.display = enabled ? "block" : "none";
31590
31626
  }
@@ -31608,6 +31644,40 @@ class SismoMap {
31608
31644
  this.map.once("load", handle);
31609
31645
  }
31610
31646
  }
31647
+ addContourLegend(classes) {
31648
+
31649
+ class ContourLegend {
31650
+ _map;
31651
+ _container;
31652
+ onAdd(map) {
31653
+ this._map = map;
31654
+ this._container = document.createElement("div");
31655
+ const imgsrc = "https://shakemaps.franceseisme.fr/2025/fr2025qqsqhy/current/products/legend_bcsfgmice.png";
31656
+ this._container.id = "contlegend";
31657
+ if (classes === undefined) {
31658
+ this._container.style.background = "lightgrey";
31659
+ this._container.style.borderRadius = "5px";
31660
+ this._container.style.color = "black";
31661
+ this._container.style.margin = "10px";
31662
+ this._container.style.display = "none";
31663
+ this._container.style.maxWidth = "800px";
31664
+ } else {
31665
+ for (const addClass of classes) {
31666
+ this._container?.classList.add(addClass);
31667
+ }
31668
+ }
31669
+ this._container.innerHTML += `<img src="${imgsrc}" />`;
31670
+ return this._container;
31671
+ }
31672
+ onRemove() {
31673
+ if (this._container?.parentNode) {
31674
+ this._container?.parentNode.removeChild(this._container);
31675
+ }
31676
+ this._map = undefined;
31677
+ }
31678
+ }
31679
+ this.map.addControl(new ContourLegend, "bottom-right");
31680
+ }
31611
31681
  addMagLegend(classes) {
31612
31682
 
31613
31683
  class MagnitudeLegend {
@@ -31700,7 +31770,7 @@ class SismoMap {
31700
31770
  this._map = undefined;
31701
31771
  }
31702
31772
  }
31703
- this.map.addControl(new IntensityLegend, "bottom-left");
31773
+ this.map.addControl(new IntensityLegend, "bottom-right");
31704
31774
  }
31705
31775
  applyFilter(filterQuery) {
31706
31776
  if (filterQuery.magnitudes.length === 0 && filterQuery.events.length === 0) {
@@ -31787,7 +31857,10 @@ class SismoMap {
31787
31857
  ];
31788
31858
  map._descPopups[1].setLngLat(popupCoords).setText(popupString).addTo(map.map);
31789
31859
  map._descPopups[1].getElement().style.color = "black";
31790
- map._descPopups[1].getElement().style.pointerEvents = "none";
31860
+ map._descPopups[1].getElement().style.pointerEvents = "none !important";
31861
+ map._descPopups[1].getElement().querySelectorAll("*").forEach((el) => {
31862
+ el.style.pointerEvents = "none";
31863
+ });
31791
31864
  const newData = {
31792
31865
  type: "Feature",
31793
31866
  properties: {},
@@ -31863,13 +31936,11 @@ class SismoMap {
31863
31936
  });
31864
31937
  }
31865
31938
  async getEventNumber() {
31866
- const source = this.map.getSource("");
31939
+ const source = this.map.getSource("events" /* EVENTS */);
31867
31940
  if (source === undefined)
31868
- return Promise.reject("");
31869
- let length = 0;
31941
+ return Promise.reject(-1);
31870
31942
  const sourceData = await source.getData();
31871
- length = sourceData.features.length;
31872
- return length;
31943
+ return sourceData.features.length;
31873
31944
  }
31874
31945
  }
31875
31946
  var export_LngLatBounds = import_maplibre_gl3.LngLatBounds;
@@ -31878,7 +31949,6 @@ export {
31878
31949
  isEventGeoJSONProperties,
31879
31950
  isEventGeoJSON,
31880
31951
  formatString,
31881
- eventTypes,
31882
31952
  createEllipse,
31883
31953
  ZoneNames,
31884
31954
  SortType,
@@ -31891,6 +31961,7 @@ export {
31891
31961
  export_LngLatBounds as LngLatBounds,
31892
31962
  Intervals,
31893
31963
  IntensitiesColors,
31964
+ EventTypes,
31894
31965
  EventToEventGeoJSON,
31895
31966
  EventRadius,
31896
31967
  Client
package/dist/client.d.ts CHANGED
@@ -48,4 +48,3 @@ export declare class Client {
48
48
  getStationsByZoneName(zoneName: string): Promise<StationGeoJSON>;
49
49
  getEventPhases(event: EventGeoJSON): Promise<EventPhases>;
50
50
  }
51
- export declare const eventTypes: Map<string, string>;
Binary file