Пример #1
0
        private static void _PopulateSimpleType(IGeometrySink sink, FGeometry.IGeometry geometry)
        {
            sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.DerivedType));

            switch (geometry.DerivedType)
            {
            case FCommon.GeometryType.GeometryType_LineString:
                using (FGeometry.DirectPositionCollection positions = ((FGeometry.ILineString)geometry).Positions)
                    CreateFigure(sink, positions);
                break;

            case FCommon.GeometryType.GeometryType_Point:
                using (FGeometry.DirectPositionCollection positions = new FGeometry.DirectPositionCollection())
                    using (FGeometry.IDirectPosition dp = ((FGeometry.IPoint)geometry).Position)
                    {
                        positions.Add(dp);
                        CreateFigure(sink, positions);
                    }
                break;

            case FCommon.GeometryType.GeometryType_Polygon:
            {
                var polygon = (FGeometry.IPolygon)geometry;
                using (FGeometry.ILinearRing exterior = polygon.ExteriorRing)
                    using (FGeometry.DirectPositionCollection positions = exterior.Positions)
                        CreateFigure(sink, positions);

                for (int i = 0; i < polygon.InteriorRingCount; ++i)
                {
                    using (FGeometry.ILinearRing interior = polygon.GetInteriorRing(i))
                        using (FGeometry.DirectPositionCollection positions = interior.Positions)
                            CreateFigure(sink, positions);
                }
            }
            break;

            default:
                throw new NotSupportedException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              SR.UnsupportedGeometryTypeException,
                              geometry.DerivedType
                              )
                          );
            }

            sink.EndGeometry();
        }
Пример #2
0
 /// <summary>Starts the call sequence for the specified <see cref="GeometryType" />.</summary>
 /// <param name="type">The type of the geometry to build.</param>
 public override void BeginGeometry(GeometryType type)
 {
     _GeometryType = GeometryTypeUtils.Convert(type);
 }
Пример #3
0
        /// <summary>Applies a geometry type call sequence to the specified <paramref name="sink" />.</summary>
        /// <param name="sink">The sink to populate.</param>
        /// <remarks>
        ///   <para>The call sequence is a set of figures, lines, and points for geometry types.</para>
        /// </remarks>
        public void Populate(IGeometrySink sink)
        {
            sink.SetCoordinateSystem(CoordinateSystem);

            switch (_Geometry.DerivedType)
            {
            case FCommon.GeometryType.GeometryType_LineString:
            case FCommon.GeometryType.GeometryType_Point:
            case FCommon.GeometryType.GeometryType_Polygon:
                _PopulateSimpleType(sink, _Geometry);
                break;

            case FCommon.GeometryType.GeometryType_MultiLineString:
                sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType));
                {
                    var multiLineString = (FGeometry.IMultiLineString)_Geometry;
                    for (int i = 0; i < multiLineString.Count; ++i)
                    {
                        using (FGeometry.ILineString lineString = multiLineString[i])
                            _PopulateSimpleType(sink, lineString);
                    }
                }
                sink.EndGeometry();
                break;

            case FCommon.GeometryType.GeometryType_MultiPoint:
                sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType));
                {
                    var multiPoint = (FGeometry.IMultiPoint)_Geometry;
                    using (FGeometry.DirectPositionCollection positions = new FGeometry.DirectPositionCollection())
                        for (int i = 0; i < multiPoint.Count; ++i)
                        {
                            using (FGeometry.IPoint point = multiPoint[i])
                                _PopulateSimpleType(sink, point);
                        }
                }
                sink.EndGeometry();
                break;

            case FCommon.GeometryType.GeometryType_MultiPolygon:
                sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType));
                {
                    var multiPolygon = (FGeometry.IMultiPolygon)_Geometry;
                    for (int i = 0; i < multiPolygon.Count; ++i)
                    {
                        using (FGeometry.IPolygon polygon = multiPolygon[i])
                            _PopulateSimpleType(sink, polygon);
                    }
                }
                sink.EndGeometry();
                break;

            case FCommon.GeometryType.GeometryType_MultiGeometry:
                sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.DerivedType));
                {
                    var multiGeometry = (FGeometry.IMultiGeometry)_Geometry;
                    for (int i = 0; i < multiGeometry.Count; ++i)
                    {
                        using (FGeometry.IGeometry geometry = multiGeometry[i])
                            _PopulateSimpleType(sink, geometry);
                    }
                }
                sink.EndGeometry();
                break;

            default:
                throw new NotSupportedException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              SR.UnsupportedGeometryTypeException,
                              _Geometry.DerivedType
                              )
                          );
            }
        }