namazu-ts 0.6.4 → 0.7.0

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 (48) hide show
  1. package/dist/browser/index.js +210 -142
  2. package/dist/client.d.ts +4 -3
  3. package/dist/node/index.js +210 -142
  4. package/dist/sismomap.d.ts +1 -2
  5. package/dist/types.d.ts +24 -28
  6. package/docs/assets/navigation.js +1 -1
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/Client.html +3 -2
  9. package/docs/classes/SismoMap.html +5 -7
  10. package/docs/modules.html +1 -1
  11. package/docs/types/Answer.html +2 -2
  12. package/docs/types/City.html +2 -2
  13. package/docs/types/CleanedEventQueryOptions.html +1 -0
  14. package/docs/types/EventFeature.html +2 -2
  15. package/docs/types/EventGeoJSON.html +2 -2
  16. package/docs/types/EventGeoJSONProperties.html +6 -9
  17. package/docs/types/EventPhases.html +1 -1
  18. package/docs/types/EventQueryOptions.html +29 -0
  19. package/docs/types/FilterQuery.html +2 -2
  20. package/docs/types/Form.html +2 -2
  21. package/docs/types/GeoJSON.html +1 -1
  22. package/docs/types/InfosPhase.html +2 -2
  23. package/docs/types/Magnitude.html +2 -2
  24. package/docs/types/Origin.html +2 -2
  25. package/docs/types/Question.html +2 -2
  26. package/docs/types/QuestionChoice.html +2 -2
  27. package/docs/types/QuestionCondition.html +1 -1
  28. package/docs/types/QuestionGroup.html +2 -2
  29. package/docs/types/SisEvent.html +2 -2
  30. package/docs/types/Station.html +2 -2
  31. package/docs/types/StationGeoJSON.html +2 -2
  32. package/docs/types/StationPhases.html +1 -1
  33. package/docs/types/Street.html +2 -2
  34. package/docs/types/Survey.html +2 -2
  35. package/docs/types/Testimony.html +2 -2
  36. package/docs/types/Zone.html +2 -2
  37. package/docs/types/Zones.html +2 -2
  38. package/docs/variables/Intervals.html +1 -1
  39. package/docs/variables/MagnitudesColors.html +1 -1
  40. package/docs/variables/ZoneNames.html +1 -1
  41. package/docs/variables/eventTypes.html +1 -1
  42. package/package.json +1 -1
  43. package/src/client.ts +69 -44
  44. package/src/maputils.ts +2 -3
  45. package/src/sismomap.ts +111 -105
  46. package/src/types.ts +83 -37
  47. package/docs/types/CleanedFDSNQueryOptions.html +0 -1
  48. package/docs/types/FDSNQueryOptions.html +0 -29
@@ -26603,7 +26603,7 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
26603
26603
  });
26604
26604
 
26605
26605
  // src/index.ts
26606
- var import_maplibre_gl2 = __toESM(require_maplibre_gl(), 1);
26606
+ var import_maplibre_gl3 = __toESM(require_maplibre_gl(), 1);
26607
26607
 
26608
26608
  // src/maputils.ts
26609
26609
  function EventToEventGeoJSON(e) {
@@ -26611,8 +26611,7 @@ function EventToEventGeoJSON(e) {
26611
26611
  const lng = e.preferredOrigin.longitude;
26612
26612
  const lat = e.preferredOrigin.latitude;
26613
26613
  let eWithMag = e;
26614
- eWithMag.mag = e.preferredMagnitude.magnitude;
26615
- eWithMag.type = e.eventType;
26614
+ eWithMag.magnitude = e.preferredMagnitude.magnitude;
26616
26615
  let feature = {
26617
26616
  id: e.publicid,
26618
26617
  properties: eWithMag,
@@ -29534,7 +29533,7 @@ var ZoneNames = [
29534
29533
  ];
29535
29534
  var MagnitudesColors = [
29536
29535
  "step",
29537
- ["get", "mag"],
29536
+ ["get", "magnitude"],
29538
29537
  "#fff900",
29539
29538
  2.5,
29540
29539
  "#ffce01",
@@ -29554,24 +29553,70 @@ var MagnitudesColors = [
29554
29553
  "#6f4e4e"
29555
29554
  ];
29556
29555
  var Intervals = new Map([
29557
- ["small", ["all", ["<", ["get", "mag"], 2.5]]],
29558
- ["3.0", ["all", [">=", ["get", "mag"], 2.5], ["<", ["get", "mag"], 3]]],
29559
- ["3.5", ["all", [">=", ["get", "mag"], 3], ["<", ["get", "mag"], 3.5]]],
29560
- ["4.0", ["all", [">=", ["get", "mag"], 3.5], ["<", ["get", "mag"], 4]]],
29561
- ["4.5", ["all", [">=", ["get", "mag"], 4], ["<", ["get", "mag"], 4.5]]],
29562
- ["5.0", ["all", [">=", ["get", "mag"], 4.5], ["<", ["get", "mag"], 5]]],
29563
- ["5.5", ["all", [">=", ["get", "mag"], 5], ["<", ["get", "mag"], 5.5]]],
29564
- ["6.0", ["all", [">=", ["get", "mag"], 5.5], ["<", ["get", "mag"], 6]]],
29565
- ["inf", ["all", [">=", ["get", "mag"], 6]]]
29556
+ ["small", ["all", ["<", ["get", "magnitude"], 2.5]]],
29557
+ [
29558
+ "3.0",
29559
+ [
29560
+ "all",
29561
+ [">=", ["get", "magnitude"], 2.5],
29562
+ ["<", ["get", "magnitude"], 3]
29563
+ ]
29564
+ ],
29565
+ [
29566
+ "3.5",
29567
+ [
29568
+ "all",
29569
+ [">=", ["get", "magnitude"], 3],
29570
+ ["<", ["get", "magnitude"], 3.5]
29571
+ ]
29572
+ ],
29573
+ [
29574
+ "4.0",
29575
+ [
29576
+ "all",
29577
+ [">=", ["get", "magnitude"], 3.5],
29578
+ ["<", ["get", "magnitude"], 4]
29579
+ ]
29580
+ ],
29581
+ [
29582
+ "4.5",
29583
+ [
29584
+ "all",
29585
+ [">=", ["get", "magnitude"], 4],
29586
+ ["<", ["get", "magnitude"], 4.5]
29587
+ ]
29588
+ ],
29589
+ [
29590
+ "5.0",
29591
+ [
29592
+ "all",
29593
+ [">=", ["get", "magnitude"], 4.5],
29594
+ ["<", ["get", "magnitude"], 5]
29595
+ ]
29596
+ ],
29597
+ [
29598
+ "5.5",
29599
+ [
29600
+ "all",
29601
+ [">=", ["get", "magnitude"], 5],
29602
+ ["<", ["get", "magnitude"], 5.5]
29603
+ ]
29604
+ ],
29605
+ [
29606
+ "6.0",
29607
+ [
29608
+ "all",
29609
+ [">=", ["get", "magnitude"], 5.5],
29610
+ ["<", ["get", "magnitude"], 6]
29611
+ ]
29612
+ ],
29613
+ ["inf", ["all", [">=", ["get", "magnitude"], 6]]]
29566
29614
  ]);
29567
29615
 
29568
29616
  // src/utils.ts
29569
29617
  function formatString(str) {
29570
29618
  return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").toLowerCase().normalize("NFC");
29571
29619
  }
29572
- function isEventGeoJSONProperties(obj) {
29573
- return !(obj.eventType !== undefined);
29574
- }
29575
29620
  function isEventGeoJSON(obj) {
29576
29621
  return obj.features !== undefined;
29577
29622
  }
@@ -29601,6 +29646,14 @@ class Client {
29601
29646
  async fetchForm(id) {
29602
29647
  return this.apiCall(`/api/v1/surveys/forms/${id}`);
29603
29648
  }
29649
+ async getEvents(args) {
29650
+ let cArgs = this.cleanQuery(args);
29651
+ if (cArgs.isErr()) {
29652
+ return Promise.reject(cArgs.error);
29653
+ }
29654
+ let query = this.buildQuery("/api/v1/events", cArgs.value);
29655
+ return this.apiCall(query);
29656
+ }
29604
29657
  getQuestion(form, question_id) {
29605
29658
  return form.questions.find((question) => question.id == question_id);
29606
29659
  }
@@ -29771,8 +29824,8 @@ class Client {
29771
29824
  }
29772
29825
  cleanQuery(options) {
29773
29826
  let query = {};
29774
- if (options.eventid !== undefined) {
29775
- query.eventid = options.eventid;
29827
+ if (options.event_publicid !== undefined) {
29828
+ query.event_publicid = options.event_publicid;
29776
29829
  let values2 = ["xml", "text", "json"];
29777
29830
  if (options.format !== undefined) {
29778
29831
  if (values2.includes(options.format)) {
@@ -29783,40 +29836,40 @@ class Client {
29783
29836
  }
29784
29837
  return ok(query);
29785
29838
  }
29786
- if (options.starttime !== undefined) {
29787
- query.starttime = options.starttime;
29839
+ if (options.start_time !== undefined) {
29840
+ query.start_time = options.start_time;
29788
29841
  } else {
29789
29842
  let date = new Date;
29790
29843
  date.setDate(date.getDate() - 30);
29791
- query.starttime = date;
29844
+ query.start_time = date;
29792
29845
  }
29793
- if (options.endtime !== undefined) {
29794
- query.endtime = options.endtime;
29846
+ if (options.end_time !== undefined) {
29847
+ query.end_time = options.end_time;
29795
29848
  }
29796
- if (options.minlatitude !== undefined) {
29797
- if (options.minlatitude <= 90 && options.minlatitude >= -90) {
29798
- query.minlatitude = options.minlatitude;
29849
+ if (options.minimal_latitude !== undefined) {
29850
+ if (options.minimal_latitude <= 90 && options.minimal_latitude >= -90) {
29851
+ query.minimal_latitude = options.minimal_latitude;
29799
29852
  } else {
29800
29853
  return err(Error("Minimum latitude should be between -90 and 90"));
29801
29854
  }
29802
29855
  }
29803
- if (options.maxlatitude !== undefined) {
29804
- if (options.maxlatitude <= 90 && options.maxlatitude >= -90) {
29805
- query.maxlatitude = options.maxlatitude;
29856
+ if (options.maximal_latitude !== undefined) {
29857
+ if (options.maximal_latitude <= 90 && options.maximal_latitude >= -90) {
29858
+ query.maximal_latitude = options.maximal_latitude;
29806
29859
  } else {
29807
29860
  return err(Error("Maximum latitude should be between -90 and 90"));
29808
29861
  }
29809
29862
  }
29810
- if (options.minlongitude !== undefined) {
29811
- if (options.minlongitude <= 180 && options.minlongitude >= -180) {
29812
- query.minlongitude = options.minlongitude;
29863
+ if (options.minimal_longitude !== undefined) {
29864
+ if (options.minimal_longitude <= 180 && options.minimal_longitude >= -180) {
29865
+ query.minimal_longitude = options.minimal_longitude;
29813
29866
  } else {
29814
29867
  return err(Error("Minimum longitude should be between -180 and 180"));
29815
29868
  }
29816
29869
  }
29817
- if (options.maxlongitude !== undefined) {
29818
- if (options.maxlongitude <= 180 && options.maxlongitude >= -180) {
29819
- query.maxlongitude = options.maxlongitude;
29870
+ if (options.maximal_longitude !== undefined) {
29871
+ if (options.maximal_longitude <= 180 && options.maximal_longitude >= -180) {
29872
+ query.maximal_longitude = options.maximal_longitude;
29820
29873
  } else {
29821
29874
  return err(Error("Maximum longitude should be between -180 and 180"));
29822
29875
  }
@@ -29835,33 +29888,33 @@ class Client {
29835
29888
  return err(Error("Longitude should be between -180 and 180"));
29836
29889
  }
29837
29890
  }
29838
- if (options.minradius !== undefined) {
29839
- if (options.minradius >= 0 && options.minradius <= 180) {
29840
- query.minradius = options.minradius;
29891
+ if (options.minimal_radius !== undefined) {
29892
+ if (options.minimal_radius >= 0 && options.minimal_radius <= 180) {
29893
+ query.minimal_radius = options.minimal_radius;
29841
29894
  } else {
29842
29895
  return err(Error("Min radius should be between 0 and 180"));
29843
29896
  }
29844
29897
  }
29845
- if (options.maxradius !== undefined) {
29846
- if (options.maxradius >= 0 && options.maxradius <= 180) {
29847
- query.maxradius = options.maxradius;
29898
+ if (options.maximal_radius !== undefined) {
29899
+ if (options.maximal_radius >= 0 && options.maximal_radius <= 180) {
29900
+ query.maximal_radius = options.maximal_radius;
29848
29901
  } else {
29849
29902
  return err(Error("Max radius should be between 0 and 180"));
29850
29903
  }
29851
29904
  }
29852
29905
  const keys = [
29853
- "mindepth",
29854
- "maxdepth",
29855
- "minmagnitude",
29856
- "maxmagnitude",
29857
- "magnitudetype",
29858
- "eventtype",
29906
+ "minimal_depth",
29907
+ "maximal_depth",
29908
+ "minimal_magnitude",
29909
+ "maximal_magnitude",
29910
+ "magnitude_type",
29911
+ "event_types",
29859
29912
  "includeallorigins",
29860
29913
  "includeallmagnitudes",
29861
29914
  "includearrivals",
29862
29915
  "catalog",
29863
29916
  "contributor",
29864
- "updatedafter"
29917
+ "updated_after"
29865
29918
  ];
29866
29919
  keys.forEach((key) => {
29867
29920
  if (options[key] !== undefined) {
@@ -29883,9 +29936,9 @@ class Client {
29883
29936
  }
29884
29937
  }
29885
29938
  let values = ["time", "time-asc", "magnitude", "magnitude-asc"];
29886
- if (options.orderby !== undefined) {
29887
- if (values.includes(options.orderby)) {
29888
- query.orderby = options.orderby;
29939
+ if (options.order_by !== undefined) {
29940
+ if (values.includes(options.order_by)) {
29941
+ query.order_by = options.order_by;
29889
29942
  } else {
29890
29943
  return err(Error("Orderby must be time, time-asc, magnitude or magnitude-asc"));
29891
29944
  }
@@ -29897,6 +29950,8 @@ class Client {
29897
29950
  } else {
29898
29951
  return err(Error("Format must be xml, text or json"));
29899
29952
  }
29953
+ } else {
29954
+ query.format = "json";
29900
29955
  }
29901
29956
  values = ["204", "404"];
29902
29957
  if (options.nodata !== undefined) {
@@ -29992,7 +30047,7 @@ var eventTypes = new Map([
29992
30047
  ["volcanic eruption", "éruption volcanique"]
29993
30048
  ]);
29994
30049
  // src/sismomap.ts
29995
- var import_maplibre_gl = __toESM(require_maplibre_gl(), 1);
30050
+ var import_maplibre_gl2 = __toESM(require_maplibre_gl(), 1);
29996
30051
 
29997
30052
  // node_modules/@turf/meta/dist/esm/index.js
29998
30053
  function coordEach(geojson, callback, excludeWrapCoord) {
@@ -54995,11 +55050,9 @@ class SismoMap {
54995
55050
  name;
54996
55051
  map;
54997
55052
  descPopup;
54998
- _layers;
54999
- _sources;
55000
55053
  _mapscene;
55001
55054
  constructor(name, map, lang, bounds) {
55002
- let descPopup = new import_maplibre_gl.default.Popup({
55055
+ let descPopup = new import_maplibre_gl2.default.Popup({
55003
55056
  closeButton: false,
55004
55057
  closeOnClick: false,
55005
55058
  maxWidth: "200px"
@@ -55014,6 +55067,51 @@ class SismoMap {
55014
55067
  if (typeof bounds != "undefined") {
55015
55068
  map.fitBounds(bounds);
55016
55069
  }
55070
+ let emptySrc = {
55071
+ type: "geojson",
55072
+ data: {
55073
+ type: "FeatureCollection",
55074
+ features: []
55075
+ }
55076
+ };
55077
+ map.addSource("src", emptySrc);
55078
+ map.addSource("stat", structuredClone(emptySrc));
55079
+ map.addLayer({
55080
+ id: "event-layer",
55081
+ source: "src",
55082
+ type: "circle",
55083
+ paint: {
55084
+ "circle-radius": [
55085
+ "*",
55086
+ 8,
55087
+ ["ln", ["+", 1, ["get", "magnitude"]]]
55088
+ ],
55089
+ "circle-color": MagnitudesColors,
55090
+ "circle-opacity": 0.8,
55091
+ "circle-stroke-width": 1,
55092
+ "circle-stroke-opacity": 0.9
55093
+ }
55094
+ });
55095
+ const svgImage = new Image(20, 20);
55096
+ const triangleSVG = `
55097
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
55098
+ <polygon points="12,2 22,22 2,22" fill="blue" />
55099
+ </svg>`;
55100
+ const encodedSVG = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(triangleSVG)}`;
55101
+ svgImage.src = encodedSVG;
55102
+ svgImage.onload = () => {
55103
+ map.addImage("triangle", svgImage);
55104
+ };
55105
+ map.addLayer({
55106
+ id: "station-layer",
55107
+ source: "stat",
55108
+ type: "symbol",
55109
+ layout: {
55110
+ "icon-image": "triangle",
55111
+ "icon-allow-overlap": true,
55112
+ "icon-size": 0.8
55113
+ }
55114
+ });
55017
55115
  let titles = ["event-layer", "station-layer"];
55018
55116
  titles.forEach((title) => {
55019
55117
  map.on("mouseenter", title, (e) => {
@@ -55021,8 +55119,6 @@ class SismoMap {
55021
55119
  map.getCanvas().style.cursor = "pointer";
55022
55120
  if (e.features == undefined)
55023
55121
  return;
55024
- if (!isEventGeoJSONProperties(e.features[0].properties))
55025
- return;
55026
55122
  let text = JSON.parse(e.features[0].properties.description);
55027
55123
  const feature = e.features[0];
55028
55124
  const [lng, lat] = feature.geometry.coordinates;
@@ -55037,23 +55133,25 @@ class SismoMap {
55037
55133
  this.name = name;
55038
55134
  this.map = map;
55039
55135
  this.descPopup = descPopup;
55040
- this._layers = [];
55041
- this._sources = [];
55042
55136
  this._mapscene = new O(this.map);
55043
55137
  this._mapscene.addLight(new AmbientLight(16777215, 0.8));
55044
55138
  this.changeLanguage(lang);
55045
55139
  }
55046
55140
  clear() {
55047
- this._layers.forEach((layer) => {
55048
- if (this.map.getLayer(layer)) {
55049
- this.map.removeLayer(layer);
55050
- }
55051
- });
55052
- this._sources.forEach((source) => {
55053
- if (this.map.getSource(source)) {
55054
- this.map.removeSource(source);
55055
- }
55056
- });
55141
+ let src = this.map.getSource("src");
55142
+ if (src != null) {
55143
+ src.setData({
55144
+ type: "FeatureCollection",
55145
+ features: []
55146
+ });
55147
+ }
55148
+ src = this.map.getSource("stat");
55149
+ if (src != null) {
55150
+ src.setData({
55151
+ type: "FeatureCollection",
55152
+ features: []
55153
+ });
55154
+ }
55057
55155
  }
55058
55156
  async displayStations(client, event, moveView = true, clear = true, stationOnly = false, model3D = true) {
55059
55157
  let eventGeo;
@@ -55111,27 +55209,7 @@ class SismoMap {
55111
55209
  this.centerView(stationsGeoJSON);
55112
55210
  }
55113
55211
  } else {
55114
- const svgImage = new Image(20, 20);
55115
- const triangleSVG = `
55116
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">
55117
- <polygon points="12,2 22,22 2,22" fill="blue" />
55118
- </svg>`;
55119
- const encodedSVG = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(triangleSVG)}`;
55120
- svgImage.src = encodedSVG;
55121
- svgImage.onload = () => {
55122
- this.map.addImage("triangle", svgImage);
55123
- };
55124
- let layerSpec = {
55125
- id: "station-layer",
55126
- source: "stat",
55127
- type: "symbol",
55128
- layout: {
55129
- "icon-image": "triangle",
55130
- "icon-allow-overlap": true,
55131
- "icon-size": 0.8
55132
- }
55133
- };
55134
- if (this.displayGeoJSON(stationsGeoJSON, "stat", layerSpec, moveView, false).isErr())
55212
+ if (this.displayGeoJSON(stationsGeoJSON, "stat", moveView, false).isErr())
55135
55213
  return Promise.reject();
55136
55214
  }
55137
55215
  return Promise.resolve();
@@ -55144,30 +55222,25 @@ class SismoMap {
55144
55222
  eventList = EventToEventGeoJSON(eventOrList);
55145
55223
  }
55146
55224
  eventList.features.forEach((_, i) => {
55147
- eventList.features[i].properties.type = eventList.features[i].properties.type || "event";
55225
+ eventList.features[i].properties.eventType = eventList.features[i].properties.eventType || "event";
55148
55226
  });
55149
- let layerSpec = {
55150
- id: "event-layer",
55151
- source: "src",
55152
- type: "circle",
55153
- paint: {
55154
- "circle-radius": ["*", 8, ["ln", ["+", 1, ["get", "mag"]]]],
55155
- "circle-color": MagnitudesColors,
55156
- "circle-opacity": 0.8,
55157
- "circle-stroke-width": 1,
55158
- "circle-stroke-opacity": 0.9
55159
- }
55160
- };
55161
- this.displayGeoJSON(eventList, "src", layerSpec, moveView, clear);
55227
+ this.displayGeoJSON(eventList, "src", moveView, clear);
55162
55228
  }
55163
55229
  updateSource(sourceName, newData) {
55164
- let source = this.map.getSource(sourceName);
55165
- let data = source?._data.geojson;
55166
- if (data === undefined)
55167
- return;
55168
- let geojson = data;
55169
- geojson.features = geojson.features.concat(newData.features);
55170
- source?.setData(geojson);
55230
+ let sismap = this;
55231
+ function upd() {
55232
+ let source = sismap.map.getSource(sourceName);
55233
+ if (source == undefined)
55234
+ setTimeout(upd, 100);
55235
+ source?.getData().then((data) => {
55236
+ console.log("coucou");
55237
+ let geojson = data;
55238
+ geojson.features = geojson.features.concat(newData.features);
55239
+ console.log(geojson);
55240
+ source?.setData(geojson);
55241
+ });
55242
+ }
55243
+ upd();
55171
55244
  }
55172
55245
  centerView(geojson) {
55173
55246
  if (geojson.features.length == 1) {
@@ -55183,33 +55256,24 @@ class SismoMap {
55183
55256
  this.map.fitBounds(bounds);
55184
55257
  }
55185
55258
  }
55186
- displayGeoJSON(geojson, sourceName, layerSpec, moveView, clear) {
55187
- if (geojson.features.length == 0)
55188
- return ok(null);
55189
- if (clear) {
55190
- this.clear();
55191
- this.map.addSource(sourceName, {
55192
- type: "geojson",
55193
- data: geojson
55194
- });
55195
- this.map.addLayer(layerSpec);
55196
- } else if (!clear && !this.map.getSource(sourceName)) {
55197
- this.map.addSource(sourceName, {
55198
- type: "geojson",
55199
- data: geojson
55200
- });
55201
- this.map.addLayer(layerSpec);
55202
- } else {
55203
- this.updateSource(sourceName, geojson);
55204
- }
55205
- if (moveView) {
55206
- this.centerView(geojson);
55207
- }
55208
- if (this._sources.includes(sourceName)) {
55209
- this._sources.push(sourceName);
55259
+ displayGeoJSON(geojson, sourceName, moveView, clear) {
55260
+ function display(map) {
55261
+ console.log("displaying");
55262
+ console.log(geojson);
55263
+ if (geojson.features.length == 0)
55264
+ return ok(null);
55265
+ if (clear) {
55266
+ map.clear();
55267
+ }
55268
+ map.updateSource(sourceName, geojson);
55269
+ if (moveView) {
55270
+ map.centerView(geojson);
55271
+ }
55210
55272
  }
55211
- if (this._layers.includes(layerSpec.id)) {
55212
- this._layers.push(layerSpec.id);
55273
+ if (this.map.loaded()) {
55274
+ display(this);
55275
+ } else {
55276
+ this.map.once("load", () => display(this));
55213
55277
  }
55214
55278
  return ok(null);
55215
55279
  }
@@ -55262,7 +55326,7 @@ class SismoMap {
55262
55326
  for (let eventName of filterQuery.events) {
55263
55327
  if (!PossibleEvents.includes(eventName))
55264
55328
  return err(Error("Wrong Event type " + eventName));
55265
- let subfilter = ["==", eventName, ["get", "type"]];
55329
+ let subfilter = ["==", eventName, ["get", "eventType"]];
55266
55330
  filter2[filter2.length - 1].push(subfilter);
55267
55331
  }
55268
55332
  }
@@ -55275,10 +55339,14 @@ class SismoMap {
55275
55339
  filter2[filter2.length - 1].push(Intervals.get(magnitude));
55276
55340
  }
55277
55341
  }
55278
- this.map.once("load", () => {
55279
- console.log(filter2);
55342
+ if (this.map.loaded()) {
55280
55343
  this.map.setFilter("event-layer", filter2);
55281
- });
55344
+ } else {
55345
+ this.map.once("load", () => {
55346
+ console.log(filter2);
55347
+ this.map.setFilter("event-layer", filter2);
55348
+ });
55349
+ }
55282
55350
  return ok(null);
55283
55351
  }
55284
55352
  clearFilter() {
@@ -55343,7 +55411,7 @@ class SismoMap {
55343
55411
  return ok(data);
55344
55412
  }
55345
55413
  }
55346
- var export_LngLatBounds = import_maplibre_gl2.LngLatBounds;
55414
+ var export_LngLatBounds = import_maplibre_gl3.LngLatBounds;
55347
55415
 
55348
55416
  export {
55349
55417
  eventTypes,
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { CleanedFDSNQueryOptions, EventPhases, FDSNQueryOptions, Zones } from './types';
2
+ import { CleanedEventQueryOptions, EventPhases, EventQueryOptions, Zones } from './types';
3
3
  import { Result } from 'neverthrow';
4
4
  import { Form, Question, Survey, City, Testimony, QuestionChoice, Answer, EventGeoJSON, SisEvent as NamazuEvent, StationGeoJSON } from './types';
5
5
  export declare class Client {
@@ -9,6 +9,7 @@ export declare class Client {
9
9
  apiCall<Type>(apiRoute: AxiosRequestConfig): Promise<Type>;
10
10
  apiCall<Type>(apiRoute: string, method?: string): Promise<Type>;
11
11
  fetchForm(id: number): Promise<Form>;
12
+ getEvents(args: EventQueryOptions): Promise<EventGeoJSON>;
12
13
  getQuestion(form: Form, question_id: number): Question | undefined;
13
14
  getChoice(question: Question, choice_id: number): QuestionChoice | undefined;
14
15
  createIndividualTestimony(eventPublicID: string, email: string): Promise<Testimony>;
@@ -32,11 +33,11 @@ export declare class Client {
32
33
  getNextQuestion(form: Form, answers: Answer[], currentQuestion?: Question): Question | undefined;
33
34
  formatDateFR(dateString: Date): string;
34
35
  translateEventType(eventType: string): string;
35
- buildQuery(url: string, options: CleanedFDSNQueryOptions): AxiosRequestConfig;
36
+ buildQuery(url: string, options: CleanedEventQueryOptions): AxiosRequestConfig;
36
37
  /**
37
38
  * <!> IF YOU WANT TO CAST AS NAMAZU TYPE LATER, SET format:'json'
38
39
  */
39
- cleanQuery(options: FDSNQueryOptions): Result<CleanedFDSNQueryOptions, Error>;
40
+ cleanQuery(options: EventQueryOptions): Result<CleanedEventQueryOptions, Error>;
40
41
  getZones(): Promise<Zones>;
41
42
  getZoneNameByEvent(event: EventGeoJSON): Promise<string>;
42
43
  getStationsByZoneName(zoneName: string): Promise<StationGeoJSON>;