public ShapefileIndexReader(string path)
        {
            _path   = path;
            _reader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read));

            Header = ShapefileHeader.Read(_reader);
        }
        public new static ShapefileDataWriter Open(string path)
        {
            ShapefileHeader header;
            int             recordNumber;

            using (BinaryReader reader = new BinaryReader(new FileStream(Path.ChangeExtension(path, ".shx"), FileMode.Open)))
            {
                header       = ShapefileHeader.Read(reader);
                recordNumber = ((int)(reader.BaseStream.Length - 100) / 8) + 1;
            }

            ShapefileDataWriter writer = new ShapefileDataWriter(path, header, FileMode.Append, FileAccess.Write);

            writer._writerShape.BaseStream.Seek(0, SeekOrigin.End);
            writer._writerIndex.BaseStream.Seek(0, SeekOrigin.End);

            writer._recordNumber = recordNumber;
            writer._filePos      = (int)writer._writerShape.BaseStream.Length / 2;

            // Need to push dbf reader to end of file.
            writer._dbf           = DbfFile.Open(Path.ChangeExtension(path, ".dbf"));
            writer._currentRecord = new DbfRecord(writer._dbf.Header);

            return(writer);
        }
        public ShapefileReader(string path, IGeometryFactory geometryFactory = null, GeometryTransform transform = null)
        {
            _gf           = geometryFactory ?? new GeometryFactory();
            _reader       = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read));
            ShapeHeader   = ShapefileHeader.Read(_reader);
            ShapeEnvelope = new Envelope();

            switch (ShapeHeader.ShapeType)
            {
            case ShapefileGeometryType.Point:
            case ShapefileGeometryType.PointZ:
                _shapeFunc = ReadPoint;
                break;

            case ShapefileGeometryType.PolyLine:
            case ShapefileGeometryType.PolyLineZ:
                _shapeFunc = ReadPolyLine;
                break;

            case ShapefileGeometryType.Polygon:
            case ShapefileGeometryType.PolygonZ:
                _shapeFunc = ReadPolygon;
                break;

            case ShapefileGeometryType.MultiPoint:
            case ShapefileGeometryType.MultiPointZ:
                _shapeFunc = ReadMultiPoint;
                break;

            default:
                throw new Exception("Shape type is not supported");
            }

            if (transform != null)
            {
                _transform = transform;

                Func <IGeometry> origFun = _shapeFunc;
                _shapeFunc = () =>
                {
                    return(_transform.Apply(origFun()));
                };
            }
        }
        public static ShapefileWriter Open(string path)
        {
            ShapefileHeader header;
            int             recordNumber;

            using (BinaryReader reader = new BinaryReader(new FileStream(Path.ChangeExtension(path, ".shx"), FileMode.Open)))
            {
                header       = ShapefileHeader.Read(reader);
                recordNumber = ((int)(reader.BaseStream.Length - 100) / 8) + 1;
            }

            ShapefileWriter writer = new ShapefileWriter(path, header, FileMode.Append, FileAccess.Write);

            writer._writerShape.BaseStream.Seek(0, SeekOrigin.End);
            writer._writerIndex.BaseStream.Seek(0, SeekOrigin.End);

            writer._recordNumber = recordNumber;
            writer._filePos      = (int)writer._writerShape.BaseStream.Length / 2;

            return(writer);
        }