public static List <string> GetSupportRasterExtensions() { int driverCount = Gdal.GetDriverCount(); List <string> extensions = new List <string>(); for (int i = 0; i < driverCount; i++) { using (OSGeo.GDAL.Driver driver = Gdal.GetDriver(i)) { string[] metadata = driver.GetMetadata(""); var str = metadata.FirstOrDefault(x => x.Contains("DMD_EXTENSION=")); if (str != null) { var extension = str.Split('=')[1]; bool isRaster = metadata.Any(x => x == "DCAP_RASTER=YES"); extension = $".{extension}"; if (!extensions.Contains(extension)) { extensions.Add(extension); } } } } return(extensions); }
/// <summary> /// Prints initialized Gdal drivers. /// </summary> private static void PrintDriversGdal() { if (!Usable) { throw new Exception(string.Format(Strings.UnableToPrintDrivers, "GDAL")); } int driverCount = Gdal.GetDriverCount(); for (int index = 0; index < driverCount; index++) { try { using (OSGeo.GDAL.Driver driver = Gdal.GetDriver(index)) { Console.WriteLine($"GDAL {index}: {driver.ShortName}-{driver.LongName}"); } } catch (Exception exception) { throw new Exception(string.Format(Strings.UnableToPrintDrivers), exception); } } }
// TODO Command private void AddBandsClick(object sender, RoutedEventArgs e) { // Get GDAL extensions StringBuilder allImageExtensions = new StringBuilder(); Dictionary <string, string> images = new Dictionary <string, string>(); for (int driverIndex = 0; driverIndex < Gdal.GetDriverCount(); ++driverIndex) { var driver = Gdal.GetDriver(driverIndex); var metadata = driver.GetMetadata(""); if (metadata.Any(m => m.StartsWith("DMD_EXTENSION"))) { string extensionMetadata = metadata.First(m => m.StartsWith("DMD_EXTENSION")); string extension = "*." + extensionMetadata.Substring(extensionMetadata.IndexOf("=") + 1); string describtionMetadata = metadata.First(m => m.StartsWith("DMD_LONGNAME")); string describtion = describtionMetadata.Substring(describtionMetadata.IndexOf("=") + 1); if (!images.ContainsKey(describtion)) { images.Add(describtion, extension); } allImageExtensions.Append(";" + extension); } } images.Add("All Files", "*.*"); StringBuilder filter = new StringBuilder(); if (allImageExtensions.Length > 0) { filter.Append($"All Images|{allImageExtensions.ToString()}"); } foreach (var image in images) { filter.Append($"|{image.Key}|{image.Value}"); } // Create an instance of the open file dialog box. var openFileDialog = new OpenFileDialog { FilterIndex = 1, Filter = filter.ToString(), Multiselect = true }; // Call the ShowDialog method to show the dialog box. var userClickedOk = openFileDialog.ShowDialog(); // Process input if the user clicked OK. if (userClickedOk == true) { for (int pathIndex = 0; pathIndex < openFileDialog.FileNames.Length; ++pathIndex) { DialogViewModel.Layers.Add(new CreateLayerViewModel(openFileDialog.FileNames[pathIndex])); } } }
/// <summary> /// Prints available GDAL drivers in DEBUG mode. /// </summary> private static void PrintDriversGdal() { int count = Gdal.GetDriverCount(); for (int i = 0; i < count; i++) { OSGeo.GDAL.Driver driver = Gdal.GetDriver(i); Console.WriteLine($"GDAL {i}: {driver.ShortName}-{driver.LongName}"); } }
private static void PrintDriversGdal() { #if DEBUG var num = Gdal.GetDriverCount(); for (var i = 0; i < num; i++) { var driver = Gdal.GetDriver(i); Console.WriteLine(string.Format("GDAL {0}: {1}-{2}", i, driver.ShortName, driver.LongName)); } #endif }
private static void PrintDriversGdal() { #if DEBUG var num = Gdal.GetDriverCount(); for (var i = 0; i < num; i++) { var driver = Gdal.GetDriver(i); Console.WriteLine($"GDAL {i}: {driver.ShortName}-{driver.LongName}"); } #endif }
/// <summary> /// Constructs a new AboutBox object. /// </summary> public AboutBox() { InitializeComponent(); // Initialize the AboutBox to display the product information from the assembly information. // Change assembly information settings for your application through either: // - Project->Properties->Application->Assembly Information // - AssemblyInfo.cs this.Text = String.Format("About {0}", AssemblyTitle); this.labelProductName.Text = AssemblyProduct; // Extract the date and time from the assembly version string[] aver = AssemblyVersion.Split(new char[] { '.' }); DateTime date = new DateTime(2000, 1, 1); date = date.AddDays(int.Parse(aver[2])); //date = date.AddSeconds(int.Parse(aver[3]) * 2); this.labelVersion.Text = String.Format("Version {0}", AssemblyVersion); this.labelCopyright.Text = AssemblyCopyright; //this.labelCompanyName.Text = AssemblyCompany; this.textBoxVersions.Text = CollectVersionInfo(); string version = mapscript.msGetVersion(); this.textBoxDescription.Text = version.Substring(version.IndexOf("OUTPUT")).Replace(" ", "\r\n"); StringBuilder s = new StringBuilder(); for (int i = 0; i < Gdal.GetDriverCount(); i++) { s.AppendLine(Gdal.GetDriver(i).LongName); } this.textBoxDescription1.Text = s.ToString(); s = new StringBuilder(); Ogr.RegisterAll(); for (int i = 0; i < Ogr.GetDriverCount(); i++) { s.AppendLine(Ogr.GetDriver(i).name); } this.textBoxDescription2.Text = s.ToString(); }
static void Main(string[] args) { try { Console.WriteLine($"Working directory: {Directory.GetCurrentDirectory()}"); Console.WriteLine("Trying to configure all twice"); GdalBase.ConfigureAll(); GdalBase.ConfigureAll(); Console.WriteLine("GDAL configured"); var version = Assembly.GetAssembly(typeof(MaxRev.Gdal.Core.GdalBase)) .GetCustomAttribute <AssemblyInformationalVersionAttribute>() .InformationalVersion; Console.WriteLine($"Package version: {version}"); Console.WriteLine(string.Join('\n', $"GDAL Version: {Gdal.VersionInfo("RELEASE_NAME")}", $"GDAL INFO: {Gdal.VersionInfo("")}")); var spatialReference = new SpatialReference(null); spatialReference.SetWellKnownGeogCS("wgs84"); for (int driverIndex = 0; driverIndex < Gdal.GetDriverCount(); driverIndex++) { var driverByName = Gdal.GetDriver(driverIndex); Console.WriteLine( driverByName != default ? $"{driverByName.ShortName} loaded successfully" : $"Failed to load {driverByName.ShortName}"); } // retrieve list of drivers for tests Console.WriteLine("Test string:"); var driverList = string.Join(',', Enumerable.Range(0, Gdal.GetDriverCount()) .Select(i => Gdal.GetDriver(i).ShortName) .OrderBy(x => x) .Select(x => $"\"{x}\"")); Console.WriteLine(driverList); Console.WriteLine("Drivers:" + Gdal.GetDriverCount()); } catch (Exception ex) { Console.WriteLine(ex); } }
public static void PrintAll() { try { Gdal.AllRegister(); Console.WriteLine("Registered GDAL drivers:"); List <DriverInfo> drivers = new List <DriverInfo>(Gdal.GetDriverCount()); for (int i = 0; i < Gdal.GetDriverCount(); ++i) { Driver driver = Gdal.GetDriver(i); DriverInfo driverInfo = new DriverInfo(driver); drivers.Add(driverInfo); } drivers.Sort(DriverInfo.CompareShortName); PrintCreateCapabilities(drivers); } catch (ApplicationException exc) { Console.WriteLine("Application exception: {0}", exc); } }
public static List <GdalRasterFileFormat> GetGdalRasterFileFormats() { List <GdalRasterFileFormat> fileFormats = new List <GdalRasterFileFormat>(); int count = Gdal.GetDriverCount(); for (int i = 0; i < count; i++) { Driver d = Gdal.GetDriver(i); string longName = d.GetMetadataItem("DMD_LONGNAME", ""); string extensions = d.GetMetadataItem("DMD_EXTENSIONS", ""); string raster = d.GetMetadataItem("DCAP_RASTER", ""); if (raster == null) { continue; } if (raster != "YES") { continue; } if (extensions == null) { continue; } if (extensions == "") { continue; } extensions = extensions.Replace(".", ""); string ext = extensions.Replace(" ", " *."); fileFormats.Add(new GdalRasterFileFormat(string.Format("{0} (*.{1})", longName, ext), extensions)); } return(fileFormats.OrderBy(x => x.LongName).Select(x => x).ToList()); }
public static void GetGdalInfo() { logger.Trace(Gdal.VersionInfo("RELEASE_NAME")); logger.Trace(Gdal.VersionInfo("VERSION_NUM")); logger.Trace(Gdal.VersionInfo("BUILD_INFO")); var drivers = new List <string>(); for (var i = 0; i < Ogr.GetDriverCount(); i++) { drivers.Add(Ogr.GetDriver(i).GetName()); } logger.Trace($"OGR Drivers list: {string.Join(",", drivers)}."); drivers = new List <string>(); for (var i = 0; i < Gdal.GetDriverCount(); i++) { drivers.Add(Gdal.GetDriver(i).GetDescription()); } logger.Trace($"GDAL Drivers list: {string.Join(",", drivers)}."); }