Exemplo n.º 1
0
        /// <summary>
        /// Initializes a ShapeFile DataProvider.
        /// </summary>
        /// <remarks>
        /// <para>If FileBasedIndex is true, the spatial index will be read from a local copy. If it doesn't exist,
        /// it will be generated and saved to [filename] + '.sidx'.</para>
        /// <para>Using a file-based index is especially recommended for ASP.NET applications which will speed up
        /// start-up time when the cache has been emptied.
        /// </para>
        /// </remarks>
        /// <param name="filename">Path to shape file</param>
        /// <param name="fileBasedIndex">Use file-based spatial index</param>
        public ShapeFile(string filename, bool fileBasedIndex)
        {
            _filename       = filename;
            _fileBasedIndex = (fileBasedIndex) && File.Exists(Path.ChangeExtension(filename, ".shx"));

            //Initialize DBF
            //string dbffile = _Filename.Substring(0, _Filename.LastIndexOf(".")) + ".dbf";
            string dbffile = Path.ChangeExtension(filename, ".dbf");

            if (File.Exists(dbffile))
            {
                _dbaseFile = new DbaseReader(dbffile);
            }
            //Parse shape header
            ParseHeader();
            //Read projection file
            ParseProjection();
        }