public override void Start()
 {
     download.CompleteCallback += new DownloadCompleteHandler(InternalDownloadComplete);
     if (download.SavedFilePath != null && download.SavedFilePath.Length > 0)
     {
         download.BackgroundDownloadFile();
     }
     else
     {
         download.BackgroundDownloadMemory();
     }
 }
		/// <summary>
		/// Method to load Shape files from shp+dbf supplied in URL
		/// </summary>
		/// <param name="shpURL"></param>
		public void loadShpFileFromURL(string shpURL)
		{		
			string shppath = m_ShapeFileRootDirectory+"\\"+Path.GetFileName(shpURL);
	
			int Nr=1;
			while(File.Exists(shppath)||File.Exists(Path.ChangeExtension(shppath,".dbf")))
			{
				shppath = m_ShapeFileRootDirectory+"\\"+Path.GetFileNameWithoutExtension(shpURL)
					+"~"+Nr.ToString()+Path.GetExtension(shpURL);
				Nr++;
			}		
						
			WebDownload dl1 = new WebDownload(shpURL);
			WebDownload dl3 = new WebDownload(Path.ChangeExtension(shpURL,".dbf"));

			dl1.CompleteCallback += new DownloadCompleteHandler(ShpDownloadComplete);			
			dl1.SavedFilePath = shppath;
			actualDownloads.Add(dl1);
			dl1.BackgroundDownloadFile();
			
			dl3.CompleteCallback += new DownloadCompleteHandler(ShpDownloadComplete);			
			dl3.SavedFilePath = Path.ChangeExtension(shppath,".dbf");
			actualDownloads.Add(dl3);
			dl3.BackgroundDownloadFile();

		}	
 public virtual void StartDownload()
 {
     QuadTile.IsDownloadingImage = true;
     download = new WebDownload(m_url);
     download.DownloadType = DownloadType.Wms;
     download.SavedFilePath = m_localFilePath + ".tmp";
     download.ProgressCallback += new DownloadProgressHandler(UpdateProgress);
     download.CompleteCallback += new DownloadCompleteHandler(DownloadComplete);
     download.BackgroundDownloadFile();
 }
		/// <summary>
		/// Method to load Shape files from shape+xml zip packs supplied in URL
		/// </summary>
		/// <param name="zipURL"></param>
		public void loadZipFileFromURL(string zipURL)
		{
			
			string zippath = m_ShapeFileRootDirectory+"\\"+Path.GetFileName(zipURL);
			int Nr=1;
			while(File.Exists(zippath))
			{
				zippath = m_ShapeFileRootDirectory+"\\"+Path.GetFileNameWithoutExtension(zipURL)
					+"~"+Nr.ToString()+Path.GetExtension(zipURL);
				Nr++;
			}

			WebDownload dl = new WebDownload(zipURL);
			dl.CompleteCallback += new DownloadCompleteHandler(ZipDownloadComplete);
			dl.SavedFilePath = zippath;
			actualDownloads.Add(dl);
			dl.BackgroundDownloadFile();
		
		}
		public virtual void StartDownload()
		{
            Log.Write(Log.Levels.Debug, "GSDR", "Starting download for " + m_url);
            QuadTile.IsDownloadingImage = true;
			download = new WebDownload(m_url);
			download.DownloadType = DownloadType.Wms;
			download.SavedFilePath = m_localFilePath + ".tmp";
			download.ProgressCallback += new DownloadProgressHandler(UpdateProgress);
			download.CompleteCallback += new WorldWind.Net.DownloadCompleteHandler(DownloadComplete);
			download.BackgroundDownloadFile();
		}
Exemple #6
0
        internal void GetTexture(DrawArgs drawArgs, int pixelsPerTile, string _datasetName, string imageExtension, string _cacheDirectory)
        {
            this.drawArgs = drawArgs;
            string _imageExtension = imageExtension;
            string _serverUri = ".ortho.tiles.virtualearth.net/tiles/";

            string quadKey = TileToQuadKey(col, row, level);

            //TODO no clue what ?g= is
            string textureUrl = String.Concat(new object[] { "http://", _datasetName, quadKey[quadKey.Length - 1], _serverUri, _datasetName, quadKey, ".", _imageExtension, "?g=", 15 });

            //load a tile from file OR download it if not cached
            string levelDir = CreateLevelDir(level, _cacheDirectory);
            string rowDir = CreateRowDir(levelDir, row);
            textureName = String.Empty; //= GetTextureName(rowDir, row, col, "dds");
            if (_datasetName == "r")
            {
                textureName = GetTextureName(rowDir, row, col, "png");
            }
            else
            {
                textureName = GetTextureName(rowDir, row, col, "jpeg");
            }
            if (File.Exists(textureName) == true)
            {
                if (!IsBadTile())
                    this.texture = TextureLoader.FromFile(drawArgs.device, textureName);
                else
                {
                    // If older than 7 days download it again
                    FileInfo fi = new FileInfo(textureName);
                    TimeSpan ts = DateTime.Now - fi.LastWriteTime;
                    if (ts.Days > 7)
                        File.Delete(textureName);
                    else
                        return;
                }
            }

            if (this.texture == null)
            {
                m_blDownloading = true;
                download = new WebDownload(textureUrl);
                download.DownloadType = DownloadType.Unspecified;
                download.SavedFilePath = textureName + ".tmp"; //?
                download.ProgressCallback += new DownloadProgressHandler(UpdateProgress);
                download.CompleteCallback += new DownloadCompleteHandler(DownloadComplete);
                download.BackgroundDownloadFile();
            }
        }
Exemple #7
0
 // Asynch download here
 internal virtual void StartDownload(string filePath, string fileName)
 {
     string url = GetServerUrl();
     download = new WebDownload(url);
     download.SavedFilePath = Path.Combine(filePath, fileName);
     download.ProgressCallback += new DownloadProgressHandler(UpdateProgress);
     download.CompleteCallback += new DownloadCompleteHandler(DownloadComplete);
     download.BackgroundDownloadFile();
     isDownloading = true;
 }
        //private Downloader downloader;

        public void GetTexture(DrawArgs drawArgs, int pixelsPerTile)
        {
            this.drawArgs = drawArgs;

            string _datasetName = _veForm.GetDataSetName();
            string _imageExtension = _veForm.GetImageExtension();
            string _serverUri = ".ortho.tiles.virtualearth.net/tiles/";

            string quadKey = TileToQuadKey(col, row, level);

            //TODO no clue what ?g= is
            string textureUrl = String.Concat(new object[] { "http://", _datasetName, quadKey[quadKey.Length - 1], _serverUri, _datasetName, quadKey, ".", _imageExtension, "?g=", 15 });

            if (_veForm.IsDebug == true)
            {
                //generate a DEBUG tile with metadata
                MemoryStream ms;
                //debug
                Bitmap b = new Bitmap(pixelsPerTile, pixelsPerTile);
                System.Drawing.Imaging.ImageFormat imageFormat;
                //could download on my own from here and add metadata to the images before storing to cache
                //Bitmap b = DownloadImage(url);
                //string levelDir = CreateLevelDir(level);
                //string rowDir = CreateRowDir(levelDir, row);
                //alMetaData.Add("wwLevel : " + level.ToString());
                alMetaData.Add("ww rowXcol : " + row.ToString() + "x" + col.ToString());
                //alMetaData.Add("wwArcDist : " + arcDistance.ToString());
                //alMetaData.Add("tileRange : " + tileRange.ToString());
                //alMetaData.Add("latXlon : " + lat.ToString("###.###") + "x" + lon.ToString("###.###"));
                //alMetaData.Add("lat : " + lat.ToString());
                //alMetaData.Add("lon : " + lon.ToString());
                alMetaData.Add("veLevel : " + level.ToString());
                //alMetaData.Add("ve rowXcol : " + t_x.ToString() + "x" + t_y.ToString());
                //alMetaData.Add("veArcDist : " + tileDistance.ToString());
                //alMetaData.Add("sinLat : " + sinLat.ToString());
                alMetaData.Add("quadKey " + quadKey.ToString());
                imageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
                b = DecorateBitmap(b, _font, _brush, alMetaData);
                //SaveBitmap(b, rowDir, row, col, _imageExtension, b.RawFormat); //, System.Drawing.Imaging.ImageFormat.Jpeg
                //url = String.Empty;
                ms = new MemoryStream();
                b.Save(ms, imageFormat);
                ms.Position = 0;
                this.texture = TextureLoader.FromStream(drawArgs.device, ms);
                ms.Close();
                ms = null;
                b.Dispose();
                b = null;
            }
            else
            {
                //load a tile from file OR download it if not cached
                string levelDir = CreateLevelDir(level, _veForm.WorldWindow.Cache.CacheDirectory);
                string mapTypeDir = CreateMapTypeDir(levelDir, _datasetName);
                string rowDir = CreateRowDir(mapTypeDir, row);
                textureName = String.Empty; //= GetTextureName(rowDir, row, col, "dds");
                if (_datasetName == "r")
                {
                    textureName = GetTextureName(rowDir, row, col, "png");
                }
                else
                {
                    textureName = GetTextureName(rowDir, row, col, "jpeg");
                }
                if (File.Exists(textureName) == true)
                {
                    this.texture = TextureLoader.FromFile(drawArgs.device, textureName);
                }
                else //download it
                {
                    /*
                    //use WebDownload instead
                    downloader = new Downloader();
                    downloader.drawArgs = drawArgs;
                    downloader.textureName = textureName;
                    downloader.textureUrl = textureUrl;
                    downloader.veTile = this;
                    downloader.mapType = _datasetName;

                    ThreadStart ts = new ThreadStart(downloader.DownloadThread);
                    Thread t = new Thread(ts);
                    t.IsBackground = true;
                    t.Start();
                    */

                    download = new WebDownload(textureUrl);
                    download.DownloadType = DownloadType.Unspecified;
                    download.SavedFilePath = textureName + ".tmp"; //?
                    download.ProgressCallback += new DownloadProgressHandler(UpdateProgress);
                    download.CompleteCallback += new DownloadCompleteHandler(DownloadComplete);
                    download.BackgroundDownloadFile();
                }
            }
        }
        //TODO: Implement Downloading + Uncompressing + Caching
        private void DownloadParsePlacenames()
        {
            try
            {
                if (m_failed)
                {
                    return;
                }

                if (m_dlInProcess)
                    return;

                //let's use the location from settings instead
                string cachefilename = m_cache.CacheDirectory +
                     string.Format("\\{0}\\WFS\\{1}\\{2}_{3}_{4}_{5}.xml.gz",
                     this.m_world.Name, this.name, this.west, this.south, this.east, this.north);

                if (!File.Exists(cachefilename))
                {
                    m_dlInProcess = true;
                    WebDownload wfsdl = new WebDownload(this.wfsURL);
                    wfsdl.SavedFilePath = cachefilename;
                    wfsdl.BackgroundDownloadFile(new DownloadCompleteHandler(DownloadComplete));
                }
                else
                    ProcessCacheFile();
            }
            catch //(Exception ex)
            {
                //Log.Write(ex);
                if (m_placeNames == null)
                    m_placeNames = new WorldWindPlacename[0];
                m_failed = true;
            }
        }