DataQuery

public struct DataQuery

At first request, the whole data according to SkyPath.dataQuery is fetched and then only the new data that appeared (delta) is fetched to save network traffic. When cached data expires or a delta can’t be received, the whole fresh data will be received again.

There are thousands of turbulence reports around the globe. To reduce network traffic usage and keep only data that is currently needed the data fetch is separated into the different types controlled by the SkyPath.dataQuery object that is set initially to default values and can be updated at any time. All of the below are optional to set but recommended due to your specific flow.

After updating SkyPath.dataQuery in any way, the check, if need to fetch new data, will be made. And if the change requires a new server fetch, the server request will be made immediately. No need to call SkyPath.fetchData(refresh:).

You can update data query at any time and in both ways by setting a property only or a whole object.

SkyPath.shared.dataQuery.polygon = polygon
SkyPath.shared.dataQuery = DataQuery(polygon: polygon)
  • Set it if you need more than just turbulence data. By default, it’s turbulence only, and only turbulence data is fetched from the server.

    Declaration

    Swift

    public var types: DataTypeOptions
  • By default, all severities of turbulence will be fetched. But you can provide a list of severities to fetch from the server if don’t need other at all.

    Declaration

    Swift

    public var sevs: [TurbulenceSeverity]
  • Polygon is a geo-fence area to fetch data inside only. Should be a closed ring and have max 250 coordinates, otherwise SkyPath.didFailToFetchNewData will be called with an error. Simplify the polygon with enough tolerance.

    The route corridor is a good example. Route line coordinates can be used to create a polygon that includes the route with a width distance. It is fetched separately from other data types and as fast as possible, and also stored offline. It is not recommended to set a worldwide polygon, use global turbulence polygons for it instead. Stored on disk, accessible offline.

    Declaration

    Swift

    public var polygon: [CLLocationCoordinate2D]?
  • A viewport is a polygon of a visible map area in the app to fetch the right data when it’s needed. Should be a closed ring and have max 250 coordinates, otherwise SkyPath.didFailToFetchNewData will be called with an error. Simplify the polygon with enough tolerance.

    Please keep in mind, that the SDK will try to fetch the data for the viewport as soon as possible after updating SkyPath.shared.dataQuery.viewport. So to save network traffic consider updating viewport when it’s needed. A good place could be when the pilot moved the map manually, released the finger and the map stopped moving after animation, or when the focused map area is moved by code far from the previously focused area. Stored in memory, accessible offline until app relaunch. The previous viewport data is replaced with new viewport data.

    Declaration

    Swift

    public var viewport: [CLLocationCoordinate2D]?
  • If true turbulence polygons will be fetched worldwide, otherwise, if polygon is set - only inside the polygon. Also if enabled the limited number of traffic and pireps worldwide data will be fetched as well if enabled in types. The default is true.

    Declaration

    Swift

    public var globalEnabled: Bool
  • A planet-wide aggregated turbulence area polygons as a GeoJSON string. Used to show turbulence areas worldwide without fetching too much data. DataQuery.types should have .turbulencePolygons to fetch it. Stored on disk, accessible offline.

    Turbulence polygons are generated per time history separately and by default only selected time history is fetched for polygons. To enable fetching polygons for all time histories up to selected set a corresponding flag. For example, if set to fetch 4h, then to have polygons available offline for 0.5h, 1h, 2h, and 4h you need to set this flag to true. Default is false.

    Declaration

    Swift

    public var globalTurbulencePolygonsUpToEnabled: Bool
  • Default initializer.

    Declaration

    Swift

    public init(types: DataTypeOptions = .turbulence,
                sevs: [TurbulenceSeverity] = TurbulenceSeverity.allCases,
                polygon: [CLLocationCoordinate2D]? = nil)

    Parameters

    types

    The types of data to fetch from the server. The default is light.

    sevs

    The severities to fetch from the server. Default is all.

    polygon

    See polygon for more details. The default is nil.