コード例 #1
0
        /// <summary>
        /// Evaluates the <see cref="Interval"/> of the <paramref name="ordinate"/>-values in
        /// <paramref name="sequence"/> and writes it using the provided <paramref name="writer"/>
        /// </summary>
        /// <param name="sequence">The sequence</param>
        /// <param name="ordinate">The ordinate</param>
        /// <param name="writer">The writer</param>
        protected void WriteInterval(CoordinateSequence sequence, Ordinate ordinate, BinaryWriter writer)
        {
            Interval interval;

            if (!sequence.TryGetOrdinateIndex(ordinate, out int ordinateIndex))
            {
                interval = ordinate == Ordinate.M
                    ? Interval.Create(ShapeFileConstants.NoDataValue)
                    : Interval.Create(double.NaN);
            }
            else if (ordinate == Ordinate.M)
            {
                double val = sequence.GetOrdinate(0, ordinateIndex);
                if (double.IsNaN(val))
                {
                    val = ShapeFileConstants.NoDataValue;
                }

                interval = Interval.Create(val);
                for (int i = 1, cnt = sequence.Count; i < cnt; i++)
                {
                    val = sequence.GetOrdinate(i, ordinateIndex);
                    if (double.IsNaN(val))
                    {
                        val = ShapeFileConstants.NoDataValue;
                    }

                    interval = interval.ExpandedByValue(val);
                }
            }
            else
            {
                double val = sequence.GetOrdinate(0, ordinateIndex);
                interval = Interval.Create(val);
                for (int i = 1, cnt = sequence.Count; i < cnt; i++)
                {
                    interval = interval.ExpandedByValue(sequence.GetOrdinate(i, ordinateIndex));
                }
            }

            writer.Write(interval.Min);
            writer.Write(interval.Max);
        }