/// <summary> /// Creates an instance of this class using some tile source configuration. /// </summary> /// <param name="configuration">The tile source configuration. If the configuration /// hasn't been initialized yet, <see cref="IConfiguration.Initialize"/> will /// be called.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="configuration"/> /// is <c>null</c>.</exception> /// <exception cref="CannotFindTileSourceException">Thrown when <paramref name="configuration"/> /// is not initialized and during initialization no tile source can be found.</exception> /// <exception cref="CannotCreateTileCacheException">Thrown when <paramref name="configuration"/> /// is not initialized and during initialization a critical error prevents the creation /// of the persistent tile cache.</exception> /// <exception cref="CannotReceiveTilesException">Thrown when <paramref name="configuration"/> /// is not initialized and during initialization no tiles can be received from the tile source.</exception> public BruTileLayer(IConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (!configuration.Initialized) { configuration.Initialize(); } this.configuration = configuration; ITileSchema tileSchema = configuration.TileSchema; sourceProjection = GetTileSourceProjectionInfo(tileSchema.Srs); Projection = sourceProjection; BruTileExtent extent = tileSchema.Extent; MyExtent = new DotSpatialExtent(extent.MinX, extent.MinY, extent.MaxX, extent.MaxY); IsVisible = true; tileFetcher = configuration.TileFetcher; tileFetcher.TileReceived += HandleTileReceived; tileFetcher.QueueEmpty += HandleQueueEmpty; // Set the wrap mode imageAttributes = new ImageAttributes(); imageAttributes.SetWrapMode(WrapMode.TileFlipXY); }
private static IConfiguration CreateStubConfiguration(MockRepository mocks, ITileFetcher tileFetcher) { var schema = mocks.Stub <ITileSchema>(); schema.Stub(s => s.Srs).Return("EPSG:28992"); schema.Stub(s => s.Extent).Return(new Extent()); var configuration = mocks.Stub <IConfiguration>(); configuration.Stub(c => c.Initialized).Return(true); configuration.Stub(c => c.TileSchema).Return(schema); configuration.Stub(c => c.TileFetcher).Return(tileFetcher); configuration.Stub(c => c.Dispose()); return(configuration); }