コード例 #1
0
        public IGeometry ToGeometry(IGeometryFactory geomFactory)
        {
            if (IsNull)
            {
                return(geomFactory.CreatePoint((ICoordinateSequence)null));
            }

            Coordinate px00 = new Coordinate(_minX, _minA - _minX);
            Coordinate px01 = new Coordinate(_minX, _minX - _minB);

            Coordinate px10 = new Coordinate(_maxX, _maxX - _maxB);
            Coordinate px11 = new Coordinate(_maxX, _maxA - _maxX);

            Coordinate py00 = new Coordinate(_minA - _minY, _minY);
            Coordinate py01 = new Coordinate(_minY + _maxB, _minY);

            Coordinate py10 = new Coordinate(_maxY + _minB, _maxY);
            Coordinate py11 = new Coordinate(_maxA - _maxY, _maxY);

            IPrecisionModel pm = geomFactory.PrecisionModel;

            pm.MakePrecise(px00);
            pm.MakePrecise(px01);
            pm.MakePrecise(px10);
            pm.MakePrecise(px11);
            pm.MakePrecise(py00);
            pm.MakePrecise(py01);
            pm.MakePrecise(py10);
            pm.MakePrecise(py11);

            CoordinateList coordList = new CoordinateList();

            coordList.Add(px00, false);
            coordList.Add(px01, false);
            coordList.Add(py10, false);
            coordList.Add(py11, false);
            coordList.Add(px11, false);
            coordList.Add(px10, false);
            coordList.Add(py01, false);
            coordList.Add(py00, false);

            if (coordList.Count == 1)
            {
                return(geomFactory.CreatePoint(px00));
            }
            Coordinate[] pts;
            if (coordList.Count == 2)
            {
                pts = coordList.ToCoordinateArray();
                return(geomFactory.CreateLineString(pts));
            }
            // must be a polygon, so add closing point
            coordList.Add(px00, false);
            pts = coordList.ToCoordinateArray();
            return(geomFactory.CreatePolygon(geomFactory.CreateLinearRing(pts), null));
        }
コード例 #2
0
        /// <summary>
        /// Returns a deep copy of this collection.
        /// </summary>
        /// <returns>The copied object.</returns>
        public object Clone()
        {
            var copy = new CoordinateList();

            foreach (var c in this)
            {
                copy.Add(c.Copy());
            }
            return(copy);
        }
コード例 #3
0
        /// <summary>
        /// If the coordinate array argument has repeated points,
        /// constructs a new array containing no repeated points.
        /// Otherwise, returns the argument.
        /// </summary>
        /// <param name="coord"></param>
        /// <returns></returns>
        public static Coordinate[] RemoveRepeatedPoints(Coordinate[] coord)
        {
            if (!HasRepeatedPoints(coord))
            {
                return(coord);
            }
            var coordList = new CoordinateList(coord, false);

            return(coordList.ToCoordinateArray());
        }
コード例 #4
0
        /// <summary>
        /// Returns a deep copy of this collection.
        /// </summary>
        /// <returns>The copied object.</returns>
        public object Clone()
        {
            CoordinateList copy = new CoordinateList();

            foreach (Coordinate c in this)
            {
                copy.Add((Coordinate)c.Clone());
            }
            return(copy);
        }
コード例 #5
0
        /**
         * Extracts the coordinates which intersect an {@link Envelope}.
         *
         * @param coordinates the coordinates to scan
         * @param env the envelope to intersect with
         * @return an array of the coordinates which intersect the envelope
         */
        public static Coordinate[] Intersection(Coordinate[] coordinates, Envelope env)
        {
            var coordList = new CoordinateList();

            for (int i = 0; i < coordinates.Length; i++)
            {
                var c = coordinates[i];
                if (env.Intersects(c))
                {
                    coordList.Add(c, true);
                }
            }
            return(coordList.ToCoordinateArray());
        }