forked from AlienDwarf/open-meteo-dotnet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from colinnuk/feature/elevation_api
Feature/elevation api
- Loading branch information
Showing
5 changed files
with
123 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace OpenMeteo | ||
{ | ||
/// <summary> | ||
/// Elevation API response | ||
/// </summary> | ||
public class ElevationApiResponse | ||
{ | ||
/// <summary> | ||
/// Elevation array in meters - this library currently only supports 1 input elevation so this will always be a single value array | ||
public float[]? Elevation { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace OpenMeteo | ||
{ | ||
internal class ElevationOptions | ||
{ | ||
public ElevationOptions(float latitude, float longitude) | ||
{ | ||
Latitude = latitude; | ||
Longitude = longitude; | ||
} | ||
|
||
/// <summary> | ||
/// Geographical WGS84 coordinate of the location | ||
/// </summary> | ||
public float Latitude { get; set; } | ||
|
||
/// <summary> | ||
/// Geographical WGS84 coordinate of the location | ||
/// </summary> | ||
public float Longitude { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenMeteo; | ||
using System.Threading.Tasks; | ||
|
||
namespace OpenMeteoTests | ||
{ | ||
[TestClass] | ||
public class ElevationTests | ||
{ | ||
private static readonly float Latitude = 52.5235f; | ||
private static readonly float Longitude = 13.4115f; | ||
|
||
[TestMethod] | ||
public async Task Elevation_Async_Test() | ||
{ | ||
OpenMeteoClient client = new(); | ||
var res = await client.QueryElevationAsync(Latitude, Longitude); | ||
|
||
Assert.IsNotNull(res); | ||
Assert.AreEqual(res.Elevation.Length, 1); | ||
} | ||
|
||
[TestMethod] | ||
public void Elevation_Sync_Test() | ||
{ | ||
OpenMeteoClient client = new(); | ||
var res = client.QueryElevation(Latitude, Longitude); | ||
|
||
Assert.IsNotNull(res); | ||
Assert.AreEqual(res.Elevation.Length, 1); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters