Beispiel #1
0
        /// <summary>
        /// Creates a new <see cref="WKBHexFileReader"/> given the
        /// <see cref="WKBReader"/> to use to parse the geometries.
        /// </summary>
        /// <param name="wkbReader">The geometry reader to use</param>
        public WKBHexFileReader(WKBReader wkbReader)
        {
            if (wkbReader == null)
            {
                throw new ArgumentNullException("wkbReader");
            }

            Limit      = -1;
            _wkbReader = wkbReader;
        }
Beispiel #2
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());
        }