Example #1
0
        /// <summary>
        /// Inserts a coordinate made up of the ordinates (<paramref name="x"/>, <paramref name="y"/>, <paramref name="z"/>, <paramref name="m"/>) at index <paramref name="index"/> to the buffer.
        ///  </summary>
        /// <param name="index">The index at which to insert the ordinate.</param>
        /// <param name="x">The x-Ordinate</param>
        /// <param name="y">The y-Ordinate</param>
        /// <param name="z">The (optional) z-Ordinate</param>
        /// <param name="m">The (optional) m-Ordinate</param>
        /// <param name="allowRepeated">Allows repeated coordinates to be added</param>
        /// <returns><value>true</value> if the coordinate was successfully inserted.</returns>
        public bool InsertCoordinate(int index, double x, double y, double?z = null, double?m = null, bool allowRepeated = true)
        {
            // Assign NoDataValue if not provided
            // Update defined flag and set Coordinate.NullValue where necessary
            var toAdd = new XYZM(x,
                                 y,
                                 z ?? _doubleNoDataChecker.NoDataValue,
                                 m ?? _doubleNoDataChecker.NoDataValue);

            CheckDefinedOrdinates(ref toAdd.Z, ref toAdd.M);

            if (!allowRepeated)
            {
                if (index > 0)
                {
                    //Check before
                    if (_coordinates[index - 1].EqualInXY(toAdd))
                    {
                        return(false);
                    }
                }
                if (index >= 0 && index < _coordinates.Count)
                {
                    //Check after
                    if (_coordinates[index].EqualInXY(toAdd))
                    {
                        return(false);
                    }
                }
            }
            _coordinates.Insert(index, toAdd);

            // Update envelope
            _extents.ExpandToInclude(x, y);

            // Update extents for z- and m-values
            _zInterval = _zInterval.ExpandedByValue(toAdd.Z);
            _mInterval = _mInterval.ExpandedByValue(toAdd.M);

            // Signal success
            return(true);
        }
Example #2
0
 public bool Equals(XYZM other) => (X, Y, Z, M).Equals((other.X, other.Y, other.Z, other.M));