コード例 #1
0
        public IPolygon CreatePolygon(ILinearRing shell, IEnumerable<ILinearRing> holes)
        {
            LinearRing l = shell as LinearRing;

            if (l == null)
            {
                throw new ArgumentException("Parameter must be a non-null LinearRing instance");
            }

            Polygon p = new Polygon(l, Enumerable.Downcast<LinearRing, ILinearRing>(holes));
            p.Factory = this;
            return p;
        }
コード例 #2
0
        public IGeometry ToGeometry(IExtents envelopeInternal)
        {
            ICoordinate[] verticies = new ICoordinate[5];

            ICoordinate min = envelopeInternal.Min;
            ICoordinate max = envelopeInternal.Max;

            verticies[0] = max;
            verticies[1] = CoordinateFactory.Create(min[Ordinates.X], max[Ordinates.Y]);
            verticies[2] = min;
            verticies[3] = CoordinateFactory.Create(max[Ordinates.X], min[Ordinates.Y]);
            verticies[4] = max;

            LinearRing ring = new LinearRing(verticies);
            ring.Factory = this;
            Polygon p = new Polygon(ring);
            p.Factory = this;
            return p;
        }
コード例 #3
0
        public IPolygon CreatePolygon(ILinearRing shell)
        {
            LinearRing l = shell as LinearRing;

            if(l == null)
            {
                throw new ArgumentException(
                    "Parameter must be a non-null LinearRing instance");
            }

            //l.Factory = this;
            Polygon p = new Polygon(l);
            p.Factory = this;
            return p;
        }
コード例 #4
0
 public IPolygon CreatePolygon(IEnumerable<ICoordinate> shell)
 {
     LinearRing ring = CreateLinearRing(shell) as LinearRing;
     ring.Factory = this;
     Polygon p = new Polygon(ring);
     p.Factory = this;
     return p;
 }
コード例 #5
0
 public IPolygon CreatePolygon()
 {
     Polygon p = new Polygon();
     p.Factory = this;
     return p;
 }
コード例 #6
0
ファイル: Polygon.cs プロジェクト: pobingwanghai/SharpMapV2
        /// <summary>
        /// Creates a deep copy of the Polygon.
        /// </summary>
        /// <returns>A copy of the Polygon instance.</returns>
        public override Geometry Clone()
        {
            Polygon p = new Polygon();
            p.ExteriorRing = ExteriorRing.Clone() as LinearRing;

            foreach (LinearRing ring in InteriorRings)
            {
                p.InteriorRings.Add(ring.Clone() as LinearRing);
            }

            return p;
        }
コード例 #7
0
ファイル: Polygon.cs プロジェクト: pobingwanghai/SharpMapV2
        ///// <summary>
        ///// Transforms the polygon to image coordinates, based on the map
        ///// </summary>
        ///// <param name="map">Map to base coordinates on</param>
        ///// <returns>Polygon in image coordinates</returns>
        //public RenderPoint[] TransformToView(SharpMap.Map map)
        //{

        //    Int32 vertices = _ExteriorRing.Vertices.Count;
        //    for (Int32 i = 0; i < _InteriorRings.Count;i++)
        //        vertices += _InteriorRings[i].Vertices.Count;

        //    System.Drawing.PointF[] v = new System.Drawing.PointF[vertices];
        //    for (Int32 i = 0; i < _ExteriorRing.Vertices.Count; i++)
        //        v[i] = SharpMap.Utilities.Transform.WorldToMap(_ExteriorRing.Vertices[i], map);
        //    Int32 j = _ExteriorRing.Vertices.Count;
        //    for (Int32 k = 0; k < _InteriorRings.Count;k++)
        //    {
        //        for (Int32 i = 0; i < _InteriorRings[k].Vertices.Count; i++)
        //            v[j + i] = SharpMap.Utilities.Transform.WorldToMap(_InteriorRings[k].Vertices[i], map);
        //        j += _InteriorRings[k].Vertices.Count;
        //    }
        //    return v;
        //}

        #region "Inherited methods from abstract class Geometry"

        /// <summary>
        /// Determines if this Polygon and the specified Polygon object has the same values
        /// </summary>
        /// <param name="p">Polygon to compare with</param>
        /// <returns></returns>
        public Boolean Equals(Polygon p)
        {
            if (ReferenceEquals(p, null))
            {
                return false;
            }

            if (!p.ExteriorRing.Equals(ExteriorRing))
            {
                return false;
            }

            if (p.InteriorRings.Count != InteriorRings.Count)
            {
                return false;
            }

            for (Int32 i = 0; i < p.InteriorRings.Count; i++)
            {
                if (!p.InteriorRings[i].Equals(InteriorRings[i]))
                {
                    return false;
                }
            }

            return true;
        }