//---------------------------------------------------------------------

        private void AssertIsErdas74Driver(DriverInfo driver)
        {
            Assert.IsNotNull(driver);
            Assert.AreEqual("Erdas 7.4", driver.Name);
            Assert.AreEqual("Landis.RasterIO.Drivers.Erdas74.Driver,Landis.RasterIO.Drivers.Erdas74",
                            driver.ImplementationName);
            Assert.AreEqual(FileAccess.ReadWrite, driver[".gis"]);
            Assert.AreEqual(FileAccess.ReadWrite, driver[".lan"]);
        }
        public void Indexer()
        {
            Dictionary<string, FileAccess> formats = new Dictionary<string, FileAccess>();
            formats[".gis"] = FileAccess.ReadWrite;
            formats[".lan"] = FileAccess.ReadWrite;
            DriverInfo info = new DriverInfo("foo", "Foo.Driver,Foo.dll", formats);

            Assert.AreEqual(FileAccess.ReadWrite, info[".gis"]);
            Assert.AreEqual(FileAccess.ReadWrite, info[".lan"]);
            Assert.AreEqual((FileAccess) 0, info[".bar"]);
        }
예제 #3
0
        //---------------------------------------------------------------------

        private IDriver GetDriver(string path,
                                  FileAccess fileAccess)
        {
            string format = Path.GetExtension(path);

            if (string.IsNullOrEmpty(format))
            {
                throw NewAppException("No file extension specified for raster map");
            }

            IList <DriverInfo> drivers = dataset.GetDrivers(format);

            if (drivers == null)
            {
                throw NewAppException("Unknown raster format: {0}", format);
            }

            //  Find first driver that supports the requested access
            DriverInfo firstDriver = null;

            foreach (DriverInfo driverInfo in drivers)
            {
                if ((driverInfo[format] & fileAccess) == fileAccess)
                {
                    firstDriver = driverInfo;
                    break;
                }
            }
            if (firstDriver == null)
            {
                string action;
                if (fileAccess == FileAccess.Read)
                {
                    action = "read";
                }
                else
                {
                    action = "write";
                }
                throw NewAppException("No drivers {0} the raster format \"{1}\"",
                                      action, format);
            }

            IDriver driver;

            if (!loadedDrivers.TryGetValue(firstDriver.Name, out driver))
            {
                driver = Loader.Load <IDriver>(firstDriver);
                loadedDrivers[firstDriver.Name] = driver;
            }
            return(driver);
        }
예제 #4
0
        //---------------------------------------------------------------------

        public DriverDataset(string path)
        {
            this.path = path;
            PersistentDriverDataset dataset = PersistentDriverDataset.Load(path);

            drivers = new List <DriverInfo>();
            foreach (PersistentDriverDataset.DriverInfo info in dataset.Drivers)
            {
                //  Create a dictionary from list of formats
                Dictionary <string, FileAccess> formats;
                formats = new Dictionary <string, FileAccess>();
                foreach (PersistentDriverDataset.FormatAccess formatAccess in info.Formats)
                {
                    formats[formatAccess.Format] = formatAccess.Access;
                }

                drivers.Add(new DriverInfo(info.Name,
                                           info.ImplementationName,
                                           formats));
            }

            this.formats = new Dictionary <string, List <DriverInfo> >();
            foreach (PersistentDriverDataset.FormatDrivers formatDrivers in dataset.Formats)
            {
                List <DriverInfo> driverList = new List <DriverInfo>();
                foreach (string driverName in formatDrivers.Drivers)
                {
                    DriverInfo driverInfo = null;
                    foreach (DriverInfo info in this.drivers)
                    {
                        if (info.Name == driverName)
                        {
                            driverInfo = info;
                            break;
                        }
                    }
                    if (driverInfo == null)
                    {
                        throw new System.ApplicationException(string.Format("Unknown raster driver: \"{0}\"", driverName));
                    }
                    driverList.Add(driverInfo);
                }
                formats[formatDrivers.Format] = driverList;
            }
        }
 public void FormatsNull()
 {
     DriverInfo info = new DriverInfo("foo", "Foo.Driver,Foo.dll", null);
 }