Exemplo n.º 1
0
        public void GetImageBordersNullSize()
        {
            string           proj = GdalWorker.GetProjString(_in4326);
            CoordinateSystem cs   = GdalWorker.GetCoordinateSystem(proj);

            Assert.Throws <ArgumentNullException>(() => GdalWorker.GetImageBorders(_in4326, null, cs));
        }
Exemplo n.º 2
0
        public void GetCoordinateSystem()
        {
            string           proj;
            CoordinateSystem cs = CoordinateSystem.Other;

            Assert.DoesNotThrowAsync(async() =>
            {
                proj = await GdalWorker.GetProjStringAsync(_in4326).ConfigureAwait(false);
                cs   = GdalWorker.GetCoordinateSystem(proj);
            });
            Assert.True(cs == Cs4326);

            Assert.DoesNotThrowAsync(async() =>
            {
                proj = await GdalWorker.GetProjStringAsync(_in3785).ConfigureAwait(false);
                cs   = GdalWorker.GetCoordinateSystem(proj);
            });
            Assert.True(cs == Cs3857);

            Assert.DoesNotThrowAsync(async() =>
            {
                proj = await GdalWorker.GetProjStringAsync(_in3395).ConfigureAwait(false);
                cs   = GdalWorker.GetCoordinateSystem(proj);
            });
            Assert.True(cs == CsOther);
        }
Exemplo n.º 3
0
        public void GetImageBordersNonExistingPath()
        {
            using Image image = Image.NewFromFile(_in4326);
            Size             size = new Size(image.Width, image.Height);
            string           proj = GdalWorker.GetProjString(_in4326);
            CoordinateSystem cs   = GdalWorker.GetCoordinateSystem(proj);

            Assert.Throws <FileNotFoundException>(() => GdalWorker.GetImageBorders(ShouldFail, size, cs));
        }
Exemplo n.º 4
0
        public void GetImageBordersNullPath()
        {
            using Image image = Image.NewFromFile(_in4326);
            Size             size = new Size(image.Width, image.Height);
            string           proj = GdalWorker.GetProjString(_in4326);
            CoordinateSystem cs   = GdalWorker.GetCoordinateSystem(proj);

            Assert.Throws <ArgumentNullException>(() => GdalWorker.GetImageBorders(null, size, cs));
        }
Exemplo n.º 5
0
        public void GetImageBordersNormal()
        {
            using Image image = Image.NewFromFile(_in4326);
            Size             size = new Size(image.Width, image.Height);
            string           proj = GdalWorker.GetProjString(_in4326);
            CoordinateSystem cs   = GdalWorker.GetCoordinateSystem(proj);

            GeoCoordinate minCoordinate = null;
            GeoCoordinate maxCoordinate = null;

            Assert.DoesNotThrow(() => (minCoordinate, maxCoordinate) = GdalWorker.GetImageBorders(_in4326, size, cs));
            Assert.True(minCoordinate is GeodeticCoordinate && maxCoordinate is GeodeticCoordinate);
        }
Exemplo n.º 6
0
        public static async ValueTask <bool> CheckInputFileAsync(string inputFilePath, CoordinateSystem targetSystem)
        {
            // File's path checked in other methods, so checking it here is not necessary

            // Get proj and gdalInfo strings
            string projString = await GdalWorker.GetProjStringAsync(inputFilePath).ConfigureAwait(false);

            CoordinateSystem inputSystem    = GdalWorker.GetCoordinateSystem(projString);
            string           gdalInfoString = await GdalWorker.InfoAsync(inputFilePath).ConfigureAwait(false);

            // Check if input image is ready for cropping
            return(inputSystem == targetSystem &&
                   gdalInfoString.Contains(GdalWorker.Byte, StringComparison.InvariantCulture));
        }