public override LayerType AddLayerType(Capabilities capabilities, string dataPath) { LayerType layerType = null; if (capabilities == null) { return(layerType); } string name = Path.GetFileNameWithoutExtension(dataPath); Dataset dataset = null; DataSource dataSource = null; try { dataset = Gdal.Open(dataPath, Access.GA_ReadOnly); } catch (Exception e) { try { dataSource = Ogr.Open(dataPath, 0); } catch (Exception exc) { } } if (dataset != null) { layerType = dataset.AddToCapabilities(name, capabilities); dataset.Dispose(); } else if (dataSource != null) { layerType = dataSource.AddToCapabilities(name, capabilities); dataSource.Dispose(); } return(layerType); }
public override LayerType AddContent(Capabilities capabilities, string dataPath) { LayerType layerType = null; if (capabilities == null) { return(layerType); } Dataset dataset = Gdal.Open(dataPath, Access.GA_ReadOnly); if (dataset != null) { layerType = dataset.AddToCapabilities(capabilities); dataset.Dispose(); } else { DataSource dataSource = Ogr.Open(dataPath, 0); layerType = dataSource.AddToCapabilities(capabilities); dataSource.Dispose(); } return(layerType); }