public GeometryPart([NotNull] GeometryPart geometryPart) { Assert.ArgumentNotNull(geometryPart, nameof(geometryPart)); LowLevelGeometries = new List <IGeometry>(geometryPart.LowLevelGeometries.Count); InnerRings = new List <IGeometry>(geometryPart.InnerRings.Count); JoinPart(geometryPart); }
private static IList <GeometryPart> GetMultipatchExteriorRingParts( [NotNull] IMultiPatch2 multipatch) { var geometryCollection = (IGeometryCollection)multipatch; var partsByExteriorRing = new Dictionary <IRing, GeometryPart>(); for (var i = 0; i < geometryCollection.GeometryCount; i++) { var ring = geometryCollection.Geometry[i] as IRing; if (ring == null) { continue; } // for multipatches we cannot use IsExterior property - it's just not correct var isBeginningRing = false; bool isExterior = multipatch.GetRingType(ring, ref isBeginningRing) != esriMultiPatchRingType.esriMultiPatchInnerRing; if (isExterior) { var newExteriorPart = new GeometryPart(ring) { LabelText = Convert.ToString(i) }; partsByExteriorRing.Add(ring, newExteriorPart); } else { IRing exteriorRing = multipatch.FindBeginningRing(ring); Assert.NotNull(exteriorRing, "No exterior ring found for inner ring"); GeometryPart part; if (!partsByExteriorRing.TryGetValue(exteriorRing, out part)) { part = new GeometryPart(exteriorRing); partsByExteriorRing.Add(exteriorRing, part); } part.AddInnerRingGeometry(ring); } } return(partsByExteriorRing.Values.ToList()); }
public static IEnumerable <GeometryPart> FromGeometry( IGeometry originalGeometry, bool groupPartsByPointIDs = false) { // each outer ring builds a low level part with all its inner ring ICollection <GeometryPart> lowLevelParts = CollectionUtils.GetCollection( GetGeometryPartsPerLowLevelGeometry(originalGeometry)); if (!groupPartsByPointIDs || !GeometryUtils.IsPointIDAware(originalGeometry)) { return(lowLevelParts); } var partsById = new Dictionary <int, GeometryPart>(); foreach (GeometryPart lowLevelPart in lowLevelParts) { IGeometry mainLowLevelGeometry = lowLevelPart.FirstGeometry; int vertexId; if (GeometryUtils.HasUniqueVertexId(mainLowLevelGeometry, out vertexId)) { GeometryPart existingPart; if (partsById.TryGetValue(vertexId, out existingPart)) { existingPart.JoinPart(lowLevelPart); } else { // It is important not to use a direct reference of the lowLevelPart, otherwise it will be changed // by merging other lowLevelParts into it. Create a new, aggregate part for each vertex id instead. var aggregate = new GeometryPart(lowLevelPart); aggregate.LabelText = Convert.ToString(vertexId); partsById.Add(vertexId, aggregate); } } else { // all parts need proper vertex ids! return(lowLevelParts); } } return(partsById.Values); }
/// <summary> /// Identifies each exterior ring as separate part, containing all its interior rings /// </summary> /// <param name="polygon"></param> /// <returns></returns> private static IEnumerable <GeometryPart> GetPolygonExteriorRingParts( [NotNull] IPolygon4 polygon) { // for all interior rings, assign to exterior ring's part // all exterior rings, add them to result if not yet added var partsByExteriorRing = new Dictionary <IRing, GeometryPart>(); var geometryCollection = (IGeometryCollection)polygon; for (var i = 0; i < geometryCollection.GeometryCount; i++) { var ring = (IRing)geometryCollection.Geometry[i]; if (ring.IsExterior) { partsByExteriorRing.Add(ring, new GeometryPart(ring)); } else { IRing exteriorRing = polygon.FindExteriorRing(ring); Assert.NotNull("No exterior ring found for inner ring"); GeometryPart part; if (!partsByExteriorRing.TryGetValue(exteriorRing, out part)) { part = new GeometryPart(exteriorRing); partsByExteriorRing.Add(exteriorRing, part); } part.AddInnerRingGeometry(ring); } } return(partsByExteriorRing.Values); }
public void JoinPart([NotNull] GeometryPart other) { LowLevelGeometries.AddRange(other.LowLevelGeometries); InnerRings.AddRange(other.InnerRings); }
public static IEnumerable <GeometryPart> GetGeometryParts( [NotNull] IGeometry originalGeometry, bool groupPartsByPointIDs) { return(GeometryPart.FromGeometry(originalGeometry, groupPartsByPointIDs)); }