Ejemplo n.º 1
0
        public void OpenExistingWritable()
        {
            ErdasImageFile
                image = new ErdasImageFile(outputGisImagePath, RWFlag.Write);

            image.Close();
        }
Ejemplo n.º 2
0
        public void ReadTooManyPixels()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(inputLanImagePath, RWFlag.Read);

                FredLanPixel pixel = new FredLanPixel();

                int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

                for (int i = 0; i < pixCount; i++)
                {
                    image.ReadPixel(pixel);
                }

                // one too many
                image.ReadPixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Ejemplo n.º 3
0
        public void OpenExistingReadOnly()
        {
            ErdasImageFile
                image = new ErdasImageFile(inputGisImagePath, RWFlag.Read);

            image.Close();
        }
Ejemplo n.º 4
0
        public void WritePixels()
        {
            Erdas74Pixel8 pixel = new Erdas74Pixel8();

            ErdasImageFile
                image = new ErdasImageFile(outputGisImagePath,
                                           new Dimensions(10, 10),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

            byte[] bytes = new byte[1];
            bytes[0] = 1;

            pixel[0].SetBytes(bytes, 0);

            int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

            for (int i = 0; i < pixCount; i++)
            {
                image.WritePixel(pixel);
            }

            image.Close();
        }
Ejemplo n.º 5
0
        public void Constructor()
        {
            ErdasImageFile image = new ErdasImageFile(gisImagePath, RWFlag.Write);
            OutputRaster <Erdas74Pixel8> raster = new OutputRaster <Erdas74Pixel8>(image);

            raster.Close();
        }
Ejemplo n.º 6
0
        public void ReadFromWritable1()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(Data.MakeOutputPath("junk.gis"),
                                           new Dimensions(10, 10),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

                Erdas74Pixel8 pixel = new Erdas74Pixel8();

                // read after opening for Write
                image.ReadPixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Ejemplo n.º 7
0
        public void Dimensions()
        {
            ErdasImageFile image = new ErdasImageFile(gisImagePath, RWFlag.Write);
            OutputRaster <Erdas74Pixel8> raster = new OutputRaster <Erdas74Pixel8>(image);

            Assert.AreEqual(60, raster.Dimensions.Rows);
            Assert.AreEqual(40, raster.Dimensions.Columns);
            raster.Close();
        }
Ejemplo n.º 8
0
        public void Metadata()
        {
            ErdasImageFile image = new ErdasImageFile(gisImagePath, RWFlag.Write);
            OutputRaster <Erdas74Pixel8> raster = new OutputRaster <Erdas74Pixel8>(image);

            double data = 0.0;

            Assert.AreEqual(false, raster.Metadata.TryGetValue <double>("Anything", ref data));

            raster.Close();
        }
Ejemplo n.º 9
0
 private void TryOpen(string filename,
                      RWFlag rwFlag)
 {
     try {
         ErdasImageFile image = new ErdasImageFile(filename, rwFlag);
     }
     catch (System.Exception exc) {
         Data.Output.WriteLine(exc.Message);
         throw;
     }
 }
Ejemplo n.º 10
0
        public void WritePixels()
        {
            ErdasImageFile image = new ErdasImageFile(gisImagePath, RWFlag.Write);
            OutputRaster <Erdas74Pixel8> raster = new OutputRaster <Erdas74Pixel8>(image);
            Erdas74Pixel8 pixel8    = new Erdas74Pixel8();
            int           totPixels = raster.Dimensions.Rows * raster.Dimensions.Columns;

            for (int i = 0; i < totPixels; i++)
            {
                raster.WritePixel(pixel8);
            }
            raster.Close();
        }
        public void ReadPixels()
        {
            ErdasImageFile image = new ErdasImageFile(gisImagePath, RWFlag.Read);
            InputRaster <Erdas74Pixel8> raster = new InputRaster <Erdas74Pixel8>(image);
            Erdas74Pixel8 pixel8    = new Erdas74Pixel8();
            int           totPixels = raster.Dimensions.Rows * raster.Dimensions.Columns;

            for (int i = 0; i < totPixels; i++)
            {
                pixel8 = raster.ReadPixel();
            }
            raster.Close();
        }
Ejemplo n.º 12
0
        public void ReadPixels()
        {
            ErdasImageFile
                image = new ErdasImageFile(inputLanImagePath, RWFlag.Read);

            FredLanPixel pixel = new FredLanPixel();

            int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

            for (int i = 0; i < pixCount; i++)
            {
                image.ReadPixel(pixel);
            }

            image.Close();
        }
Ejemplo n.º 13
0
 private void TryCtor(string filename,
                      Dimensions dimensions,
                      int bandCount,
                      System.TypeCode bandType,
                      IMetadata metadata)
 {
     try {
         ErdasImageFile image = new ErdasImageFile(filename, dimensions,
                                                   bandCount, bandType,
                                                   metadata);
     }
     catch (System.Exception exc) {
         Data.Output.WriteLine(exc.Message);
         throw;
     }
 }
Ejemplo n.º 14
0
        public void ConstructNewGis()
        {
            ErdasImageFile
                image = new ErdasImageFile(outputGisImagePath,
                                           new Dimensions(60, 40),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

            Assert.AreEqual(60, image.Dimensions.Rows);
            Assert.AreEqual(40, image.Dimensions.Columns);
            Assert.AreEqual(1, image.BandCount);
            Assert.AreEqual(System.TypeCode.Byte, image.BandType);
            Assert.AreEqual(null, image.Metadata);

            image.Close();  // needed or file stays locked after run of tests. why?
        }
Ejemplo n.º 15
0
        public void ConstructNewLan()
        {
            ErdasImageFile
                image =
                new ErdasImageFile(outputLanImagePath,
                                   new Dimensions(100, 50),
                                   2,
                                   System.TypeCode.UInt16,
                                   null);

            Assert.AreEqual(100, image.Dimensions.Rows);
            Assert.AreEqual(50, image.Dimensions.Columns);
            Assert.AreEqual(2, image.BandCount);
            Assert.AreEqual(System.TypeCode.UInt16, image.BandType);
            Assert.AreEqual(null, image.Metadata);

            image.Close();  // needed or file stays locked after run of tests. why?
        }
Ejemplo n.º 16
0
        public void Init()
        {
            gisImagePath = Data.MakeOutputPath("OutputRasterTests.gis");
            ErdasImageFile image;

            image = new ErdasImageFile(gisImagePath,
                                       new Dimensions(60, 40),
                                       1,
                                       System.TypeCode.Byte,
                                       null);
            image.Close();

            lanImagePath = Data.MakeOutputPath("OutputRasterTests.lan");
            image        = new ErdasImageFile(lanImagePath,
                                              new Dimensions(100, 50),
                                              2,
                                              System.TypeCode.UInt16,
                                              null);
            image.Close();
        }
Ejemplo n.º 17
0
 public void WriteTooManyPixels()
 {
     try {
         ErdasImageFile image = new ErdasImageFile(gisImagePath, RWFlag.Write);
         OutputRaster <Erdas74Pixel8> raster = new OutputRaster <Erdas74Pixel8>(image);
         using (raster) {
             Erdas74Pixel8 pixel8    = new Erdas74Pixel8();
             int           totPixels = raster.Dimensions.Rows * raster.Dimensions.Columns;
             for (int i = 0; i < totPixels; i++)
             {
                 raster.WritePixel(pixel8);
             }
             // write one too many
             raster.WritePixel(pixel8);
         }
     }
     catch (System.Exception exc) {
         Data.Output.WriteLine(exc.Message);
         throw;
     }
 }
Ejemplo n.º 18
0
        private void TryCtor <T>(string imagePath,
                                 RWFlag rwFlag)
            where T : IPixel, new()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(imagePath, rwFlag);
                OutputRaster <T> raster = new OutputRaster <T>(image);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Ejemplo n.º 19
0
        public void WriteTooManyPixels()
        {
            ErdasImageFile image = null;

            try {
                Erdas74Pixel8 pixel = new Erdas74Pixel8();

                image = new ErdasImageFile(outputGisImagePath,
                                           new Dimensions(10, 10),
                                           1,
                                           System.TypeCode.Byte,
                                           null);

                byte[] bytes = new byte[1];
                bytes[0] = 1;

                pixel[0].SetBytes(bytes, 0);

                int pixCount = image.Dimensions.Rows * image.Dimensions.Columns;

                for (int i = 0; i < pixCount; i++)
                {
                    image.WritePixel(pixel);
                }

                // one too many
                image.WritePixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }
Ejemplo n.º 20
0
        public void WriteToReadable()
        {
            ErdasImageFile image = null;

            try {
                image = new ErdasImageFile(Data.MakeOutputPath("junk.gis"),
                                           RWFlag.Read);

                Erdas74Pixel8 pixel = new Erdas74Pixel8();

                // write after opening for Read
                image.WritePixel(pixel);
            }
            catch (System.Exception exc) {
                Data.Output.WriteLine(exc.Message);
                throw;
            }
            finally {
                if (image != null)
                {
                    image.Close();
                }
            }
        }