示例#1
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.GeometryType)
            {
            case SmGeometries.GeometryType2.LineString:
            case SmGeometries.GeometryType2.Point:
            case SmGeometries.GeometryType2.Polygon:
                _PopulateSimpleType(sink, _Geometry);
                break;

            case SmGeometries.GeometryType2.GeometryCollection:
            case SmGeometries.GeometryType2.MultiLineString:
            case SmGeometries.GeometryType2.MultiPoint:
            case SmGeometries.GeometryType2.MultiPolygon:
                sink.BeginGeometry(GeometryTypeUtils.Convert(_Geometry.GeometryType));
                foreach (SmGeometries.Geometry g in (IEnumerable <SmGeometries.Geometry>)_Geometry)
                {
                    _PopulateSimpleType(sink, g);
                }
                sink.EndGeometry();
                break;

            default:
                throw new NotSupportedException(
                          string.Format(
                              CultureInfo.CurrentCulture,
                              SR.UnsupportedGeometryTypeException,
                              _Geometry.GeometryType
                              )
                          );
            }
        }
示例#2
0
        private static void _PopulateSimpleType(IGeometrySink sink, SmGeometries.Geometry geometry)
        {
            sink.BeginGeometry(GeometryTypeUtils.Convert(geometry.GeometryType));

            switch (geometry.GeometryType)
            {
            case SmGeometries.GeometryType2.LineString:
                CreateFigure(sink, ((SmGeometries.LineString)geometry).Vertices);
                break;

            case SmGeometries.GeometryType2.Point:
                CreateFigure(sink, new SmGeometries.Point[] { (SmGeometries.Point)geometry });
                break;

            case SmGeometries.GeometryType2.Polygon:
            {
                var pol = (SmGeometries.Polygon)geometry;
                CreateFigure(sink, pol.ExteriorRing.Vertices);

                if (pol.InteriorRings != null)
                {
                    foreach (SmGeometries.LinearRing lr in pol.InteriorRings)
                    {
                        CreateFigure(sink, lr.Vertices);
                    }
                }
            }
            break;

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

            sink.EndGeometry();
        }