Esempio n. 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();
        }
Esempio n. 2
0
        private static void CreateFigure(IGeometrySink sink, FGeometry.DirectPositionCollection positions)
        {
            if ((positions == null) || (positions.Count == 0))
            {
                return;
            }

            using (FGeometry.IDirectPosition p0 = positions[0])
            {
                if (p0.Dimensionality > 2)
                {
                    sink.BeginFigure(p0.X, p0.Y, p0.Z);
                }
                else
                {
                    sink.BeginFigure(p0.X, p0.Y, null);
                }
            }

            for (int i = 1; i < positions.Count; ++i)
            {
                using (FGeometry.IDirectPosition pi = positions[i])
                {
                    if (pi.Dimensionality > 2)
                    {
                        sink.AddLine(pi.X, pi.Y, pi.Z);
                    }
                    else
                    {
                        sink.AddLine(pi.X, pi.Y, null);
                    }
                }
            }

            sink.EndFigure();
        }
Esempio n. 3
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();
        }
Esempio n. 4
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
                    )
                );
            }

        }
Esempio n. 5
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
                              )
                          );
            }
        }