Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of the commmand server from a file
        /// </summary>
        /// <param name="Filename">The filename of the dbf to read, edit or append to</param>
        public Commands(string Filename)
        {
            if (Filename == null)
            {
                throw new ArgumentNullException(Filename);
            }
            // check for the file existing here, otherwise we will not get an error
            //until we read the first record or read the header.
            if (!File.Exists(Filename))
            {
                throw new FileNotFoundException(String.Format("Could not find file \"{0}\"", Filename));
            }
            _Filename = Filename;

            dBaseReader dr = new dBaseReader(Filename);
            _Header = dr.GetHeader();
        }
Exemplo n.º 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 ShapefileReader(string filename, GeometryFactory geometryFactory) 
		{
			if (filename == null)
				throw new ArgumentNullException("filename");
			if (geometryFactory == null)
				throw new ArgumentNullException("geometryFactory");
			_geometryFactory = geometryFactory;
			_open = true;			

			if (filename.ToLower().EndsWith(".shp"))
				filename = filename.ToLower().Replace(".shp",String.Empty);
			
			 _dbfReader = new dBaseReader(filename + ".dbf");
			 _shpReader = new ShapeReader(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 FieldDescriptor[_dbfHeader.Fields.Length + 1];
			_dbaseFields[0] = FieldDescriptor.ShapeField();
			for(int i=0; i < _dbfHeader.Fields.Length; i++)
				_dbaseFields[i+1] = _dbfHeader.Fields[i];
			
			_ShapeHeader = _shpReader.Header;			
			_dbfEnumerator = _dbfReader.GetEnumerator();
			_shpEnumerator = _shpReader.GetEnumerator();
			_moreRecords = true;
		}