Example #1
0
 protected override string GetDownloadUrl(IGeoSpatialDownloadTile tile)
 {
     return string.Format(CultureInfo.InvariantCulture,
         m_formatString, m_serverUri,
              m_dataSetName, tile.Level, tile.Col, tile.Row,
              tile.West, tile.South, tile.East, tile.North);
 }
Example #2
0
        internal ArcIMSDownloadRequest(IGeoSpatialDownloadTile oTile, ArcIMSImageStore oImageStore, string strLocalFilePath, CultureInfo oInfo)
            : base(oTile, oImageStore, strLocalFilePath, oImageStore.ServerUri.ToBaseUri())
        {
            m_oCultureInfo = oInfo;

            CalculateArtificialZoom();
        }
Example #3
0
 internal DapTileDownload(string imagePath, IGeoSpatialDownloadTile oTile, DAPImageStore imageStore)
     : base()
 {
     m_oTile       = oTile;
     m_oImageStore = imageStore;
     Url           = imageStore.Server.Url;
 }
Example #4
0
 protected override void QueueDownload(IGeoSpatialDownloadTile oTile, string strLocalFilePath)
 {
     oTile.TileSet.AddToDownloadQueue(oTile.TileSet.Camera,
                                      new ArcIMSDownloadRequest(oTile, this, strLocalFilePath, m_oCultureInfo));
 }
Example #5
0
 protected override void QueueDownload(IGeoSpatialDownloadTile tile, string filePath)
 {
     tile.TileSet.AddToDownloadQueue(tile.TileSet.Camera,
                                     new DAPDownloadRequest(tile, this, filePath));
 }
Example #6
0
 protected virtual void QueueDownload(IGeoSpatialDownloadTile tile, string filePath)
 {
     string url = GetDownloadUrl(tile);
     tile.TileSet.AddToDownloadQueue(tile.TileSet.Camera,
        new GeoSpatialDownloadRequest(tile, this, filePath, url));
 }
Example #7
0
        /// <summary>
        /// Figure out how to download the image.
        /// TODO: Allow subclasses to have control over how images are downloaded, 
        /// not just the download url.
        /// </summary>
        protected virtual string GetDownloadUrl(IGeoSpatialDownloadTile tile)
        {
            // No local image, return our "duplicate" tile if any
            if (m_duplicateTexturePath != null && File.Exists(m_duplicateTexturePath))
                return m_duplicateTexturePath;

            // No image available anywhere, give up
            return "";
        }
Example #8
0
        internal Texture LoadFile(IGeoSpatialDownloadTile tile)
        {
            string filePath = GetLocalPath(tile);
            tile.ImageFilePath = filePath;
            // remove broken files
            if (File.Exists(filePath))
            {
                FileInfo fi = new FileInfo(filePath);
                if (fi.Length == 0)
                    File.Delete(filePath);
            }
            if (!File.Exists(filePath))
            {
                string badFlag = filePath + ".txt";
                if (File.Exists(badFlag))
                {
                    FileInfo fi = new FileInfo(badFlag);
                    if (DateTime.Now - fi.LastWriteTime < TimeSpan.FromDays(1))
                    {
                        return null;
                    }
                    // Timeout period elapsed, retry
                    File.Delete(badFlag);
                }

                if (IsDownloadableLayer)
                {
                    QueueDownload(tile, filePath);
                    return null;
                }

                if (DuplicateTexturePath == null)
                    // No image available, neither local nor online.
                    return null;

                filePath = DuplicateTexturePath;
            }

            // Use color key
            Texture texture = null;
            if (tile.TileSet.ColorKeyMax != 0)
            {
                texture = ImageHelper.LoadTexture(filePath, tile.TileSet.ColorKey,
                   tile.TileSet.ColorKeyMax);
            }
            else
            {
                texture = ImageHelper.LoadTexture(filePath, tile.TileSet.ColorKey);
            }
            if (texture == null) return null;

            SurfaceDescription sd = texture.GetLevelDescription(0);
            if (sd.Width != sd.Height)
                Log.Write(Log.Levels.Error, "ISTOR", "non-square texture in file " + filePath + "may cause export issues :");
            tile.TextureSizePixels = sd.Width;

            if (tile.TileSet.CacheExpirationTime != TimeSpan.MaxValue)
            {
                FileInfo fi = new FileInfo(filePath);
                DateTime expiry = fi.LastWriteTimeUtc.Add(tile.TileSet.CacheExpirationTime);
                if (DateTime.UtcNow > expiry)
                    QueueDownload(tile, filePath);
            }

            return texture;
        }
Example #9
0
        internal virtual string GetLocalPath(IGeoSpatialDownloadTile tile)
        {
            if (tile.Level >= m_levelCount)
                throw new ArgumentException(string.Format("Level {0} not available.",
                   tile.Level));

            string relativePath = String.Format(@"{0}\{1:D4}\{1:D4}_{2:D4}.{3}",
               tile.Level, tile.Row, tile.Col, m_imageFileExtension);

            if (m_dataDirectory != null)
            {
                // Search data directory first
                string rawFullPath = Path.Combine(m_dataDirectory, relativePath);
                if (File.Exists(rawFullPath))
                    return rawFullPath;
            }

            // If cache doesn't exist, fall back to duplicate texture path.
            if (m_cacheDirectory == null)
                return m_duplicateTexturePath;

            // Try cache with default file extension
            string cacheFullPath = Path.Combine(m_cacheDirectory, relativePath);
            if (File.Exists(cacheFullPath))
                return cacheFullPath;

            // Try cache but accept any valid image file extension
            const string ValidExtensions = ".bmp.dds.dib.hdr.jpg.jpeg.pfm.png.ppm.tga.gif.tif";

            string cacheSearchPath = Path.GetDirectoryName(cacheFullPath);
            if (Directory.Exists(cacheSearchPath))
            {
                foreach (string imageFile in Directory.GetFiles(
                   cacheSearchPath,
                   Path.GetFileNameWithoutExtension(cacheFullPath) + ".*"))
                {
                    string extension = Path.GetExtension(imageFile).ToLower();
                    if (ValidExtensions.IndexOf(extension) < 0)
                        continue;

                    return imageFile;
                }
            }

            return cacheFullPath;
        }
Example #10
0
 /// <summary>
 /// Deletes the cached copy of the tile.
 /// </summary>
 /// <param name="tile"></param>
 internal virtual void DeleteLocalCopy(IGeoSpatialDownloadTile tile)
 {
     string filename = GetLocalPath(tile);
     if (File.Exists(filename))
         File.Delete(filename);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.GeoSpatialDownloadRequest"/> class.
 /// </summary>
 /// <param name="tile"></param>
 public GeoSpatialDownloadRequest(IGeoSpatialDownloadTile tile, ImageStore imageStore, string localFilePath, string downloadUrl)
 {
     m_tile = tile;
     m_url = downloadUrl;
     m_localFilePath = localFilePath;
     m_imageStore = imageStore;
 }
Example #12
0
 internal DAPDownloadRequest(IGeoSpatialDownloadTile tile, DAPImageStore imageStore, string localFilePath)
     : base(tile, imageStore, localFilePath, "")
 {
     m_DapImageStore = imageStore;
 }
Example #13
0
 internal DapTileDownload(string imagePath, IGeoSpatialDownloadTile oTile, DAPImageStore imageStore)
     : base()
 {
     m_oTile = oTile;
      m_oImageStore = imageStore;
      Url = imageStore.Server.Url;
 }
Example #14
0
 internal DAPDownloadRequest(IGeoSpatialDownloadTile tile, DAPImageStore imageStore, string localFilePath)
     : base(tile, imageStore, localFilePath, "")
 {
     m_DapImageStore = imageStore;
 }
Example #15
0
        internal ArcIMSDownloadRequest(IGeoSpatialDownloadTile oTile, ArcIMSImageStore oImageStore, string strLocalFilePath, CultureInfo oInfo)
            : base(oTile, oImageStore, strLocalFilePath, oImageStore.ServerUri.ToBaseUri())
        {
            m_oCultureInfo = oInfo;

            CalculateArtificialZoom();
        }
Example #16
0
 /// <summary>
 /// This can be used by mesh calculation to calculate projected meshes for tiles
 /// </summary>
 internal virtual void GetProjectionCorners(IGeoSpatialDownloadTile tile, out UV ul, out UV ur, out UV ll, out UV lr)
 {
     // For normal quad tiles this is equal to the geographic coordinates
     ul = new UV(tile.West, tile.North);
     ur = new UV(tile.East, tile.North);
     ll = new UV(tile.West, tile.South);
     lr = new UV(tile.East, tile.South);
 }
Example #17
0
 protected override void QueueDownload(IGeoSpatialDownloadTile oTile, string strLocalFilePath)
 {
     oTile.TileSet.AddToDownloadQueue(oTile.TileSet.Camera,
     new ArcIMSDownloadRequest(oTile, this, strLocalFilePath, m_oCultureInfo));
 }
Example #18
0
 protected override void QueueDownload(IGeoSpatialDownloadTile tile, string filePath)
 {
     tile.TileSet.AddToDownloadQueue(tile.TileSet.Camera,
         new DAPDownloadRequest(tile, this, filePath));
 }