public async Task given_projected_points_retrieve_points_transformed() { Container.GetService <MockContextRepository>().TryGetAs <MockTileContext>("simple_points", out MockTileContext context); var raw = new LayerTileCacheAccessor(() => new MockTransformedCacheStorage(), () => new MockRawCacheStorage()); var generator = new Generator(context, raw, new LayerInitializationFileService(Container.GetService <IFileProvider>())); var retriever = new TileRetrieverService(raw, context, generator); var tile = await retriever.GetTile(0, 0, 0); Assert.IsNotNull(tile); }
public TileRetrieverService( LayerTileCacheAccessor cacheAccessor, ITileContext context, Generator tileGenerator) { this.tileGenerator = tileGenerator; this.cacheAccessor = cacheAccessor; this.tileContext = context; this.tileTransform = new Transform(context.Extent, context.Buffer); if (tileContext == null) { throw new NotSupportedException("The TileContext must have a value."); } }
public async Task given_feature_in_projected_coords_process_into_basic_tile() { Container.GetService <MockContextRepository>().TryGetAs <MockTileContext>("base", out MockTileContext context); var accessor = new LayerTileCacheAccessor(() => null, () => new MockRawCacheStorage()); var generator = new Generator(context, accessor, new LayerInitializationFileService(Container.GetService <IFileProvider>())); await generator.GenerateTile(0, 0, 0); var tile = accessor.GetRawTile(context.Identifier, 0, 0, 0); Assert.AreEqual(0d, tile.X); Assert.AreEqual(0d, tile.Y); Assert.AreEqual(1d, tile.ZoomSquared); Assert.AreEqual(386, tile.NumberOfPoints); Assert.AreEqual(6, tile.NumberOfSimplifiedPoints); Assert.AreEqual(1, tile.NumberOfFeatures); }
public async Task projected_into_features_initialize_layer_from_features_expect_cached_tile() { // Covers the case that the GeoJsonContext is not the context that initializes the TileRetrieverService // var geoJSON = Container.GetService <IConfigurationStrategy>().GetJson("populated_points_two_US"); var uniqueId = Guid.NewGuid().ToString().Substring(0, 6); var context = new GeoJsonContext(geoJSON) { Identifier = uniqueId, MaxZoom = 14, Buffer = 64, Extent = 4096, Tolerance = 3 }; var tileContext = new SimpleTileContext() { MaxZoom = 14, Buffer = 64, Extent = 4096, Tolerance = 3 }; var accessor = new LayerTileCacheAccessor(() => new MockTransformedCacheStorage(), () => new MockRawCacheStorage()); var generator = new Generator(tileContext, accessor, new LayerInitializationFileService(Container.GetService <IFileProvider>())); var retriever = new TileRetrieverService(accessor, tileContext, generator); var pipeline = new DetermineCollectionsTypePipeline() .ExtendWith(new ParseGeoJsonToFeatures() .IterateWith(new ProjectGeoJSONToGeometric( (geoItem) => new WebMercatorProcessor(geoItem))) .ExtendWith(new GeometricSimplification()) .ExtendWith(new InitializeProjectedFeatures(retriever))); await pipeline.Process(context); // Its important that this succeeded // Assert.IsNotNull(context.Features); }
public void given_feature_in_projected_coords_process_into_second_level_tile() { Container.GetService <MockContextRepository>().TryGetAs <MockTileContext>("base", out MockTileContext context); var coloradoFeature = Container.GetService <IConfigurationStrategy>().Into <List <Feature> >("colorado_outline_projected"); context.TileFeatures = coloradoFeature; var accessor = new LayerTileCacheAccessor(() => null, () => new MockRawCacheStorage()); var generator = new Generator(context, accessor, new LayerInitializationFileService(Container.GetService <IFileProvider>())); generator.SplitTile(context.TileFeatures.ToArray(), zoom: 0, x: 0, y: 0, currentZoom: 1, currentX: 0, currentY: 0); generator.SplitTile(context.TileFeatures.ToArray(), zoom: 1, x: 0, y: 0, currentZoom: 2, currentX: 0, currentY: 1); generator.SplitTile(context.TileFeatures.ToArray(), zoom: 2, x: 0, y: 1, currentZoom: 3, currentX: 1, currentY: 3); var tile = accessor.GetRawTile(context.Identifier, 0, 0, 0); Assert.AreEqual(0d, tile.X); Assert.AreEqual(0d, tile.Y); Assert.AreEqual(1d, tile.ZoomSquared); Assert.AreEqual(386, tile.NumberOfPoints); Assert.AreEqual(6, tile.NumberOfSimplifiedPoints); Assert.AreEqual(1, tile.NumberOfFeatures); }
public async Task project_raw_points_into_features_initialize_layer_from_features_expect_cached_tile() { var geoJSON = Container.GetService <IConfigurationStrategy>().GetJson("populated_points_two_US"); var uniqueId = Guid.NewGuid().ToString().Substring(0, 6); var context = new GeoJsonContext(geoJSON) { Identifier = uniqueId, MaxZoom = 14, Buffer = 64, Extent = 4096, Tolerance = 3 }; var accessor = new LayerTileCacheAccessor(() => new MockTransformedCacheStorage(), () => new MockRawCacheStorage()); var generator = new Generator(context, accessor, new LayerInitializationFileService(Container.GetService <IFileProvider>())); var retriever = new TileRetrieverService(accessor, context, generator); var pipeline = new DetermineCollectionsTypePipeline() .ExtendWith(new ParseGeoJsonToFeatures() .IterateWith(new ProjectGeoJSONToGeometric( (geoItem) => new WebMercatorProcessor(geoItem))) .ExtendWith(new GeometricSimplification()) .ExtendWith(new InitializeProjectedFeatures(retriever))); await pipeline.Process(context); var tile = await retriever.GetTile(1, 0, 0); Assert.IsNotNull(tile); var transformed = tile as ITransformedTile; var featue = transformed.TransformedFeatures.First(); (int X, int Y)coordinates = transformed.TransformedFeatures.First().Coordinates.First(); Assert.AreEqual(1707, coordinates.X); Assert.AreEqual(3109, coordinates.Y); }