Methods
armIntList() → {void}
Arms the intensity list, making it visible.
Used when the report type includes intensity/points data.
Returns:
- Type
- void
(private) armTsComponent() → {void}
Arms the tsunami component by making the tsunami information container visible.
This function is called when tsunami data is available and needs to be displayed.
Returns:
- Type
- void
boundEpicenter(epicenterLng, epicenterLat)
Custom epicenter / bounding function for Foreign reports.
This was different from the internalBound function due to this one not having maxZoom.
Parameters:
| Name | Type | Description |
|---|---|---|
epicenterLng |
mapboxgl.LngLatLike | |
epicenterLat |
mapboxgl.LngLatLike |
boundMarkers(epicenter, stationCoordinates)
Bounds the map view to the epicenter and stations.
Parameters:
| Name | Type | Description |
|---|---|---|
epicenter |
* | The epicenter coordinates. |
stationCoordinates |
* | The coordinates of the stations. |
classifyData(code) → {String}
Classifies the type of data based on the response (data) code (not HTTP status).
551 is a normal hypocenter related report like DetailScale or ScalePrompt.
556 is a special warning (earthquake early warning) like Destination from 551 but includes more information.
Parameters:
| Name | Type | Description |
|---|---|---|
code |
Number |
- Source:
Returns:
The type of data classified.
- Type
- String
clearAllTsAssets() → {void}
Clears all tsunami-related assets and events, including layers and intervals.
Returns:
- Type
- void
(private) clearEEWSources() → {void}
Clears the Yahoo EEW sources by setting them to empty data and resets the current bounds.
Returns:
- Type
- void
(private) clearTsunamiLayers() → {void}
Function to clear all tsunami-related layers and intervals.
Returns:
- Type
- void
(private) createGeoJSONCircle(center, radiusInKm, points) → {Object}
Creates a GeoJSON circle feature.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
center |
Array | [longitude, latitude] of the circle's center | |
radiusInKm |
Number | Radius of the circle in kilometers | |
points |
Number | 64 | Number of points to use for the circle geometry |
Returns:
GeoJSON feature representing the circle
- Type
- Object
disarmIntList() → {void}
Disarms the intensity list, making it invisible.
Used when the report type doesn't include intensity/points data.
Returns:
- Type
- void
(private) disarmTsComponent() → {void}
Disarms the tsunami component by hiding the tsunami information container.
This function is called when there is no tsunami data to display.
Returns:
- Type
- void
eewLoop() → {Promise.<void>}
This tertiary loop fetches EEW data and updates the map if available.
Returns:
Returns a promise that resolves when the data fetching and rendering is complete or when there is no new data.
- Type
- Promise.<void>
(private) ensureEpicenterImage() → {Promise.<void>}
Ensures that the epicenter icon image is loaded and added to the map.
Returns:
Resolves when the image is loaded and added to the map, or if it already exists
- Type
- Promise.<void>
(private) extendBoundsWithCircle(center, radiusInKm, bounds) → {void}
Extends the given bounds to include the area covered by a circle.
Parameters:
| Name | Type | Description |
|---|---|---|
center |
Array | [longitude, latitude] of the circle's center |
radiusInKm |
Number | Radius of the circle in kilometers |
bounds |
mapboxgl.LngLatBounds | Bounds to extend |
Returns:
- Type
- void
fetchData(url) → {String}
Fetches data from a given URL and returns the response as JSON.
Parameters:
| Name | Type | Description |
|---|---|---|
url |
String |
- Source:
Returns:
JSON response from the fetch request if successful
- Type
- String
getPrefectureMap() → {Promise.<Map>}
Get mappings for the prefecture data (like lat,lon) from a CSV file.
Returns:
Returns a promise that resolves to a Mappings of prefecture data.
- Type
- Promise.<Map>
getYahooEEWBounds() → {mapboxgl.LngLatBounds|null}
Returns the current bounds of the Yahoo EEW data on the map.
Returns:
Current bounds of the Yahoo EEW layer
- Type
- mapboxgl.LngLatBounds | null
hideInfoBox() → {void}
Hides the infoBox component in the UI.
Returns:
- Type
- void
initMap() → {void}
Initializes the Mapbox map with the specified configuration.
Sets up the map container, style, center, zoom level, and other properties.
And also initializes the minimap and sets up the map's terrain and drag/zoom behavior.
Then starts the main loop for data fetching and rendering.
- Source:
Returns:
- Type
- void
(private) initSources() → {void}
Initializes the necessary sources (if they don't exist) and layers for rendering Yahoo EEW data on the map.
Returns:
- Type
- void
internalBound(bound) → {void}
Internal function to fit the map camera to a given bounds.
This was made so we don't need to pass the arguments every time we want to do bound actions.
Configured to make the bound to do quick smooth linear zooming into the bounds with max zoom level of 7.
Parameters:
| Name | Type | Description |
|---|---|---|
bound |
mapboxgl.LngLatBounds | The bounds to fit the camera to. |
- Source:
Throws:
-
Throws an error if the provided bound is not a valid LngLatBounds.
- Type
- Error
Returns:
- Type
- void
mainLoop() → {Promise.<void>}
This main loop fetches data from the API and renders it based on the data type.
Returns:
Returns a promise that resolves when the main loop completes.
- Type
- Promise.<void>
(private) parseCoordinate(coordStr) → {Number|null}
Parses a coordinate string and converts it into decimal degrees.
Parameters:
| Name | Type | Description |
|---|---|---|
coordStr |
String | Coordinate string (example: N11.2 or E32) |
Returns:
Parsed coordinate in decimal degrees, or null if invalid
- Type
- Number | null
plotRegions(data, prefectureMap) → {Promise.<Array>}
Function to plot regions as icons on the map based on the provided data, intensity (or called scale) and prefecture map.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Data containing region information with points and their scales. |
prefectureMap |
Map | Map containing prefecture information with lat, lng, and other details. |
Returns:
Returns a promise that resolves to an array of prefecture coordinates.
- Type
- Promise.<Array>
plotStations(data) → {Promise.<Array>}
Iterate and plots the stations with it's intensity on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
* | Data containing station information. |
Returns:
Returns a promise that resolves to an array of station coordinates.
- Type
- Promise.<Array>
renderDE(data) → {Promise.<void>}
A part of the main rendering logic for Destination (DE) on response code 551.
Renders the Epicenter Destination data on the map and updates the information box and sidebar.
Includes:
- Clearing previous plotted data
- Epicenter icon update
- Epicenter bounding
- Information box update
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The earthquake data to render. |
Returns:
Returns a promise that resolves when the Destination is rendered.
- Type
- Promise.<void>
renderDS(data) → {Promise.<void>}
A part of the main rendering logic for DetailScale (DS) on response code 551.
Renders the DetailScale data on the map and updates the information box and sidebar.
Includes:
- Clearing previous plotted data
- Epicenter icon update
- Station plotting with intensity
- Map bounding to epicenter and stations
- Info box update with detailed epicenter information
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The DetailScale data to render. |
Throws:
-
Throws an error if the stationRef.csv cannot be fetched or parsed.
- Type
- Error
Returns:
Returns a promise that resolves when the DetailScale is rendered.
- Type
- Promise.<void>
renderSP(data) → {Promise.<void>}
A part of the main rendering logic for ScalePrompt (SP) on response code 551.
Renders the ScalePrompt data on the map and updates the information box and sidebar.
Includes:
- Clearing previous plotted data
- Prefecture icon update
- Prefecture bounding
- Information box update
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | The ScalePrompt data to render. |
Returns:
Returns a promise that resolves when the ScalePrompt is rendered.
- Type
- Promise.<void>
renderTS(data) → {promise.<void>}
A part of the main rendering logic for Tsunami (TS) on special logic event recieved by the /jma endpoint of the API.
Renders the Tsunami data on the map and updates the sidebar with tsunami area information.
Includes:
- Clearing previous plotted data
- Fetching tsunami areas from a geojson file
- Plotting tsunami areas on the map
- Bounding the map to the plotted areas
- Updating the sidebar with tsunami area information
Parameters:
| Name | Type | Description |
|---|---|---|
data |
object | The tsunami data to render. |
Throws:
-
Throws if the tsunami areas geojson cannot be fetched or parsed.
- Type
- error
Returns:
Returns a promise that resolves when the tsunami data is rendered.
- Type
- promise.<void>
(private) renderWave(id, center, radius, bounds) → {void}
Renders wave (a circle) on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | Layer ID |
center |
Array | [longitude, latitude] of the wave's center |
radius |
Number | Radius of the wave in kilometers |
bounds |
mapboxgl.LngLatBounds | Bounds to extend |
Returns:
- Type
- void
renderYahooEEW(eewData) → {Promise.<void>}
Renders Yahoo EEW data on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
eewData |
Object | JSON data containing EEW information |
Returns:
- Type
- Promise.<void>
setTheme(theme) → {void}
Sets the theme for the application as CSS vars and classes, not the map theme.
Parameters:
| Name | Type | Description |
|---|---|---|
theme |
String | Theme to set ('light' or 'dark'). |
- Source:
Returns:
- Type
- void
showInfoBox() → {void}
Shows the infoBox component in the UI.
Returns:
- Type
- void
startMainLoop() → {void}
This function starts the main loop and sets up intervals for data fetching.
Returns:
- Type
- void
tsFetchLoop() → {Promise.<void>}
This secondary loop fetches tsunami data (from /jma endpoints) and updates the map if available.
Returns:
Returns a promise that resolves when the data fetching and rendering is complete or when there is no new data.
- Type
- Promise.<void>
updateEpicenterIcon(epicenterLng, epicenterLat)
Helper function to update the epicenter icon on the map.
Parameters:
| Name | Type | Description |
|---|---|---|
epicenterLng |
* | Longitude of the epicenter |
epicenterLat |
* | Latitude of the epicenter |
updateInfoBox(reportType, unTranslatedEpicenter, magnitude, depth, time, additionalInfo, maxInt) → {void}
Update the text in the infoBox component in the UI.
Parameters:
| Name | Type | Description |
|---|---|---|
reportType |
String | The report type (e.g "Hypocenter Report", "Flash Report" etc.) |
unTranslatedEpicenter |
String | Untranslated epicenter name, this will be translated |
magnitude |
Number | Magnitude of the earthquake |
depth |
Number | Depth of the earthquake |
time |
String | The time given by the API, default api TZ: JST (GMT+9) |
additionalInfo |
String | Additional information about the earthquake (UNUSED) |
maxInt |
String | Maximum intensity of the earthquake (e.g. "5+", "6-", etc.) |
Returns:
- Type
- void
updateIntList(data, stationMap) → {Promise.<void>}
Iterate and updates the intensity list with the provided data and station map.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object | Data containing intensity points and earthquake information. |
stationMap |
Map | Map containing station information with latitude and longitude. |
Returns:
Returns a promise that resolves when the intensity list is updated.
- Type
- Promise.<void>
(private) updateTsunamiSidebar(areas, geojsonFeatures) → {void}
Updates the sidebar with tsunami area information.
Parameters:
| Name | Type | Description |
|---|---|---|
areas |
* | Tsunami areas to be displayed in the sidebar. |
geojsonFeatures |
* | GeoJSON features containing area information. |
Returns:
- Type
- void
Type Definitions
Config
Global/Main configuration object.
Type:
- Object
Properties:
| Name | Type | Description | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
map |
Object | Map configurations.
Properties
|
|||||||||||||||
api |
Object | API configurations.
Properties
|