using System.Collections.Generic; using System.IO; using Core.GIS.SharpMap.Api.Layers; using Core.GIS.SharpMap.Data.Providers; using Core.GIS.SharpMap.Layers; namespace Core.Plugins.SharpMapGis { /// /// Create layers from file datasource /// public static class FileBasedLayerFactory { public static IEnumerable CreateLayersFromFile(string path) { string fileName = Path.GetFileNameWithoutExtension(path); switch (Path.GetExtension(path).ToLower()) { case ".shp": //todo: optimize ogr featureprovider and replace shapefile by ogr provider //var shapeFile = new OgrFeatureProvider(path, Path.GetFileNameWithoutExtension(path)); var shapeFile = new ShapeFile(path); var shapeFileLayer = SharpMapLayerFactory.CreateLayer(shapeFile); shapeFileLayer.Name = fileName; yield return shapeFileLayer; break; } } } }