/// <summary> /// This will return the correct shapefile type by reading the fileName. /// </summary> /// <param name="fileName">A string specifying the file with the extension .shp to open.</param> /// <param name="progressHandler">receives progress messages and overrides the ProgressHandler on the DataManager.DefaultDataManager</param> /// <returns>A correct shapefile object which is exclusively for reading the .shp data</returns> public static new Shapefile OpenFile(string fileName, IProgressHandler progressHandler) { var ext = Path.GetExtension(fileName); if (ext != null) { ext = ext.ToLower(); } if (ext != ".shp" && ext != ".shx" && ext != ".dbf") { throw new ArgumentException(String.Format("The file extension {0} is not supported by Shapefile data provider.", ext)); } string name = Path.ChangeExtension(fileName, ".shp"); var head = new ShapefileHeader(); head.Open(name); switch (head.ShapeType) { case ShapeType.MultiPatch: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.MultiPoint: case ShapeType.MultiPointM: case ShapeType.MultiPointZ: var mpsf = new MultiPointShapefile(); mpsf.Open(name, progressHandler); return(mpsf); case ShapeType.NullShape: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.Point: case ShapeType.PointM: case ShapeType.PointZ: var psf = new PointShapefile(); psf.Open(name, progressHandler); return(psf); case ShapeType.Polygon: case ShapeType.PolygonM: case ShapeType.PolygonZ: var pgsf = new PolygonShapefile(); pgsf.Open(name, progressHandler); return(pgsf); case ShapeType.PolyLine: case ShapeType.PolyLineM: case ShapeType.PolyLineZ: var lsf = new LineShapefile(); lsf.Open(name, progressHandler); return(lsf); } return(null); }
/// <summary> /// This will return the correct shapefile type by reading the fileName. /// </summary> /// <param name="fileName">A string specifying the file with the extension .shp to open.</param> /// <param name="progressHandler">receives progress messages and overrides the ProgressHandler on the DataManager.DefaultDataManager</param> /// <exception cref="NotImplementedException">Throws a NotImplementedException if the ShapeType of the loaded file is NullShape or MultiPatch.</exception> /// <returns>A correct shapefile object which is exclusively for reading the .shp data</returns> public static new Shapefile OpenFile(string fileName, IProgressHandler progressHandler) { var ext = Path.GetExtension(fileName)?.ToLower(); if (ext != ".shp" && ext != ".shx" && ext != ".dbf") { throw new ArgumentException(string.Format(DataStrings.FileExtension0NotSupportedByShapefileDataProvider, ext)); } string name = Path.ChangeExtension(fileName, ".shp"); var head = new ShapefileHeader(); head.Open(name); switch (head.ShapeType) { case ShapeType.MultiPatch: case ShapeType.NullShape: throw new NotImplementedException(DataStrings.ShapeTypeNotYetSupported); case ShapeType.MultiPoint: case ShapeType.MultiPointM: case ShapeType.MultiPointZ: var mpsf = new MultiPointShapefile(); mpsf.Open(name, progressHandler); return(mpsf); case ShapeType.Point: case ShapeType.PointM: case ShapeType.PointZ: var psf = new PointShapefile(); psf.Open(name, progressHandler); return(psf); case ShapeType.Polygon: case ShapeType.PolygonM: case ShapeType.PolygonZ: var pgsf = new PolygonShapefile(); pgsf.Open(name, progressHandler); return(pgsf); case ShapeType.PolyLine: case ShapeType.PolyLineM: case ShapeType.PolyLineZ: var lsf = new LineShapefile(); lsf.Open(name, progressHandler); return(lsf); } return(null); }
/// <summary> /// This will return the correct shapefile type by reading the fileName. /// </summary> /// <param name="fileName">A string specifying the file with the extension .shp to open.</param> /// <param name="progressHandler">receives progress messages and overrides the ProgressHandler on the DataManager.DefaultDataManager</param> /// <returns>A correct shapefile object which is exclusively for reading the .shp data</returns> public static new Shapefile OpenFile(string fileName, IProgressHandler progressHandler) { var ext = Path.GetExtension(fileName); if (ext != null) ext = ext.ToLower(); if (ext != ".shp" && ext != ".shx" && ext != ".dbf") throw new ArgumentException(String.Format("The file extension {0} is not supported by Shapefile data provider.", ext)); string name = Path.ChangeExtension(fileName, ".shp"); var head = new ShapefileHeader(); head.Open(name); switch (head.ShapeType) { case ShapeType.MultiPatch: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.MultiPoint: case ShapeType.MultiPointM: case ShapeType.MultiPointZ: var mpsf = new MultiPointShapefile(); mpsf.Open(name, progressHandler); return mpsf; case ShapeType.NullShape: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.Point: case ShapeType.PointM: case ShapeType.PointZ: var psf = new PointShapefile(); psf.Open(name, progressHandler); return psf; case ShapeType.Polygon: case ShapeType.PolygonM: case ShapeType.PolygonZ: var pgsf = new PolygonShapefile(); pgsf.Open(name, progressHandler); return pgsf; case ShapeType.PolyLine: case ShapeType.PolyLineM: case ShapeType.PolyLineZ: var lsf = new LineShapefile(); lsf.Open(name, progressHandler); return lsf; } return null; }
/// <summary> /// This will return the correct shapefile type by reading the fileName. /// </summary> /// <param name="fileName">A string specifying the file with the extension .shp to open.</param> /// <param name="progressHandler">receives progress messages and overrides the ProgressHandler on the DataManager.DefaultDataManager</param> /// <returns>A correct shapefile object which is exclusively for reading the .shp data</returns> public static new Shapefile OpenFile(string fileName, IProgressHandler progressHandler) { string ext = Path.GetExtension(fileName).ToLower(); if (ext != ".shp" && ext != ".shx" && ext != ".dbf") { throw new ArgumentException(String.Format("The file extension {0} is not supported by Shapefile data provider.", ext)); } string name = Path.ChangeExtension(fileName, ".shp"); ShapefileHeader head = new ShapefileHeader(); head.Open(name); PointShapefile psf; LineShapefile lsf; PolygonShapefile pgsf; MultiPointShapefile mpsf; switch (head.ShapeType) { case ShapeType.MultiPatch: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.MultiPoint: case ShapeType.MultiPointM: case ShapeType.MultiPointZ: mpsf = new MultiPointShapefile(); mpsf.Open(name, progressHandler); return(mpsf); case ShapeType.NullShape: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.Point: case ShapeType.PointM: case ShapeType.PointZ: // Instantiate a new object to handle the point shapefile psf = new PointShapefile(); // Open the geometric components of the data (but not the dbf components) psf.Open(name, progressHandler); return(psf); case ShapeType.Polygon: case ShapeType.PolygonM: case ShapeType.PolygonZ: pgsf = new PolygonShapefile(); pgsf.Open(name, progressHandler); return(pgsf); case ShapeType.PolyLine: case ShapeType.PolyLineM: case ShapeType.PolyLineZ: lsf = new LineShapefile(); lsf.Open(name, progressHandler); return(lsf); } return(null); }
/// <summary> /// This will return the correct shapefile type by reading the fileName. /// </summary> /// <param name="fileName">A string specifying the file with the extension .shp to open.</param> /// <param name="progressHandler">receives progress messages and overrides the ProgressHandler on the DataManager.DefaultDataManager</param> /// <returns>A correct shapefile object which is exclusively for reading the .shp data</returns> public static new Shapefile OpenFile(string fileName, IProgressHandler progressHandler) { string ext = Path.GetExtension(fileName).ToLower(); if (ext != ".shp" && ext != ".shx" && ext != ".dbf") throw new ArgumentException(String.Format("The file extension {0} is not supported by Shapefile data provider.", ext)); string name = Path.ChangeExtension(fileName, ".shp"); ShapefileHeader head = new ShapefileHeader(); head.Open(name); PointShapefile psf; LineShapefile lsf; PolygonShapefile pgsf; MultiPointShapefile mpsf; switch (head.ShapeType) { case ShapeType.MultiPatch: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.MultiPoint: case ShapeType.MultiPointM: case ShapeType.MultiPointZ: mpsf = new MultiPointShapefile(); mpsf.Open(name, progressHandler); return mpsf; case ShapeType.NullShape: throw new NotImplementedException("This shape type is not yet supported."); case ShapeType.Point: case ShapeType.PointM: case ShapeType.PointZ: // Instantiate a new object to handle the point shapefile psf = new PointShapefile(); // Open the geometric components of the data (but not the dbf components) psf.Open(name, progressHandler); return psf; case ShapeType.Polygon: case ShapeType.PolygonM: case ShapeType.PolygonZ: pgsf = new PolygonShapefile(); pgsf.Open(name, progressHandler); return pgsf; case ShapeType.PolyLine: case ShapeType.PolyLineM: case ShapeType.PolyLineZ: lsf = new LineShapefile(); lsf.Open(name, progressHandler); return lsf; } return null; }