namazu-ts 0.25.0 → 0.26.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.
- package/dist/browser/index.js +229 -237
- package/dist/client.d.ts +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/node/index.js +231 -239
- package/dist/sismomap.d.ts +3 -5
- package/dist/utils.d.ts +5 -0
- package/docs/assets/search.js +1 -1
- package/docs/classes/Client.html +3 -2
- package/docs/classes/SismoMap.html +7 -8
- package/docs/functions/EventToEventGeoJSON.html +1 -1
- package/docs/functions/createEllipse.html +1 -1
- package/docs/functions/formatString.html +1 -1
- package/docs/functions/isEventGeoJSON.html +1 -1
- package/docs/functions/isEventGeoJSONProperties.html +1 -1
- package/docs/variables/eventTypes.html +1 -1
- package/package.json +1 -1
- package/src/client.ts +71 -1
- package/src/index.ts +0 -1
- package/src/sismomap.ts +16 -102
- package/src/utils.ts +53 -1
- package/src/maputils.ts +0 -48
package/dist/browser/index.js
CHANGED
|
@@ -27039,175 +27039,6 @@ ${n2.shaderPreludeCode.vertexSource}`, define: n2.shaderDefine }, defaultProject
|
|
|
27039
27039
|
// src/index.ts
|
|
27040
27040
|
var import_maplibre_gl3 = __toESM(require_maplibre_gl(), 1);
|
|
27041
27041
|
|
|
27042
|
-
// node_modules/@turf/helpers/dist/esm/index.js
|
|
27043
|
-
var earthRadius = 6371008.8;
|
|
27044
|
-
var factors = {
|
|
27045
|
-
centimeters: earthRadius * 100,
|
|
27046
|
-
centimetres: earthRadius * 100,
|
|
27047
|
-
degrees: 360 / (2 * Math.PI),
|
|
27048
|
-
feet: earthRadius * 3.28084,
|
|
27049
|
-
inches: earthRadius * 39.37,
|
|
27050
|
-
kilometers: earthRadius / 1000,
|
|
27051
|
-
kilometres: earthRadius / 1000,
|
|
27052
|
-
meters: earthRadius,
|
|
27053
|
-
metres: earthRadius,
|
|
27054
|
-
miles: earthRadius / 1609.344,
|
|
27055
|
-
millimeters: earthRadius * 1000,
|
|
27056
|
-
millimetres: earthRadius * 1000,
|
|
27057
|
-
nauticalmiles: earthRadius / 1852,
|
|
27058
|
-
radians: 1,
|
|
27059
|
-
yards: earthRadius * 1.0936
|
|
27060
|
-
};
|
|
27061
|
-
function lengthToRadians(distance, units = "kilometers") {
|
|
27062
|
-
const factor = factors[units];
|
|
27063
|
-
if (!factor) {
|
|
27064
|
-
throw new Error(units + " units is invalid");
|
|
27065
|
-
}
|
|
27066
|
-
return distance / factor;
|
|
27067
|
-
}
|
|
27068
|
-
function lengthToDegrees(distance, units) {
|
|
27069
|
-
return radiansToDegrees(lengthToRadians(distance, units));
|
|
27070
|
-
}
|
|
27071
|
-
function radiansToDegrees(radians) {
|
|
27072
|
-
const normalisedRadians = radians % (2 * Math.PI);
|
|
27073
|
-
return normalisedRadians * 180 / Math.PI;
|
|
27074
|
-
}
|
|
27075
|
-
|
|
27076
|
-
// node_modules/@turf/meta/dist/esm/index.js
|
|
27077
|
-
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
27078
|
-
if (geojson === null)
|
|
27079
|
-
return;
|
|
27080
|
-
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
27081
|
-
for (var featureIndex = 0;featureIndex < stop; featureIndex++) {
|
|
27082
|
-
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
27083
|
-
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
27084
|
-
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
27085
|
-
for (var geomIndex = 0;geomIndex < stopG; geomIndex++) {
|
|
27086
|
-
var multiFeatureIndex = 0;
|
|
27087
|
-
var geometryIndex = 0;
|
|
27088
|
-
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
27089
|
-
if (geometry === null)
|
|
27090
|
-
continue;
|
|
27091
|
-
coords = geometry.coordinates;
|
|
27092
|
-
var geomType = geometry.type;
|
|
27093
|
-
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
27094
|
-
switch (geomType) {
|
|
27095
|
-
case null:
|
|
27096
|
-
break;
|
|
27097
|
-
case "Point":
|
|
27098
|
-
if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
27099
|
-
return false;
|
|
27100
|
-
coordIndex++;
|
|
27101
|
-
multiFeatureIndex++;
|
|
27102
|
-
break;
|
|
27103
|
-
case "LineString":
|
|
27104
|
-
case "MultiPoint":
|
|
27105
|
-
for (j = 0;j < coords.length; j++) {
|
|
27106
|
-
if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
27107
|
-
return false;
|
|
27108
|
-
coordIndex++;
|
|
27109
|
-
if (geomType === "MultiPoint")
|
|
27110
|
-
multiFeatureIndex++;
|
|
27111
|
-
}
|
|
27112
|
-
if (geomType === "LineString")
|
|
27113
|
-
multiFeatureIndex++;
|
|
27114
|
-
break;
|
|
27115
|
-
case "Polygon":
|
|
27116
|
-
case "MultiLineString":
|
|
27117
|
-
for (j = 0;j < coords.length; j++) {
|
|
27118
|
-
for (k = 0;k < coords[j].length - wrapShrink; k++) {
|
|
27119
|
-
if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
27120
|
-
return false;
|
|
27121
|
-
coordIndex++;
|
|
27122
|
-
}
|
|
27123
|
-
if (geomType === "MultiLineString")
|
|
27124
|
-
multiFeatureIndex++;
|
|
27125
|
-
if (geomType === "Polygon")
|
|
27126
|
-
geometryIndex++;
|
|
27127
|
-
}
|
|
27128
|
-
if (geomType === "Polygon")
|
|
27129
|
-
multiFeatureIndex++;
|
|
27130
|
-
break;
|
|
27131
|
-
case "MultiPolygon":
|
|
27132
|
-
for (j = 0;j < coords.length; j++) {
|
|
27133
|
-
geometryIndex = 0;
|
|
27134
|
-
for (k = 0;k < coords[j].length; k++) {
|
|
27135
|
-
for (l = 0;l < coords[j][k].length - wrapShrink; l++) {
|
|
27136
|
-
if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
27137
|
-
return false;
|
|
27138
|
-
coordIndex++;
|
|
27139
|
-
}
|
|
27140
|
-
geometryIndex++;
|
|
27141
|
-
}
|
|
27142
|
-
multiFeatureIndex++;
|
|
27143
|
-
}
|
|
27144
|
-
break;
|
|
27145
|
-
case "GeometryCollection":
|
|
27146
|
-
for (j = 0;j < geometry.geometries.length; j++)
|
|
27147
|
-
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
27148
|
-
return false;
|
|
27149
|
-
break;
|
|
27150
|
-
default:
|
|
27151
|
-
throw new Error("Unknown Geometry Type");
|
|
27152
|
-
}
|
|
27153
|
-
}
|
|
27154
|
-
}
|
|
27155
|
-
}
|
|
27156
|
-
|
|
27157
|
-
// node_modules/@turf/bbox/dist/esm/index.js
|
|
27158
|
-
function bbox(geojson, options = {}) {
|
|
27159
|
-
if (geojson.bbox != null && options.recompute !== true) {
|
|
27160
|
-
return geojson.bbox;
|
|
27161
|
-
}
|
|
27162
|
-
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
27163
|
-
coordEach(geojson, (coord) => {
|
|
27164
|
-
if (result[0] > coord[0]) {
|
|
27165
|
-
result[0] = coord[0];
|
|
27166
|
-
}
|
|
27167
|
-
if (result[1] > coord[1]) {
|
|
27168
|
-
result[1] = coord[1];
|
|
27169
|
-
}
|
|
27170
|
-
if (result[2] < coord[0]) {
|
|
27171
|
-
result[2] = coord[0];
|
|
27172
|
-
}
|
|
27173
|
-
if (result[3] < coord[1]) {
|
|
27174
|
-
result[3] = coord[1];
|
|
27175
|
-
}
|
|
27176
|
-
});
|
|
27177
|
-
return result;
|
|
27178
|
-
}
|
|
27179
|
-
// src/maputils.ts
|
|
27180
|
-
function EventToEventGeoJSON(e) {
|
|
27181
|
-
let evGeoJson = { type: "FeatureCollection", features: [] };
|
|
27182
|
-
const lng = e.preferredOrigin.longitude;
|
|
27183
|
-
const lat = e.preferredOrigin.latitude;
|
|
27184
|
-
const eWithMag = e;
|
|
27185
|
-
eWithMag.magnitude = e.preferredMagnitude.magnitude;
|
|
27186
|
-
const feature = {
|
|
27187
|
-
id: e.publicid,
|
|
27188
|
-
properties: eWithMag,
|
|
27189
|
-
geometry: { coordinates: [lng, lat], type: "Point" },
|
|
27190
|
-
type: "Feature"
|
|
27191
|
-
};
|
|
27192
|
-
evGeoJson.features.push(feature);
|
|
27193
|
-
return evGeoJson;
|
|
27194
|
-
}
|
|
27195
|
-
function createEllipse(midMinorAxisLength, midMajorAxisLength, rotation, center) {
|
|
27196
|
-
const cos = Math.cos(rotation);
|
|
27197
|
-
const sin = Math.sin(rotation);
|
|
27198
|
-
const delta = 0.2;
|
|
27199
|
-
const coords = [];
|
|
27200
|
-
for (let t = 0;t < 2 * Math.PI; t += delta) {
|
|
27201
|
-
const x = lengthToDegrees(midMinorAxisLength * Math.cos(t), "meters");
|
|
27202
|
-
const y = lengthToDegrees(midMajorAxisLength * Math.sin(t), "meters");
|
|
27203
|
-
let coord = [
|
|
27204
|
-
cos * x - sin * y + center[0],
|
|
27205
|
-
sin * x + cos * y + center[1]
|
|
27206
|
-
];
|
|
27207
|
-
coords.push(coord);
|
|
27208
|
-
}
|
|
27209
|
-
return coords;
|
|
27210
|
-
}
|
|
27211
27042
|
// node_modules/axios/lib/helpers/bind.js
|
|
27212
27043
|
function bind(fn, thisArg) {
|
|
27213
27044
|
return function wrap() {
|
|
@@ -27966,12 +27797,12 @@ var platform_default = {
|
|
|
27966
27797
|
// node_modules/axios/lib/helpers/toURLEncodedForm.js
|
|
27967
27798
|
function toURLEncodedForm(data, options) {
|
|
27968
27799
|
return toFormData_default(data, new platform_default.classes.URLSearchParams, {
|
|
27969
|
-
visitor: function(value, key, path,
|
|
27800
|
+
visitor: function(value, key, path, helpers) {
|
|
27970
27801
|
if (platform_default.isNode && utils_default.isBuffer(value)) {
|
|
27971
27802
|
this.append(key, value.toString("base64"));
|
|
27972
27803
|
return false;
|
|
27973
27804
|
}
|
|
27974
|
-
return
|
|
27805
|
+
return helpers.defaultVisitor.apply(this, arguments);
|
|
27975
27806
|
},
|
|
27976
27807
|
...options
|
|
27977
27808
|
});
|
|
@@ -30289,7 +30120,175 @@ var Intervals = new Map([
|
|
|
30289
30120
|
["inf", ["all", [">=", ["get", "magnitude"], 6]]]
|
|
30290
30121
|
]);
|
|
30291
30122
|
|
|
30123
|
+
// node_modules/@turf/helpers/dist/esm/index.js
|
|
30124
|
+
var earthRadius = 6371008.8;
|
|
30125
|
+
var factors = {
|
|
30126
|
+
centimeters: earthRadius * 100,
|
|
30127
|
+
centimetres: earthRadius * 100,
|
|
30128
|
+
degrees: 360 / (2 * Math.PI),
|
|
30129
|
+
feet: earthRadius * 3.28084,
|
|
30130
|
+
inches: earthRadius * 39.37,
|
|
30131
|
+
kilometers: earthRadius / 1000,
|
|
30132
|
+
kilometres: earthRadius / 1000,
|
|
30133
|
+
meters: earthRadius,
|
|
30134
|
+
metres: earthRadius,
|
|
30135
|
+
miles: earthRadius / 1609.344,
|
|
30136
|
+
millimeters: earthRadius * 1000,
|
|
30137
|
+
millimetres: earthRadius * 1000,
|
|
30138
|
+
nauticalmiles: earthRadius / 1852,
|
|
30139
|
+
radians: 1,
|
|
30140
|
+
yards: earthRadius * 1.0936
|
|
30141
|
+
};
|
|
30142
|
+
function lengthToRadians(distance, units = "kilometers") {
|
|
30143
|
+
const factor = factors[units];
|
|
30144
|
+
if (!factor) {
|
|
30145
|
+
throw new Error(units + " units is invalid");
|
|
30146
|
+
}
|
|
30147
|
+
return distance / factor;
|
|
30148
|
+
}
|
|
30149
|
+
function lengthToDegrees(distance, units) {
|
|
30150
|
+
return radiansToDegrees(lengthToRadians(distance, units));
|
|
30151
|
+
}
|
|
30152
|
+
function radiansToDegrees(radians) {
|
|
30153
|
+
const normalisedRadians = radians % (2 * Math.PI);
|
|
30154
|
+
return normalisedRadians * 180 / Math.PI;
|
|
30155
|
+
}
|
|
30156
|
+
|
|
30157
|
+
// node_modules/@turf/meta/dist/esm/index.js
|
|
30158
|
+
function coordEach(geojson, callback, excludeWrapCoord) {
|
|
30159
|
+
if (geojson === null)
|
|
30160
|
+
return;
|
|
30161
|
+
var j, k, l, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type = geojson.type, isFeatureCollection = type === "FeatureCollection", isFeature = type === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
|
|
30162
|
+
for (var featureIndex = 0;featureIndex < stop; featureIndex++) {
|
|
30163
|
+
geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
|
|
30164
|
+
isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
|
|
30165
|
+
stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
|
|
30166
|
+
for (var geomIndex = 0;geomIndex < stopG; geomIndex++) {
|
|
30167
|
+
var multiFeatureIndex = 0;
|
|
30168
|
+
var geometryIndex = 0;
|
|
30169
|
+
geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
|
|
30170
|
+
if (geometry === null)
|
|
30171
|
+
continue;
|
|
30172
|
+
coords = geometry.coordinates;
|
|
30173
|
+
var geomType = geometry.type;
|
|
30174
|
+
wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
|
|
30175
|
+
switch (geomType) {
|
|
30176
|
+
case null:
|
|
30177
|
+
break;
|
|
30178
|
+
case "Point":
|
|
30179
|
+
if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
30180
|
+
return false;
|
|
30181
|
+
coordIndex++;
|
|
30182
|
+
multiFeatureIndex++;
|
|
30183
|
+
break;
|
|
30184
|
+
case "LineString":
|
|
30185
|
+
case "MultiPoint":
|
|
30186
|
+
for (j = 0;j < coords.length; j++) {
|
|
30187
|
+
if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
30188
|
+
return false;
|
|
30189
|
+
coordIndex++;
|
|
30190
|
+
if (geomType === "MultiPoint")
|
|
30191
|
+
multiFeatureIndex++;
|
|
30192
|
+
}
|
|
30193
|
+
if (geomType === "LineString")
|
|
30194
|
+
multiFeatureIndex++;
|
|
30195
|
+
break;
|
|
30196
|
+
case "Polygon":
|
|
30197
|
+
case "MultiLineString":
|
|
30198
|
+
for (j = 0;j < coords.length; j++) {
|
|
30199
|
+
for (k = 0;k < coords[j].length - wrapShrink; k++) {
|
|
30200
|
+
if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
30201
|
+
return false;
|
|
30202
|
+
coordIndex++;
|
|
30203
|
+
}
|
|
30204
|
+
if (geomType === "MultiLineString")
|
|
30205
|
+
multiFeatureIndex++;
|
|
30206
|
+
if (geomType === "Polygon")
|
|
30207
|
+
geometryIndex++;
|
|
30208
|
+
}
|
|
30209
|
+
if (geomType === "Polygon")
|
|
30210
|
+
multiFeatureIndex++;
|
|
30211
|
+
break;
|
|
30212
|
+
case "MultiPolygon":
|
|
30213
|
+
for (j = 0;j < coords.length; j++) {
|
|
30214
|
+
geometryIndex = 0;
|
|
30215
|
+
for (k = 0;k < coords[j].length; k++) {
|
|
30216
|
+
for (l = 0;l < coords[j][k].length - wrapShrink; l++) {
|
|
30217
|
+
if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false)
|
|
30218
|
+
return false;
|
|
30219
|
+
coordIndex++;
|
|
30220
|
+
}
|
|
30221
|
+
geometryIndex++;
|
|
30222
|
+
}
|
|
30223
|
+
multiFeatureIndex++;
|
|
30224
|
+
}
|
|
30225
|
+
break;
|
|
30226
|
+
case "GeometryCollection":
|
|
30227
|
+
for (j = 0;j < geometry.geometries.length; j++)
|
|
30228
|
+
if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false)
|
|
30229
|
+
return false;
|
|
30230
|
+
break;
|
|
30231
|
+
default:
|
|
30232
|
+
throw new Error("Unknown Geometry Type");
|
|
30233
|
+
}
|
|
30234
|
+
}
|
|
30235
|
+
}
|
|
30236
|
+
}
|
|
30237
|
+
|
|
30238
|
+
// node_modules/@turf/bbox/dist/esm/index.js
|
|
30239
|
+
function bbox(geojson, options = {}) {
|
|
30240
|
+
if (geojson.bbox != null && options.recompute !== true) {
|
|
30241
|
+
return geojson.bbox;
|
|
30242
|
+
}
|
|
30243
|
+
const result = [Infinity, Infinity, -Infinity, -Infinity];
|
|
30244
|
+
coordEach(geojson, (coord) => {
|
|
30245
|
+
if (result[0] > coord[0]) {
|
|
30246
|
+
result[0] = coord[0];
|
|
30247
|
+
}
|
|
30248
|
+
if (result[1] > coord[1]) {
|
|
30249
|
+
result[1] = coord[1];
|
|
30250
|
+
}
|
|
30251
|
+
if (result[2] < coord[0]) {
|
|
30252
|
+
result[2] = coord[0];
|
|
30253
|
+
}
|
|
30254
|
+
if (result[3] < coord[1]) {
|
|
30255
|
+
result[3] = coord[1];
|
|
30256
|
+
}
|
|
30257
|
+
});
|
|
30258
|
+
return result;
|
|
30259
|
+
}
|
|
30292
30260
|
// src/utils.ts
|
|
30261
|
+
function EventToEventGeoJSON(e) {
|
|
30262
|
+
let evGeoJson = { type: "FeatureCollection", features: [] };
|
|
30263
|
+
const lng = e.preferredOrigin.longitude;
|
|
30264
|
+
const lat = e.preferredOrigin.latitude;
|
|
30265
|
+
const eWithMag = e;
|
|
30266
|
+
eWithMag.magnitude = e.preferredMagnitude.magnitude;
|
|
30267
|
+
const feature = {
|
|
30268
|
+
id: e.publicid,
|
|
30269
|
+
properties: eWithMag,
|
|
30270
|
+
geometry: { coordinates: [lng, lat], type: "Point" },
|
|
30271
|
+
type: "Feature"
|
|
30272
|
+
};
|
|
30273
|
+
evGeoJson.features.push(feature);
|
|
30274
|
+
return evGeoJson;
|
|
30275
|
+
}
|
|
30276
|
+
function createEllipse(midMinorAxisLength, midMajorAxisLength, rotation, center) {
|
|
30277
|
+
const cos = Math.cos(rotation);
|
|
30278
|
+
const sin = Math.sin(rotation);
|
|
30279
|
+
const delta = 0.2;
|
|
30280
|
+
const coords = [];
|
|
30281
|
+
for (let t = 0;t < 2 * Math.PI; t += delta) {
|
|
30282
|
+
const x = lengthToDegrees(midMinorAxisLength * Math.cos(t), "meters");
|
|
30283
|
+
const y = lengthToDegrees(midMajorAxisLength * Math.sin(t), "meters");
|
|
30284
|
+
let coord = [
|
|
30285
|
+
cos * x - sin * y + center[0],
|
|
30286
|
+
sin * x + cos * y + center[1]
|
|
30287
|
+
];
|
|
30288
|
+
coords.push(coord);
|
|
30289
|
+
}
|
|
30290
|
+
return coords;
|
|
30291
|
+
}
|
|
30293
30292
|
function formatString(str) {
|
|
30294
30293
|
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "-").toLowerCase().normalize("NFC");
|
|
30295
30294
|
}
|
|
@@ -30326,6 +30325,54 @@ class Client {
|
|
|
30326
30325
|
});
|
|
30327
30326
|
return a;
|
|
30328
30327
|
}
|
|
30328
|
+
async getStations(event) {
|
|
30329
|
+
let eventGeo;
|
|
30330
|
+
let zone = "";
|
|
30331
|
+
if (typeof event === "string") {
|
|
30332
|
+
eventGeo = EventToEventGeoJSON(await this.fetchEvent(event));
|
|
30333
|
+
} else if (isEventGeoJSON(event)) {
|
|
30334
|
+
eventGeo = event;
|
|
30335
|
+
zone = await this.getZoneNameByEvent(eventGeo);
|
|
30336
|
+
} else {
|
|
30337
|
+
eventGeo = EventToEventGeoJSON(event);
|
|
30338
|
+
zone = event.zone.slug;
|
|
30339
|
+
}
|
|
30340
|
+
if (eventGeo.features.length != 1) {
|
|
30341
|
+
return Promise.reject(Error("If passing a EventGeoJSON, it should only have one feature"));
|
|
30342
|
+
}
|
|
30343
|
+
let phasesPromise = this.getEventPhases(eventGeo);
|
|
30344
|
+
let stationList = await this.getStationsByZoneName(zone);
|
|
30345
|
+
let stationsMap = new Map;
|
|
30346
|
+
stationList.features.forEach((station) => {
|
|
30347
|
+
let stationPhase = station;
|
|
30348
|
+
stationPhase.properties.phases = [];
|
|
30349
|
+
stationsMap.set(stationPhase.properties.stationcode, stationPhase);
|
|
30350
|
+
});
|
|
30351
|
+
let phases = await phasesPromise;
|
|
30352
|
+
let absentStations = [];
|
|
30353
|
+
let stationsGeoJSON = {
|
|
30354
|
+
type: "FeatureCollection",
|
|
30355
|
+
features: []
|
|
30356
|
+
};
|
|
30357
|
+
phases.forEach((phase) => {
|
|
30358
|
+
let station = stationsMap.get(phase.stationCode);
|
|
30359
|
+
if (station == undefined) {
|
|
30360
|
+
absentStations.push(phase);
|
|
30361
|
+
return;
|
|
30362
|
+
}
|
|
30363
|
+
station?.properties.phases.push(phase);
|
|
30364
|
+
});
|
|
30365
|
+
stationsMap.forEach((station) => {
|
|
30366
|
+
if (station.properties.phases.length == 0)
|
|
30367
|
+
return;
|
|
30368
|
+
station.properties.description = {
|
|
30369
|
+
fr: station.properties.stationcode,
|
|
30370
|
+
en: station.properties.stationcode
|
|
30371
|
+
};
|
|
30372
|
+
stationsGeoJSON.features.push(station);
|
|
30373
|
+
});
|
|
30374
|
+
return [phases, stationsGeoJSON];
|
|
30375
|
+
}
|
|
30329
30376
|
async fetchForm(id) {
|
|
30330
30377
|
return this.apiCall(`/api/v1/surveys/forms/${id}`);
|
|
30331
30378
|
}
|
|
@@ -30829,8 +30876,8 @@ class SismoMap {
|
|
|
30829
30876
|
_maxSpinZoom = 5;
|
|
30830
30877
|
_slowSpinZoom = 3;
|
|
30831
30878
|
_usable = false;
|
|
30832
|
-
|
|
30833
|
-
|
|
30879
|
+
_userInteracting = false;
|
|
30880
|
+
_distancePerSecond = 5;
|
|
30834
30881
|
constructor(name, map, lang, legendClasses, bounds) {
|
|
30835
30882
|
this._descPopups = [];
|
|
30836
30883
|
let descPopup = new import_maplibre_gl2.default.Popup({
|
|
@@ -30993,22 +31040,22 @@ class SismoMap {
|
|
|
30993
31040
|
scale._container.id = "scale";
|
|
30994
31041
|
this.makeUsable();
|
|
30995
31042
|
map.on("mousedown", () => {
|
|
30996
|
-
this.
|
|
31043
|
+
this._userInteracting = true;
|
|
30997
31044
|
});
|
|
30998
31045
|
map.on("mouseup", () => {
|
|
30999
|
-
this.
|
|
31046
|
+
this._userInteracting = false;
|
|
31000
31047
|
this.spinGlobe();
|
|
31001
31048
|
});
|
|
31002
31049
|
map.on("dragend", () => {
|
|
31003
|
-
this.
|
|
31050
|
+
this._userInteracting = false;
|
|
31004
31051
|
this.spinGlobe();
|
|
31005
31052
|
});
|
|
31006
31053
|
map.on("pitchend", () => {
|
|
31007
|
-
this.
|
|
31054
|
+
this._userInteracting = false;
|
|
31008
31055
|
this.spinGlobe();
|
|
31009
31056
|
});
|
|
31010
31057
|
map.on("rotateend", () => {
|
|
31011
|
-
this.
|
|
31058
|
+
this._userInteracting = false;
|
|
31012
31059
|
this.spinGlobe();
|
|
31013
31060
|
});
|
|
31014
31061
|
map.on("moveend", () => {
|
|
@@ -31081,7 +31128,7 @@ class SismoMap {
|
|
|
31081
31128
|
startSpin() {
|
|
31082
31129
|
this.map.flyTo({ center: [5, 22], zoom: 2 });
|
|
31083
31130
|
this._spinEnabled = true;
|
|
31084
|
-
this.
|
|
31131
|
+
this._userInteracting = false;
|
|
31085
31132
|
this.map.once("moveend", () => {
|
|
31086
31133
|
this.spinGlobe();
|
|
31087
31134
|
});
|
|
@@ -31100,6 +31147,7 @@ class SismoMap {
|
|
|
31100
31147
|
}
|
|
31101
31148
|
displayStationPopup(station) {
|
|
31102
31149
|
this._descPopups[0].setLngLat(station.geometry.coordinates).setText(station.properties.stationcode).addTo(this.map);
|
|
31150
|
+
this._descPopups[0].getElement().style.color = "black";
|
|
31103
31151
|
}
|
|
31104
31152
|
displayStations(stations, moveView = true, clear = true) {
|
|
31105
31153
|
for (let i = 0;i < stations.features.length; i++) {
|
|
@@ -31113,62 +31161,6 @@ class SismoMap {
|
|
|
31113
31161
|
}
|
|
31114
31162
|
this.displayGeoJSON(stations, "stations" /* STATIONS */, moveView, clear);
|
|
31115
31163
|
}
|
|
31116
|
-
async getAndDisplayStations(client, event, moveView = true, clear = true, stationOnly = false) {
|
|
31117
|
-
let eventGeo;
|
|
31118
|
-
let zone = "";
|
|
31119
|
-
if (isEventGeoJSON(event)) {
|
|
31120
|
-
eventGeo = event;
|
|
31121
|
-
zone = await client.getZoneNameByEvent(eventGeo);
|
|
31122
|
-
} else {
|
|
31123
|
-
eventGeo = EventToEventGeoJSON(event);
|
|
31124
|
-
zone = event.zone.slug;
|
|
31125
|
-
}
|
|
31126
|
-
if (eventGeo.features.length != 1) {
|
|
31127
|
-
return Promise.reject(Error("If passing a EventGeoJSON, it should only have one feature"));
|
|
31128
|
-
}
|
|
31129
|
-
if (clear) {
|
|
31130
|
-
this.clear();
|
|
31131
|
-
}
|
|
31132
|
-
if (!stationOnly)
|
|
31133
|
-
this.displayEvents(eventGeo, false, false);
|
|
31134
|
-
let phasesPromise = client.getEventPhases(eventGeo);
|
|
31135
|
-
let stationList = await client.getStationsByZoneName(zone);
|
|
31136
|
-
let stationsMap = new Map;
|
|
31137
|
-
stationList.features.forEach((station) => {
|
|
31138
|
-
let stationPhase = station;
|
|
31139
|
-
stationPhase.properties.phases = [];
|
|
31140
|
-
stationsMap.set(stationPhase.properties.stationcode, stationPhase);
|
|
31141
|
-
});
|
|
31142
|
-
let phases = await phasesPromise;
|
|
31143
|
-
let absentStations = [];
|
|
31144
|
-
let stationsGeoJSON = {
|
|
31145
|
-
type: "FeatureCollection",
|
|
31146
|
-
features: []
|
|
31147
|
-
};
|
|
31148
|
-
phases.forEach((phase) => {
|
|
31149
|
-
let station = stationsMap.get(phase.stationCode);
|
|
31150
|
-
if (station == undefined) {
|
|
31151
|
-
absentStations.push(phase);
|
|
31152
|
-
return;
|
|
31153
|
-
}
|
|
31154
|
-
station?.properties.phases.push(phase);
|
|
31155
|
-
});
|
|
31156
|
-
stationsMap.forEach((station) => {
|
|
31157
|
-
if (station.properties.phases.length == 0)
|
|
31158
|
-
return;
|
|
31159
|
-
station.properties.description = {
|
|
31160
|
-
fr: station.properties.stationcode,
|
|
31161
|
-
en: station.properties.stationcode
|
|
31162
|
-
};
|
|
31163
|
-
stationsGeoJSON.features.push(station);
|
|
31164
|
-
});
|
|
31165
|
-
console.log("Absent stations : ");
|
|
31166
|
-
console.log(absentStations);
|
|
31167
|
-
if (this.displayGeoJSON(stationsGeoJSON, "stations" /* STATIONS */, moveView, false).isErr()) {
|
|
31168
|
-
return Promise.reject();
|
|
31169
|
-
}
|
|
31170
|
-
return [phases, stationsGeoJSON];
|
|
31171
|
-
}
|
|
31172
31164
|
displayEvents(eventOrList, moveView = true, clear = true, sortOrder) {
|
|
31173
31165
|
let eventList;
|
|
31174
31166
|
if (isEventGeoJSON(eventOrList)) {
|
|
@@ -31241,9 +31233,9 @@ class SismoMap {
|
|
|
31241
31233
|
return ok(null);
|
|
31242
31234
|
}
|
|
31243
31235
|
spinGlobe() {
|
|
31244
|
-
if (!this.
|
|
31236
|
+
if (!this._userInteracting && this._spinEnabled && this.map.getZoom() < this._maxSpinZoom) {
|
|
31245
31237
|
const center = this.map.getCenter();
|
|
31246
|
-
center.lng -= this.
|
|
31238
|
+
center.lng -= this._distancePerSecond;
|
|
31247
31239
|
!this.map.isMoving() && this.map.easeTo({ center, duration: 1000, easing: (n) => n });
|
|
31248
31240
|
}
|
|
31249
31241
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare class Client {
|
|
|
8
8
|
setBaseUrl(baseUrl: string): void;
|
|
9
9
|
apiCall<Type>(apiRoute: AxiosRequestConfig): Promise<Type>;
|
|
10
10
|
apiCall<Type>(apiRoute: string, method?: string): Promise<Type>;
|
|
11
|
+
getStations(event: string | NamazuEvent | EventGeoJSON): Promise<[EventPhases, StationGeoJSON]>;
|
|
11
12
|
fetchForm(id: number): Promise<Form>;
|
|
12
13
|
getEvents(args: EventQueryOptions): Promise<EventGeoJSON<EventGeoJSONProperties>>;
|
|
13
14
|
private abortPendingRequestAndPrepare;
|