示例#1
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (list != null)
            {
                list.Clear();
                list = null;
            }
            list       = provider.Projection.GetAreaTileList(area, zoom, 0);
            maxOfTiles = provider.Projection.GetTileMatrixMaxXY(zoom);
            all        = list.Count;

            int countOk = 0;
            int retry   = 0;

            Stuff.Shuffle <GPoint>(list);

            for (int i = 0; i < all; i++)
            {
                if (worker.CancellationPending)
                {
                    break;
                }

                GPoint p = list[i];
                {
                    if (CacheTiles(zoom, p))
                    {
                        countOk++;
                        retry = 0;
                    }
                    else
                    {
                        if (++retry <= 1) // retry only one
                        {
                            i--;
                            System.Threading.Thread.Sleep(1111);
                            continue;
                        }
                        else
                        {
                            retry = 0;
                        }
                    }
                }

                worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

                System.Threading.Thread.Sleep(sleep);
            }

            e.Result = countOk;

            if (!IsDisposed)
            {
                done.WaitOne();
            }
        }
示例#2
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (list != null)
            {
                list.Clear();
                list = null;
            }
            list       = provider.Projection.GetAreaTileList(area, zoom, 0);
            maxOfTiles = provider.Projection.GetTileMatrixMaxXY(zoom);
            all        = list.Count;

            int countOk    = 0;
            int retryCount = 0;

            if (Shuffle)
            {
                Stuff.Shuffle <GPoint>(list);
            }

            lock (this)
            {
                CachedTiles.Clear();
            }

            for (int i = 0; i < all; i++)
            {
                if (worker.CancellationPending)
                {
                    break;
                }

                GPoint p = list[i];
                {
                    // 参数 for SQLite 离线地图存储
                    // 2017-09-17 by Mark Lee
                    p.gid       = this.gid;
                    p.parentGid = this.parentGid;
                    if (CacheTiles(zoom, p))
                    {
                        if (Overlay != null)
                        {
                            lock (this)
                            {
                                CachedTiles.Enqueue(p);
                            }
                        }
                        countOk++;
                        retryCount = 0;
                    }
                    else
                    {
                        if (++retryCount <= retry) // retry only one
                        {
                            i--;
                            System.Threading.Thread.Sleep(1111);
                            continue;
                        }
                        else
                        {
                            retryCount = 0;
                        }
                    }
                }

                worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

                if (sleep > 0)
                {
                    System.Threading.Thread.Sleep(sleep);
                }
            }

            e.Result = countOk;

            if (!IsDisposed)
            {
                done.WaitOne();
            }
        }
示例#3
0
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if(list != null)
             {
            list.Clear();
            list = null;
             }
             list = prj.GetAreaTileList(area, zoom, 0);
             maxOfTiles = prj.GetTileMatrixMaxXY(zoom);
             all = list.Count;

             int countOk = 0;
             int retry = 0;

             Stuff.Shuffle<GPoint>(list);
             var types = GMaps.Instance.GetAllLayersOfType(type);

             for(int i = 0; i < all; i++)
             {
            if(worker.CancellationPending)
               break;

            GPoint p = list[i];
            {
               if(CacheTiles(ref types, zoom, p))
               {
                  countOk++;
                  retry = 0;
               }
               else
               {
                  if(++retry <= 1) // retry only one
                  {
                     i--;
                     System.Threading.Thread.Sleep(1111);
                     continue;
                  }
                  else
                  {
                     retry = 0;
                  }
               }
            }

            worker.ReportProgress((int) ((i+1)*100/all), i+1);

            System.Threading.Thread.Sleep(sleep);
             }

             e.Result = countOk;
        }
示例#4
0
      void worker_DoWork(object sender, DoWorkEventArgs e)
      {
         if(list != null)
         {
            list.Clear();
            list = null;
         }
         list = provider.Projection.GetAreaTileList(area, zoom, 0);
         maxOfTiles = provider.Projection.GetTileMatrixMaxXY(zoom);
         all = list.Count;

         int countOk = 0;
         int retryCount = 0;

         if(Shuffle)
         {
            Stuff.Shuffle<GPoint>(list);
         }

         lock(this)
         {
            CachedTiles.Clear();
         }

         for(int i = 0; i < all; i++)
         {
            if(worker.CancellationPending)
               break;

            GPoint p = list[i];
            {
               if(CacheTiles(zoom, p))
               {
                   if (Overlay != null)
                   {
                       lock (this)
                       {
                           CachedTiles.Enqueue(p);
                       }
                   }
                  countOk++;
                  retryCount = 0;
               }
               else
               {
                  if(++retryCount <= retry) // retry only one
                  {
                     i--;
                     System.Threading.Thread.Sleep(1111);
                     continue;
                  }
                  else
                  {
                     retryCount = 0;
                  }
               }
            }

            worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

            if (sleep > 0)
            {
                System.Threading.Thread.Sleep(sleep);
            }
         }

         e.Result = countOk;

         if(!IsDisposed)
         {
            done.WaitOne();
         }
      }
        void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            if (list != null)
            {
                list.Clear();
                list = null;
            }
            if (!area.IsEmpty)
            {
                list = provider.Projection.GetAreaTileList(area, zoom, 0);
            }
            else
            {
                list = provider.Projection.GetAreaTileList1(area1, zoom, 0);
            }
            maxOfTiles = provider.Projection.GetTileMatrixMaxXY(zoom);
            all        = list.Count;

            int countOk    = 0;
            int retryCount = 0;

            if (Shuffle)
            {
                Stuff.Shuffle <GPoint>(list);
            }

            lock (this)
            {
                CachedTiles.Clear();
            }

            if (all < MyProcessThreadCount)//小数据量不用开线程
            {
                for (int i = 0; i < all; i++)
                {
                    if (worker.CancellationPending)
                    {
                        break;
                    }

                    GPoint p = list[i];
                    {
                        if (CacheTiles(zoom, p))
                        {
                            if (Overlay != null)
                            {
                                lock (this)
                                {
                                    CachedTiles.Enqueue(p);
                                }
                            }
                            countOk++;
                            retryCount = 0;
                        }
                        else
                        {
                            if (++retryCount <= retry) // retry only one
                            {
                                i--;
                                System.Threading.Thread.Sleep(1111);
                                continue;
                            }
                            else
                            {
                                retryCount = 0;
                            }
                        }
                    }
                    worker.ReportProgress((int)((i + 1) * 100 / all), i + 1);

                    if (sleep > 0)
                    {
                        System.Threading.Thread.Sleep(sleep);
                    }
                }
            }
            else
            {
                int threadCount = all / MyProcessThreadCount;
                threadCount = threadCount > MyProcessThreadCount ? MyProcessThreadCount : threadCount;
                int step = all / threadCount;
                int last = all % threadCount;
                MyThreadData.ProcessCount = 0;
                for (int i = 0; i < threadCount; i++)
                {
                    ParameterizedThreadStart ParStart = new ParameterizedThreadStart(ThreadMethod);
                    int start = i * step;
                    int end   = (i + 1) * step;
                    if (i == threadCount - 1)
                    {
                        end += last;
                    }
                    MyThreadData data     = new MyThreadData(start, end);
                    Thread       myThread = new Thread(ParStart);
                    myThread.Start(data);
                }
                while (true)
                {
                    if (MyThreadData.ThreadDataExist > 0)
                    {
                        System.Threading.Thread.Sleep(100);
                        int percent = (int)((MyThreadData.ProcessCount) * 100 / all);

                        worker.ReportProgress(percent > 101 ? 100 : percent, MyThreadData.ProcessCount > all ? all : MyThreadData.ProcessCount);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            e.Result = countOk;

            if (!IsDisposed)
            {
                done.WaitOne();
            }
        }