namazu-ts 0.24.0 → 0.24.2
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.
- package/README.md +8 -0
- package/dist/browser/index.js +61 -60
- package/dist/node/index.js +61 -60
- package/dist/sismomap.d.ts +3 -4
- package/dist/types.d.ts +10 -2
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/SismoMap.html +6 -7
- package/docs/enums/NamazuSource.html +6 -0
- package/docs/index.html +9 -0
- package/docs/modules.html +1 -1
- package/docs/types/Answer.html +2 -2
- package/docs/types/CleanedEventQueryOptions.html +1 -1
- package/docs/types/EventCity.html +2 -2
- package/docs/types/EventFeature.html +2 -2
- package/docs/types/EventGeoJSON.html +2 -2
- package/docs/types/EventGeoJSONProperties.html +2 -2
- package/docs/types/EventGeojsonDescriptionProperty.html +2 -2
- package/docs/types/EventPhases.html +1 -1
- package/docs/types/EventQueryOptions.html +2 -2
- package/docs/types/FDSNQueryOptions.html +2 -2
- package/docs/types/FilterQuery.html +2 -2
- package/docs/types/Form.html +2 -2
- package/docs/types/FormCity.html +2 -2
- package/docs/types/GeoJSON.html +1 -1
- package/docs/types/InfosPhase.html +2 -2
- package/docs/types/Magnitude.html +2 -2
- package/docs/types/NamazuEvent.html +3 -2
- package/docs/types/Origin.html +2 -2
- package/docs/types/Quality.html +2 -2
- package/docs/types/Question.html +2 -2
- package/docs/types/QuestionChoice.html +2 -2
- package/docs/types/QuestionCondition.html +1 -1
- package/docs/types/QuestionGroup.html +2 -2
- package/docs/types/Station.html +2 -2
- package/docs/types/StationFeature.html +1 -0
- package/docs/types/StationGeoJSON.html +2 -2
- package/docs/types/Street.html +2 -2
- package/docs/types/Survey.html +2 -2
- package/docs/types/Testimony.html +2 -2
- package/docs/types/Uncertainty.html +2 -2
- package/docs/types/Zone.html +2 -2
- package/docs/types/ZoneDesc.html +2 -2
- package/docs/types/Zones.html +2 -2
- package/docs/variables/Intervals.html +1 -1
- package/docs/variables/MagnitudesColors.html +1 -1
- package/docs/variables/PossibleEvents.html +1 -1
- package/docs/variables/SortFilters.html +1 -1
- package/docs/variables/ZoneNames.html +1 -1
- package/package.json +1 -1
- package/src/sismomap.ts +91 -77
- package/src/types.ts +12 -3
- package/docs/types/StationPhases.html +0 -1
package/README.md
CHANGED
|
@@ -11,7 +11,15 @@ To build library:
|
|
|
11
11
|
```bash
|
|
12
12
|
bun run build
|
|
13
13
|
```
|
|
14
|
+
___
|
|
15
|
+
|
|
16
|
+
Types you can find in the sources :
|
|
14
17
|
|
|
18
|
+
- NamazuSource.LINE => doesn't have a namazu name but it's just a feature with EventGeoJSONDescriptionProperty+Geometry
|
|
19
|
+
- NamazuSource.UNCERTAINTY => doesn't have a namazu name but it's a GeoJSON Polygon
|
|
20
|
+
- NamazuSource.STATIONS => StationGeoJSON
|
|
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
|
+
- NamazuSource.POPUP => Not really a source, it's just used as a placeholder for sismap._descPopup that contains maplibre.Popup
|
|
15
23
|
___
|
|
16
24
|
|
|
17
25
|
## Small example
|
package/dist/browser/index.js
CHANGED
|
@@ -30179,6 +30179,14 @@ var NamazuLayers;
|
|
|
30179
30179
|
NamazuLayers2["STATIONS"] = "station-layer";
|
|
30180
30180
|
NamazuLayers2["EVENTS"] = "event-layer";
|
|
30181
30181
|
})(NamazuLayers ||= {});
|
|
30182
|
+
var NamazuSource;
|
|
30183
|
+
((NamazuSource2) => {
|
|
30184
|
+
NamazuSource2["UNCERTAINTY"] = "uncertainty";
|
|
30185
|
+
NamazuSource2["LINE"] = "ligne";
|
|
30186
|
+
NamazuSource2["STATIONS"] = "station";
|
|
30187
|
+
NamazuSource2["EVENTS"] = "event";
|
|
30188
|
+
NamazuSource2["POPUP"] = "popup";
|
|
30189
|
+
})(NamazuSource ||= {});
|
|
30182
30190
|
var PossibleEvents = [
|
|
30183
30191
|
"event",
|
|
30184
30192
|
"earthquake",
|
|
@@ -30850,13 +30858,13 @@ class SismoMap {
|
|
|
30850
30858
|
coordinates: []
|
|
30851
30859
|
}
|
|
30852
30860
|
};
|
|
30853
|
-
map.addSource("
|
|
30861
|
+
map.addSource("uncertainty" /* UNCERTAINTY */, {
|
|
30854
30862
|
type: "geojson",
|
|
30855
30863
|
data: emptyPolygon
|
|
30856
30864
|
});
|
|
30857
|
-
map.addSource("event"
|
|
30858
|
-
map.addSource("station"
|
|
30859
|
-
map.addSource("ligne"
|
|
30865
|
+
map.addSource("event" /* EVENTS */, emptySrc);
|
|
30866
|
+
map.addSource("station" /* STATIONS */, structuredClone(emptySrc));
|
|
30867
|
+
map.addSource("ligne" /* LINE */, {
|
|
30860
30868
|
type: "geojson",
|
|
30861
30869
|
data: {
|
|
30862
30870
|
type: "Feature",
|
|
@@ -30878,8 +30886,8 @@ class SismoMap {
|
|
|
30878
30886
|
map.addImage("triangle", svgImage, { sdf: true });
|
|
30879
30887
|
};
|
|
30880
30888
|
map.addLayer({
|
|
30881
|
-
id: "ellipsoid"
|
|
30882
|
-
source: "
|
|
30889
|
+
id: "ellipsoid" /* UNCERTAINTY */,
|
|
30890
|
+
source: "uncertainty" /* UNCERTAINTY */,
|
|
30883
30891
|
type: "fill",
|
|
30884
30892
|
paint: {
|
|
30885
30893
|
"fill-color": "#FF5F1F",
|
|
@@ -30887,9 +30895,9 @@ class SismoMap {
|
|
|
30887
30895
|
}
|
|
30888
30896
|
});
|
|
30889
30897
|
map.addLayer({
|
|
30890
|
-
id: "ligne"
|
|
30898
|
+
id: "ligne" /* LINE */,
|
|
30891
30899
|
type: "line",
|
|
30892
|
-
source: "ligne"
|
|
30900
|
+
source: "ligne" /* LINE */,
|
|
30893
30901
|
layout: {
|
|
30894
30902
|
"line-join": "round",
|
|
30895
30903
|
"line-cap": "round"
|
|
@@ -30900,8 +30908,8 @@ class SismoMap {
|
|
|
30900
30908
|
}
|
|
30901
30909
|
});
|
|
30902
30910
|
map.addLayer({
|
|
30903
|
-
id: "station-layer"
|
|
30904
|
-
source: "station"
|
|
30911
|
+
id: "station-layer" /* STATIONS */,
|
|
30912
|
+
source: "station" /* STATIONS */,
|
|
30905
30913
|
type: "symbol",
|
|
30906
30914
|
layout: {
|
|
30907
30915
|
"icon-image": "triangle",
|
|
@@ -30915,8 +30923,8 @@ class SismoMap {
|
|
|
30915
30923
|
}
|
|
30916
30924
|
});
|
|
30917
30925
|
map.addLayer({
|
|
30918
|
-
id: "event-layer"
|
|
30919
|
-
source: "event"
|
|
30926
|
+
id: "event-layer" /* EVENTS */,
|
|
30927
|
+
source: "event" /* EVENTS */,
|
|
30920
30928
|
type: "circle",
|
|
30921
30929
|
paint: {
|
|
30922
30930
|
"circle-radius": [
|
|
@@ -30930,11 +30938,11 @@ class SismoMap {
|
|
|
30930
30938
|
"circle-stroke-opacity": 0.9
|
|
30931
30939
|
}
|
|
30932
30940
|
});
|
|
30933
|
-
let titles = ["event-layer"
|
|
30941
|
+
let titles = ["event-layer" /* EVENTS */, "station-layer" /* STATIONS */];
|
|
30934
30942
|
titles.forEach((title) => {
|
|
30935
30943
|
map.on("mouseenter", title, (e) => {
|
|
30936
30944
|
map.getCanvas().style.cursor = "pointer";
|
|
30937
|
-
if (e.features == undefined
|
|
30945
|
+
if (e.features == undefined)
|
|
30938
30946
|
return;
|
|
30939
30947
|
let text = JSON.parse(e.features[0].properties.description);
|
|
30940
30948
|
const feature = e.features[0];
|
|
@@ -30957,20 +30965,20 @@ class SismoMap {
|
|
|
30957
30965
|
this.changeLanguage(lang);
|
|
30958
30966
|
}
|
|
30959
30967
|
clear() {
|
|
30960
|
-
this.clearSource("popup");
|
|
30961
|
-
this.clearSource("event");
|
|
30962
|
-
this.clearSource("station");
|
|
30963
|
-
this.clearSource("
|
|
30964
|
-
this.clearSource("ligne");
|
|
30968
|
+
this.clearSource("popup" /* POPUP */);
|
|
30969
|
+
this.clearSource("event" /* EVENTS */);
|
|
30970
|
+
this.clearSource("station" /* STATIONS */);
|
|
30971
|
+
this.clearSource("uncertainty" /* UNCERTAINTY */);
|
|
30972
|
+
this.clearSource("ligne" /* LINE */);
|
|
30965
30973
|
}
|
|
30966
30974
|
clearLignePopup() {
|
|
30967
|
-
this.clearSource("popup");
|
|
30968
|
-
this.clearSource("ligne");
|
|
30975
|
+
this.clearSource("popup" /* POPUP */);
|
|
30976
|
+
this.clearSource("ligne" /* LINE */);
|
|
30969
30977
|
}
|
|
30970
30978
|
clearSource(sourceName) {
|
|
30971
30979
|
let data;
|
|
30972
30980
|
switch (sourceName) {
|
|
30973
|
-
case "
|
|
30981
|
+
case "uncertainty" /* UNCERTAINTY */: {
|
|
30974
30982
|
data = {
|
|
30975
30983
|
type: "Feature",
|
|
30976
30984
|
geometry: {
|
|
@@ -30990,15 +30998,15 @@ class SismoMap {
|
|
|
30990
30998
|
};
|
|
30991
30999
|
break;
|
|
30992
31000
|
}
|
|
30993
|
-
case "station"
|
|
30994
|
-
case "event"
|
|
31001
|
+
case "station" /* STATIONS */:
|
|
31002
|
+
case "event" /* EVENTS */: {
|
|
30995
31003
|
data = {
|
|
30996
31004
|
type: "FeatureCollection",
|
|
30997
31005
|
features: []
|
|
30998
31006
|
};
|
|
30999
31007
|
break;
|
|
31000
31008
|
}
|
|
31001
|
-
case "popup"
|
|
31009
|
+
case "popup" /* POPUP */: {
|
|
31002
31010
|
this._descPopups.forEach((popup) => popup.remove());
|
|
31003
31011
|
}
|
|
31004
31012
|
default:
|
|
@@ -31052,7 +31060,7 @@ class SismoMap {
|
|
|
31052
31060
|
};
|
|
31053
31061
|
}
|
|
31054
31062
|
}
|
|
31055
|
-
this.displayGeoJSON(stations, "station"
|
|
31063
|
+
this.displayGeoJSON(stations, "station" /* STATIONS */, moveView, clear);
|
|
31056
31064
|
}
|
|
31057
31065
|
async getAndDisplayStations(client, event, moveView = true, clear = true, stationOnly = false) {
|
|
31058
31066
|
let eventGeo;
|
|
@@ -31105,7 +31113,7 @@ class SismoMap {
|
|
|
31105
31113
|
});
|
|
31106
31114
|
console.log("Absent stations : ");
|
|
31107
31115
|
console.log(absentStations);
|
|
31108
|
-
if (this.displayGeoJSON(stationsGeoJSON, "station"
|
|
31116
|
+
if (this.displayGeoJSON(stationsGeoJSON, "station" /* STATIONS */, moveView, false).isErr()) {
|
|
31109
31117
|
return Promise.reject();
|
|
31110
31118
|
}
|
|
31111
31119
|
return [phases, stationsGeoJSON];
|
|
@@ -31120,7 +31128,7 @@ class SismoMap {
|
|
|
31120
31128
|
eventList.features.forEach((_, i) => {
|
|
31121
31129
|
eventList.features[i].properties.eventType = eventList.features[i].properties.eventType || "event";
|
|
31122
31130
|
});
|
|
31123
|
-
this.displayGeoJSON(eventList, "event"
|
|
31131
|
+
this.displayGeoJSON(eventList, "event" /* EVENTS */, moveView, clear, sortOrder);
|
|
31124
31132
|
}
|
|
31125
31133
|
updateSource(sourceName, newData) {
|
|
31126
31134
|
let sismap = this;
|
|
@@ -31153,7 +31161,7 @@ class SismoMap {
|
|
|
31153
31161
|
displayGeoJSON(geojson, sourceName, moveView, clear, sortOrder) {
|
|
31154
31162
|
function display(map) {
|
|
31155
31163
|
let val = 0;
|
|
31156
|
-
if (sourceName == "event") {
|
|
31164
|
+
if (sourceName == "event" /* EVENTS */) {
|
|
31157
31165
|
if (sortOrder) {
|
|
31158
31166
|
if (sortOrder.includes("time")) {
|
|
31159
31167
|
geojson.features.forEach((elem, index) => {
|
|
@@ -31163,7 +31171,7 @@ class SismoMap {
|
|
|
31163
31171
|
val = SortFilters.get(sortOrder);
|
|
31164
31172
|
}
|
|
31165
31173
|
}
|
|
31166
|
-
map.map.setLayoutProperty("event-layer"
|
|
31174
|
+
map.map.setLayoutProperty("event-layer" /* EVENTS */, "circle-sort-key", val);
|
|
31167
31175
|
if (clear) {
|
|
31168
31176
|
map.clear();
|
|
31169
31177
|
}
|
|
@@ -31292,7 +31300,7 @@ class SismoMap {
|
|
|
31292
31300
|
}
|
|
31293
31301
|
applyFilter(filterQuery) {
|
|
31294
31302
|
if (filterQuery.magnitudes.length == 0 && filterQuery.events.length == 0) {
|
|
31295
|
-
this.map.setFilter("event-layer"
|
|
31303
|
+
this.map.setFilter("event-layer" /* EVENTS */, null);
|
|
31296
31304
|
return ok(null);
|
|
31297
31305
|
}
|
|
31298
31306
|
let filter2 = ["all"];
|
|
@@ -31315,16 +31323,16 @@ class SismoMap {
|
|
|
31315
31323
|
}
|
|
31316
31324
|
}
|
|
31317
31325
|
if (this.map.loaded() || this._usable) {
|
|
31318
|
-
this.map.setFilter("event-layer"
|
|
31326
|
+
this.map.setFilter("event-layer" /* EVENTS */, filter2);
|
|
31319
31327
|
} else {
|
|
31320
31328
|
this.map.once("load", () => {
|
|
31321
|
-
this.map.setFilter("event-layer"
|
|
31329
|
+
this.map.setFilter("event-layer" /* EVENTS */, filter2);
|
|
31322
31330
|
});
|
|
31323
31331
|
}
|
|
31324
31332
|
return ok(null);
|
|
31325
31333
|
}
|
|
31326
31334
|
clearFilter() {
|
|
31327
|
-
this.map.setFilter("event-layer"
|
|
31335
|
+
this.map.setFilter("event-layer" /* EVENTS */, null);
|
|
31328
31336
|
}
|
|
31329
31337
|
displayEllipse(midMinorAxisLength, midMajorAxisLength, rotation, center) {
|
|
31330
31338
|
const coords = createEllipse(midMinorAxisLength, midMajorAxisLength, rotation, center);
|
|
@@ -31332,12 +31340,13 @@ class SismoMap {
|
|
|
31332
31340
|
}
|
|
31333
31341
|
async displayLink(phase, popupString, linkColor = "#888", linkOpacity = 1, linkWidth = 6) {
|
|
31334
31342
|
async function display(map) {
|
|
31335
|
-
|
|
31336
|
-
if (
|
|
31337
|
-
|
|
31343
|
+
const eventsrc = map.map.getSource("event" /* EVENTS */);
|
|
31344
|
+
if (eventsrc == undefined) {
|
|
31345
|
+
console.error("Event source inexistent ?");
|
|
31346
|
+
return;
|
|
31338
31347
|
}
|
|
31339
|
-
const src =
|
|
31340
|
-
const statSrc = map.map.getSource("station");
|
|
31348
|
+
const src = await eventsrc.getData();
|
|
31349
|
+
const statSrc = map.map.getSource("station" /* STATIONS */);
|
|
31341
31350
|
let geojson = await statSrc.getData();
|
|
31342
31351
|
const stationsGeoJSON = geojson;
|
|
31343
31352
|
let station = undefined;
|
|
@@ -31347,9 +31356,9 @@ class SismoMap {
|
|
|
31347
31356
|
break;
|
|
31348
31357
|
}
|
|
31349
31358
|
}
|
|
31350
|
-
map.map.setPaintProperty("ligne"
|
|
31351
|
-
map.map.setPaintProperty("ligne"
|
|
31352
|
-
map.map.setPaintProperty("ligne"
|
|
31359
|
+
map.map.setPaintProperty("ligne" /* LINE */, "line-color", linkColor);
|
|
31360
|
+
map.map.setPaintProperty("ligne" /* LINE */, "line-opacity", linkOpacity);
|
|
31361
|
+
map.map.setPaintProperty("ligne" /* LINE */, "line-width", linkWidth);
|
|
31353
31362
|
if (station == undefined) {
|
|
31354
31363
|
return Promise.resolve();
|
|
31355
31364
|
}
|
|
@@ -31371,7 +31380,7 @@ class SismoMap {
|
|
|
31371
31380
|
]
|
|
31372
31381
|
}
|
|
31373
31382
|
};
|
|
31374
|
-
map.map.getSource("ligne")?.setData(newData);
|
|
31383
|
+
map.map.getSource("ligne" /* LINE */)?.setData(newData);
|
|
31375
31384
|
}
|
|
31376
31385
|
if (this.map.loaded() || this._usable) {
|
|
31377
31386
|
display(this);
|
|
@@ -31399,7 +31408,7 @@ class SismoMap {
|
|
|
31399
31408
|
}
|
|
31400
31409
|
};
|
|
31401
31410
|
function upd() {
|
|
31402
|
-
let source = sismap.map.getSource("
|
|
31411
|
+
let source = sismap.map.getSource("uncertainty" /* UNCERTAINTY */);
|
|
31403
31412
|
if (source == undefined)
|
|
31404
31413
|
setTimeout(upd, 100);
|
|
31405
31414
|
source?.setData(newData);
|
|
@@ -31429,23 +31438,14 @@ class SismoMap {
|
|
|
31429
31438
|
});
|
|
31430
31439
|
});
|
|
31431
31440
|
}
|
|
31432
|
-
getEventNumber() {
|
|
31433
|
-
let source = this.
|
|
31441
|
+
async getEventNumber() {
|
|
31442
|
+
let source = this.map.getSource("");
|
|
31443
|
+
if (source == undefined)
|
|
31444
|
+
return Promise.reject("");
|
|
31434
31445
|
let length = 0;
|
|
31435
|
-
|
|
31436
|
-
|
|
31437
|
-
|
|
31438
|
-
length = s.features.length;
|
|
31439
|
-
});
|
|
31440
|
-
return ok(length);
|
|
31441
|
-
}
|
|
31442
|
-
getSourceGeoJSON() {
|
|
31443
|
-
let source = this.map.getSource("event");
|
|
31444
|
-
let data = source?._data.geojson;
|
|
31445
|
-
if (data === undefined) {
|
|
31446
|
-
return err(Error("Source not defined yet"));
|
|
31447
|
-
}
|
|
31448
|
-
return ok(data);
|
|
31446
|
+
const sourceData = await source.getData();
|
|
31447
|
+
length = sourceData.features.length;
|
|
31448
|
+
return length;
|
|
31449
31449
|
}
|
|
31450
31450
|
}
|
|
31451
31451
|
var export_LngLatBounds = import_maplibre_gl3.LngLatBounds;
|
|
@@ -31460,6 +31460,7 @@ export {
|
|
|
31460
31460
|
SortFilters,
|
|
31461
31461
|
SismoMap,
|
|
31462
31462
|
PossibleEvents,
|
|
31463
|
+
NamazuSource,
|
|
31463
31464
|
NamazuLayers,
|
|
31464
31465
|
MagnitudesColors,
|
|
31465
31466
|
export_LngLatBounds as LngLatBounds,
|
package/dist/node/index.js
CHANGED
|
@@ -42538,6 +42538,14 @@ var NamazuLayers;
|
|
|
42538
42538
|
NamazuLayers2["STATIONS"] = "station-layer";
|
|
42539
42539
|
NamazuLayers2["EVENTS"] = "event-layer";
|
|
42540
42540
|
})(NamazuLayers ||= {});
|
|
42541
|
+
var NamazuSource;
|
|
42542
|
+
((NamazuSource2) => {
|
|
42543
|
+
NamazuSource2["UNCERTAINTY"] = "uncertainty";
|
|
42544
|
+
NamazuSource2["LINE"] = "ligne";
|
|
42545
|
+
NamazuSource2["STATIONS"] = "station";
|
|
42546
|
+
NamazuSource2["EVENTS"] = "event";
|
|
42547
|
+
NamazuSource2["POPUP"] = "popup";
|
|
42548
|
+
})(NamazuSource ||= {});
|
|
42541
42549
|
var PossibleEvents = [
|
|
42542
42550
|
"event",
|
|
42543
42551
|
"earthquake",
|
|
@@ -43209,13 +43217,13 @@ class SismoMap {
|
|
|
43209
43217
|
coordinates: []
|
|
43210
43218
|
}
|
|
43211
43219
|
};
|
|
43212
|
-
map.addSource("
|
|
43220
|
+
map.addSource("uncertainty" /* UNCERTAINTY */, {
|
|
43213
43221
|
type: "geojson",
|
|
43214
43222
|
data: emptyPolygon
|
|
43215
43223
|
});
|
|
43216
|
-
map.addSource("event"
|
|
43217
|
-
map.addSource("station"
|
|
43218
|
-
map.addSource("ligne"
|
|
43224
|
+
map.addSource("event" /* EVENTS */, emptySrc);
|
|
43225
|
+
map.addSource("station" /* STATIONS */, structuredClone(emptySrc));
|
|
43226
|
+
map.addSource("ligne" /* LINE */, {
|
|
43219
43227
|
type: "geojson",
|
|
43220
43228
|
data: {
|
|
43221
43229
|
type: "Feature",
|
|
@@ -43237,8 +43245,8 @@ class SismoMap {
|
|
|
43237
43245
|
map.addImage("triangle", svgImage, { sdf: true });
|
|
43238
43246
|
};
|
|
43239
43247
|
map.addLayer({
|
|
43240
|
-
id: "ellipsoid"
|
|
43241
|
-
source: "
|
|
43248
|
+
id: "ellipsoid" /* UNCERTAINTY */,
|
|
43249
|
+
source: "uncertainty" /* UNCERTAINTY */,
|
|
43242
43250
|
type: "fill",
|
|
43243
43251
|
paint: {
|
|
43244
43252
|
"fill-color": "#FF5F1F",
|
|
@@ -43246,9 +43254,9 @@ class SismoMap {
|
|
|
43246
43254
|
}
|
|
43247
43255
|
});
|
|
43248
43256
|
map.addLayer({
|
|
43249
|
-
id: "ligne"
|
|
43257
|
+
id: "ligne" /* LINE */,
|
|
43250
43258
|
type: "line",
|
|
43251
|
-
source: "ligne"
|
|
43259
|
+
source: "ligne" /* LINE */,
|
|
43252
43260
|
layout: {
|
|
43253
43261
|
"line-join": "round",
|
|
43254
43262
|
"line-cap": "round"
|
|
@@ -43259,8 +43267,8 @@ class SismoMap {
|
|
|
43259
43267
|
}
|
|
43260
43268
|
});
|
|
43261
43269
|
map.addLayer({
|
|
43262
|
-
id: "station-layer"
|
|
43263
|
-
source: "station"
|
|
43270
|
+
id: "station-layer" /* STATIONS */,
|
|
43271
|
+
source: "station" /* STATIONS */,
|
|
43264
43272
|
type: "symbol",
|
|
43265
43273
|
layout: {
|
|
43266
43274
|
"icon-image": "triangle",
|
|
@@ -43274,8 +43282,8 @@ class SismoMap {
|
|
|
43274
43282
|
}
|
|
43275
43283
|
});
|
|
43276
43284
|
map.addLayer({
|
|
43277
|
-
id: "event-layer"
|
|
43278
|
-
source: "event"
|
|
43285
|
+
id: "event-layer" /* EVENTS */,
|
|
43286
|
+
source: "event" /* EVENTS */,
|
|
43279
43287
|
type: "circle",
|
|
43280
43288
|
paint: {
|
|
43281
43289
|
"circle-radius": [
|
|
@@ -43289,11 +43297,11 @@ class SismoMap {
|
|
|
43289
43297
|
"circle-stroke-opacity": 0.9
|
|
43290
43298
|
}
|
|
43291
43299
|
});
|
|
43292
|
-
let titles = ["event-layer"
|
|
43300
|
+
let titles = ["event-layer" /* EVENTS */, "station-layer" /* STATIONS */];
|
|
43293
43301
|
titles.forEach((title) => {
|
|
43294
43302
|
map.on("mouseenter", title, (e) => {
|
|
43295
43303
|
map.getCanvas().style.cursor = "pointer";
|
|
43296
|
-
if (e.features == undefined
|
|
43304
|
+
if (e.features == undefined)
|
|
43297
43305
|
return;
|
|
43298
43306
|
let text = JSON.parse(e.features[0].properties.description);
|
|
43299
43307
|
const feature = e.features[0];
|
|
@@ -43316,20 +43324,20 @@ class SismoMap {
|
|
|
43316
43324
|
this.changeLanguage(lang);
|
|
43317
43325
|
}
|
|
43318
43326
|
clear() {
|
|
43319
|
-
this.clearSource("popup");
|
|
43320
|
-
this.clearSource("event");
|
|
43321
|
-
this.clearSource("station");
|
|
43322
|
-
this.clearSource("
|
|
43323
|
-
this.clearSource("ligne");
|
|
43327
|
+
this.clearSource("popup" /* POPUP */);
|
|
43328
|
+
this.clearSource("event" /* EVENTS */);
|
|
43329
|
+
this.clearSource("station" /* STATIONS */);
|
|
43330
|
+
this.clearSource("uncertainty" /* UNCERTAINTY */);
|
|
43331
|
+
this.clearSource("ligne" /* LINE */);
|
|
43324
43332
|
}
|
|
43325
43333
|
clearLignePopup() {
|
|
43326
|
-
this.clearSource("popup");
|
|
43327
|
-
this.clearSource("ligne");
|
|
43334
|
+
this.clearSource("popup" /* POPUP */);
|
|
43335
|
+
this.clearSource("ligne" /* LINE */);
|
|
43328
43336
|
}
|
|
43329
43337
|
clearSource(sourceName) {
|
|
43330
43338
|
let data;
|
|
43331
43339
|
switch (sourceName) {
|
|
43332
|
-
case "
|
|
43340
|
+
case "uncertainty" /* UNCERTAINTY */: {
|
|
43333
43341
|
data = {
|
|
43334
43342
|
type: "Feature",
|
|
43335
43343
|
geometry: {
|
|
@@ -43349,15 +43357,15 @@ class SismoMap {
|
|
|
43349
43357
|
};
|
|
43350
43358
|
break;
|
|
43351
43359
|
}
|
|
43352
|
-
case "station"
|
|
43353
|
-
case "event"
|
|
43360
|
+
case "station" /* STATIONS */:
|
|
43361
|
+
case "event" /* EVENTS */: {
|
|
43354
43362
|
data = {
|
|
43355
43363
|
type: "FeatureCollection",
|
|
43356
43364
|
features: []
|
|
43357
43365
|
};
|
|
43358
43366
|
break;
|
|
43359
43367
|
}
|
|
43360
|
-
case "popup"
|
|
43368
|
+
case "popup" /* POPUP */: {
|
|
43361
43369
|
this._descPopups.forEach((popup) => popup.remove());
|
|
43362
43370
|
}
|
|
43363
43371
|
default:
|
|
@@ -43411,7 +43419,7 @@ class SismoMap {
|
|
|
43411
43419
|
};
|
|
43412
43420
|
}
|
|
43413
43421
|
}
|
|
43414
|
-
this.displayGeoJSON(stations, "station"
|
|
43422
|
+
this.displayGeoJSON(stations, "station" /* STATIONS */, moveView, clear);
|
|
43415
43423
|
}
|
|
43416
43424
|
async getAndDisplayStations(client, event, moveView = true, clear = true, stationOnly = false) {
|
|
43417
43425
|
let eventGeo;
|
|
@@ -43464,7 +43472,7 @@ class SismoMap {
|
|
|
43464
43472
|
});
|
|
43465
43473
|
console.log("Absent stations : ");
|
|
43466
43474
|
console.log(absentStations);
|
|
43467
|
-
if (this.displayGeoJSON(stationsGeoJSON, "station"
|
|
43475
|
+
if (this.displayGeoJSON(stationsGeoJSON, "station" /* STATIONS */, moveView, false).isErr()) {
|
|
43468
43476
|
return Promise.reject();
|
|
43469
43477
|
}
|
|
43470
43478
|
return [phases, stationsGeoJSON];
|
|
@@ -43479,7 +43487,7 @@ class SismoMap {
|
|
|
43479
43487
|
eventList.features.forEach((_, i) => {
|
|
43480
43488
|
eventList.features[i].properties.eventType = eventList.features[i].properties.eventType || "event";
|
|
43481
43489
|
});
|
|
43482
|
-
this.displayGeoJSON(eventList, "event"
|
|
43490
|
+
this.displayGeoJSON(eventList, "event" /* EVENTS */, moveView, clear, sortOrder);
|
|
43483
43491
|
}
|
|
43484
43492
|
updateSource(sourceName, newData) {
|
|
43485
43493
|
let sismap = this;
|
|
@@ -43512,7 +43520,7 @@ class SismoMap {
|
|
|
43512
43520
|
displayGeoJSON(geojson, sourceName, moveView, clear, sortOrder) {
|
|
43513
43521
|
function display(map) {
|
|
43514
43522
|
let val = 0;
|
|
43515
|
-
if (sourceName == "event") {
|
|
43523
|
+
if (sourceName == "event" /* EVENTS */) {
|
|
43516
43524
|
if (sortOrder) {
|
|
43517
43525
|
if (sortOrder.includes("time")) {
|
|
43518
43526
|
geojson.features.forEach((elem, index) => {
|
|
@@ -43522,7 +43530,7 @@ class SismoMap {
|
|
|
43522
43530
|
val = SortFilters.get(sortOrder);
|
|
43523
43531
|
}
|
|
43524
43532
|
}
|
|
43525
|
-
map.map.setLayoutProperty("event-layer"
|
|
43533
|
+
map.map.setLayoutProperty("event-layer" /* EVENTS */, "circle-sort-key", val);
|
|
43526
43534
|
if (clear) {
|
|
43527
43535
|
map.clear();
|
|
43528
43536
|
}
|
|
@@ -43651,7 +43659,7 @@ class SismoMap {
|
|
|
43651
43659
|
}
|
|
43652
43660
|
applyFilter(filterQuery) {
|
|
43653
43661
|
if (filterQuery.magnitudes.length == 0 && filterQuery.events.length == 0) {
|
|
43654
|
-
this.map.setFilter("event-layer"
|
|
43662
|
+
this.map.setFilter("event-layer" /* EVENTS */, null);
|
|
43655
43663
|
return $ok(null);
|
|
43656
43664
|
}
|
|
43657
43665
|
let filter2 = ["all"];
|
|
@@ -43674,16 +43682,16 @@ class SismoMap {
|
|
|
43674
43682
|
}
|
|
43675
43683
|
}
|
|
43676
43684
|
if (this.map.loaded() || this._usable) {
|
|
43677
|
-
this.map.setFilter("event-layer"
|
|
43685
|
+
this.map.setFilter("event-layer" /* EVENTS */, filter2);
|
|
43678
43686
|
} else {
|
|
43679
43687
|
this.map.once("load", () => {
|
|
43680
|
-
this.map.setFilter("event-layer"
|
|
43688
|
+
this.map.setFilter("event-layer" /* EVENTS */, filter2);
|
|
43681
43689
|
});
|
|
43682
43690
|
}
|
|
43683
43691
|
return $ok(null);
|
|
43684
43692
|
}
|
|
43685
43693
|
clearFilter() {
|
|
43686
|
-
this.map.setFilter("event-layer"
|
|
43694
|
+
this.map.setFilter("event-layer" /* EVENTS */, null);
|
|
43687
43695
|
}
|
|
43688
43696
|
displayEllipse(midMinorAxisLength, midMajorAxisLength, rotation, center) {
|
|
43689
43697
|
const coords = createEllipse(midMinorAxisLength, midMajorAxisLength, rotation, center);
|
|
@@ -43691,12 +43699,13 @@ class SismoMap {
|
|
|
43691
43699
|
}
|
|
43692
43700
|
async displayLink(phase, popupString, linkColor = "#888", linkOpacity = 1, linkWidth = 6) {
|
|
43693
43701
|
async function display(map) {
|
|
43694
|
-
|
|
43695
|
-
if (
|
|
43696
|
-
|
|
43702
|
+
const eventsrc = map.map.getSource("event" /* EVENTS */);
|
|
43703
|
+
if (eventsrc == undefined) {
|
|
43704
|
+
console.error("Event source inexistent ?");
|
|
43705
|
+
return;
|
|
43697
43706
|
}
|
|
43698
|
-
const src =
|
|
43699
|
-
const statSrc = map.map.getSource("station");
|
|
43707
|
+
const src = await eventsrc.getData();
|
|
43708
|
+
const statSrc = map.map.getSource("station" /* STATIONS */);
|
|
43700
43709
|
let geojson = await statSrc.getData();
|
|
43701
43710
|
const stationsGeoJSON = geojson;
|
|
43702
43711
|
let station = undefined;
|
|
@@ -43706,9 +43715,9 @@ class SismoMap {
|
|
|
43706
43715
|
break;
|
|
43707
43716
|
}
|
|
43708
43717
|
}
|
|
43709
|
-
map.map.setPaintProperty("ligne"
|
|
43710
|
-
map.map.setPaintProperty("ligne"
|
|
43711
|
-
map.map.setPaintProperty("ligne"
|
|
43718
|
+
map.map.setPaintProperty("ligne" /* LINE */, "line-color", linkColor);
|
|
43719
|
+
map.map.setPaintProperty("ligne" /* LINE */, "line-opacity", linkOpacity);
|
|
43720
|
+
map.map.setPaintProperty("ligne" /* LINE */, "line-width", linkWidth);
|
|
43712
43721
|
if (station == undefined) {
|
|
43713
43722
|
return Promise.resolve();
|
|
43714
43723
|
}
|
|
@@ -43730,7 +43739,7 @@ class SismoMap {
|
|
|
43730
43739
|
]
|
|
43731
43740
|
}
|
|
43732
43741
|
};
|
|
43733
|
-
map.map.getSource("ligne")?.setData(newData);
|
|
43742
|
+
map.map.getSource("ligne" /* LINE */)?.setData(newData);
|
|
43734
43743
|
}
|
|
43735
43744
|
if (this.map.loaded() || this._usable) {
|
|
43736
43745
|
display(this);
|
|
@@ -43758,7 +43767,7 @@ class SismoMap {
|
|
|
43758
43767
|
}
|
|
43759
43768
|
};
|
|
43760
43769
|
function upd() {
|
|
43761
|
-
let source = sismap.map.getSource("
|
|
43770
|
+
let source = sismap.map.getSource("uncertainty" /* UNCERTAINTY */);
|
|
43762
43771
|
if (source == undefined)
|
|
43763
43772
|
setTimeout(upd, 100);
|
|
43764
43773
|
source?.setData(newData);
|
|
@@ -43788,23 +43797,14 @@ class SismoMap {
|
|
|
43788
43797
|
});
|
|
43789
43798
|
});
|
|
43790
43799
|
}
|
|
43791
|
-
getEventNumber() {
|
|
43792
|
-
let source = this.
|
|
43800
|
+
async getEventNumber() {
|
|
43801
|
+
let source = this.map.getSource("");
|
|
43802
|
+
if (source == undefined)
|
|
43803
|
+
return Promise.reject("");
|
|
43793
43804
|
let length = 0;
|
|
43794
|
-
|
|
43795
|
-
|
|
43796
|
-
|
|
43797
|
-
length = s.features.length;
|
|
43798
|
-
});
|
|
43799
|
-
return $ok(length);
|
|
43800
|
-
}
|
|
43801
|
-
getSourceGeoJSON() {
|
|
43802
|
-
let source = this.map.getSource("event");
|
|
43803
|
-
let data = source?._data.geojson;
|
|
43804
|
-
if (data === undefined) {
|
|
43805
|
-
return $err(Error("Source not defined yet"));
|
|
43806
|
-
}
|
|
43807
|
-
return $ok(data);
|
|
43805
|
+
const sourceData = await source.getData();
|
|
43806
|
+
length = sourceData.features.length;
|
|
43807
|
+
return length;
|
|
43808
43808
|
}
|
|
43809
43809
|
}
|
|
43810
43810
|
var export_LngLatBounds = import_maplibre_gl3.LngLatBounds;
|
|
@@ -43819,6 +43819,7 @@ export {
|
|
|
43819
43819
|
SortFilters,
|
|
43820
43820
|
SismoMap,
|
|
43821
43821
|
PossibleEvents,
|
|
43822
|
+
NamazuSource,
|
|
43822
43823
|
NamazuLayers,
|
|
43823
43824
|
MagnitudesColors,
|
|
43824
43825
|
export_LngLatBounds as LngLatBounds,
|
package/dist/sismomap.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
2
2
|
import maplibregl from 'maplibre-gl';
|
|
3
|
-
import { EventGeoJSON, EventPhases, NamazuEvent, GeoJSON, Station, StationGeoJSON, InfosPhase, FilterQuery } from './types';
|
|
3
|
+
import { EventGeoJSON, EventPhases, NamazuEvent, GeoJSON, Station, StationGeoJSON, InfosPhase, FilterQuery, NamazuSource } from './types';
|
|
4
4
|
import { Client } from './client';
|
|
5
5
|
import { Result } from 'neverthrow';
|
|
6
6
|
export declare class SismoMap {
|
|
@@ -21,7 +21,7 @@ export declare class SismoMap {
|
|
|
21
21
|
/**
|
|
22
22
|
* Possible source names : polygon,ligne,event,station,popup
|
|
23
23
|
*/
|
|
24
|
-
clearSource(sourceName:
|
|
24
|
+
clearSource(sourceName: NamazuSource): void;
|
|
25
25
|
stopSpin(): void;
|
|
26
26
|
startSpin(): void;
|
|
27
27
|
makeUsable(): void;
|
|
@@ -84,6 +84,5 @@ export declare class SismoMap {
|
|
|
84
84
|
displayRect(minlng: number, minlat: number, maxlng: number, maxlat: number): void;
|
|
85
85
|
displayPolygon(coords: number[][]): void;
|
|
86
86
|
changeLanguage(lang: string): void;
|
|
87
|
-
getEventNumber():
|
|
88
|
-
getSourceGeoJSON(): Result<EventGeoJSON, Error>;
|
|
87
|
+
getEventNumber(): Promise<number>;
|
|
89
88
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -4,6 +4,13 @@ export declare enum NamazuLayers {
|
|
|
4
4
|
STATIONS = "station-layer",
|
|
5
5
|
EVENTS = "event-layer"
|
|
6
6
|
}
|
|
7
|
+
export declare enum NamazuSource {
|
|
8
|
+
UNCERTAINTY = "uncertainty",
|
|
9
|
+
LINE = "ligne",
|
|
10
|
+
STATIONS = "station",
|
|
11
|
+
EVENTS = "event",
|
|
12
|
+
POPUP = "popup"
|
|
13
|
+
}
|
|
7
14
|
export declare const PossibleEvents: Array<string>;
|
|
8
15
|
export type EventGeojsonDescriptionProperty = {
|
|
9
16
|
fr: string;
|
|
@@ -117,6 +124,7 @@ export type Uncertainty = {
|
|
|
117
124
|
};
|
|
118
125
|
export type NamazuEvent = {
|
|
119
126
|
id: number;
|
|
127
|
+
description: EventGeojsonDescriptionProperty;
|
|
120
128
|
zone: ZoneDesc;
|
|
121
129
|
publicid: string;
|
|
122
130
|
eventType: string;
|
|
@@ -274,7 +282,7 @@ export type Station = {
|
|
|
274
282
|
type: string;
|
|
275
283
|
};
|
|
276
284
|
};
|
|
277
|
-
export type
|
|
285
|
+
export type StationFeature = Station & {
|
|
278
286
|
properties: {
|
|
279
287
|
phases: EventPhases;
|
|
280
288
|
description: {
|
|
@@ -285,7 +293,7 @@ export type StationPhases = Station & {
|
|
|
285
293
|
};
|
|
286
294
|
export type StationGeoJSON = {
|
|
287
295
|
type: string;
|
|
288
|
-
features:
|
|
296
|
+
features: StationFeature[];
|
|
289
297
|
};
|
|
290
298
|
export declare const ZoneNames: string[];
|
|
291
299
|
export declare const MagnitudesColors: (string | number | string[])[];
|