/// <summary>
 /// Opens a shapefile.  This obtains an inram copy of the vector geometries, but
 /// uses a database style link to the dbf fields so that it will obtain specific
 /// field values upon request.  Once a local copy exists, it will be stored in
 /// the Layers.
 /// </summary>
 /// <param name="FileOrConnection"></param>
 public void Open(string FileOrConnection)
 {
     _filenameOrConnection = FileOrConnection;
     ShapeReader sfReader = new ShapeReader(FileOrConnection);
     IEnumerator Shape = sfReader.GetEnumerator();
    // FeatureSet myShapefileLayer = new FeatureSet(this);
     //IFeature CurrentFeature;
     while (Shape.MoveNext())
     {
        // TO DO
     }
 }
        /// <summary>
        /// Reads all the information from the specified file.  This also sends status messages through progressHandler.
        /// </summary>
        public void Open(IProgressHandler progressHandler)
        {
            
            IFeature currentFeature;
            string dbfFile = Path.ChangeExtension(Filename, ".dbf");
            FileStream myStream = new FileStream(dbfFile, FileMode.Open, FileAccess.Read, FileShare.Read);
            BinaryReader myReader = new BinaryReader(myStream);
            ReadTableHeader(myReader); // based on the header, set up the fields information etc.

            ProgressMeter pm = new ProgressMeter(progressHandler, "Opening " + Path.GetFileName(Filename), _numRecords);
             
           
            
            ShapeReader myShapeReader = new ShapeReader(Filename);
            IEnumerator en = myShapeReader.GetEnumerator();
            en.MoveNext();
            // Reading the Table elements as well as the shapes in a single progress loop.
            for (int row = 0; row < _numRecords; row++)
            {
                // --------- DATABASE --------- CurrentFeature = ReadTableRow(myReader);
                // rem this line if the DATABASE is turned back on
                currentFeature = new Feature();

                currentFeature.BasicGeometry = (IBasicGeometry)en.Current;
                en.MoveNext();
                Features.Add(currentFeature);

             
                // --------- DATABASE ---------  _Table.Rows.Add(CurrentFeature.DataRow);

                // If a progress message needs to be updated, this will handle that.
                
                pm.CurrentValue = row;
                

            }
            Envelope = null; // invalidate the envelope so that it will be re-calculated from all the points
            
            pm.Reset(); // Shows the basic "Ready." message indicating that we are done with this step.
            

        }
		/// <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;
		}