Nowcasting
Overview
Nowcasting (aka Nowcast) is turbulence prediction data issued by the SkyPath.
Nowcast data is issued hourly for up to 6 hours forecast.
H3 resolution 5 is used by SkyPath for the nowcast area.
Each nowcast item covers ~252.9 square km hexagon area (as per the H3 resolutions table) and 1000 feet of altitude.
Each hexagon is connected to the other so this allows for covering the area better.
So one nowcast item covers for example FL370..<FL380
or FL380..<FL390
.
Setup in DataQuery
By default, the nowcast data fetch is disabled. It should be included in the DataQuery.types
list:
SkyPath.shared.dataQuery.types = [.turbulence, .nowcast]
Or using a DataTypeOptions.set(type:enabled:)
function :
SkyPath.shared.dataQuery.types.set(type: .nowcast, enabled: true)
It can be enabled or disabled at any time.
When enabled, nowcast will be fetched from the server hourly. Fetched data will be stored on disk and will be available offline.
Nowcast data will be fetched for areas set in DataQuery.polygon
and DataQuery.viewport
, similar to the turbulence fetch flow.
The SkyPathDelegate.didReceiveNewNowcast()
delegate function will be called when the SDK has fetched new nowcast data from the server.
Query
Get nowcast data using a query locally cached on disk data without making a server request.
Use NowcastQuery
to get filtered data as a GeoJSON string or as an array of objects.
It blocks the current thread, so using a separate background thread is recommended.
var query = NowcastQuery(
hours: .now,
altRange: altRange,
resultOptions: .geoJSON)
query.polygon = polygon
do {
let result = try SkyPath.shared.nowcast(with: query).get()
let geoJSON = result.geoJSON
// Show geoJSON on the map
} catch {
print(error)
}
H3 resolution 5 is used by SkyPath for the items area. Each item covers ~252.9 square km hexagon area (as per the H3 resolutions table) and 1000 feet of altitude. Each hexagon is connected to the other so this allows for covering the area better. So one item covers for example FL370..<FL380
or FL380..<FL390
.
In order to get items for specific tiles use NowcastQuery.tiles
property. It accepts h3
or h3-alt
format. Such tile id can be taken from NowcastItem.tile
property which is a Tile
object with the corresponding properties Tile.key
and Tile.keyByCoord
or Tile.h3Hex
.
GeoJSON vs Items
NowcastQuery.resultOptions
determines in which format returns the queried data.
-
items
will provide an array ofNowcastItem
objects. It can be used for postprocessing and converting for rendering in a custom way. -
geoJSON
will generate a GeoJSON string to visualize on the map. It has a geometry polygon to draw the hexagons and extra properties for each one like severity and others. Please note that the properties fields could not match theNowcastItem
fields as it's not equivalent objects. -
geoJSONData
is the same asgeoJSON
just asData
not asString
.
The GeoJSON string is not intended to provide all the details about each item. It is intended to have minimal details to visualize on the map. NowcastItem
can be used to get all details per each item.
Item Details
NowcastItem
has all the details about the item.
For example, when need to show item details by tapping on the item on the map, the GeoJSON feature properties could not have all the needed values. Also, it could be hard to find all items in the tapped area using GeoJSON only.
Here is the flow:
-
When tapping the GeoJSON feature on the map, take the
h3Hex
string from the properties. It's the H3 index of the tapped hexagon. -
Query data from the SDK in the tapped hexagon.
do {
let query = NowcastQuery(resultOptions: .items, aggregate: false, tiles: [h3Hex])
let result = try SkyPath.shared.nowcast(with: query).get()
// Process `result.items`
} catch {
print(error)
}
Forecast hour NowcastItem.forecastH
means a rounded hour since it was generated, so forecastH=0 will be "now till next rounded hour".
For example, if currently it's 14:40 and data was just received the forecastH=0 will be for the range 14:00:00-14:59:59, forecastH=1 for 15:00:00-15:59:59, and so on.
You can use the NowcastHours enum to get exact time ranges from a reference date.
However, it's better to use the NowcastItem.ts
field, a Unix timestamp for the time this prediction is valid.
It takes into account generation time so it will be correct like 15:00:00 or 16:00:00.
At the moment, it's an hourly forecast so each report is valid for an hour since NowcastItem.ts.