Example #1
0
        public void TileFetcherShouldBehaveProperlyWithNoisyResponses()
        {
            // Arrange
            var schema = new GlobalSphericalMercator();
            var tileSource = new TileSource(new SometimesFailingTileProvider(), schema);
            var memoryCache = new MemoryCache<Feature>(14, 17);
            var tileFetcher = new TileFetcher(tileSource, memoryCache);
            var random = new Random(31747074);

            // Act
            for (int i = 0; i < 100; i++)
            {
                var randomLevel = "5";
                var randomCol = random.Next(schema.GetMatrixWidth(randomLevel));
                var randomRow = random.Next(schema.GetMatrixHeight(randomLevel));
                var tileRange = new TileRange(randomCol - 2, randomRow - 2, 5, 5);
                var unitsPerPixel = schema.Resolutions[randomLevel].UnitsPerPixel;
                var extent = TileTransform.TileToWorld(tileRange, randomLevel, schema);
                tileFetcher.ViewChanged(TileTransform.TileToWorld(tileRange, randomLevel, schema).ToBoundingBox(),unitsPerPixel );
                var tileInfos = schema.GetTileInfos(extent, randomLevel);
                foreach (var tileInfo in tileInfos)
                {
                    var tiles = memoryCache.Find(tileInfo.Index);

                }
            }

            // Assert
            Assert.True(memoryCache.TileCount == 0);
        }
        public FileTileLayerConfiguration(string name, string path, string format, int min, int max)
        {
            LegendText = name;

            _path = path;
            _format = format;
            _minTiles = min;
            _maxTiles = max;

            TileSource = new TileSource(
                new FileTileProvider(path, format, new TimeSpan(0)),
                new TileSchema());

            TileCache = TileFetcher.NoopCache.Instance;
        }
Example #3
0
        public void TileFetcherShouldBehaveProperlyWithFailingTileRequests()
        {
            // Arrange
            var schema = new GlobalSphericalMercator();
            var tileSource = new TileSource(new FailingTileProvider(), schema);
            var memoryCache = new MemoryCache<Feature>();
            var tileFetcher = new TileFetcher(tileSource, memoryCache);

            // Act
            tileFetcher.ViewChanged(schema.Extent.ToBoundingBox(), schema.Resolutions["2"].UnitsPerPixel);
            while (tileFetcher.Busy) { }

            // Assert
            Assert.True(memoryCache.TileCount == 0);
        }
Example #4
0
		public Window1()
		{
			_dispatcherTimer.Tick += new EventHandler(_dispatcherTimer_Tick);

			AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

			InitializeComponent();
			map.ErrorMessageChanged += map_ErrorMessageChanged;
			Loaded += Window1_Loaded;

			ChooserViewModel root = itemChooser.Items[0] as ChooserViewModel;

			CommandBindings.Add(
				new CommandBinding(
					ApplicationCommands.Undo,
					( sender, e ) => // Execute
					{
						e.Handled = true;
						root.IsChecked = false;
						itemChooser.Focus();
					},
					( sender, e ) => // CanExecute
					{
						e.Handled = true;
						e.CanExecute = ( root.IsChecked != false );
					} ) );

			itemChooser.Focus();

			string appdir = Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location );

			TileSource tileSource = new TileSource(
				new FileTileProvider( new FileCache( appdir + "\\Tiles", "jpg" ) ),
				new TileSchema()
			);

			map.RootLayer = new TileLayer( tileSource );

			_fileSystemWatcher.Changed += fileSystemWatcher_Changed;

			InitializeTransform( tileSource.Schema );
		}
        public BruTileCustomLayer(IApplication application, TileSource tileSource, FileCache fileCache)
        {
            _tileSource = tileSource;
            _fileCache = fileCache;
            _simplefilefetcher = new SimpleFileFetcher(tileSource, fileCache);
            var spatialReferences = new SpatialReferences();
            _dataSpatialReference = spatialReferences.GetSpatialReference(_tileSource.Schema.Srs);

            if (SpatialReference.FactoryCode == 0)
            {
                // zet dan de spatial ref...
                m_spatialRef = _dataSpatialReference;
            }
            var mxdoc = (IMxDocument)application.Document;
            _map = mxdoc.FocusMap;
            var envelope = GetDefaultEnvelope();

            // If there is only one layer in the TOC zoom to this layer...
            if (_map.LayerCount == 0)
            {
                ((IActiveView)_map).Extent = envelope;
            }
        }
Example #6
0
        public void TileFetcherWithReturningNull()
        {
            // Arrange
            var tileProvider = new NullTileProvider();
            var tileSchema = new GlobalSphericalMercator();
            var tileSource = new TileSource(tileProvider, tileSchema);
            var tileFetcher = new TileFetcher(tileSource, new MemoryCache<Feature>());

            // Act
            for (int i = 0; i < 300; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    tileFetcher.ViewChanged(tileSchema.Extent.ToBoundingBox(), tileSchema.Resolutions[j.ToString()].UnitsPerPixel);
                    System.Threading.Thread.Sleep(10);
                }
            }

            // Assert
            while (tileFetcher.Busy) { }

            Assert.Pass("The fetcher did not go into an infinite loop");
        }