Exemplo n.º 1
0
        /// <summary>
        /// Converts the contents of this <see cref="CoordinateBuffer"/> to a coordinate sequence using the provided <paramref name="converter"/>.
        /// </summary>
        /// <param name="converter">The converter to use</param>
        /// <returns>A coordinate sequence</returns>
        public ICoordinateSequence ToSequence(CoordinateBufferToSequenceConverterHandler converter)
        {
            // If we have a converter, use it
            if (converter != null)
            {
                return(converter(this));
            }

            // so we don't. Bummer
            return(ToSequence());
        }
Exemplo n.º 2
0
        private static void TestToSequenceMethod(CoordinateBufferToSequenceConverterHandler converter)
        {
            var rnd    = new Random(8894);
            var buffer = new CoordinateBuffer();

            for (var i = 0; i < NumCoordinates; i++)
            {
                buffer.AddCoordinate(rnd.NextDouble(), rnd.NextDouble());
            }

            System.Diagnostics.Trace.WriteLine(
                string.Format("\nConversion using {0} method", converter.Method.Name));

            var sw = new System.Diagnostics.Stopwatch();

            sw.Start();
            var seqCold = buffer.ToSequence(converter);

            sw.Stop();
            System.Diagnostics.Trace.WriteLine(
                string.Format("  Cold converting sequence of {0} coordinates in {1}ms.", NumCoordinates, sw.ElapsedMilliseconds));

            long total = 0;

            foreach (var rndBuffer in (_randomCoordinateBuffers ?? (_randomCoordinateBuffers = RandomCoordinateBuffers(NumTests))))
            {
                sw.Stop();
                sw.Start();
                var seqWarm = rndBuffer.ToSequence(converter);
                sw.Stop();
                Assert.AreEqual(rndBuffer.Count, seqWarm.Count);
                total += sw.ElapsedTicks;
            }
            System.Diagnostics.Trace.WriteLine(
                string.Format("  Warm converting {0} random coordinate buffers in {1}ticks.", NumTests, total));
        }
        private static void TestToSequenceMethod(CoordinateBufferToSequenceConverterHandler converter)
        {
            var rnd = new Random(8894);
            var buffer = new CoordinateBuffer();

            for (var i = 0; i < NumCoordinates; i++)
                buffer.AddCoordinate(rnd.NextDouble(), rnd.NextDouble());

            System.Diagnostics.Trace.WriteLine(
                string.Format("\nConversion using {0} method", converter.Method.Name));

            var sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            var seqCold = buffer.ToSequence(converter);
            sw.Stop();
            System.Diagnostics.Trace.WriteLine(
                string.Format("  Cold converting sequence of {0} coordinates in {1}ms.", NumCoordinates, sw.ElapsedMilliseconds));
            
            long total = 0;
            foreach (var rndBuffer in (_randomCoordinateBuffers ?? (_randomCoordinateBuffers = RandomCoordinateBuffers(NumTests))))
            {
                sw.Stop();
                sw.Start();
                var seqWarm = rndBuffer.ToSequence(converter);
                sw.Stop();
                Assert.AreEqual(rndBuffer.Count, seqWarm.Count);
                total += sw.ElapsedTicks;
            }
            System.Diagnostics.Trace.WriteLine(
                string.Format("  Warm converting {0} random coordinate buffers in {1}ticks.", NumTests, total));

        }