Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="name"></param>
 /// <param name="levels"></param>
 /// <param name="env">wkid of envelope must be 4326</param>
 /// <param name="polygon">If null, means download extent is rectangle and drawed by using mouse by user; if not null, means download extent is a polygon by importing a shapefile.</param>
 public DownloadProfile(string name, int[] levels, PBS.Util.Envelope env, PBS.Util.Polygon polygon)
 {
     Name     = name;
     Levels   = levels;
     Envelope = env;
     Polygon  = polygon;
 }
Пример #2
0
        public void DownloadAsync(int[] Levels, string Output)
        {
            string fileName = AppDomain.CurrentDomain.BaseDirectory + "CustomTile.xml";

            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException(fileName + " does not exist!");
            }
            XDocument xDoc    = XDocument.Load(fileName);
            XElement  element = xDoc.Element("TileInfo");

            PBS.Util.Envelope g = new PBS.Util.Envelope(Convert.ToDouble(element.Element("DownLoadExtent").Attribute("xmin").Value), Convert.ToDouble(element.Element("DownLoadExtent").Attribute("ymin").Value),
                                                        Convert.ToDouble(element.Element("DownLoadExtent").Attribute("xmax").Value), Convert.ToDouble(element.Element("DownLoadExtent").Attribute("ymax").Value));
            string             fileDest   = "cache/" + Output;
            DataSourceOtherMap pgisSource = new DataSourceOtherMap("", true)
            {
                OutputFileName = Output, downloadExtent = g
            };

            pgisSource.ConvertCompleted += (s, a) =>
            {
                MessageBox.Show("Convert Success !");
            };
            BackgroundWorker bw = new BackgroundWorker();

            bw.DoWork += (s, a) =>
            {
                try
                {
                    pgisSource.ConvertToMBTiles(fileDest, "", "", "", Levels, g, false);
                }
                catch (Exception e)
                {
                    Utility.Log(LogLevel.Error, e, "Error");
                }
            };
            bw.RunWorkerAsync();
        }
Пример #3
0
        private void StartButtonClicked(object parameters)
        {
            if (!IsValidFilename(Output))
            {
                MessageBox.Show(App.Current.FindResource("msgOutputPathError").ToString(), App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (File.Exists(Output))
            {
                if (MessageBox.Show(App.Current.FindResource("msgOverwrite").ToString(), App.Current.FindResource("msgWarning").ToString(), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
                {
                    return;
                }
                else
                {
                    try
                    {
                        File.Delete(Output);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            try
            {
                TilingScheme tilingScheme = PBS.Service.SchemaProvider.Inst.getSchema("OtherMap", null, null);

                var   lods   = tilingScheme.LODs;
                int[] Levels = new int[lods.Count()];
                int   i      = 0;
                foreach (var lod in lods)
                {
                    Levels[i] = lod.LevelID;
                    i++;
                }

                PBS.Util.Envelope g        = PBS.Service.SchemaProvider.Inst.getDownloadExtend("OtherMap");
                string            fileDest = Output;
                Datasource = new DataSourceOtherMap("", true)
                {
                    OutputFileName = Output, downloadExtent = g
                };
                Datasource.ConvertCompleted += (s, a) =>
                {
                    if (a.Successful)
                    {
                        string str = App.Current.FindResource("msgConvertComplete").ToString();
                        if (DoCompact)
                        {
                            str += "\r\n" + App.Current.FindResource("msgCompactResult").ToString() + (Datasource.ConvertingStatus.SizeBeforeCompact / 1024).ToString("N0") + "KB --> " + (Datasource.ConvertingStatus.SizeAfterCompact / 1024).ToString("N0") + "KB";
                        }
                        MessageBox.Show(str, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                };

                // Datasource.ConvertCancelled += (s, a) =>
                //{
                //};
                BackgroundWorker bw = new BackgroundWorker();
                bw.DoWork += (s, a) =>
                {
                    IsIdle = false;
                    try
                    {
                        Datasource.ConvertToMBTiles(fileDest, "", "", "", Levels, g, false);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, App.Current.FindResource("msgError").ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    IsIdle = true;
                };
                bw.RunWorkerAsync();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }