IRing GetRing(Ring r) { CurveSegmentCollection csc = new CurveSegmentCollection(); foreach (IDivider d in r.Edge) { LineGeometry line = d.LineGeometry; ICurveSegmentAbstract cseg = null; if (line is SectionGeometry) { SectionGeometry section = (line as SectionGeometry); line = section.Make(); } if (line is MultiSegmentGeometry) { MultiSegmentGeometry mseg = (line as MultiSegmentGeometry); DirectPositionCollection dpc = GetDirectPositions(mseg.Data); cseg = m_Factory.CreateLineStringSegment(dpc); } else if (line is SegmentGeometry) { SegmentGeometry segment = (line as SegmentGeometry); DirectPositionCollection dpc = GetDirectPositions(new IPosition[] { segment.Start, segment.End }); cseg = m_Factory.CreateLineStringSegment(dpc); } else if (line is ArcGeometry) { ArcGeometry arc = (line as ArcGeometry); IPosition mp = arc.GetMidPosition(); IDirectPosition bc = m_Factory.CreatePositionXY(arc.BC.X, arc.BC.Y); IDirectPosition mid = m_Factory.CreatePositionXY(mp.X, mp.Y); IDirectPosition ec = m_Factory.CreatePositionXY(arc.EC.X, arc.EC.Y); cseg = m_Factory.CreateCircularArcSegment(bc, mid, ec); } else { throw new NotSupportedException("Unknown line type: " + line.GetType().Name); } csc.Add(cseg); } return(m_Factory.CreateRing(csc)); }
private static ICurveSegmentAbstract FlattenCurveSegment(ICurveSegmentAbstract curveSegment, FgfGeometryFactory factory) { switch (curveSegment.DerivedType) { case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_CircularArcSegment: return(FlattenCircularArcSegment((ICircularArcSegment)curveSegment, factory)); case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_LinearRing: throw new NotSupportedException("Unable to flatten this segment type"); //Uh, ILinearRing doesn't inherit from ICurveSegmentAbstract case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_LineStringSegment: return(FlattenLineStringSegment((ILineStringSegment)curveSegment, factory)); case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_Ring: throw new NotSupportedException("Unable to flatten this segment type"); //Uh, IRing doesn't inherit from ICurveSegmentAbstract } throw new ArgumentException("Unknown curve segment type"); }
private static ICurveSegmentAbstract FlattenCurveSegment(ICurveSegmentAbstract curveSegment, FgfGeometryFactory factory) { switch (curveSegment.DerivedType) { case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_CircularArcSegment: return FlattenCircularArcSegment((ICircularArcSegment)curveSegment, factory); case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_LinearRing: throw new NotSupportedException("Unable to flatten this segment type"); //Uh, ILinearRing doesn't inherit from ICurveSegmentAbstract case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_LineStringSegment: return FlattenLineStringSegment((ILineStringSegment)curveSegment, factory); case OSGeo.FDO.Common.GeometryComponentType.GeometryComponentType_Ring: throw new NotSupportedException("Unable to flatten this segment type"); //Uh, IRing doesn't inherit from ICurveSegmentAbstract } throw new ArgumentException("Unknown curve segment type"); }