| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.Collections; |
| | 5 | | using System.Collections.Generic; |
| | 6 | | using System.Linq; |
| | 7 | |
|
| | 8 | | namespace Azure.Core.GeoJson |
| | 9 | | { |
| | 10 | | /// <summary> |
| | 11 | | /// Represents a geometry that is composed of multiple geometries. |
| | 12 | | /// </summary> |
| | 13 | | public sealed class GeoCollection : GeoObject, IReadOnlyList<GeoObject> |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Initializes new instance of <see cref="GeoCollection"/>. |
| | 17 | | /// </summary> |
| | 18 | | /// <param name="geometries">The collection of inner geometries.</param> |
| 0 | 19 | | public GeoCollection(IEnumerable<GeoObject> geometries): this(geometries, null, DefaultProperties) |
| | 20 | | { |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | /// <summary> |
| | 24 | | /// Initializes new instance of <see cref="GeoCollection"/>. |
| | 25 | | /// </summary> |
| | 26 | | /// <param name="geometries">The collection of inner geometries.</param> |
| | 27 | | /// <param name="boundingBox">The <see cref="GeoBoundingBox"/> to use.</param> |
| | 28 | | /// <param name="additionalProperties">The set of additional properties associated with the <see cref="GeoObject |
| 16 | 29 | | public GeoCollection(IEnumerable<GeoObject> geometries, GeoBoundingBox? boundingBox, IReadOnlyDictionary<string, |
| | 30 | | { |
| 16 | 31 | | Argument.AssertNotNull(geometries, nameof(geometries)); |
| | 32 | |
|
| 16 | 33 | | Geometries = geometries.ToArray(); |
| 16 | 34 | | } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Gets the list of <see cref="GeoObject"/> geometry is composed of. |
| | 38 | | /// </summary> |
| 24 | 39 | | internal IReadOnlyList<GeoObject> Geometries { get; } |
| | 40 | |
|
| | 41 | | /// <inheritdoc /> |
| | 42 | | public IEnumerator<GeoObject> GetEnumerator() |
| | 43 | | { |
| 0 | 44 | | return Geometries.GetEnumerator(); |
| | 45 | | } |
| | 46 | |
|
| | 47 | | IEnumerator IEnumerable.GetEnumerator() |
| | 48 | | { |
| 0 | 49 | | return GetEnumerator(); |
| | 50 | | } |
| | 51 | |
|
| | 52 | | /// <inheritdoc /> |
| 0 | 53 | | public int Count => Geometries.Count; |
| | 54 | |
|
| | 55 | | /// <inheritdoc /> |
| 0 | 56 | | public GeoObject this[int index] => Geometries[index]; |
| | 57 | | } |
| | 58 | | } |