public async Task add_new_model_to_the_layer__with_features_expect_tile_rendering() { var layerService = new LayerInitializationFileService(Container.GetService <IFileProvider>()); // Simulates the generation of projected features from a GEOJSON file // var simpleFeatures = Container.GetService <IConfigurationStrategy>().Into <List <Feature> >("populated_points_two_projected"); var newLayer = new LayerInformationModel { Identifier = Guid.NewGuid(), Name = Guid.NewGuid().ToString().Substring(0, 6), Properties = new Property[] { new Property { Name = LayerProperties.Features, Value = simpleFeatures, ValueType = typeof(List <IGeometryItem>) } } }; layerService.AddLayer(newLayer); // the Add layer method removes the features and replaces it with a count // Assert.AreEqual(2, newLayer.Properties.First(p => p.Name == LayerProperties.Features).Value); // NOW try to retrieve the tile from memory // var context = new SimpleTileContext() { Identifier = newLayer.Name, MaxZoom = 14, Buffer = 64, Extent = 4096, Tolerance = 3 }; var accessor = new LayerTileCacheAccessor(() => new MockTransformedCacheStorage(), () => new MockRawCacheStorage()); var generator = new Generator(context, accessor, layerService); var retriever = new TileRetrieverService(accessor, context, generator); var tile = await retriever.GetTile(1, 0, 0); Assert.IsNotNull(tile); }
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); }