Exemplo n.º 1
0
 private void OnAreaChanged(LatLonRect oldArea, LatLonRect newArea)
 {
     if ((ZoomLevel < SmallThreshold && lastZoomLevel != -1) || (newArea.Span.Latitude > MAX_LAT_RANGE * 8 || newArea.Span.Longitude > MAX_LON_RANGE * 8))
     {
         ShownStops.Clear();
         PendingRegions.Clear();
     }
     else
     {
         IEnumerable <LatLonRect> newRegion;
         if (lastZoomLevel < SmallThreshold)
         {
             newRegion = new LatLonRect[] { newArea }
         }
         ;
         else
         {
             newRegion = oldArea.GetNewRegion(newArea);
         }
         AppendRegions(newRegion);
         if (!IsBusy)
         {
             RefreshShownStops(TokenSource.Token, !ManuallyDownloadStops);
         }
     }
     lastZoomLevel = ZoomLevel;
 }
 private void OnAreaChanged(LatLonRect oldArea, LatLonRect newArea)
 {
     if ((ZoomLevel < SmallThreshold && lastZoomLevel != -1) || (newArea.Span.Latitude > MAX_LAT_RANGE * 8 || newArea.Span.Longitude > MAX_LON_RANGE * 8))
     {
         ShownStops.Clear();
         PendingRegions.Clear();
     }
     else
     {
         IEnumerable<LatLonRect> newRegion;
         if (lastZoomLevel < SmallThreshold)
             newRegion = new LatLonRect[] { newArea };
         else
             newRegion = oldArea.GetNewRegion(newArea);
         AppendRegions(newRegion);
         if (!IsBusy)
             RefreshShownStops(TokenSource.Token, !ManuallyDownloadStops);
     }
     lastZoomLevel = ZoomLevel;
 }
Exemplo n.º 3
0
        public void LatLonRect_GetNewRegionTests()
        {
            LatLonRect rect     = new LatLonRect(8, 10, 4, 5);
            var        reg      = rect.GetNewRegion(new LatLonRect(7, 12, 4, 4)).ToList();
            var        expected = new LatLonRect(7, 12, 4, 10);

            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion0: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(7, 5, 4, 4);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion0: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            if (reg.Count > 0)
            {
                Assert.Fail($"GetNewRegion0: result contains unexpected entries:{reg.Aggregate("", (acc, rct) => acc + $" ({rct.ToString()})")}.");
            }

            reg      = rect.GetNewRegion(new LatLonRect(9, 12, 1, 1)).ToList();
            expected = new LatLonRect(9, 10, 8, 5);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(9, 12, 8, 10);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(8, 12, 4, 10);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(4, 12, 1, 10);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(4, 10, 1, 5);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(4, 5, 1, 1);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(8, 5, 4, 1);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            expected = new LatLonRect(9, 5, 8, 1);
            if (!reg.Contains(expected))
            {
                Assert.Fail($"GetNewRegion1: expected to contain {expected}, which it does not.");
            }
            reg.Remove(expected);
            if (reg.Count > 0)
            {
                Assert.Fail($"GetNewRegion1: result contains unexpected entries:{reg.Aggregate("", (acc, rct) => acc + $" ({rct.ToString()})")}.");
            }
        }