Beispiel #1
0
        /// <summary>
        /// Initialize Shapefile class using existing .shp and .shx file.
        /// </summary>
        public Shapefile(string directory, string name)
        {
            this.FilePath = directory + "\\" + name;
            string  shxPath = this.FilePath + ".shx";
            ShxFile shxFile = new ShxFile(shxPath);
            Dictionary <int, int> indexes = shxFile.ReadContent();
            string  shpPath = this.FilePath + ".shp";
            ShpFile shpFile = new ShpFile(shpPath);

            this.Box    = shpFile.ReadBoundingBox();
            this.shapes = shpFile.ReadShapes(indexes);
        }
Beispiel #2
0
 /// <summary>
 /// Save the Shapefile as .shp and .shx files.
 /// </summary>
 /// <param name="directory"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public bool Save(string directory, string name)
 {
     if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(name))
     {
         return(false);
     }
     else
     {
         this.FilePath = directory + "\\" + name;
         string shxPath = this.FilePath + ".shx";
         ShxFile.Save(shxPath, Box, shapes);
         string shpPath = this.FilePath + ".shp";
         ShpFile.Save(shpPath, Box, shapes);
         return(true);
     }
 }