Beispiel #1
0
 private static BoundingBox CalculateExtent(TiffProperties tiffProperties, WorldProperties worldProperties)
 {
     var minX = worldProperties.XCenterOfUpperLeftPixel - worldProperties.PixelSizeX * 0.5;
     var maxX = minX + worldProperties.PixelSizeX * tiffProperties.Width + worldProperties.PixelSizeX * 0.5;
     var maxY = worldProperties.YCenterOfUpperLeftPixel + worldProperties.PixelSizeY * 0.5;
     var minY = maxY + worldProperties.PixelSizeY * tiffProperties.Height - worldProperties.PixelSizeY * 0.5;
     return new BoundingBox(minX, minY, maxX, maxY);
 }
Beispiel #2
0
        private static BoundingBox CalculateExtent(TiffProperties tiffProperties, WorldProperties worldProperties)
        {
            var minX = worldProperties.XCenterOfUpperLeftPixel - worldProperties.PixelSizeX * 0.5;
            var maxX = minX + worldProperties.PixelSizeX * tiffProperties.Width + worldProperties.PixelSizeX * 0.5;
            var maxY = worldProperties.YCenterOfUpperLeftPixel + worldProperties.PixelSizeY * 0.5;
            var minY = maxY + worldProperties.PixelSizeY * tiffProperties.Height - worldProperties.PixelSizeY * 0.5;

            return(new BoundingBox(minX, minY, maxX, maxY));
        }
Beispiel #3
0
        public GeoTiffProvider(string tiffPath, List <Color> noDataColors = null)
        {
            MemoryStream data;

            if (!File.Exists(tiffPath))
            {
                throw new ArgumentException(string.Format("Tiff file expected at {0}", tiffPath));
            }

            string worldPath = GetPathWithoutExtension(tiffPath) + WorldExtention;

            if (!File.Exists(worldPath))
            {
                throw new ArgumentException(string.Format("World file expected at {0}", worldPath));
            }

            TiffProperties  tiffProperties  = LoadTiff(tiffPath);
            WorldProperties worldProperties = LoadWorld(worldPath);

            _extent = CalculateExtent(tiffProperties, worldProperties);

            try
            {
                try
                {
                    data = ReadImageAsStream(tiffPath, noDataColors);
                }
                catch (OutOfMemoryException e)
                {
                    throw new OutOfMemoryException("Out of memory", e.InnerException);
                }
            }
            catch (ExternalException e)
            {
                throw new ExternalException(e.Message, e.InnerException);
            }

            _feature = new Feature {
                Geometry = new Raster(data, _extent)
            };
            _feature.Styles.Add(new VectorStyle());
        }
        public GeoTiffProvider(string tiffPath, List<Color> noDataColors = null)
        {
            if (!File.Exists(tiffPath))
            {
                throw new ArgumentException(string.Format("Tiff file expected at {0}", tiffPath));
            }

            worldPath = GetPathWithoutExtension(tiffPath) + WorldExtention;
            if (!File.Exists(worldPath))
            {
                throw new ArgumentException(string.Format("World file expected at {0}", worldPath));
            }

            tiffProperties = LoadTiff(tiffPath);
            worldProperties = LoadWorld(worldPath);
            extent = CalculateExtent(tiffProperties, worldProperties);

            try
            {
                try
                {
                    data = ReadImageAsStream(tiffPath, noDataColors);
                }
                catch (OutOfMemoryException e)
                {
                    throw new OutOfMemoryException("Out of memory", e.InnerException);
                }
            }
            catch (ExternalException e)
            {
                throw new ExternalException(e.Message, e.InnerException);
            }

            feature = new Feature { Geometry = new Raster(data, extent) };
            feature.Styles.Add(new VectorStyle());
        }