ストリーミングはほとんどのブラウザと
Developerアプリで視聴できます。
-
今日の天気情報にコンテキストをもたらす
WeatherKitを利用すると、種類別降水量、高度別雲量、最大風速など、詳細な天気予報データを取得できます。1日の時間帯別に天気データを集計し、気温や降水量の大幅な変化を予測する方法をご紹介します。AppleのHistorical Comparisonsデータセットを使用して現在の天気と過去の天気を比較したり、世界各地の過去の天気データを調べたりすることができます。AppleのSwift APIとREST APIを使用し、これらすべてを迅速に実行する方法も確認しましょう。
関連する章
- 0:00 - Introduction
- 1:10 - Richer forecast details
- 10:03 - Highlight weather changes
- 14:10 - Faster data transfer
リソース
- Forum: Maps & Location
- Request authentication for WeatherKit REST API
- WeatherKit
- WeatherKit REST API
関連ビデオ
WWDC22
-
ダウンロードArray
-
-
2:40 - Fetch Precipitation Amount
import CoreLocation import Foundation import WeatherKit extension CLLocation { static var newYork: CLLocation { CLLocation(latitude: 50.710, longitude: -74.006) } } let hourlyPrecipitation = try await WeatherService() .weather(for: .newYork, including: .hourly) .map(\.precipitationAmount)
-
3:25 - Fetch Precipitation Amount (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=forecastHourly&relativeHourlyStart=0&relativeHourlyEnd=1&hourlyRelativeTo=now&timezone=America/New_York
-
6:05 - Weather Changes
import CoreLocation import Foundation import WeatherKit extension Date { var isTomorrow: Bool { return Calendar.current.isDateInTomorrow(self) } } let changes = try await WeatherService() .weather(for: .newYork, including: .changes) let lowTemperatureChanges = changes? .filter(\.date.isTomorrow) .map(\.lowTemperature) if let lowTemperatureChanges, lowTemperatureChanges.contains(.decrease) { // Lower temperatures expected tomorrow }
-
6:43 - Weather Changes (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=weatherChanges
-
8:17 - Historical Comparisons
import CoreLocation import Foundation import WeatherKit let mostSignificant = try await WeatherService() .weather(for: .newYork, including: .historicalComparisons)? .first switch mostSignificant { case .highTemperature(let trend), .lowTemperature(let trend): // Display temperature trend break case .some, .none: break }
-
8:36 - Historical Comparisons (REST)
https://weatherkit.apple.com/api/v2/weather/en-US/40.710/-74.006?dataSets=historicalComparisons
-
11:11 - Monthly Statistics
import CoreLocation import Foundation import WeatherKit let averagePrecipitation = try await WeatherService() .monthlyStatistics( for: .newYork, startMonth: 1, endMonth: 12, including: .precipitation ) let averagePrecipitationAmountsPerMonth = Dictionary( grouping: averagePrecipitation, by: \.month )
-
11:41 - Monthly Statistics (REST)
https://weatherkit.apple.com/api/v2/statistics/monthly/40.710/-74.006?dataSets=precipitation&start=1&end=12
-
12:52 - Daily Summary
import CoreLocation import Foundation import WeatherKit extension Date { static var thirtyDaysAgo: Date { return Calendar.current.date(byAdding: .day, value: -30, to: .now)! } } let pastThirtyDaysSummary = try await WeatherService() .dailySummary( for: .newYork, forDaysIn: DateInterval(start: .thirtyDaysAgo, end: .now), including: .precipitation ) .first if let pastThirtyDaysSummary { // We have a daily weather summary for each day in the past 30 days }
-
13:22 - Daily Summary (REST)
https://weatherkit.apple.com/api/v2/summary/daily/40.710/-74.006?dataSets=precipitation&start=2024-05-12&end=2024-06-10
-
-
特定のトピックをお探しの場合は、上にトピックを入力すると、関連するトピックにすばやく移動できます。
クエリの送信中にエラーが発生しました。インターネット接続を確認して、もう一度お試しください。