Skip to content

Commit

Permalink
Move weather out from under experiments.
Browse files Browse the repository at this point in the history
  • Loading branch information
panaaj committed Jan 27, 2024
1 parent 91e79ed commit a9b3265
Show file tree
Hide file tree
Showing 18 changed files with 981 additions and 670 deletions.
10 changes: 5 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
- **Added**: Toggle the display chart bounds on the map.
- **Added**: Support for Mapbox styles.
- **Updated**: New Map icons for waypoints and AIS targets.
- **Experiment (Weather)**:
- Removed NOAA service option.
- Display map icon at location where weather data was retrieved.
- Clicking map icon displays observation data.
- Weather data is relocated under the _meteo.default-fb_ context (See [nmea0183-signalk PR #245](https://github.com/SignalK/nmea0183-signalk/pull/245)).
- **Added**: Display weather data from paths within the `meteo` context
- Weather graduated from experiment to mainstream feature.
- Display meto stations on the map.
- Clicking on meto station icon displays available observation data.
- Weather data from station closest to vessel position is available via the _meteo.freeboard-sk_ path (See [nmea0183-signalk PR #245](https://github.com/SignalK/nmea0183-signalk)).
- **Experiment (Route)**:
- Render start / Finish line when present in route properties and route is active.

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ _**Signal K Standard Alarms:**_
- mob
- fire
- sinking
- flooding
- collision
- grounding
- listing
- adrift
- piracy
- abandon
Expand Down
18 changes: 10 additions & 8 deletions helper/lib/openweather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,18 @@ export class OpenWeather implements IWeatherService {
const current: OWObservation = owData.current;

obs = {
timestamp: current.dt
date: current.dt
? new Date(current.dt * 1000).toISOString()
: new Date().toISOString(),
description: current.weather[0].description ?? '',
outside: {
sun: {
sunrise: new Date(current.sunrise * 1000).toISOString() ?? null,
sunset: new Date(current.sunset * 1000).toISOString() ?? null,
sunset: new Date(current.sunset * 1000).toISOString() ?? null
},
horizontalVisibility: current.visibility ?? null,
outside: {
uvIndex: current.uvi ?? null,
cloudCover: current.clouds ?? null,
horizontalVisibility: current.visibility ?? null,
temperature: current.temp ?? null,
feelsLikeTemperature: current.feels_like ?? null,
dewPointTemperature: current.dew_point ?? null,
Expand Down Expand Up @@ -195,20 +197,20 @@ export class OpenWeather implements IWeatherService {
const forecasts = owData[period];
forecasts.forEach((f: OWForecast) => {
const forecast: SKMeteo = {
timestamp: f.dt
date: f.dt
? new Date(f.dt * 1000).toISOString()
: new Date().toISOString(),
description: f.weather[0].description ?? '',
sun: {},
outside: {},
water: {},
wind: {}
};

if (period === 'daily') {
forecast.outside.sunrise =
forecast.sun.sunrise =
new Date(f.sunrise * 1000).toISOString() ?? null;
forecast.outside.sunset =
new Date(f.sunset * 1000).toISOString() ?? null;
forecast.sun.sunset = new Date(f.sunset * 1000).toISOString() ?? null;
forecast.outside.minTemperature = f.temp.min ?? null;
forecast.outside.maxTemperature = f.temp.max ?? null;
forecast.outside.feelsLikeTemperature = f.feels_like.day ?? null;
Expand Down
139 changes: 99 additions & 40 deletions helper/openApi.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
"name": "weather",
"description": "Weather resources."
},
{
"name": "stations-self",
"description": "Weather data from station closest to vessel position."
},
{
"name": "stations",
"description": "Weather station data."
Expand Down Expand Up @@ -70,13 +74,40 @@
"type": "object",
"required": ["timestamp"],
"properties": {
"timestamp": {
"date": {
"$ref": "#/components/schemas/IsoTime"
},
"description": {
"type": "string",
"example": "broken clouds"
},
"horizontalVisibility": {
"type": "number",
"example": 5000,
"description": "Visibilty (m)"
},
"horizontalVisibilityOverRange": {
"type": "boolean",
"example": "true",
"description": "Visibilty distance is greater than the range of the measuring equipment."
},
"sunlight": {
"type": "object",
"required": ["times"],
"properties": {
"times": {
"type": "object",
"properties": {
"sunrise": {
"$ref": "#/components/schemas/IsoTime"
},
"sunset": {
"$ref": "#/components/schemas/IsoTime"
}
}
}
}
},
"outside": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -136,17 +167,17 @@
"type": "number",
"example": 56,
"description": "Amount of precipitation (mm)"
},
"horizontalVisibility": {
"type": "number",
"example": 5000,
"description": "Visibilty (m)"
}
}
},
"wind": {
"type": "object",
"properties": {
"averageSpeed": {
"type": "number",
"example": 9.3,
"description": "Average wind speed (m/s)"
},
"speedTrue": {
"type": "number",
"example": 15.3,
Expand All @@ -155,17 +186,17 @@
"directionTrue": {
"type": "number",
"example": 2.145,
"description": "Wind direction (rad)"
"description": "Wind direction relative to true north (rad)"
},
"gust": {
"type": "number",
"example": 21.6,
"description": "Wind gust (m/s)"
},
"gustDirection": {
"gustDirectionTrue": {
"type": "number",
"example": 2.6,
"description": "Wind gust direction (rad)"
"description": "Wind gust direction relative to true north (rad)"
}
}
},
Expand All @@ -182,41 +213,51 @@
"example": 11.9,
"description": "Water level (m)"
},
"levelTrend": {
"levelTendency": {
"type": "number",
"enum": ["steady","decreasing","increasing"],
"example": "steady",
"description": "Water level trend"
},
"waveSignificantHeight": {
"type": "number",
"example": 2.6,
"description": "Wave height (m)"
},
"waveDirection": {
"type": "number",
"example": 2.3876,
"description": "Wave direction (rad)"
},
"wavePeriod": {
"type": "number",
"example": 2.3876,
"description": "Wave period (m/s)"
},
"swellHeight": {
"type": "number",
"example": 2.6,
"description": "Swell height (m)"
},
"swellDirection": {
"type": "number",
"example": 2.3876,
"description": "Swell direction (rad)"
"waves": {
"type": "object",
"properties": {
"significantHeight": {
"type": "number",
"example": 2.6,
"description": "Wave height (m)"
},
"directionTrue": {
"type": "number",
"example": 2.3876,
"description": "Wave direction relative to true north (rad)"
},
"period": {
"type": "number",
"example": 2.3876,
"description": "Wave period (m/s)"
}
}
},
"swellPeriod": {
"type": "number",
"example": 2.3876,
"description": "Swell period (m/s)"
"swell": {
"type": "object",
"properties": {
"height": {
"type": "number",
"example": 2.6,
"description": "Swell height (m)"
},
"directionTrue": {
"type": "number",
"example": 2.3876,
"description": "Swell direction relative to true north (rad)"
},
"period": {
"type": "number",
"example": 2.3876,
"description": "Swell period (m/s)"
}
}
},
"seaState": {
"type": "number",
Expand All @@ -238,12 +279,12 @@
"current": {
"type": "object",
"properties": {
"surfaceSpeed": {
"drift": {
"type": "number",
"example": 3.4,
"description": "Surface current speed (m/s)"
},
"surfaceDirection": {
"set": {
"type": "number",
"example": 1.74,
"description": "Surface current direction (rad)"
Expand Down Expand Up @@ -405,6 +446,24 @@
}
}
},
"/freeboard-sk": {
"get": {
"tags": ["stations-self"],
"summary": "Weather station data closest to vessel position.",
"responses": {
"default": {
"description": "Data from weather station that weather proivder deems closest to the vessel position.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/WeatherStationResponseModel"
}
}
}
}
}
}
},
"/{id}": {
"parameters": [
{
Expand Down
Loading

0 comments on commit a9b3265

Please sign in to comment.