/// <inheritdoc/>
        /// <remarks>
        /// The <see cref="Polygon.ExteriorRing"/> is guaranteed to be orientated counter-clockwise.
        /// <br/>The <see cref="Polygon.InteriorRings"/> are guaranteed to be orientated clockwise.
        /// </remarks>
        public override Polygon CreatePolygon(LinearRing shell, LinearRing[] holes)
        {
            if (shell != null)
            {
                if (!shell.IsCCW)
                {
                    shell = ReverseRing(shell);
                }
            }

            if (holes != null)
            {
                for (int i = 0; i < holes.Length; i++)
                {
                    if (holes[i].IsCCW)
                    {
                        holes[i] = ReverseRing(holes[i]);
                    }
                }
            }

            return(base.CreatePolygon(shell, holes));
        }
Example #2
0
        /// <summary>
        /// Constructs a <c>Polygon</c> with the given exterior boundary and
        /// interior boundaries.
        /// </summary>
        /// <param name="shell">
        /// The outer boundary of the new <c>Polygon</c>,
        /// or <c>null</c> or an empty <c>LinearRing</c> if the empty
        /// point is to be created.
        /// </param>
        /// <param name="holes">
        /// The inner boundaries of the new <c>Polygon</c>
        /// , or <c>null</c> or empty <c>LinearRing</c>s if the empty
        /// point is to be created.
        /// </param>
        /// <param name="factory"></param>
        public Polygon(LinearRing shell, LinearRing[] holes, GeometryFactory factory) : base(factory)
        {
            if (shell == null)
            {
                shell = Factory.CreateLinearRing();
            }
            if (holes == null)
            {
                holes = new LinearRing[] { }
            }
            ;
            if (HasNullElements(holes))
            {
                throw new ArgumentException("holes must not contain null elements");
            }
            if (shell.IsEmpty && HasNonEmptyElements(holes))
            {
                throw new ArgumentException("shell is empty but holes are not");
            }

            _shell = shell;
            _holes = holes;
        }
Example #3
0
 /// <summary>
 /// Constructs a <c>Polygon</c> with the given exterior boundary.
 /// </summary>
 /// <param name="shell">the outer boundary of the new <c>Polygon</c>, or
 /// <c>null</c> or an empty <c>LinearRing</c> if
 /// the empty geometry is to be created.</param>
 /// <returns>the created Polygon</returns>
 /// <exception cref="ArgumentException">If the boundary ring is invalid</exception>
 public virtual Polygon CreatePolygon(LinearRing shell)
 {
     return(CreatePolygon(shell, null));
 }
Example #4
0
 /// <summary>
 /// Constructs a <c>Polygon</c> with the given exterior boundary and
 /// interior boundaries.
 /// </summary>
 /// <param name="shell">
 /// The outer boundary of the new <c>Polygon</c>, or
 /// <c>null</c> or an empty <c>LinearRing</c> if
 /// the empty point is to be created.
 /// </param>
 /// <param name="holes">
 /// The inner boundaries of the new <c>Polygon</c>, or
 /// <c>null</c> or empty <c>LinearRing</c> s if
 /// the empty point is to be created.
 /// </param>
 /// <returns>A <see cref="Polygon"/> object</returns>
 public virtual Polygon CreatePolygon(LinearRing shell, LinearRing[] holes)
 {
     return(new Polygon(shell, holes, this));
 }
Example #5
0
 /// <summary>
 /// Constructs a <c>Polygon</c> with the given exterior boundary.
 /// </summary>
 /// <param name="shell">
 /// The outer boundary of the new <c>Polygon</c>,
 /// or <c>null</c> or an empty <c>LinearRing</c> if the empty
 /// polygon is to be created.
 /// </param>
 public Polygon(LinearRing shell) : this(shell, null, DefaultFactory)
 {
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Polygon"/> class.
 /// </summary>
 /// <param name="shell">
 /// The outer boundary of the new <c>Polygon</c>,
 /// or <c>null</c> or an empty <c>LinearRing</c> if the empty
 /// point is to be created.
 /// </param>
 /// <param name="holes">
 /// The inner boundaries of the new <c>Polygon</c>
 /// , or <c>null</c> or empty <c>LinearRing</c>s if the empty
 /// point is to be created.
 /// </param>
 /// <remarks>
 /// For create this <see cref="Geometry"/> is used a standard <see cref="GeometryFactory"/>
 /// with <see cref="PrecisionModel" /> <c> == </c> <see cref="PrecisionModels.Floating"/>.
 /// </remarks>
 public Polygon(LinearRing shell, LinearRing[] holes) : this(shell, holes, DefaultFactory)
 {
 }
Example #7
0
        /* BEGIN ADDED BY MPAUL42: monoGIS team */

        /// <summary>
        /// Constructs a <c>Polygon</c> with the given exterior boundary.
        /// </summary>
        /// <param name="shell">
        /// The outer boundary of the new <c>Polygon</c>,
        /// or <c>null</c> or an empty <c>LinearRing</c> if the empty
        /// polygon is to be created.
        /// </param>
        /// <param name="factory"></param>
        public Polygon(LinearRing shell, GeometryFactory factory) : this(shell, null, factory)
        {
        }
 private static LinearRing ReverseRing(LinearRing ring)
 {
     return((LinearRing)ring.Reverse());
 }
 /// <inheritdoc/>
 /// <remarks>
 /// The <see cref="Polygon.ExteriorRing"/> is guaranteed to be orientated counter-clockwise.
 /// </remarks>
 public override Polygon CreatePolygon(LinearRing shell)
 {
     return(CreatePolygon(shell, null));
 }