From 4e5b5d1897d90eda909a25ebc86ded9c4cdf3aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Fri, 23 Jul 2021 20:57:17 +0200 Subject: [PATCH 01/13] added GetCurrentCondition --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 12 +- .../IAzureMapsServices.cs | 7 +- .../Weather/CurrentConditions.cs | 164 ++++++++++++++++++ .../Weather/CurrentConditionsResponse.cs | 11 ++ .../Weather/GetCurrentConditionsRequest.cs | 43 +++++ .../AzureMapsRestToolkit/Weather/PastHours.cs | 19 ++ .../Weather/PrecipitationSummary.cs | 50 ++++++ .../Weather/PressureTendency.cs | 19 ++ .../Weather/TemperatureSummary.cs | 19 ++ .../Weather/WeatherUnit.cs | 27 +++ .../AzureMapsRestToolkit/Weather/Wind.cs | 23 +++ .../Weather/WindDirection.cs | 23 +++ .../AzureMapsRestToolkit/Weather/WindSpeed.cs | 28 +++ AzureMapsToolkit-Core-Test/UnitTest.cs | 15 +- 14 files changed, 457 insertions(+), 3 deletions(-) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditions.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditionsResponse.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PastHours.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PrecipitationSummary.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PressureTendency.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/TemperatureSummary.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnit.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Wind.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindDirection.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindSpeed.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 1f69c87..df064c5 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -21,6 +21,7 @@ using System.Text; using Azure.Core.GeoJson; using AzureMapsToolkit.Elevation; +using AzureMapsToolkit.Weather; //using Newtonsoft.Json.Linq; namespace AzureMapsToolkit @@ -1152,7 +1153,6 @@ public virtual async Task> GetTrafficInc #endregion - #region Elevation public virtual async Task> GetElevationDataForBoundingBox(GetElevationDataForBoundingBoxRequest req) { @@ -1227,5 +1227,15 @@ public virtual async Task> PostElevationDataForPolylin #endregion + #region Weather + + public virtual async Task> GetCurrentCondition(GetCurrentConditionsRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/currentConditions/json", req); + return res; + } + + #endregion + } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index 1e23558..97e2fd7 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -15,6 +15,7 @@ using AzureMapsToolkit.Spatial; using AzureMapsToolkit.Timezone; using AzureMapsToolkit.Traffic; +using AzureMapsToolkit.Weather; namespace AzureMapsToolkit { @@ -141,9 +142,13 @@ public interface IAzureMapsServices Task> GetElevationDataForBoundingBox(GetElevationDataForBoundingBoxRequest req); Task> GetElevationDataForPoints(GetElevationDataForPointsRequest req); - + Task> GetElevationDataForPolyline(GetElevationDataForPolylineRequest req); + Task> PostElevationDataForPoints(PostDataForPoints[] req); + Task> PostElevationDataForPolyline(PostDataForPolylineRequest req, PostDataForPolylineData[] data); + + Task> GetCurrentCondition(GetCurrentConditionsRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditions.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditions.cs new file mode 100644 index 0000000..bc5366d --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditions.cs @@ -0,0 +1,164 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class CurrentConditions + { + /// + /// Perceived outdoor temperature caused by the combination of air temperature, relative humidity, and wind speed in specified unit. + /// + [JsonPropertyName("apparentTemperature")] + public WeatherUnit ApparentTemperature { get; set; } + + /// + /// Cloud ceiling in specified unit. The ceiling is a measurement of the height of the base of the lowest clouds. + /// + [JsonPropertyName("ceiling")] + public WeatherUnit Ceiling { get; set; } + + /// + /// Percent representing cloud cover. + /// + [JsonPropertyName("cloudCover")] + public int CloudCover { get; set; } + + /// + /// Date and time of the current observation displayed in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("dateTime")] + public string DateTime { get; set; } + + /// + /// The dewpoint temperature in specified unit. The dewpoint temperature is the temperature that the air must be cooled to in order to reach saturation. + /// + [JsonPropertyName("dewPoint")] + public WeatherUnit DewPoint { get; set; } + + /// + /// Indicates the presence or absence of precipitation. True indicates the presence of precipitation, false indicates the absence of precipitation. + /// + [JsonPropertyName("hasPrecipitation")] + public bool HasPrecipitation { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Indicates the time of the day. True indicates 'day',', false indicates 'night. + /// + [JsonPropertyName("isDayTime")] + public bool IsDayTime { get; set; } + + /// + /// Cause of limited visibility. + /// + [JsonPropertyName("obstructionsToVisibility")] + public string ObstructionsToVisibility { get; set; } + + /// + /// Departure from the temperature observed 24 hours ago in specified unit. + /// + [JsonPropertyName("past24HourTemperatureDeparture")] + public WeatherUnit Past24HourTemperatureDeparture { get; set; } + + /// + /// Phrase description of the current weather condition. Displayed in specified language. + /// + [JsonPropertyName("phrase")] + public string Phrase { get; set; } + + /// + /// Departure from the temperature observed 24 hours ago in specified unit. + /// + [JsonPropertyName("precipitationSummary")] + public PrecipitationSummary PrecipitationSummary { get; set; } + + /// + /// Atmospheric pressure in specified unit. + /// + [JsonPropertyName("pressure")] + public WeatherUnit Pressure { get; set; } + + /// + /// Atmospheric pressure change. + /// + [JsonPropertyName("pressureTendency")] + public PressureTendency PressureTendency { get; set; } + + /// + /// RealFeel™ Temperature being returned. + /// + [JsonPropertyName("realFeelTemperature")] + public WeatherUnit RealFeelTemperature { get; set; } + + /// + /// RealFeel™ Temperature being returned. Describes what the temperature really feels like in the shade. + /// + [JsonPropertyName("realFeelTemperatureShade")] + public WeatherUnit RealFeelTemperatureShade { get; set; } + + [JsonPropertyName("relativeHumidity")] + public int RelativeHumidity { get; set; } + + /// + /// Temperature being returned. + /// + [JsonPropertyName("temperature")] + public WeatherUnit Temperature { get; set; } + + [JsonPropertyName("temperatureSummary")] + public TemperatureSummary TemperatureSummary { get; set; } + + /// + /// Measure of the strength of the ultraviolet radiation from the sun. Supported values are: + /// 0-2 - Low danger from the sun's UV rays or the average person. + /// 3-5 - Moderate risk of harm from unprotected sun exposure. + /// 6-7 - High risk of harm from unprotected sun exposure. + /// 8-10 - Very high risk of harm from unprotected sun exposure. + /// 11+ - Extreme risk of harm from unprotected sun exposure. + /// + [JsonPropertyName("uvIndex")] + public int UvIndex { get; set; } + + /// + /// Phrase associated with the uvIndex. + /// + [JsonPropertyName("uvIndexPhrase")] + public string UvIndexPhrase { get; set; } + + /// + /// Visibility in specified unit. A measure of the distance at which an object or light can be clearly discerned. + /// + [JsonPropertyName("visibility")] + public WeatherUnit Visibility { get; set; } + + /// + /// The temperature to which air may be cooled by evaporating water into it at constant pressure until it reaches saturation. + /// + [JsonPropertyName("wetBulbTemperature")] + public WeatherUnit WetBulbTemperature { get; set; } + + /// + /// Wind details being returned including speed and direction. + /// + [JsonPropertyName("wind")] + public Wind Wind { get; set; } + + /// + /// Perceived air temperature on exposed skin due to wind. + /// + [JsonPropertyName("windChillTemperature")] + public WeatherUnit WindChillTemperature { get; set; } + + /// + /// Wind gust. Wind gust is a sudden, brief increase in speed of the wind. + /// + [JsonPropertyName("windGust")] + public Wind WindGust { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditionsResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditionsResponse.cs new file mode 100644 index 0000000..526b921 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/CurrentConditionsResponse.cs @@ -0,0 +1,11 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class CurrentConditionsResponse + { + [JsonPropertyName("results")] + public CurrentConditions[] Results { get; set; } + } + +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs new file mode 100644 index 0000000..bd7206e --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs @@ -0,0 +1,43 @@ +using AzureMapsToolkit.Common; + +namespace AzureMapsToolkit.Weather +{ + /// + /// Get Current Conditions service returns detailed current weather conditions such as precipitation, temperature and wind for a given coordinate location. Also, observations from the past 6 or 24 hours for a particular location can be retrieved. The basic information returned with the response include details such as observation date and time, brief description of the weather conditions, weather icon, precipitation indicator flags, and temperature. Additional details such as RealFeel™ Temperature and UV index are also returned. + /// + public class GetCurrentConditionsRequest : RequestBase + { + /// + /// Coordinates of the location for which current conditions information is requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". + /// + public string Query { get; set; } + + /// + /// Return full details for the current conditions. Available values are + /// - true - Returns full details.By default all details are returned. + /// - false - Returns a truncated version of the current condition data, which includes observation date time, weather phrase, icon code, precipitation indicator flag, and temperature. + /// + public bool Details { get; set; } = true; + + /// + /// Time frame of the returned weather conditions. By default, the most current weather conditions will be returned. Default value is 0. Supported values are: + /// -0 - Return the most current weather conditions. + /// 6 - Return weather conditions from past 6 hours. + /// 24 - Return weather conditions from past 24 hours. + /// + public int Duration { get; set; } = 0; + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + public string Language { get; set; } + + /// + /// Specifies to return the data in either metric units or imperial units. Default value is metric. + /// - imperial + /// - metric + /// + public string Unit { get; set; } + } + +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PastHours.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PastHours.cs new file mode 100644 index 0000000..8b39adb --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PastHours.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class PastHours + { + /// + /// maximum + /// + [JsonPropertyName("maximum")] + public WeatherUnit Maximum { get; set; } + + /// + /// minimum + /// + [JsonPropertyName("minimum")] + public WeatherUnit Minimum { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PrecipitationSummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PrecipitationSummary.cs new file mode 100644 index 0000000..810e196 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PrecipitationSummary.cs @@ -0,0 +1,50 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class PrecipitationSummary + { + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past 12 hours. + /// + [JsonPropertyName("past12Hours")] + public WeatherUnit Past12Hours { get; set; } + + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past 18 hours. + /// + [JsonPropertyName("past18Hours")] + public WeatherUnit Past18Hours { get; set; } + + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past 24 hours. + /// + [JsonPropertyName("past24Hours")] + public WeatherUnit Past24Hours { get; set; } + + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past three hours. + /// + [JsonPropertyName("past3Hours")] + public WeatherUnit Past3Hours { get; set; } + + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past six hours. Contains Metric and Imperial Values. + /// + [JsonPropertyName("past6Hours")] + public WeatherUnit Past6Hours { get; set; } + + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past nine hours. + /// + [JsonPropertyName("past9Hours")] + public WeatherUnit Past9Hours { get; set; } + + /// + /// The amount of precipitation (liquid equivalent) that has fallen in the past hour. + /// + [JsonPropertyName("pastHour")] + public WeatherUnit PastHour { get; set; } + } +} + \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PressureTendency.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PressureTendency.cs new file mode 100644 index 0000000..9907a7a --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/PressureTendency.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class PressureTendency + { + /// + /// Pressure tendency code regardless of language. One of F=Falling, S=Steady, R=Rising. + /// + [JsonPropertyName("code")] + public string Code { get; set; } + + /// + /// Description of the pressure tendency in specified language + /// + [JsonPropertyName("localizedDescription")] + public string LocalizedDescription { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/TemperatureSummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/TemperatureSummary.cs new file mode 100644 index 0000000..7748561 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/TemperatureSummary.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class TemperatureSummary + { + [JsonPropertyName("past12Hours")] + public PastHours Past12Hours { get; set; } + + [JsonPropertyName("past24Hours")] + public PastHours Past24Hours { get; set; } + + [JsonPropertyName("past6Hours")] + public PastHours Past6Hours { get; set; } + + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnit.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnit.cs new file mode 100644 index 0000000..4ecba46 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnit.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class WeatherUnit + { + /// + /// Type of unit for the returned value. + /// + [JsonPropertyName("unit")] + public string Unit { get; set; } + + /// + /// Numeric ID value associated with the type of unit being displayed. Can be used for unit translation. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("unitType")] + public int UnitType { get; set; } + + /// + /// Rounded value. + /// + [JsonPropertyName("value")] + public double Value { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Wind.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Wind.cs new file mode 100644 index 0000000..0e40e45 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Wind.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + /// + /// Wind details being returned including speed and direction. + /// + public class Wind + { + /// + /// Wind direction + /// + [JsonPropertyName("direction")] + public WindDirection Direction { get; set; } + + /// + /// Speed of the wind in specified unit. + /// + [JsonPropertyName("speed")] + public WindSpeed Speed { get; set; } + + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindDirection.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindDirection.cs new file mode 100644 index 0000000..1fba79a --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindDirection.cs @@ -0,0 +1,23 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + /// + /// + /// + public class WindDirection + { + /// + /// Wind direction in Azimuth degrees, starting at true North and continuing in clockwise direction. North is 0 degrees, east is 90 degrees, south is 180 degrees, west is 270 degrees. Possible values 0-359. + /// + [JsonPropertyName("degrees")] + public double Degrees { get; set; } + + /// + /// Direction abbreviation in the specified language. + /// + [JsonPropertyName("localizedDescription")] + public string LocalizedDescription { get; set; } + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindSpeed.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindSpeed.cs new file mode 100644 index 0000000..eae99c5 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WindSpeed.cs @@ -0,0 +1,28 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + /// + /// Speed of wind in specified unit. + /// + public class WindSpeed + { + /// + /// Type of unit for the speed value. + /// + [JsonPropertyName("unit")] + public string Unit { get; set; } + + /// + /// Numeric ID value associated with the type of unit being displayed. Can be used for unit translation. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("unitType")] + public int UnitType { get; set; } + + /// + /// Rounded value of the speed. + /// + [JsonPropertyName("value")] + public double Value { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index 88706e3..2c79c9c 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -15,7 +15,7 @@ using AzureMapsToolkit.Search; using AzureMapsToolkit.Timezone; using AzureMapsToolkit.Traffic; - +using AzureMapsToolkit.Weather; using Xunit; namespace AzureMapsToolkit_Core_Test @@ -1211,5 +1211,18 @@ public void PostElevationDataForPoline() Assert.Equal(5, res.Result.Result.Length); } + + [Fact] + public void GetCurrentCondition() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetCurrentConditionsRequest + { + Query = "47.641268,-122.125679" + }; + var res = am.GetCurrentCondition(q).Result; + + Assert.Null(res.Error); + } } } From c814f2191122f4c2f495de5d33af6f0328cd1e3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 11:10:12 +0200 Subject: [PATCH 02/13] added GetCurrentCondition --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 12 ++ .../IAzureMapsServices.cs | 1 + .../Weather/AirAndPollen.cs | 39 +++++ .../Weather/DailyForecast.cs | 70 ++++++++ .../Weather/DailyForecastResponse.cs | 19 +++ .../Weather/DailyForecastSummary.cs | 40 +++++ .../Weather/DayOrNight.cs | 153 ++++++++++++++++++ .../Weather/DegreeDaySummary.cs | 21 +++ .../Weather/GetCurrentConditionsRequest.cs | 2 +- .../Weather/GetDailyForecastRequest.cs | 36 +++++ .../Weather/LocalSource.cs | 27 ++++ .../AzureMapsRestToolkit/Weather/Unit.cs | 18 +++ .../Weather/WeatherUnitRange.cs | 22 +++ AzureMapsToolkit-Core-Test/UnitTest.cs | 17 +- 14 files changed, 475 insertions(+), 2 deletions(-) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AirAndPollen.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecast.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastResponse.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastSummary.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DayOrNight.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DegreeDaySummary.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LocalSource.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Unit.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnitRange.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index df064c5..9509589 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1229,12 +1229,24 @@ public virtual async Task> PostElevationDataForPolylin #region Weather + /// + /// Get Current Conditions service returns detailed current weather conditions such as precipitation, temperature and wind for a given coordinate location. Also, observations from the past 6 or 24 hours for a particular location can be retrieved. The basic information returned with the response include details such as observation date and time, brief description of the weather conditions, weather icon, precipitation indicator flags, and temperature. Additional details such as RealFeel™ Temperature and UV index are also returned. + /// + /// + /// public virtual async Task> GetCurrentCondition(GetCurrentConditionsRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/currentConditions/json", req); return res; } + + public virtual async Task> GetDailyForecast(GetDailyForecastRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/daily/json", req); + return res; + } + #endregion } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index 97e2fd7..c830354 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -150,5 +150,6 @@ public interface IAzureMapsServices Task> PostElevationDataForPolyline(PostDataForPolylineRequest req, PostDataForPolylineData[] data); Task> GetCurrentCondition(GetCurrentConditionsRequest req); + Task> GetDailyForecast(GetDailyForecastRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AirAndPollen.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AirAndPollen.cs new file mode 100644 index 0000000..5fe2275 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AirAndPollen.cs @@ -0,0 +1,39 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class AirAndPollen + { + /// + /// Category of the air quality or pollution type. For example, low, high, good, moderate, unhealthy, hazardous. + /// + [JsonPropertyName("category")] + public string Category { get; set; } + + /// + /// Value associated with the air quality or pollution category. These values range from 1 to 6. 1 implying good conditions, 6 implying hazardous conditions. + /// + [JsonPropertyName("categoryValue")] + public int CategoryValue { get; set; } + + /// + /// Name of the pollen or pollutant. For example, grass, mold, weed, air quality, tree and UV index. + /// + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// Only exists for air quality. Examples include ozone and particle pollution. + /// + [JsonPropertyName("type")] + public string Type { get; set; } + + /// + /// Value of the given type above. Values associated with mold, grass, weed and tree are in units of parts per cubic meter. Both air quality and UV are indices, so they are unitless. + /// + [JsonPropertyName("value")] + public int Value { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecast.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecast.cs new file mode 100644 index 0000000..8535c16 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecast.cs @@ -0,0 +1,70 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DailyForecast + { + /// + /// airAndPollen + /// + [JsonPropertyName("airAndPollen")] + public AirAndPollen[] AirAndPollen { get; set; } + + /// + /// Date and time of the current observation displayed in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("date")] + public string Date { get; set; } + + /// + /// Day + /// + [JsonPropertyName("day")] + public DayOrNight Day { get; set; } + + /// + /// Summary of Heating Degree Day or Cooling Degree Day information + /// + [JsonPropertyName("degreeDaySummary")] + public DegreeDaySummary DegreeDaySummary { get; set; } + + /// + /// Hours of sun. + /// + [JsonPropertyName("hoursOfSun")] + public double HoursOfSun { get; set; } + + /// + /// Night + /// + [JsonPropertyName("night")] + public DayOrNight Night { get; set; } + + /// + /// RealFeel™ Temperature being returned. + /// + [JsonPropertyName("realFeelTemperature")] + public WeatherUnitRange RealFeelTemperature { get; set; } + + /// + /// RealFeel™ Temperature being returned. Describes what the temperature really feels like in the shade. + /// + [JsonPropertyName("realFeelTemperatureShade")] + public WeatherUnitRange RealFeelTemperatureShade { get; set; } + + /// + /// Source(s) of the forecast data. + /// + [JsonPropertyName("sources")] + public string[] Sources { get; set; } + + /// + /// Temperature values for the day. + /// + [JsonPropertyName("temperature")] + public WeatherUnitRange Temperature { get; set; } + + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastResponse.cs new file mode 100644 index 0000000..e3c9acb --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastResponse.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DailyForecastResponse + { + /// + /// Forecast data for each requested day. + /// + [JsonPropertyName("forecasts")] + public DailyForecast[] Forecasts { get; set; } + + /// + /// Summary for the main conditions for the requested time period. Notice that summary can cover only part of the time period. + /// + [JsonPropertyName("summary")] + public DailyForecastSummary Summary { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastSummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastSummary.cs new file mode 100644 index 0000000..d9bb500 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyForecastSummary.cs @@ -0,0 +1,40 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DailyForecastSummary + { + /// + /// one or 2 word(s) to summarize the phrase + /// + [JsonPropertyName("category")] + public string Category { get; set; } + + /// + /// Date and time that the summary period ends, displayed in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("endDate")] + public string EndDate { get; set; } + + /// + /// Summary phrase of the daily forecast. Displayed in specified language. + /// + [JsonPropertyName("phrase")] + public string Phrase { get; set; } + + /// + /// severity + /// + [JsonPropertyName("severity")] + public int Severity { get; set; } + + + /// + /// Date and time that the summary is in effect, displayed in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("startDate")] + public string StartDate { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DayOrNight.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DayOrNight.cs new file mode 100644 index 0000000..41c84a6 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DayOrNight.cs @@ -0,0 +1,153 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DayOrNight + { + /// + /// Percent representing cloud cover. + /// + [JsonPropertyName("cloudCover")] + public int CloudCover { get; set; } + + /// + /// Indicates the presence or absence of precipitation. True indicates the presence of precipitation, false indicates the absence of precipitation. + /// + [JsonPropertyName("hasPrecipitation")] + public bool HasPrecipitation { get; set; } + + /// + /// Hours of ice. + /// + [JsonPropertyName("hoursOfIce")] + public double HoursOfIce { get; set; } + + /// + /// Hours of precipitation + /// + [JsonPropertyName("hoursOfPrecipitation")] + public double HoursOfPrecipitation { get; set; } + + /// + /// Hours of rain. + /// + [JsonPropertyName("hoursOfRain")] + public double HoursOfRain { get; set; } + + /// + /// Hours of snow. + /// + [JsonPropertyName("hoursOfSnow")] + public double HoursOfSnow { get; set; } + + /// + /// Ice + /// + [JsonPropertyName("ice")] + public WeatherUnit Ice { get; set; } + + /// + /// Percent representing the probability of ice. For example, '30'. + /// + [JsonPropertyName("iceProbability")] + public int IceProbability { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Phrase description of the icon. Displayed in specified language. For example, 'Sunny'. + /// + [JsonPropertyName("iconPhrase")] + public string IconPhrase { get; set; } + + /// + /// + /// + [JsonPropertyName("localSource")] + public LocalSource LocalSource { get; set; } + + /// + /// Phrase description of the forecast in specified language. Azure Maps attempts to keep this phrase under 100 characters in length, but some languages/weather events may result in a longer phrase length, exceeding 100 characters. + /// + [JsonPropertyName("longPhrase")] + public string LongPhrase { get; set; } + + /// + /// Description of the intensity. + /// + [JsonPropertyName("precipitationIntensity")] + public string PrecipitationIntensity { get; set; } + + /// + /// Percent representing the probability of precipitation. For example, '20'. + /// + [JsonPropertyName("precipitationProbability")] + public int PrecipitationProbability { get; set; } + + /// + /// "Specifies the type of precipitation (""rain"" ""snow"" ""ice"" or ""mix""). If dbz = zero, precipitationType is not present in the response." + /// + [JsonPropertyName("precipitationType")] + public string PrecipitationType { get; set; } + + /// + /// Rain + /// + [JsonPropertyName("rain")] + public WeatherUnit Rain { get; set; } + + /// + /// Percent representing the probability of rain. For example, '40'. + /// + [JsonPropertyName("rainProbability")] + public int RainProbability { get; set; } + + /// + /// Phrase description of the forecast in specified language. Azure Maps attempts to keep this phrase under 30 characters in length, but some languages/weather events may result in a longer phrase length, exceeding 30 characters. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + + /// + /// Snow + /// + [JsonPropertyName("snow")] + public WeatherUnit Snow { get; set; } + + /// + /// Percent representing the probability of snow. For example, '30'. + /// + [JsonPropertyName("snowProbability")] + public int SnowProbability { get; set; } + + /// + /// Percent representing the probability of a thunderstorm. For example, '80'. + /// + [JsonPropertyName("thunderstormProbability")] + public int ThunderstormProbability { get; set; } + + /// + /// Total liquid equivalent of precipitation during the forecast period. + /// + [JsonPropertyName("totalLiquid")] + public WeatherUnit TotalLiquid { get; set; } + + /// + /// Wind details being returned including speed and direction. + /// + [JsonPropertyName("wind")] + public Wind Wind { get; set; } + + /// + /// Wind gust. Wind gust is a sudden, brief increase in speed of the wind. + /// + [JsonPropertyName("windGust")] + public Wind WindGust { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DegreeDaySummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DegreeDaySummary.cs new file mode 100644 index 0000000..62a5f20 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DegreeDaySummary.cs @@ -0,0 +1,21 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DegreeDaySummary + { + /// + /// Number of degrees that the mean temperature is above 65 degrees F/ 18 degree C. + /// + [JsonPropertyName("cooling")] + public WeatherUnit Cooling { get; set; } + + /// + /// Number of degrees that the mean temperature is below 65 degrees F/ 18 degree C. + /// + [JsonPropertyName("heating")] + public WeatherUnit Heating { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs index bd7206e..85dbedd 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetCurrentConditionsRequest.cs @@ -37,7 +37,7 @@ public class GetCurrentConditionsRequest : RequestBase /// - imperial /// - metric /// - public string Unit { get; set; } + public Unit Unit { get; set; } } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs new file mode 100644 index 0000000..9f1fd28 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs @@ -0,0 +1,36 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetDailyForecastRequest : RequestBase + { + /// + /// Coordinates of the location for which current conditions information is requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + /// + /// Specifies for how many days the daily forecast responses are returned. Available values are + /// 1 - Return forecast data for the next day. Returned by default. + /// 5 - Return forecast data for the next 5 days. + /// 10 - Return forecast data for the next 10 days. + /// 25 - Return forecast data for the next 25 days.Only available in S1 SKU. + /// 45 - Return forecast data for the next 45 days.Only available in S1 SKU. + /// + [JsonPropertyName("duration")] + public int? Duration { get; set; } + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + public string Language { get; set; } + + /// + /// Specifies to return the data in either metric units or imperial units. Default value is metric. + /// + [JsonPropertyName("unit")] + public Unit Unit { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LocalSource.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LocalSource.cs new file mode 100644 index 0000000..13303b7 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LocalSource.cs @@ -0,0 +1,27 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class LocalSource + { + /// + /// Numeric identifier, unique to the local data provider. + /// + [JsonPropertyName("id")] + public int Id { get; set; } + + /// + /// Name of the local data provider. Name is displayed in the language specified by language code in URL, if available. Otherwise, Name is displayed in English or the language in which the name was provided. + /// + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// Weather code provided by the local data provider. This weather code allows the forecast to be matched to icons provided by the local data provider instead of Azure Maps icons. + /// + [JsonPropertyName("weatherCode")] + public string WeatherCode { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Unit.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Unit.cs new file mode 100644 index 0000000..8e58099 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Unit.cs @@ -0,0 +1,18 @@ +namespace AzureMapsToolkit.Weather +{ + /// + /// Specifies to return the data in either metric units or imperial units. Default value is metric. + /// + public enum Unit + { + /// + /// Return data in imperial units. Some example units of imperial system are Fahrenheit and mile. + /// + imperial, + + /// + /// Return data in metric units. Some example units of metric system are Celsius and kilometer. + /// + metric + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnitRange.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnitRange.cs new file mode 100644 index 0000000..3cf233b --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherUnitRange.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + /// + /// Returned temperature values. + /// + public class WeatherUnitRange + { + /// + /// Maximum temperature for the time period + /// + [JsonPropertyName("maximum")] + public WeatherUnit Maximum { get; set; } + + /// + /// Minimum temperature for the time period. + /// + [JsonPropertyName("minimum")] + public WeatherUnit Minimum { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index 2c79c9c..867b07f 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1218,11 +1218,26 @@ public void GetCurrentCondition() var am = new AzureMapsToolkit.AzureMapsServices(_KEY); var q = new GetCurrentConditionsRequest { - Query = "47.641268,-122.125679" + Query = "47.641268,-122.125679", + Unit = Unit.imperial }; var res = am.GetCurrentCondition(q).Result; Assert.Null(res.Error); } + + [Fact] + public void GetDailyForeCast() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetDailyForecastRequest + { + Query = "62.6490341,30.0734812", + Unit = Unit.metric + }; + var res = am.GetDailyForecast(q).Result; + + Assert.Null(res.Error); + } } } From fed5e36f1a756ee35bc8d6321a9245aab2f17de1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 13:28:16 +0200 Subject: [PATCH 03/13] added GetDailyIndices --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 6 ++ .../IAzureMapsServices.cs | 1 + .../Weather/DailyIndex.cs | 57 +++++++++++++++++++ .../Weather/DailyIndicesResponse.cs | 10 ++++ .../Weather/GetDailyIndicesRequest.cs | 42 ++++++++++++++ AzureMapsToolkit-Core-Test/UnitTest.cs | 15 +++++ 6 files changed, 131 insertions(+) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndex.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndicesResponse.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyIndicesRequest.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 9509589..7c930c7 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1247,6 +1247,12 @@ public virtual async Task> GetDailyForecast(GetD return res; } + public virtual async Task> GetDailyIndices(GetDailyIndicesRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/indices/daily/json", req); + return res; + } + #endregion } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index c830354..87cc57e 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -151,5 +151,6 @@ public interface IAzureMapsServices Task> GetCurrentCondition(GetCurrentConditionsRequest req); Task> GetDailyForecast(GetDailyForecastRequest req); + Task> GetDailyIndices(GetDailyIndicesRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndex.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndex.cs new file mode 100644 index 0000000..e1589b5 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndex.cs @@ -0,0 +1,57 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DailyIndex + { + /// + /// Describes the direction of the value and categoryValue. For example, when ascending=True, the poorest index value is 0 and the best index value is 10. When ascending=True, the poorest index value is 10 and the best index value is 0. + /// + [JsonPropertyName("ascending")] + public bool Ascending { get; set; } + + /// + /// "Textual description for categoryValue corresponding to the level that the index value falls under, for example ""Very Good""." + /// + [JsonPropertyName("category")] + public string Category { get; set; } + + /// + /// Level that the index value falls under, represented by an integer. This value can be 1 through 5 and should be used in combination with the ascending flag because it can differ among indices. For example, the following values apply for Mosquito Activity: Low=1, Moderate=2, High=3, Very High=4, and Extreme=5. + /// + [JsonPropertyName("categoryValue")] + public int CategoryValue { get; set; } + + /// + /// Date and time of the current observation displayed in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("dateTime")] + public string DateTime { get; set; } + + /// + /// "A textual explanation that can be used for display purposes to summarize the index value and category. For example, when the index value for Flight Delays is very good, the description will be ""Conditions are excellent for flying!""." + /// + [JsonPropertyName("description")] + public string Description { get; set; } + + /// + /// Numeric ID used to identify the specific index. Please refer to Weather Service Concepts for details and to see the supported index IDs. For example, the index ID can support UI visualization scenarios. + /// + [JsonPropertyName("indexId")] + public int IndexId { get; set; } + + /// + /// "Name of the index, for example, ""Construction"", ""Outdoor Activity"", ""Flight Delays""." + /// + [JsonPropertyName("indexName")] + public string IndexName { get; set; } + + /// + /// Index value. Ranges from 0.0 to 10.0. Please refer to Weather Service Concepts for details and to see the supported ranges. + /// + [JsonPropertyName("value")] + public double Value { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndicesResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndicesResponse.cs new file mode 100644 index 0000000..cf72ac4 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/DailyIndicesResponse.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class DailyIndicesResponse + { + [JsonPropertyName("results")] + public DailyIndex[] Results { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyIndicesRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyIndicesRequest.cs new file mode 100644 index 0000000..54f4a78 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyIndicesRequest.cs @@ -0,0 +1,42 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetDailyIndicesRequest : RequestBase + { + /// + /// Coordinates of the location for which daily indices are requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + /// + /// Specifies for how many days the daily indices are returned. By default, the indices data for the current day will be returned. When requesting future indices data, the current day is included in the response as day 1. Available values are + /// 1 - Return daily index data for the current day. Default value. + /// 5 - Return 5 days of daily index data starting from the current day. + /// 10 - Return 10 days of daily index data starting from the current day. + /// 15 - Return 15 days of daily index data starting from the current day. + /// + [JsonPropertyName("duration")] + public int? Duration { get; set; } + + /// + /// Numeric index group identifier that can be used for restricting returned results to the corresponding subset of indices (index group). Cannot be paired with indexId. Please refer to Weather Service Concepts for details and to see the supported index groups. + /// + [JsonPropertyName("indexGroupId")] + public int? IndexGroupId { get; set; } + + /// + /// Numeric index identifier that can be used for restricting returned results to the corresponding index type. Cannot be paired with indexGroupId. Please refer to Weather Service Concepts for details and to see the supported indices. + /// + [JsonPropertyName("indexId")] + public int? IndexId { get; set; } + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + [JsonPropertyName("language")] + public string Language { get; set; } + } +} diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index 867b07f..d77287f 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1239,5 +1239,20 @@ public void GetDailyForeCast() Assert.Null(res.Error); } + + [Fact] + public void GetDailyIndices() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetDailyIndicesRequest + { + Query = "43.84745,-79.37849", + //IndexGroupId = 11 + }; + var res = am.GetDailyIndices(q).Result; + + Assert.Null(res.Error); + + } } } From aff6fac55f3176b1fccf585bf83129106f32bd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 14:00:46 +0200 Subject: [PATCH 04/13] added GetHourlyForecast --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 6 + .../IAzureMapsServices.cs | 1 + .../Weather/GetHourlyForecastRequest.cs | 40 +++++ .../Weather/HourlyForecast.cs | 160 ++++++++++++++++++ .../Weather/HourlyForecastResponse.cs | 13 ++ AzureMapsToolkit-Core-Test/UnitTest.cs | 16 +- 6 files changed, 235 insertions(+), 1 deletion(-) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetHourlyForecastRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecast.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecastResponse.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 7c930c7..abfee83 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1253,6 +1253,12 @@ public virtual async Task> GetDailyIndices(GetDai return res; } + public virtual async Task> GetHourlyForecast(GetHourlyForecastRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/hourly/json", req); + return res; + } + #endregion } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index 87cc57e..1ec4d70 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -152,5 +152,6 @@ public interface IAzureMapsServices Task> GetCurrentCondition(GetCurrentConditionsRequest req); Task> GetDailyForecast(GetDailyForecastRequest req); Task> GetDailyIndices(GetDailyIndicesRequest req); + Task> GetHourlyForecast(GetHourlyForecastRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetHourlyForecastRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetHourlyForecastRequest.cs new file mode 100644 index 0000000..9aabdc6 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetHourlyForecastRequest.cs @@ -0,0 +1,40 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetHourlyForecastRequest : RequestBase + { + /// + /// Coordinates of the location for which hourly forecast information is requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + /// + /// Time frame of the returned weather forecast. By default, the forecast data for next hour will be returned. Available values are + /// 1 - Return forecast data for the next hour. Default value. + /// 12 - Return hourly forecast for next 12 hours. + /// 24 - Return hourly forecast for next 24 hours. + /// 72 - Return hourly forecast for next 72 hours (3 days). + /// 120 - Return hourly forecast for next 120 hours (5 days). Only available in S1 SKU. + /// 240 - Return hourly forecast for next 240 hours (10 days). Only available in S1 SKU. + /// + [JsonPropertyName("duration")] + public int? Duration { get; set; } = 1; + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + [JsonPropertyName("language")] + public string Language { get; set; } + + /// + /// Specifies to return the data in either metric units or imperial units. Default value is metric. + /// + [JsonPropertyName("unit")] + public Unit Unit { get; set; } + + + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecast.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecast.cs new file mode 100644 index 0000000..b70c20d --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecast.cs @@ -0,0 +1,160 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class HourlyForecast + { + + /// + /// Cloud ceiling in specified unit. The ceiling is a measurement of the height of the base of the lowest clouds. + /// + [JsonPropertyName("ceiling")] + public WeatherUnit Ceiling { get; set; } + + /// + /// Percent representing cloud cover. + /// + [JsonPropertyName("cloudCover")] + public int CloudCover { get; set; } + + /// + /// Date and time of the forecast in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("date")] + public string Date { get; set; } + + /// + /// The dewpoint temperature in specified unit. The dewpoint temperature is the temperature that the air must be cooled to in order to reach saturation. + /// + [JsonPropertyName("dewPoint")] + public WeatherUnit DewPoint { get; set; } + + /// + /// Indicates the presence or absence of precipitation. True indicates the presence of precipitation, false indicates the absence of precipitation. + /// + [JsonPropertyName("hasPrecipitation")] + public bool HasPrecipitation { get; set; } + + /// + /// Ice + /// + [JsonPropertyName("ice")] + public WeatherUnit Ice { get; set; } + + /// + /// Percent representing the probability of snow. For example, '5'. + /// + [JsonPropertyName("iceProbability")] + public int IceProbability { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Phrase description of the weather icon. + /// + [JsonPropertyName("iconPhrase")] + public string IconPhrase { get; set; } + + /// + /// Specifies whether or not it is daylight. True indicates day light. + /// + [JsonPropertyName("isDaylight")] + public bool IsDaylight { get; set; } + + /// + /// Percent representing the probability of precipitation. For example, '20'. + /// + [JsonPropertyName("precipitationProbability")] + public int PrecipitationProbability { get; set; } + + /// + /// Rain + /// + [JsonPropertyName("rain")] + public WeatherUnit Rain { get; set; } + + /// + /// Percent representing the probability of rain. For example, '50'. + /// + [JsonPropertyName("rainProbability")] + public int RainProbability { get; set; } + + /// + /// RealFeel™ Temperature being returned. Describes what the temperature really feels like in the shade. + /// + [JsonPropertyName("realFeelTemperature")] + public WeatherUnit RealFeelTemperature { get; set; } + + /// + /// Relative humidity is the amount of water vapor present in air expressed as a percentage of the amount needed for saturation at the same temperature. + /// + [JsonPropertyName("relativeHumidity")] + public int RelativeHumidity { get; set; } + + /// + /// Snow + /// + [JsonPropertyName("snow")] + public WeatherUnit Snow { get; set; } + + /// + /// Percent representing the probability of snow. For example, '50'. + /// + [JsonPropertyName("snowProbability")] + public int SnowProbability { get; set; } + + /// + /// Temperature being returned. + /// + [JsonPropertyName("temperature")] + public WeatherUnit Temperature { get; set; } + + /// + /// Total liquid equivalent of precipitation during the forecast period. + /// + [JsonPropertyName("totalLiquid")] + public WeatherUnit TotalLiquid { get; set; } + + /// + /// Measure of the strength of the ultraviolet radiation from the sun. Supported values are: 0-2 - Low danger from the sun's UV rays or the average person. 3-5 - Moderate risk of harm from unprotected sun exposure. 6-7 - High risk of harm from unprotected sun exposure. 8-10 - Very high risk of harm from unprotected sun exposure. 11+ - Extreme risk of harm from unprotected sun exposure. + /// + [JsonPropertyName("uvIndex")] + public int UvIndex { get; set; } + + /// + /// Phrase associated with the uvIndex. + /// + [JsonPropertyName("uvIndexPhrase")] + public string UvIndexPhrase { get; set; } + + /// + /// Visibility in specified unit. A measure of the distance at which an object or light can be clearly discerned. + /// + [JsonPropertyName("visibility")] + public WeatherUnit Visibility { get; set; } + + /// + /// The temperature to which air may be cooled by evaporating water into it at constant pressure until it reaches saturation. + /// + [JsonPropertyName("wetBulbTemperature")] + public WeatherUnit WetBulbTemperature { get; set; } + + /// + /// Wind details being returned including speed and direction. + /// + [JsonPropertyName("wind")] + public Wind Wind { get; set; } + + /// + /// Wind gust. Wind gust is a sudden, brief increase in speed of the wind. + /// + [JsonPropertyName("windGust")] + public Wind WindGust { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecastResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecastResponse.cs new file mode 100644 index 0000000..03ec4e9 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HourlyForecastResponse.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class HourlyForecastResponse + { + /// + /// Forecast data for each returned hour. + /// + [JsonPropertyName("forecasts")] + public HourlyForecast[] Forecasts { get; set; } + } +} diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index d77287f..68e6df9 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1252,7 +1252,21 @@ public void GetDailyIndices() var res = am.GetDailyIndices(q).Result; Assert.Null(res.Error); - + + } + + [Fact] + public void GetHourlyForecast() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetHourlyForecastRequest + { + Query = "47.632346,-122.13887", + Duration = 12 + }; + var res = am.GetHourlyForecast(q).Result; + + Assert.Null(res.Error); } } } From 659e2e60cac461b1b6204573e8d9684f71b45c1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 15:47:50 +0200 Subject: [PATCH 05/13] added GetMinuteForecastRequest --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 6 ++ .../IAzureMapsServices.cs | 1 + .../AzureMapsRestToolkit/Weather/Color.cs | 33 +++++++++ .../Weather/GetMinuteForecastRequest.cs | 28 ++++++++ .../AzureMapsRestToolkit/Weather/Interval.cs | 69 +++++++++++++++++++ .../Weather/IntervalSummary.cs | 51 ++++++++++++++ .../Weather/MinuteForecastResponse.cs | 25 +++++++ .../Weather/MinuteForecastSummary.cs | 39 +++++++++++ AzureMapsToolkit-Core-Test/UnitTest.cs | 15 ++++ 9 files changed, 267 insertions(+) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Color.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetMinuteForecastRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Interval.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/IntervalSummary.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastResponse.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastSummary.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index abfee83..2d37517 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1259,6 +1259,12 @@ public virtual async Task> GetHourlyForecast(Ge return res; } + public virtual async Task> GetMinuteForecast(GetMinuteForecastRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/minute/json", req); + return res; + } + #endregion } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index 1ec4d70..b22e9f0 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -153,5 +153,6 @@ public interface IAzureMapsServices Task> GetDailyForecast(GetDailyForecastRequest req); Task> GetDailyIndices(GetDailyIndicesRequest req); Task> GetHourlyForecast(GetHourlyForecastRequest req); + Task> GetMinuteForecast(GetMinuteForecastRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Color.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Color.cs new file mode 100644 index 0000000..0574450 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Color.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Color + { + /// + /// Blue component of the RGB value + /// + [JsonPropertyName("blue")] + public int Blue { get; set; } + + /// + /// Green component of the RGB value. + /// + [JsonPropertyName("green")] + public int Green { get; set; } + + /// + /// Hexadecimal color value. + /// + [JsonPropertyName("hex")] + public string Hex { get; set; } + + /// + /// Red component of the RGB value. + /// + [JsonPropertyName("red")] + public int Red { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetMinuteForecastRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetMinuteForecastRequest.cs new file mode 100644 index 0000000..e071db3 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetMinuteForecastRequest.cs @@ -0,0 +1,28 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetMinuteForecastRequest : RequestBase + { + /// + /// + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + /// + /// Specifies time interval in minutes for the returned weather forecast. Supported values are: 1 - Retrieve forecast for 1-minute intervals. Returned by default. 5 - Retrieve forecasts for 5-minute intervals.15 - Retrieve forecasts for 15-minute intervals. + /// + [JsonPropertyName("interval")] + public int? Interval { get; set; } + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + [JsonPropertyName("language")] + public string Language { get; set; } + + + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Interval.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Interval.cs new file mode 100644 index 0000000..1927f16 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Interval.cs @@ -0,0 +1,69 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Interval + { + /// + /// Percent representing cloud cover. + /// + [JsonPropertyName("cloudCover")] + public int CloudCover { get; set; } + + /// + /// The full spectrum color that maps to the dBZ (decibel relative to Z). If dbz is zero, color is not present in the response. + /// + [JsonPropertyName("color")] + public Color Color { get; set; } + + /// + /// A unit that represents forecasted precipitation intensity. + /// + [JsonPropertyName("dbz")] + public double Dbz { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// The first minute for the interval. + /// + [JsonPropertyName("minute")] + public int Minute { get; set; } + + /// + /// "Specifies the type of precipitation (""rain"" ""snow"" ""ice"" or ""mix""). If dbz is zero, precipitationType is not present in the response." + /// + [JsonPropertyName("precipitationType")] + public string PrecipitationType { get; set; } + + /// + /// A short phrase describing precipitation condition for the interval. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + + /// + /// The band color that maps to the precipitation type and threshold. If dbz is zero, not present in the response. + /// + [JsonPropertyName("simplifiedColor")] + public Color SimplifiedColor { get; set; } + + /// + /// The date and time for the start of the interval in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("startTime")] + public string StartTime { get; set; } + + /// + /// Key that specifies the threshold value. Along with precipitationType, can be used to determine the simplifiedColor. If dbz is zero, not present in the response. + /// + [JsonPropertyName("threshold")] + public string Threshold { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/IntervalSummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/IntervalSummary.cs new file mode 100644 index 0000000..b27b8b8 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/IntervalSummary.cs @@ -0,0 +1,51 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class IntervalSummary + { + /// + /// Brief summary phrase. Phrase length is approximately 60 characters. + /// + [JsonPropertyName("briefPhrase")] + public string BriefPhrase { get; set; } + + /// + /// The last minute to which the summary applies. + /// + [JsonPropertyName("endMinute")] + public int EndMinute { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Long summary phrase. Phrase length is 60+ characters. + /// + [JsonPropertyName("longPhrase")] + public string LongPhrase { get; set; } + + /// + /// Short summary phrase. Phrase length is approximately 25 characters. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + + /// + /// The first minute to which the summary applies. + /// + [JsonPropertyName("startMinute")] + public int StartMinute { get; set; } + + /// + /// The number of minutes for which the summary applies. + /// + [JsonPropertyName("totalMinutes")] + public int TotalMinutes { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastResponse.cs new file mode 100644 index 0000000..2f3bcf4 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastResponse.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class MinuteForecastResponse + { + /// + /// Summary information for each interval in the forecast. The Summaries breaks down each potential interval where precipitation starts and stops. + /// + [JsonPropertyName("intervalSummaries")] + public IntervalSummary[] IntervalSummaries { get; set; } + + /// + /// Forecast data for each interval in the forecast. + /// + [JsonPropertyName("Intervals")] + public Interval[] Intervals { get; set; } + + /// + /// Phrase summaries for the entire forecast period. + /// + [JsonPropertyName("summary")] + public MinuteForecastSummary Summary { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastSummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastSummary.cs new file mode 100644 index 0000000..e80ec6f --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/MinuteForecastSummary.cs @@ -0,0 +1,39 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class MinuteForecastSummary + { + /// + /// Summary phrase for the next 120 minutes. Phrase length is approximately 60 characters. + /// + [JsonPropertyName("briefPhrase")] + public string BriefPhrase { get; set; } + + /// + /// Summary phrase for the next 60 minutes. Phrase length is approximately 60 characters. + /// + [JsonPropertyName("briefPhrase60")] + public string BriefPhrase60 { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Long summary phrase for the next 120 minutes. Phrase length is 60+ characters. + /// + [JsonPropertyName("longPhrase")] + public string LongPhrase { get; set; } + + /// + /// Short summary phrase for the next 120 minutes. Phrase length is approximately 25 characters. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index 68e6df9..66b6b82 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1268,5 +1268,20 @@ public void GetHourlyForecast() Assert.Null(res.Error); } + + [Fact] + public void GetMinuteForecast() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetMinuteForecastRequest + { + Query = "47.632346,-122.13887", + Interval = 5 + }; + var res = am.GetMinuteForecast(q).Result; + + Assert.Null(res.Error); + } + } } From 91f3316c5fd15452a074fedebbfb8f8a622a1646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 16:05:56 +0200 Subject: [PATCH 06/13] added GetQuerterDayForecast --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 10 +- .../IAzureMapsServices.cs | 3 +- ...recastRequest.cs => GetForecastRequest.cs} | 2 +- .../Weather/GetQuarterDayForecastRequest.cs | 16 ++ .../AzureMapsRestToolkit/Weather/Quarter.cs | 22 +++ .../Weather/QuarterDayForecast.cs | 148 ++++++++++++++++++ .../Weather/QuarterDayForecastResponse.cs | 18 +++ AzureMapsToolkit-Core-Test/UnitTest.cs | 17 +- 8 files changed, 231 insertions(+), 5 deletions(-) rename AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/{GetDailyForecastRequest.cs => GetForecastRequest.cs} (96%) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetQuarterDayForecastRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Quarter.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecastResponse.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 2d37517..24c9b54 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1241,9 +1241,9 @@ public virtual async Task> GetCurrentConditi } - public virtual async Task> GetDailyForecast(GetDailyForecastRequest req) + public virtual async Task> GetDailyForecast(GetForecastRequest req) { - var res = await ExecuteRequest($"{baseDomain}/weather/forecast/daily/json", req); + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/daily/json", req); return res; } @@ -1265,6 +1265,12 @@ public virtual async Task> GetMinuteForecast(Ge return res; } + public virtual async Task> GetQuarterDayForecast(GetForecastRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/quarterDay/json", req); + return res; + } + #endregion } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index b22e9f0..90144ea 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -150,9 +150,10 @@ public interface IAzureMapsServices Task> PostElevationDataForPolyline(PostDataForPolylineRequest req, PostDataForPolylineData[] data); Task> GetCurrentCondition(GetCurrentConditionsRequest req); - Task> GetDailyForecast(GetDailyForecastRequest req); + Task> GetDailyForecast(GetForecastRequest req); Task> GetDailyIndices(GetDailyIndicesRequest req); Task> GetHourlyForecast(GetHourlyForecastRequest req); Task> GetMinuteForecast(GetMinuteForecastRequest req); + Task> GetQuarterDayForecast(GetForecastRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetForecastRequest.cs similarity index 96% rename from AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs rename to AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetForecastRequest.cs index 9f1fd28..738937d 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetDailyForecastRequest.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetForecastRequest.cs @@ -3,7 +3,7 @@ namespace AzureMapsToolkit.Weather { - public class GetDailyForecastRequest : RequestBase + public class GetForecastRequest : RequestBase { /// /// Coordinates of the location for which current conditions information is requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetQuarterDayForecastRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetQuarterDayForecastRequest.cs new file mode 100644 index 0000000..b83b01e --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetQuarterDayForecastRequest.cs @@ -0,0 +1,16 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetQuarterDayForecastRequest : RequestBase + { + /// + /// Coordinates of the location for which quarter-day forecast information is requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + public int MyProperty { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Quarter.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Quarter.cs new file mode 100644 index 0000000..a6deb68 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Quarter.cs @@ -0,0 +1,22 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Quarter + { + + [JsonPropertyName("0")] + public string _0 { get; set; } + + [JsonPropertyName("1")] + public string _1 { get; set; } + + [JsonPropertyName("2")] + public string _2 { get; set; } + + [JsonPropertyName("3")] + public string _3 { get; set; } + + } +} + diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs new file mode 100644 index 0000000..7d7f943 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs @@ -0,0 +1,148 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class QuarterDayForecast + { + + /// + /// Percent representing cloud cover. + /// + [JsonPropertyName("cloudCover")] + public int CloudCover { get; set; } + + /// + /// Date and time of the forecast in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("date")] + public string Date { get; set; } + + /// + /// The dewpoint temperature in specified unit. The dewpoint temperature is the temperature that the air must be cooled to in order to reach saturation. + /// + [JsonPropertyName("dewPoint")] + public WeatherUnit DewPoint { get; set; } + + /// + /// Date and time of the beginning of the forecast quarter displayed in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. + /// + [JsonPropertyName("effectiveDate")] + public string EffectiveDate { get; set; } + + /// + /// Indicates the presence or absence of precipitation. True indicates the presence of precipitation, false indicates the absence of precipitation. + /// + [JsonPropertyName("hasPrecipitation")] + public bool HasPrecipitation { get; set; } + + /// + /// Ice + /// + [JsonPropertyName("ice")] + public WeatherUnit Ice { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Phrase description of the icon. Displayed in specified language. For example, 'Sunny'. + /// + [JsonPropertyName("iconPhrase")] + public string IconPhrase { get; set; } + + /// + /// Short summary phrase summary for quarter. + /// + [JsonPropertyName("phrase")] + public string Phrase { get; set; } + + /// + /// Description of the intensity. + /// + [JsonPropertyName("precipitationIntensity")] + public string PrecipitationIntensity { get; set; } + + /// + /// Percent representing the probability of precipitation. For example, '20'. + /// + [JsonPropertyName("precipitationProbability")] + public int PrecipitationProbability { get; set; } + + /// + /// "Specifies the type of precipitation (""rain"" ""snow"" ""ice"" or ""mix""). If dbz = zero, precipitationType is not present in the response." + /// + [JsonPropertyName("precipitationType")] + public string PrecipitationType { get; set; } + + /// + /// Quarter of the day. + /// + [JsonPropertyName("quarter")] + public Quarter Quarter { get; set; } + + /// + /// Rain + /// + [JsonPropertyName("rain")] + public WeatherUnit Rain { get; set; } + + /// + /// RealFeel™ Temperature values for the quarter. + /// + [JsonPropertyName("realFeelTemperature")] + public WeatherUnitRange RealFeelTemperature { get; set; } + + /// + /// Relative humidity is the amount of water vapor present in air expressed as a percentage of the amount needed for saturation at the same temperature. + /// + [JsonPropertyName("relativeHumidity")] + public int RelativeHumidity { get; set; } + + /// + /// Snow + /// + [JsonPropertyName("snow")] + public WeatherUnit Snow { get; set; } + + /// + /// Temperature values for the quarter. + /// + [JsonPropertyName("temperature")] + public WeatherUnitRange Temperature { get; set; } + + /// + /// Percent representing the probability of a thunderstorm. For example, '10'. + /// + [JsonPropertyName("thunderstormProbability")] + public int ThunderstormProbability { get; set; } + + /// + /// Total liquid equivalent of precipitation during the forecast period. + /// + [JsonPropertyName("totalLiquid")] + public WeatherUnit TotalLiquid { get; set; } + + /// + /// Visibility in specified unit. A measure of the distance at which an object or light can be clearly discerned. + /// + [JsonPropertyName("visibility")] + public WeatherUnit Visibility { get; set; } + + /// + /// Wind details being returned including speed and direction. + /// + [JsonPropertyName("wind")] + public Wind Wind { get; set; } + + /// + /// Wind gust. Wind gust is a sudden, brief increase in speed of the wind. + /// + [JsonPropertyName("windGust")] + public Wind WindGust { get; set; } + + + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecastResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecastResponse.cs new file mode 100644 index 0000000..1f695e4 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecastResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace AzureMapsToolkit.Weather +{ + public class QuarterDayForecastResponse + { + /// + /// Forecast data for each quarter in the response. + /// + [JsonPropertyName("forecasts")] + public QuarterDayForecast[] Forecasts { get; set; } + } +} diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index 66b6b82..bdfdd8d 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1230,7 +1230,7 @@ public void GetCurrentCondition() public void GetDailyForeCast() { var am = new AzureMapsToolkit.AzureMapsServices(_KEY); - var q = new GetDailyForecastRequest + var q = new GetForecastRequest { Query = "62.6490341,30.0734812", Unit = Unit.metric @@ -1283,5 +1283,20 @@ public void GetMinuteForecast() Assert.Null(res.Error); } + [Fact] + public void GetQuerterDayForecast() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetForecastRequest + { + Query = "47.632346,-122.13887", + Duration = 5 + }; + var res = am.GetQuarterDayForecast(q).Result; + + Assert.Null(res.Error); + + } + } } From e749cc6aa0591c0f72c6e59c8f901d1237b9c99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 17:01:15 +0200 Subject: [PATCH 07/13] added GetSevereWeatherAlerts --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 10 ++- .../IAzureMapsServices.cs | 3 +- .../AzureMapsRestToolkit/Weather/AlertArea.cs | 51 +++++++++++++ .../Weather/Description.cs | 19 +++++ .../Weather/GetSevereWeatherAlertsRequest.cs | 29 +++++++ .../Weather/LatestStatus.cs | 19 +++++ .../Weather/QuarterDayForecast.cs | 2 +- .../Weather/SevereWeatherAlert.cs | 75 +++++++++++++++++++ .../Weather/SevereWeatherAlertsResponse.cs | 10 +++ AzureMapsToolkit-Core-Test/UnitTest.cs | 15 ++++ 10 files changed, 229 insertions(+), 4 deletions(-) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AlertArea.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Description.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetSevereWeatherAlertsRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LatestStatus.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlert.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlertsResponse.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 24c9b54..7f818fd 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1265,9 +1265,15 @@ public virtual async Task> GetMinuteForecast(Ge return res; } - public virtual async Task> GetQuarterDayForecast(GetForecastRequest req) + public virtual async Task> GetQuarterDayForecast(GetForecastRequest req) { - var res = await ExecuteRequest($"{baseDomain}/weather/forecast/quarterDay/json", req); + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/quarterDay/json", req); + return res; + } + + public virtual async Task> GetSevereWeatherAlerts(GetSevereWeatherAlertsRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/forecast/quarterDay/json", req); return res; } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index 90144ea..5054a0e 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -154,6 +154,7 @@ public interface IAzureMapsServices Task> GetDailyIndices(GetDailyIndicesRequest req); Task> GetHourlyForecast(GetHourlyForecastRequest req); Task> GetMinuteForecast(GetMinuteForecastRequest req); - Task> GetQuarterDayForecast(GetForecastRequest req); + Task> GetQuarterDayForecast(GetForecastRequest req); + Task> GetSevereWeatherAlerts(GetSevereWeatherAlertsRequest req); } } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AlertArea.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AlertArea.cs new file mode 100644 index 0000000..515d52f --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/AlertArea.cs @@ -0,0 +1,51 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class AlertArea + { + /// + /// Full details associated with the alert. Returned if details=True. This field is always returned in the language(s) of choice by the issuing provider and Azure Maps only returns what is created by the provider. Please note, some countries/regions may offer their native language and English. Language parameter won’t apply to this field. + /// + [JsonPropertyName("alertDetails")] + public string AlertDetails { get; set; } + + /// + /// Language of the alertDetails. This field helps to point out that the language of the alertDetails may differ from the requested language parameter. Returned if details=True. Language code has been derived from the ISO 639-1 Alpha-2 codes. + /// + [JsonPropertyName("alertDetailsLanguageCode")] + public string AlertDetailsLanguageCode { get; set; } + + /// + /// The end date and time of the alert in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. If the alert crosses multiple time zones the returned time in the response is the local time to the requested coordinate location. + /// + [JsonPropertyName("endTime")] + public string EndTime { get; set; } + + /// + /// The latest status of the alert in the current area. + /// + [JsonPropertyName("latestStatus")] + public LatestStatus LatestStatus { get; set; } + + /// + /// The name of an area which is affected by the alert. The location that was requested falls under the alert area. + /// + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// The start date and time of the alert in ISO 8601 format, for example, 2019-10-27T19:39:57-08:00. If the alert crosses multiple time zones the returned time in the response is the local time to the requested coordinate location. + /// + [JsonPropertyName("startTime")] + public string StartTime { get; set; } + + /// + /// Text summarizing the alert in the returned area. + /// + [JsonPropertyName("summary")] + public string Summary { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Description.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Description.cs new file mode 100644 index 0000000..87884a2 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Description.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Description + { + /// + /// Description of the alert in English (en-US). + /// + [JsonPropertyName("english")] + public string English { get; set; } + + /// + /// Description of the alert in the specified language. By default English (en-US) is returned if the language parameter is not specified in the request. + /// + [JsonPropertyName("localized")] + public string Localized { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetSevereWeatherAlertsRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetSevereWeatherAlertsRequest.cs new file mode 100644 index 0000000..d4fb5de --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetSevereWeatherAlertsRequest.cs @@ -0,0 +1,29 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetSevereWeatherAlertsRequest : RequestBase + { + /// + /// Coordinates of the location for which severe weather alerts are requested. The applicable query is specified as a comma separated string composed by latitude followed by longitude e.g. "47.641268,-122.125679". + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + /// + /// Return full details for the severe weather alerts. Available values are. true - Returns full details. By default all details are returned. false - Returns a truncated version of the alerts data, which excludes the area-specific full description of alert details (alertDetails). + /// + [JsonPropertyName("details")] + public string Details { get; set; } + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + [JsonPropertyName("language")] + public string Language { get; set; } + + + + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LatestStatus.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LatestStatus.cs new file mode 100644 index 0000000..0b8b189 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/LatestStatus.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class LatestStatus + { + /// + /// The latest status keyword for the alert, in the specified language. By default, returned in English (en-US). + /// + [JsonPropertyName("localized")] + public string Localized { get; set; } + + /// + /// Latest status keyword for the alert, in English (en-US) + /// + [JsonPropertyName("english")] + public string English { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs index 7d7f943..43c3f7d 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs @@ -81,7 +81,7 @@ public class QuarterDayForecast /// Quarter of the day. /// [JsonPropertyName("quarter")] - public Quarter Quarter { get; set; } + public string Quarter { get; set; } /// /// Rain diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlert.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlert.cs new file mode 100644 index 0000000..1650a36 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlert.cs @@ -0,0 +1,75 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class SevereWeatherAlert + { + /// + /// Information about the alert specific to the affected area(s). + /// + [JsonPropertyName("alertAreas")] + public AlertArea[] AlertAreas { get; set; } + + /// + /// A unique numerical identifier for a weather alert. + /// + [JsonPropertyName("alertId")] + public int AlertId { get; set; } + + /// + /// Category of the alert. + /// + [JsonPropertyName("category")] + public string Category { get; set; } + + /// + /// Classification of the alert. This field is not available for all countries and therefore not always returned. + /// + [JsonPropertyName("class")] + public string Class { get; set; } + + /// + /// "2-character ISO 3166-1 Alpha-2 country code, for example, ""US""." + /// + [JsonPropertyName("countryCode")] + public string CountryCode { get; set; } + + /// + /// Description of the alert. + /// + [JsonPropertyName("description")] + public Description Description { get; set; } + + /// + /// A disclaimer regarding the source of the alert information. This field is not always available. For example, disclaimer may include details about the delays or potential issues related to the alarm. + /// + [JsonPropertyName("disclaimer")] + public string Disclaimer { get; set; } + + /// + /// Severity level of the alert. This field is not available for all countries and therefore not always returned. + /// + [JsonPropertyName("level")] + public string Level { get; set; } + + /// + /// Number signifying the importance or ranking order of the given alert within the country/region it has originated. A lower number signifies a higher priority. For example, 1 is the highest priority. The number varies by country/region and can change over time as each country/region evolves their alert systems. + /// + [JsonPropertyName("priority")] + public int Priority { get; set; } + + /// + /// The provider of the alert information. By default the source is returned in English (en-US). The alerts are from official Government Meteorological Agencies and leading global weather alert providers. + /// + [JsonPropertyName("source")] + public string Source { get; set; } + + /// + /// A numerical identifier associated with the source provider name of the alert data. + /// + [JsonPropertyName("sourceId")] + public int SourceId { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlertsResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlertsResponse.cs new file mode 100644 index 0000000..0505365 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SevereWeatherAlertsResponse.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class SevereWeatherAlertsResponse + { + [JsonPropertyName("SevereWeatherAlert")] + public SevereWeatherAlert SevereWeatherAlert { get; set; } + } +} diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index bdfdd8d..ed99a27 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1298,5 +1298,20 @@ public void GetQuerterDayForecast() } + [Fact] + public void GetSevereWeatherAlerts() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetSevereWeatherAlertsRequest + { + Query = "47.632346,-122.13887", + + }; + var res = am.GetSevereWeatherAlerts(q).Result; + + Assert.Null(res.Error); + + } + } } From 266d9e3bb253ef55ce4dd8a2a58e557b02767a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 17:08:22 +0200 Subject: [PATCH 08/13] updated GetQuerterDayForecast --- AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs | 2 +- .../AzureMapsRestToolkit/Weather/QuarterDayForecast.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 7f818fd..7e17508 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1273,7 +1273,7 @@ public virtual async Task> GetQuarterDayFor public virtual async Task> GetSevereWeatherAlerts(GetSevereWeatherAlertsRequest req) { - var res = await ExecuteRequest($"{baseDomain}/weather/forecast/quarterDay/json", req); + var res = await ExecuteRequest($"{baseDomain}/weather/severe/alerts/json", req); return res; } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs index 43c3f7d..2d2a9c4 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/QuarterDayForecast.cs @@ -81,7 +81,7 @@ public class QuarterDayForecast /// Quarter of the day. /// [JsonPropertyName("quarter")] - public string Quarter { get; set; } + public int Quarter { get; set; } /// /// Rain From a417f475abc7578277b36d18c9f1ccb69dd9f61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 18:07:34 +0200 Subject: [PATCH 09/13] added GetWeatherAlongRoute --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 39 ++++++++- .../Weather/GetWeatherAlongRouteRequest.cs | 25 ++++++ .../Weather/HazardDetails.cs | 30 +++++++ .../AzureMapsRestToolkit/Weather/Hazards.cs | 24 ++++++ .../Weather/Notification.cs | 33 ++++++++ .../AzureMapsRestToolkit/Weather/SunGlare.cs | 20 +++++ .../AzureMapsRestToolkit/Weather/Waypoint.cs | 82 +++++++++++++++++++ .../Weather/WeatherAlongRoutePrecipitation.cs | 19 +++++ .../Weather/WeatherAlongRouteResponse.cs | 16 ++++ .../Weather/WeatherAlongRouteSummary.cs | 16 ++++ AzureMapsToolkit-Core-Test/UnitTest.cs | 14 ++++ 11 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetWeatherAlongRouteRequest.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HazardDetails.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Hazards.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Notification.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SunGlare.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Waypoint.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRoutePrecipitation.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteResponse.cs create mode 100644 AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteSummary.cs diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index 7e17508..a0cd1cc 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1241,42 +1241,79 @@ public virtual async Task> GetCurrentConditi } + /// + /// The service returns detailed weather forecast such as temperature and wind by day for the next 1, 5, 10, 15, 25, or 45 days for a given coordinate location. The response include details such as temperature, wind, precipitation, air quality, and UV index. + /// In S0 you can request daily forecast for the next 1, 5, 10, and 15 days. In S1 you can also request daily forecast for the next 25 days, and 45 days. + /// + /// + /// public virtual async Task> GetDailyForecast(GetForecastRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/forecast/daily/json", req); return res; } + /// + /// There may be times when you want to know if the weather conditions are optimal for a specific activity, for example, for outdoor construction, indoor activities, running or farming including soil moisture information. Azure Maps Indices API returns index values that will guide end users to plan future activities. For example, a health mobile application can notify users that today is good weather for running or for other outdoors activities like for playing golf, and retail stores can optimize their digital marketing campaigns based on predicted index values. The service returns in daily indices values for current and next 5, 10 and 15 days starting from current day. + /// + /// + /// public virtual async Task> GetDailyIndices(GetDailyIndicesRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/indices/daily/json", req); return res; } + /// + /// Request detailed weather forecast by the hour for the next 1, 12, 24 (1 day), 72 (3 days), 120 (5 days), and 240 hours (10 days) for the given the given coordinate location. The API returns details such as temperature, humidity, wind, precipitation, and ultraviolet (UV) index. + /// In S0 you can request hourly forecast for the next 1, 12, 24 hours (1 day), and 72 hours (3 days). In S1 you can also request hourly forecast for the next 120 (5 days) and 240 hours (10 days). + /// + /// + /// public virtual async Task> GetHourlyForecast(GetHourlyForecastRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/forecast/hourly/json", req); return res; } + /// + /// Get Minute Forecast service returns minute-by-minute forecasts for a given location for the next 120 minutes. Users can request weather forecasts in the interval of 1, 5 and 15 minutes. The response will include details such as the type of precipitation (including rain, snow, or a mixture of both), start time, and precipitation intensity value (dBZ). + /// + /// + /// public virtual async Task> GetMinuteForecast(GetMinuteForecastRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/forecast/minute/json", req); return res; } + /// + /// Service returns detailed weather forecast by quarter-day for the next 1, 5, 10, or 15 days for a given location. Response data is presented by quarters of the day - morning, afternoon, evening, and overnight. Details such as temperature, humidity, wind, precipitation, and UV index are returned. + /// + /// + /// public virtual async Task> GetQuarterDayForecast(GetForecastRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/forecast/quarterDay/json", req); return res; } - + /// + /// Severe weather phenomenon can significantly impact our everyday life and business operations. For example, severe weather conditions such as tropical storms, high winds or flooding can close roads and force logistics companies to reroute their fleet causing delays in reaching destinations and breaking the cold chain of refrigerated food products.  Azure Maps Severe Weather Alerts API returns the severe weather alerts that are available worldwide from both official Government Meteorological Agencies and leading global to regional weather alert providers. The service can return details such as alert type, category, level and detailed description about the active severe alerts for the requested location, like hurricanes, thunderstorms, lightning, heat waves or forest fires. + /// + /// + /// public virtual async Task> GetSevereWeatherAlerts(GetSevereWeatherAlertsRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/severe/alerts/json", req); return res; } + public virtual async Task> GetWeatherAlongRoute(GetWeatherAlongRouteRequest req) + { + var res = await ExecuteRequest($"{baseDomain}/weather/route/json", req); + return res; + } + #endregion } diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetWeatherAlongRouteRequest.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetWeatherAlongRouteRequest.cs new file mode 100644 index 0000000..3177620 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/GetWeatherAlongRouteRequest.cs @@ -0,0 +1,25 @@ +using AzureMapsToolkit.Common; +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class GetWeatherAlongRouteRequest : RequestBase + { + /// + /// Coordinates through which the route is calculated, separated by colon (:) and entered in chronological order. A minimum of two waypoints is required. A single API call may contain up to 60 waypoints. A waypoint indicates location, ETA, and optional heading: latitude,longitude,ETA,heading, where + /// Latitude - Latitude coordinate in decimal degrees. + /// Longitude - Longitude coordinate in decimal degrees. + /// ETA(estimated time of arrival) - The number of minutes from the present time that it will take for the vehicle to reach the waypoint.Allowed range is from 0.0 to 120.0 minutes. + /// Heading - An optional value indicating the vehicle heading as it passes the waypoint. Expressed in clockwise degrees relative to true north.This is issued to calculate sun glare as a driving hazard.Allowed range is from 0.0 to 360.0 degrees.If not provided, a heading will automatically be derived based on the position of neighboring waypoints. + /// It is recommended to stay within, or close to, the distance that can be traveled within 120-mins or shortly after. This way a more accurate assessment can be provided for the trip and prevent isolated events not being captured between waypoints. Information can and should be updated along the route (especially for trips greater than 2 hours) to continuously pull new waypoints moving forward, but also to ensure that forecast information for content such as precipitation type and intensity is accurate as storms develop and dissipate over time. + /// + [JsonPropertyName("query")] + public string Query { get; set; } + + /// + /// Language in which search results should be returned. Should be one of supported IETF language tags, case insensitive. When data in specified language is not available for a specific field, default language is used. Default value is en-us. + /// + [JsonPropertyName("language")] + public string Language { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HazardDetails.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HazardDetails.cs new file mode 100644 index 0000000..3f92b6d --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/HazardDetails.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class HazardDetails + { + /// + /// A unique identifier (non-displayable) for each type of hazard: LightRain, ModerateRain, HeavyRain, LightMix, ModerateMix, HeavyMix, LightSnow, ModerateSnow, HeavySnow, LightIce, ModerateIce, HeavyIce, Hail, LargeHail, SunGlare, SunGlareHigh, Lightning, SevereLightning, WindModerate, WindHigh, WindExtreme, FloodWarning, FlashFloodWarning, TornadoWarning, TsunamiWarning, SevereThunderstormWarning. + /// + [JsonPropertyName("")] + public string HazardCode { get; set; } + + /// + /// A severity/hazard index. + /// 0 - No hazard + /// 1 - Be informed, be aware. + /// 2 - Pay attention, be prepared. + /// 3 - Take action. + /// 4 - Life threatening, emergency. + /// + [JsonPropertyName("hazardIndex")] + public int HazardIndex { get; set; } + + /// + /// A displayable short phrase describing the forecasted conditions and precipitation intensity/type. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Hazards.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Hazards.cs new file mode 100644 index 0000000..d886dd0 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Hazards.cs @@ -0,0 +1,24 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Hazards + { + /// + /// Details of the weather hazards affecting the trip. + /// + [JsonPropertyName("hazardDetails")] + public HazardDetails[] HazardDetails { get; set; } + + /// + /// A severity/hazard index. + /// 0 - No hazard. + /// 1 - Be informed, be aware. + /// 2 - Pay attention, be prepared. + /// 3 - Take action. + /// 4 - Life threatening, emergency. + /// + [JsonPropertyName("maxHazardIndex")] + public int MaxHazardIndex { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Notification.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Notification.cs new file mode 100644 index 0000000..cfc90f0 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Notification.cs @@ -0,0 +1,33 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Notification + { + /// + /// A unique identifier (non-displayable) for each type of hazard: LightRain, ModerateRain, HeavyRain, LightMix, ModerateMix, HeavyMix, LightSnow, ModerateSnow, HeavySnow, LightIce, ModerateIce, HeavyIce, Hail, LargeHail, SunGlare, SunGlareHigh, Lightning, SevereLightning, WindModerate, WindHigh, WindExtreme, FloodWarning, FlashFloodWarning, TornadoWarning, TsunamiWarning, SevereThunderstormWarning. + /// + [JsonPropertyName("hazardCode")] + public string HazardCode { get; set; } + + /// + /// A severity/hazard index.0 - No hazard.1 - Be informed, be aware.2 - Pay attention, be prepared.3 - Take action.4 - Life threatening, emergency. + /// + [JsonPropertyName("hazardIndex")] + public int HazardIndex { get; set; } + + /// + /// A displayable short phrase describing the forecasted conditions and precipitation intensity/type. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + + /// + /// A type of notification generated to warn drivers of the onset of a hazard, or increase in intensity of a hazard. + /// + [JsonPropertyName("type")] + public string Type { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SunGlare.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SunGlare.cs new file mode 100644 index 0000000..2a2e132 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/SunGlare.cs @@ -0,0 +1,20 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class SunGlare + { + /// + /// If the vehicle heading value is not provided for a waypoint, then the service will calculate a heading based upon the location of neighboring waypoints if provided. + /// + [JsonPropertyName("calculatedVehicleHeading")] + public int calculatedVehicleHeading { get; set; } + + /// + /// An index from 0 to 100 indicating sun glare intensity for a driver. A value of 50 and above can be considered a hazard for some drivers and a value of 100 signifies the driver is driving straight into the sun and atmospheric conditions are clear allowing for the full intensity of the sun to blind the driver. + /// + [JsonPropertyName("glareIndex")] + public int GlareIndex { get; set; } + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Waypoint.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Waypoint.cs new file mode 100644 index 0000000..d21cece --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/Waypoint.cs @@ -0,0 +1,82 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class Waypoint + { + + /// + /// Percent representing cloud cover. + /// + [JsonPropertyName("cloudCover")] + public int CloudCover { get; set; } + + /// + /// + /// + [JsonPropertyName("hazards")] + public Hazards Hazards { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + + /// + /// Indicates the time of the day. True indicates 'day',', false indicates 'night. + /// + [JsonPropertyName("isDayTime")] + public bool IsDayTime { get; set; } + + /// + /// values of 1 and higher mean there is a thunderstorm in increasing intensity." + /// + [JsonPropertyName("lightningCount")] + public int LightningCount { get; set; } + + /// + /// + /// + [JsonPropertyName("notifications")] + public Notification[] Notifications { get; set; } + + /// + /// + /// + [JsonPropertyName("precipitation")] + public WeatherAlongRoutePrecipitation Precipitation { get; set; } + + /// + /// A displayable short phrase describing the forecasted conditions and precipitation intensity/type. + /// + [JsonPropertyName("shortPhrase")] + public string ShortPhrase { get; set; } + + /// + /// A rating that indicates how blinding the sun is for the driver. + /// + [JsonPropertyName("sunGlare")] + public SunGlare SunGlare { get; set; } + + /// + /// + /// + [JsonPropertyName("temperature")] + public WeatherUnit Temperature { get; set; } + + /// + /// Wind details being returned including speed and direction. + /// + [JsonPropertyName("wind")] + public Wind Wind { get; set; } + + /// + /// Wind details being returned including speed and direction. + /// + [JsonPropertyName("windGust")] + public Wind WindGust { get; set; } + + + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRoutePrecipitation.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRoutePrecipitation.cs new file mode 100644 index 0000000..09c89b9 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRoutePrecipitation.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class WeatherAlongRoutePrecipitation + { + /// + /// The forecasted precipitation intensity in dBZ (decibels relative to Z) from 0.0 to 100.0. + /// + [JsonPropertyName("dbz")] + public double Dbz { get; set; } + + /// + /// Precipitation type.If precipitation should occur, the type that it will be: "RAIN," "HAIL," "SNOW," "ICE," or "MIX." + /// + [JsonPropertyName("type")] + public string Type { get; set; } + } +} \ No newline at end of file diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteResponse.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteResponse.cs new file mode 100644 index 0000000..afb8d1b --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteResponse.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class WeatherAlongRouteResponse + { + [JsonPropertyName("summary")] + public WeatherAlongRouteSummary Summary { get; set; } + + /// + /// Data for each waypoint returned in the same order as specified in the request. + /// + [JsonPropertyName("waypoints")] + public Waypoint[] Waypoints { get; set; } + } +} diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteSummary.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteSummary.cs new file mode 100644 index 0000000..dc804e5 --- /dev/null +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/Weather/WeatherAlongRouteSummary.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +namespace AzureMapsToolkit.Weather +{ + public class WeatherAlongRouteSummary + { + [JsonPropertyName("hazards")] + public Hazards Hazards { get; set; } + + /// + /// Numeric value representing an image that displays the iconPhrase. Please refer to Weather Service Concepts for details. + /// + [JsonPropertyName("iconCode")] + public int IconCode { get; set; } + } +} diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index ed99a27..131fa2a 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -1313,5 +1313,19 @@ public void GetSevereWeatherAlerts() } + [Fact] + public void GetWeatherAlongRoute() + { + var am = new AzureMapsToolkit.AzureMapsServices(_KEY); + var q = new GetWeatherAlongRouteRequest + { + Query = "38.907,-77.037,0:38.907,-77.009,10:38.926,-76.928,20:39.033,-76.852,30:39.168,-76.732,40:39.269,-76.634,50:39.287,-76.612,60" + + }; + var res = am.GetWeatherAlongRoute(q).Result; + + Assert.Null(res.Error); + } + } } From 8ffd63d2f86d5292df8c5da21ab5ceb3dad7e93e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 18:08:55 +0200 Subject: [PATCH 10/13] updated interface --- .../AzureMapsRestToolkit/AzureMapsServices.cs | 8 ++++++++ .../AzureMapsRestToolkit/IAzureMapsServices.cs | 1 + 2 files changed, 9 insertions(+) diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs index a0cd1cc..f4d0648 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsServices.cs @@ -1308,6 +1308,14 @@ public virtual async Task> GetSevereWeathe return res; } + /// + /// Weather along a route API returns hyper local (one kilometer or less), up-to-the-minute weather nowcasts, weather hazard assessments, and notifications along a route described as a sequence of waypoints. This includes a list of weather hazards affecting the waypoint or route, and the aggregated hazard index for each waypoint might be used to paint each portion of a route according to how safe it is for the driver. When submitting the waypoints, it is recommended to stay within, or close to, the distance that can be traveled within 120-mins or shortly after. Data is updated every five minutes. + /// The service supplements Azure Maps Route Service that allows you to first request a route between an origin and a destination and use that as an input for Weather Along Route endpoint + /// In addition, the service supports scenarios to generate weather notifications for waypoints that experience an increase in intensity of a weather hazard. For example, if the vehicle is expected to begin experiencing heavy rain as it reaches a waypoint, a weather notification for heavy rain will be generated for that waypoint allowing the end product to display a heavy rain notification before the driver reaches that waypoint. The trigger for when to display the notification for a waypoint could be based, for example, on a geofence, or selectable distance to the waypoint. + /// The API covers all regions of the planet except latitudes above Greenland and Antarctica. + /// + /// + /// public virtual async Task> GetWeatherAlongRoute(GetWeatherAlongRouteRequest req) { var res = await ExecuteRequest($"{baseDomain}/weather/route/json", req); diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs index 5054a0e..f4258f6 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/IAzureMapsServices.cs @@ -156,5 +156,6 @@ public interface IAzureMapsServices Task> GetMinuteForecast(GetMinuteForecastRequest req); Task> GetQuarterDayForecast(GetForecastRequest req); Task> GetSevereWeatherAlerts(GetSevereWeatherAlertsRequest req); + Task> GetWeatherAlongRoute(GetWeatherAlongRouteRequest req); } } From 45b81dd91f2f54c146e0a1be37ed0c177d5a030d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 18:11:11 +0200 Subject: [PATCH 11/13] updated version --- .../AzureMapsRestToolkit/AzureMapsRestToolkit.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsRestToolkit.csproj b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsRestToolkit.csproj index 3a01e4b..cff48f2 100644 --- a/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsRestToolkit.csproj +++ b/AzureMapsRestToolkit/AzureMapsRestToolkit/AzureMapsRestToolkit.csproj @@ -13,9 +13,9 @@ GIT .NET Azure Maps REST API 7.0.0 - 7.0.0.0 + 7.1.0.0 AzureMapsToolkit - 7.0.0.0 + 7.1.0.0 Per Fahlen,Vincent Baaij © 2021 MIT From 156fd19974e2e62e19757e31d2cff64b1a58ba2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20Fahl=C3=A9n?= Date: Sat, 24 Jul 2021 18:22:01 +0200 Subject: [PATCH 12/13] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 85805e8..ee60497 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Azure Maps REST Services -[![NuGet](https://img.shields.io/badge/NuGet-7.0.0-blue.svg)](https://www.nuget.org/packages/AzureMapsRestToolkit/) +[![NuGet](https://img.shields.io/badge/NuGet-7.1.0-blue.svg)](https://www.nuget.org/packages/AzureMapsRestToolkit/) [![license](https://img.shields.io/badge/license-MIT-yellow.svg)](https://github.com/perfahlen/AzureMapsRestServices/blob/master/LICENSE) # .NET 5 library to access AzureMaps Services -This library covers 50 Azure Maps services including the following services +This library covers 73 Azure Maps endpoints including the following services - Data services - Geolocation services - Render services @@ -15,6 +15,8 @@ This library covers 50 Azure Maps services including the following services - TimeZone services - Traffic services - Mobility services +- Weather services +- Elevation services ## Exceptions Exception is captures by the library and if any exceptions captured it will be return in the __Error__ property in the returned object. See example below. From a06f69583a7eb7ef1862852e3e0c8ff45ed3b231 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Luthi?= Date: Mon, 28 Sep 2020 14:35:42 +0200 Subject: [PATCH 13/13] Use an environment variable (AZURE_MAPS_KEY) for running unit tests This way, the project compiles out of the box. --- AzureMapsToolkit-Core-Test/Readme.txt | 11 +---------- AzureMapsToolkit-Core-Test/UnitTest.cs | 9 +++++++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/AzureMapsToolkit-Core-Test/Readme.txt b/AzureMapsToolkit-Core-Test/Readme.txt index c32d37c..f72413a 100644 --- a/AzureMapsToolkit-Core-Test/Readme.txt +++ b/AzureMapsToolkit-Core-Test/Readme.txt @@ -1,10 +1 @@ -1. Create a file named AzureMapsKey.cs -2. paste the following snippet into that file. - -namespace AzureMapsToolkit_Core_Test -{ - public static class AzureMapsKey - { - public const string _KEY = ""; - } -} +Please set the AZURE_MAPS_KEY environment variable to a valid Azure Maps key for running the unit tests. \ No newline at end of file diff --git a/AzureMapsToolkit-Core-Test/UnitTest.cs b/AzureMapsToolkit-Core-Test/UnitTest.cs index 131fa2a..e5718d9 100644 --- a/AzureMapsToolkit-Core-Test/UnitTest.cs +++ b/AzureMapsToolkit-Core-Test/UnitTest.cs @@ -22,9 +22,14 @@ namespace AzureMapsToolkit_Core_Test { public class UnitTest { + private static readonly string _KEY; - const string _KEY = AzureMapsKey._KEY; - + static UnitTest() + { + _KEY = Environment.GetEnvironmentVariable("AZURE_MAPS_KEY"); + if (string.IsNullOrEmpty(_KEY)) + throw new Exception("Please set the AZURE_MAPS_KEY environment variable to a valid Azure Maps key."); + } [Fact] public void InvalidIPCountry()