Download Request Class Downloadrequest is the abstract base class of various download requests, first derive the network download request class Webdownloadrequest, then derive the geospatial download request Class Geospatialdownloadrequest (abstract Class), Then derive the terrain download request Class Terraindownloadrequest. The class diagram for these classes is as follows.
Abstract base class download request Class Downloadrequest
Abstract base class download request class Downloadrequest The meanings of each field and property are described below:
Internal static downloadqueue queue;//Specifies the download queue object that stores the download request object
Object M_owner; Specify the owner of the download request
Public abstract string key//the unique string key that identifies the download request
public object owner//Specifies the owner of the download request
Public abstract float progress//indicates the progress of the download request completion, between (0,1)
Public abstract bool isdownloading//identifies whether the download request is being downloaded
Constructor protected Downloadrequest (object owner) simply specifies the owner of the download request
The virtual method public virtual float Calculatescore () calculates the score of the download request, which is used to prioritize the download and to overload the north in the derived class to give precedence. Returns a score, or float when the download request is no longer active. MinValue
Abstract method public abstract void Start () begins processing the request and must be overloaded by the derived class
public virtual void OnComplete () derived classes need to call this virtual method to send a processing completion signal
Network download Request Class Webdownloadrequest
Network download request Class webdownloadrequest The meanings of each field and attribute are described below:
Protected webdownload download;//Network Download object
protected static string temporaryextension = ". tmp";//network download file temporary extension
public string Savefilepath
public override float Progress
public override string Key
public override bool Isdownloading
public override void Start ()
public override float Calculatescore ()
The above six members are the members of the overloaded parent class, see the parent class for details, and do not repeat them.
The constructor public webdownloadrequest (object owner) completes assigning a value to the owner of the request owner of the parent class, while instantiating the network download object download with an empty string. The overloaded constructor instantiates the network download object download with the given download request URL.
The virtual method protected virtual void Internaldownloadcomplete (webdownload download) needs to be overloaded, and when the download has been completed to be notified, internal calls to the following DownloadComplete ( ) virtual functions.
The virtual function protected virtual void downloadcomplete () needs to be overloaded in a derived class where no functionality is implemented.
Geo-Spatial Download request Class Geospatialdownloadrequest
Geospatial download Request Class Geospatialdownloadrequest is an abstract class, and the meanings of each field and property are described below:
public abstract int color//identifies the color of the download information for this layer
Public abstract float south//The southern border of the tile currently requested, in degrees 10
Public abstract float north//the north boundary of the tile currently requested, in degrees 10
Public abstract float east//the eastern boundary of the tile currently requested, in degrees 10
Public abstract float west//the western boundary of the currently requested tile, 10 in degrees
Constructor protected Geospatialdownloadrequest (object owner, string uri): base (owner, URI) calls the constructor of the parent class, Also set the download type to DOWNLOADTYPE.WMS
Terrain download Request Class Terraindownloadrequest
Terrain download Request Class terraindownloadrequest The meanings of each field and attribute are described below:
Public terraintile terraintile;//Download request the Terrain tile object to download
Const string contenttypezip = "Application/zip";//The compression type that identifies the content of the downloaded data
Const string contenttype7z = "application/x-7z-compressed";
Const string contenttypexcompressed = "application/x-compressed";
public abstract int color//The following five members are members that correspond to overloaded parent classes
Public abstract Float South
Public abstract float North
public abstract Float East
public abstract Float West
public override float Calculatescore ()
Constructor public terraindownloadrequest (Terraintile tile, terraintileservice owner, int row, int col, int targetlevel) With the given tile object parameters assigned to the tile variable members, with a given tile owner, tile row number, tile column number, tile level and other information to construct the network download object URL string.
method public void Downloadinforeground () to download tile data in the foreground. The process steps are: Call DownloadFile to download the data and store it in the specified target path, and then call the Processfile function to process the downloaded data if you snap to "FileNotFoundException" The exception calls Flagbadtile to create an empty file, and if the "WebException" exception is caught, the Flagbadtile function is called according to the HttpWebResponse response, and the other exception is not processed.
The virtual function protected override void DownloadComplete () overloads the Grandfather class method, which is the callback function when the tile download is complete, and internally calls the following two methods. Verify the validity of the data when the download is complete.
method void Flagbadtile () if the server does not have the requested data, create an empty file to identify the missing file and send a signal that "the current request is permanently unavailable for some reason" and avoid hitting the server with a duplicate request. Tile tiles will handle removing this empty file and re-initiating the request to the server.
Method protected void Processfile () is processed differently depending on the compression type of the downloaded data content. Three types of compression type specific processing methods For: Zip compression types are handled with the Fastzip class in the ICSharpCode.SharpZipLib.dll assembly, 7z or xcompressed compression types are started with the process and ProcessStartInfo classes \system\ 7za.exe program to handle.
WorldWind Source Analysis Series: Download Request class Downloadrequest