Beispiel #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="DbaseFileEnumerator"/> class.
            /// </summary>
            /// <param name="parent"></param>
            public DbaseFileEnumerator(DbaseMemoryStreamReader parent)
            {
                _parent = parent;

                //FileStream stream = new FileStream(parent._filename, FileMode.Open, FileAccess.Read, FileShare.Read);
                //_dbfStream = new BinaryReader(stream, PlatformUtilityEx.GetDefaultEncoding());
                _dbfStream = new BinaryReader(_parent._inputStream, PlatformUtilityEx.GetDefaultEncoding());
                ReadHeader();
            }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the ShapefileDataReader class.
        /// </summary>
        /// <param name="filename">The shapefile to read (minus the .shp extension)</param>
        ///<param name="geometryFactory">The GeometryFactory to use.</param>
        public ShapeMemoryStreamDataReader(Stream shpStream, Stream dbfStream, IGeometryFactory geometryFactory)
        {
            if (shpStream == null)
            {
                throw new ArgumentNullException("shpStream");
            }
            if (dbfStream == null)
            {
                throw new ArgumentNullException("dbfStream");
            }
            if (geometryFactory == null)
            {
                throw new ArgumentNullException("geometryFactory");
            }
            _open = true;

            //if (filename.ToLower().EndsWith(".shp"))
            //    filename = filename.ToLower().Replace(".shp", String.Empty);

            _shpReader = new ShapeMemoryStreamReader(shpStream, geometryFactory);
            _dbfReader = new DbaseMemoryStreamReader(dbfStream);

            //_dbfReader = new DbaseFileReader(filename + ".dbf");
            //_shpReader = new ShapefileReader(filename + ".shp", geometryFactory);

            _dbfHeader = _dbfReader.GetHeader();

            _recordCount = _dbfHeader.NumRecords;

            // copy dbase fields to our own array. Insert into the first position, the shape column
            _dbaseFields    = new DbaseFieldDescriptor[_dbfHeader.Fields.Length + 1];
            _dbaseFields[0] = DbaseFieldDescriptor.ShapeField();
            for (int i = 0; i < _dbfHeader.Fields.Length; i++)
            {
                _dbaseFields[i + 1] = _dbfHeader.Fields[i];
            }

            _shpHeader     = _shpReader.Header;
            _dbfEnumerator = _dbfReader.GetEnumerator();
            _shpEnumerator = _shpReader.GetEnumerator();
            _moreRecords   = true;
        }