-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
GeoCollection.cs
63 lines (53 loc) · 2.21 KB
/
GeoCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
namespace Azure.Core.GeoJson
{
/// <summary>
/// Represents a geometry that is composed of multiple geometries.
/// </summary>
[JsonConverter(typeof(GeoJsonConverter))]
public sealed class GeoCollection : GeoObject, IReadOnlyList<GeoObject>
{
/// <summary>
/// Initializes new instance of <see cref="GeoCollection"/>.
/// </summary>
/// <param name="geometries">The collection of inner geometries.</param>
public GeoCollection(IEnumerable<GeoObject> geometries): this(geometries, null, DefaultProperties)
{
}
/// <summary>
/// Initializes new instance of <see cref="GeoCollection"/>.
/// </summary>
/// <param name="geometries">The collection of inner geometries.</param>
/// <param name="boundingBox">The <see cref="GeoBoundingBox"/> to use.</param>
/// <param name="customProperties">The set of custom properties associated with the <see cref="GeoObject"/>.</param>
public GeoCollection(IEnumerable<GeoObject> geometries, GeoBoundingBox? boundingBox, IReadOnlyDictionary<string, object?> customProperties): base(boundingBox, customProperties)
{
Argument.AssertNotNull(geometries, nameof(geometries));
Geometries = geometries.ToArray();
}
/// <summary>
/// Gets the list of <see cref="GeoObject"/> geometry is composed of.
/// </summary>
internal IReadOnlyList<GeoObject> Geometries { get; }
/// <inheritdoc />
public IEnumerator<GeoObject> GetEnumerator()
{
return Geometries.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <inheritdoc />
public int Count => Geometries.Count;
/// <inheritdoc />
public GeoObject this[int index] => Geometries[index];
/// <inheritdoc />
public override GeoObjectType Type { get; } = GeoObjectType.GeometryCollection;
}
}