예제 #1
0
 public GLOBETileDesignator(string fileindex, string filename, double minlat, double maxlat, double minlon, double maxlon, int minelv, int maxelv, int rows, int columns, int version, string url, GLOBETILESTATUS status, bool local, DateTime lastupdated)
 {
     FileIndex   = fileindex;
     FileName    = filename;
     MinLat      = minlat;
     MaxLat      = maxlat;
     MinLon      = minlon;
     MaxLon      = maxlon;
     MinElv      = minelv;
     MaxElv      = maxelv;
     Rows        = rows;
     Columns     = columns;
     Version     = version;
     URL         = url;
     Status      = status;
     Local       = local;
     LastUpdated = lastupdated;
 }
예제 #2
0
 public void FromTable(DataTable dt)
 {
     if (dt == null)
     {
         return;
     }
     this.Clear();
     foreach (DataRow row in dt.Rows)
     {
         string          index       = row["FileIndex"].ToString();
         string          filename    = row["FileName"].ToString();
         double          minlat      = System.Convert.ToDouble(row["MinLat"]);
         double          maxlat      = System.Convert.ToDouble(row["MaxLat"]);
         double          minlon      = System.Convert.ToDouble(row["MinLon"]);
         double          maxlon      = System.Convert.ToDouble(row["MaxLon"]);
         int             minelv      = System.Convert.ToInt32(row["MinElv"]);
         int             maxelv      = System.Convert.ToInt32(row["MaxElv"]);
         int             rows        = System.Convert.ToInt32(row["Rows"]);
         int             columns     = System.Convert.ToInt32(row["Columns"]);
         int             version     = System.Convert.ToInt32(row["Version"]);
         string          url         = row["URL"].ToString();
         GLOBETILESTATUS status      = (GLOBETILESTATUS)Enum.Parse(typeof(GLOBETILESTATUS), row["Status"].ToString());
         bool            local       = System.Convert.ToBoolean(row["Local"]);
         DateTime        lastupdated = DateTime.UtcNow;
         try
         {
             try
             {
                 lastupdated = DateTime.ParseExact(row["LastUpdated"].ToString(), "yyyy-MM-dd HH:mm:ssZ", CultureInfo.InvariantCulture);
                 lastupdated = lastupdated.ToUniversalTime();
             }
             catch
             {
             }
             Update(new GLOBETileDesignator(index, filename, minlat, maxlat, minlon, maxlon, minelv, maxelv, rows, columns, version, url, status, local, lastupdated));
         }
         catch
         {
         }
     }
 }
예제 #3
0
 public DataTable FromJSONArray(string filename)
 {
     if (!File.Exists(filename))
     {
         return(new DataTableGLOBE());
     }
     try
     {
         using (StreamReader sr = new StreamReader(File.OpenRead(filename)))
         {
             string         json = sr.ReadToEnd();
             JSONArrayGLOBE a    = JsonConvert.DeserializeObject <JSONArrayGLOBE>(json);
             // check version
             if (String.Compare(Version, a.version) != 0)
             {
                 // do upgrade/downgrade stuff here
             }
             else
             {
                 foreach (List <string> l in a.tiles)
                 {
                     string          fileindex = l[0];
                     string          FileName  = l[1];
                     double          minlat    = System.Convert.ToDouble(l[2], CultureInfo.InvariantCulture);
                     double          maxlat    = System.Convert.ToDouble(l[3], CultureInfo.InvariantCulture);
                     double          minlon    = System.Convert.ToDouble(l[4], CultureInfo.InvariantCulture);
                     double          maxlon    = System.Convert.ToDouble(l[5], CultureInfo.InvariantCulture);
                     int             minelv    = System.Convert.ToInt32(l[6]);
                     int             maxelv    = System.Convert.ToInt32(l[7]);
                     int             rows      = System.Convert.ToInt32(l[8]);
                     int             columns   = System.Convert.ToInt32(l[9]);
                     int             version   = System.Convert.ToInt32(l[10]);
                     string          url       = l[11];
                     GLOBETILESTATUS status    = GLOBETILESTATUS.UNDEFINED;
                     try
                     {
                         status = (GLOBETILESTATUS)Enum.Parse(typeof(GLOBETILESTATUS), l[12]);
                     }
                     catch
                     {
                     }
                     bool     local       = System.Convert.ToBoolean(l[13]);
                     DateTime lastupdated = DateTime.UtcNow;
                     try
                     {
                         lastupdated = System.Convert.ToDateTime(l[4]);
                     }
                     catch
                     {
                     }
                     Update(new GLOBETileDesignator(fileindex, filename, minlat, maxlat, minlon, maxlon, minelv, maxelv, rows, columns, version, url, status, local, lastupdated));
                 }
             }
         }
         return(ToTable());
     }
     catch (Exception ex)
     {
     }
     return(new DataTableGLOBE());
 }
예제 #4
0
 public GLOBETileDesignator(string fileindex, string filename, double minlat, double maxlat, double minlon, double maxlon, int minelv, int maxelv, int rows, int columns, int version, string url, GLOBETILESTATUS status, bool local)
     : this(fileindex, filename, minlat, maxlat, minlon, maxlon, minelv, maxelv, rows, columns, version, url, status, local, DateTime.UtcNow)
 {
 }