Esempio n. 1
0
        /// <summary>
        /// Reads a sequence of geometries.<br/>
        /// If an <see cref="Offset"/> is specified, geometries read up to the offset count are skipped.
        /// If a <see cref="Limit"/> is specified, no more than <see cref="Limit"/> geometries are read.
        /// </summary>
        /// <param name="streamReader">The stream reader to use.</param>
        /// <exception cref="IOException">Thrown if an I/O exception was encountered</exception>
        /// <exception cref="ParseException">Thrown if an error occured reading a geometry</exception>
        private ReadOnlyCollection <Geometry> Read(StreamReader streamReader)
        {
            var geoms = new List <Geometry>();
            int count = 0;

            while (!IsAtEndOfFile(streamReader) && !IsAtLimit(geoms))
            {
                string line = streamReader.ReadLine();
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }

                var g = _wkbReader.Read(WKBReader.HexToBytes(line));
                if (count >= Offset)
                {
                    geoms.Add(g);
                }
                count++;
            }
            return(geoms.AsReadOnly());
        }