public static IPolygon CreatePolygon(IGeometry template, IEnumerable <Linestring> rings) { IPolygon poly = GeometryFactory.CreateEmptyPolygon(template); IRing ringTemplate = GeometryFactory.CreateEmptyRing(template); foreach (Linestring closedLinestring in rings) { Assert.True(closedLinestring.IsClosed, "Linestring is not closed."); IRing ring = CreateRing(closedLinestring, ringTemplate); ((IGeometryCollection)poly).AddGeometry(ring); } ((IGeometryCollection)poly).GeometriesChanged(); return(poly); }
private static T CreateEmptyPolycurve <T>(Ordinates ordinates, [CanBeNull] IGeometry template = null) where T : IPolycurve { bool createPolygon = typeof(IPolygon).IsAssignableFrom(typeof(T)); if (template != null) { return(createPolygon ? (T)GeometryFactory.CreateEmptyPolygon(template) : (T)GeometryFactory.CreateEmptyPolyline(template)); } bool zAware = ordinates == Ordinates.Xyz || ordinates == Ordinates.Xyzm; bool mAware = ordinates == Ordinates.Xym || ordinates == Ordinates.Xyzm; return(createPolygon ? (T)GeometryFactory.CreatePolygon(null, zAware, mAware) : (T)GeometryFactory.CreateEmptyPolyline(null, zAware, mAware)); }
public static IPolygon CreatePolygon(IGeometry template, IRing ringTemplate, RingGroup ringGroup) { IPolygon poly = GeometryFactory.CreateEmptyPolygon(template); IRing mainRing = CreateRing(ringGroup.ExteriorRing, ringTemplate); ((IGeometryCollection)poly).AddGeometry(mainRing); foreach (Linestring interiorRing in ringGroup.InteriorRings) { IRing inner = CreateRing(interiorRing, ringTemplate); ((IGeometryCollection)poly).AddGeometry(inner); } ((IGeometryCollection)poly).GeometriesChanged(); return(poly); }