| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | |
|
| | 6 | | namespace Azure.Core.GeoJson |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Represents information about the coordinate range of the <see cref="GeoObject"/>. |
| | 10 | | /// </summary> |
| | 11 | | public sealed class GeoBoundingBox : IEquatable<GeoBoundingBox> |
| | 12 | | { |
| | 13 | | /// <summary> |
| | 14 | | /// The westmost value of <see cref="GeoObject"/> coordinates. |
| | 15 | | /// </summary> |
| 16 | 16 | | public double West { get; } |
| | 17 | |
|
| | 18 | | /// <summary> |
| | 19 | | /// The southmost value of <see cref="GeoObject"/> coordinates. |
| | 20 | | /// </summary> |
| 16 | 21 | | public double South { get; } |
| | 22 | |
|
| | 23 | | /// <summary> |
| | 24 | | /// The eastmost value of <see cref="GeoObject"/> coordinates. |
| | 25 | | /// </summary> |
| 16 | 26 | | public double East { get; } |
| | 27 | |
|
| | 28 | | /// <summary> |
| | 29 | | /// The northmost value of <see cref="GeoObject"/> coordinates. |
| | 30 | | /// </summary> |
| 16 | 31 | | public double North { get; } |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// The minimum altitude value of <see cref="GeoObject"/> coordinates. |
| | 35 | | /// </summary> |
| 22 | 36 | | public double? MinAltitude { get; } |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// The maximum altitude value of <see cref="GeoObject"/> coordinates. |
| | 40 | | /// </summary> |
| 22 | 41 | | public double? MaxAltitude { get; } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Initializes a new instance of <see cref="GeoBoundingBox"/>. |
| | 45 | | /// </summary> |
| 8 | 46 | | public GeoBoundingBox(double west, double south, double east, double north) : this(west, south, east, north, nul |
| | 47 | | { |
| 8 | 48 | | } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Initializes a new instance of <see cref="GeoBoundingBox"/>. |
| | 52 | | /// </summary> |
| 16 | 53 | | public GeoBoundingBox(double west, double south, double east, double north, double? minAltitude, double? maxAlti |
| | 54 | | { |
| 16 | 55 | | West = west; |
| 16 | 56 | | South = south; |
| 16 | 57 | | East = east; |
| 16 | 58 | | North = north; |
| 16 | 59 | | MinAltitude = minAltitude; |
| 16 | 60 | | MaxAltitude = maxAltitude; |
| 16 | 61 | | } |
| | 62 | |
|
| | 63 | | /// <inheritdoc /> |
| | 64 | | public bool Equals(GeoBoundingBox other) |
| | 65 | | { |
| 0 | 66 | | return West.Equals(other.West) && |
| 0 | 67 | | South.Equals(other.South) && |
| 0 | 68 | | East.Equals(other.East) && |
| 0 | 69 | | North.Equals(other.North) && |
| 0 | 70 | | Nullable.Equals(MinAltitude, other.MinAltitude) && |
| 0 | 71 | | Nullable.Equals(MaxAltitude, other.MaxAltitude); |
| | 72 | | } |
| | 73 | |
|
| | 74 | | /// <inheritdoc /> |
| | 75 | | public override bool Equals(object? obj) |
| | 76 | | { |
| 0 | 77 | | return obj is GeoBoundingBox other && Equals(other); |
| | 78 | | } |
| | 79 | |
|
| | 80 | | /// <inheritdoc /> |
| | 81 | | public override int GetHashCode() |
| | 82 | | { |
| 0 | 83 | | return HashCodeBuilder.Combine(West, South, East, North, MinAltitude, MaxAltitude); |
| | 84 | | } |
| | 85 | | } |
| | 86 | | } |