public List <GeoReferencedImage> GetTiles(BoundingBox geographicBoundingBox, double mapScale) { //94.12.17 //int zoomLevel = GetZoomLevel(mapScale); int zoomLevel = IRI.Ham.SpatialBase.Mapping.WebMercatorUtility.GetZoomLevel(mapScale); var result = new List <IRI.Ham.SpatialBase.GeoReferencedImage>(); //What if there were no imagesource for this zoom level if (!this.ImageSources.Any(i => i.ZoomLevel == zoomLevel)) { return(result); } var lowerLeft = WebMercatorUtility.LatLonToImageNumber(geographicBoundingBox.YMin, geographicBoundingBox.XMin, zoomLevel); var upperRight = WebMercatorUtility.LatLonToImageNumber(geographicBoundingBox.YMax, geographicBoundingBox.XMax, zoomLevel); var imageSource = this.ImageSources.Single(i => i.ZoomLevel == zoomLevel); for (int i = (int)lowerLeft.X; i <= upperRight.X; i++) { for (int j = (int)upperRight.Y; j <= lowerLeft.Y; j++) { //94.12.17 //string imageName; //if (imageSource.IsZoomLevelIncluded) //{ // imageName = string.Format("{0}{1}_{2}_{3}.{4}", imageSource.ImagePrefix, i, j, zoomLevel, imageSource.FileExtension); //} //else //{ // imageName = string.Format("{0}{1}_{2}.{3}", imageSource.ImagePrefix, i, j, imageSource.FileExtension); //} //string fileName = System.IO.Path.Combine(imageSource.ImageDirectory, imageName); string fileName = imageSource.GetFileName(j, i); if (System.IO.File.Exists(fileName)) { result.Add(new IRI.Ham.SpatialBase.GeoReferencedImage( System.IO.File.ReadAllBytes(fileName), WebMercatorUtility.GetWgs84ImageBoundingBox(j, i, zoomLevel))); } } } System.Diagnostics.Trace.WriteLine(string.Format("{0} Images founded; zoom level = {1}", result.Count, zoomLevel)); return(result); }
public List <GeoReferencedImage> GetTiles(BoundingBox geographicBoundingBox, double mapScale) { //94.12.17 //int zoomLevel = GetZoomLevel(mapScale); int zoomLevel = IRI.Ham.SpatialBase.Mapping.WebMercatorUtility.GetZoomLevel(mapScale); var result = new List <IRI.Ham.SpatialBase.GeoReferencedImage>(); //What if there were no imagesource for this zoom level if (!_archive.Entries.Any(i => i.FullName.StartsWith(zoomLevel.ToString(), StringComparison.OrdinalIgnoreCase))) { return(result); } var lowerLeft = WebMercatorUtility.LatLonToImageNumber(geographicBoundingBox.YMin, geographicBoundingBox.XMin, zoomLevel); var upperRight = WebMercatorUtility.LatLonToImageNumber(geographicBoundingBox.YMax, geographicBoundingBox.XMax, zoomLevel); for (int i = (int)lowerLeft.X; i <= upperRight.X; i++) { for (int j = (int)upperRight.Y; j <= lowerLeft.Y; j++) { //var zipArchive = new System.IO.Compression.ZipArchive(archive.Open()); if (_archive.Entries.Any(e => e.FullName.Equals(_fileNameRule(zoomLevel, j, i), StringComparison.OrdinalIgnoreCase))) { var stream = _archive.Entries.Single(e => e.FullName.Equals(_fileNameRule(zoomLevel, j, i), StringComparison.OrdinalIgnoreCase)).Open(); byte[] bytes = Common.Helpers.StreamHelper.ToByteArray(stream); //using (var memoryStream = new System.IO.MemoryStream()) //{ // stream.CopyTo(memoryStream); // bytes = memoryStream.ToArray(); //} result.Add(new GeoReferencedImage(bytes, WebMercatorUtility.GetWgs84ImageBoundingBox(j, i, zoomLevel))); } } } System.Diagnostics.Trace.WriteLine(string.Format("{0} Images founded; zoom level = {1}", result.Count, zoomLevel)); return(result); }
public List <GeoReferencedImage> GetTilesForGoogleEarth(BoundingBox geographicBoundingBox, double mapScale) { //94.12.17 //int zoomLevel = GetZoomLevel(mapScale); int zoomLevel = IRI.Msh.Common.Mapping.WebMercatorUtility.GetZoomLevel(mapScale); var result = new List <GeoReferencedImage>(); //What if there were no imagesource for this zoom level if (!this.ImageSources.Any(i => i.ZoomLevel == zoomLevel)) { return(result); } var lowerLeft = WebMercatorUtility.LatLonToImageNumber(geographicBoundingBox.YMin, geographicBoundingBox.XMin, zoomLevel); var upperRight = WebMercatorUtility.LatLonToImageNumber(geographicBoundingBox.YMax, geographicBoundingBox.XMax, zoomLevel); var imageSource = this.ImageSources.Single(i => i.ZoomLevel == zoomLevel); for (int i = (int)lowerLeft.X; i <= upperRight.X; i++) { for (int j = (int)upperRight.Y; j <= lowerLeft.Y; j++) { string fileName = imageSource.GetFileName(j, i); if (System.IO.File.Exists(fileName)) { result.Add(new GeoReferencedImage( System.IO.File.ReadAllBytes(fileName), WebMercatorUtility.GetWgs84ImageBoundingBox(j, i, zoomLevel))); } } } System.Diagnostics.Trace.WriteLine(string.Format("{0} Images founded; zoom level = {1}", result.Count, zoomLevel)); return(result); }