Exemplo n.º 1
0
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Method fills Serialization information about GPGeometry.
        /// </summary>
        /// <param name="info">Serialization Info.</param>
        /// <param name="context">Streaming Context.</param>
        /// <exception cref="SerializationException">In case of geometry type is not
        /// supported.</exception>
        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            if (_value is GPPoint)
            {
                GPPoint pt = (GPPoint)_value;
                info.AddValue(GPAttribute.POINT_X, pt.X);
                info.AddValue(GPAttribute.POINT_Y, pt.Y);
            }
            else if (_value is GPPolygon)
            {
                GPPolygon polygon = _value as GPPolygon;
                info.AddValue(GPAttribute.POLYGON_RINGS, polygon.Rings);
            }
            else if (_value is GPPolyline)
            {
                GPPolyline polyline = _value as GPPolyline;
                info.AddValue(GPAttribute.POLYLINE_PATHS, polyline.Paths);
            }
            else
            {
                // Unsupported geometry type.
                throw new SerializationException(
                          Properties.Messages.Error_UnsupportedGPGeometryObject);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Method converts Polygon object to GPPolygon object.
        /// </summary>
        /// <param name="polygon">Polygon object to convert.</param>
        /// <returns>GPPolygon object.</returns>
        public static GPPolygon PolygonToGPPolygon(Polygon polygon)
        {
            double[][][] rings = new double[polygon.Groups.Length][][];
            for (int nGroup = 0; nGroup < polygon.Groups.Length; nGroup++)
            {
                rings[nGroup] = new double[polygon.Groups[nGroup]][];

                Point[] points = polygon.GetGroupPoints(nGroup);
                for (int nPoint = 0; nPoint < points.Length; nPoint++)
                {
                    rings[nGroup][nPoint]    = new double[2];
                    rings[nGroup][nPoint][0] = points[nPoint].X;
                    rings[nGroup][nPoint][1] = points[nPoint].Y;
                }
            }

            GPPolygon gppolygon = new GPPolygon();

            gppolygon.Rings            = rings;
            gppolygon.SpatialReference = new GPSpatialReference(WKID);

            return(gppolygon);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Converts the specified <see cref="GPPolygon"/> object to the <see cref="Polygon"/> one.
 /// </summary>
 /// <param name="polygon">The reference to the <see cref="GPPolygon"/> object to be
 /// converted.</param>
 /// <returns>A new <see cref="Polygon"/> object equivalent to the specified
 /// polygon.</returns>
 public static Polygon GPPolygonToPolygon(GPPolygon polygon)
 {
     return(_MakePolyCurve(polygon.Rings, (groups, points) => new Polygon(groups, points)));
 }