/
TMultiPolygon.cs
58 lines (48 loc) · 1.81 KB
/
TMultiPolygon.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
using System.Collections.Generic;
using System.Linq;
// ReSharper disable InconsistentNaming
namespace RosReestrImp.Geometry
{
/// <summary>Мултиполигон</summary>
public class TMultiPolygon : TGeometryCollection
{
/// <summary></summary>
public new static readonly string Type = "MULTIPOLYGON";
/// <summary>Конструктор из списка</summary>
/// <param name="nPolygons"></param>
public TMultiPolygon(List<TPolygon> nPolygons) //: base((List<TGeometry>)nPolygons.Cast<TGeometry>())
{
Geometries.AddRange(nPolygons.GetRange(0, nPolygons.Count));
}
/// <inheritdoc/>
public override bool IsEmpty() => Geometries is not { Count: > 0 };
/// <inheritdoc/>
public override GeometryType GetGeometryType() => GeometryType.MultiPolygon;
/// <inheritdoc/>
public override double[] GetXYArray() => null;
/// <inheritdoc/>
public override double[] GetZArray() => null;
/// <inheritdoc/>
public override TMBR GetMBR()
{
TMBR res = null;
foreach (var p in Geometries)
{
if (res == null) res = p.GetMBR();
else res.AddMBR(p.GetMBR());
}
return res;
}
/// <inheritdoc/>
public override bool IsValid()
{
if (Geometries == null) return false;
return Geometries.Count > 0 && Geometries.All(ls => ls.IsValid());
}
/// <inheritdoc/>
public override string ToShortWKT2D()
=> string.Join(", ", Geometries.Select(p => $"({p.ToShortWKT2D()})"));
/// <inheritdoc/>
public override string ToWKT2D() => IsEmpty() ? $"{Type} {Emp}" : $"{Type}({ToShortWKT2D()})";
}
}