public void PreprocessWithPlaceAndWay_ShouldMergePlaceIntoIt() { var node1 = CreateNode(1, 0, 0); var node2 = CreateNode(2, 0, 1); var node3 = CreateNode(3, 1, 1); var node4 = CreateNode(4, 1, 0); var node5 = CreateNode(5, 0.5, 0.6); node5.Tags.Add("place", "any"); var way1 = new CompleteWay { Id = 6, Tags = new TagsCollection { { FeatureAttributes.NAME, "name" }, { "place", "any" } }, Nodes = new[] { node1, node2, node3, node4, node1 } }; var osmElements = new List <ICompleteOsmGeo> { node5, way1 }; var dictionary = new Dictionary <string, List <ICompleteOsmGeo> > { { FeatureAttributes.NAME, osmElements } }; var results = _preprocessorExecutor.Preprocess(dictionary); results = _preprocessorExecutor.MergePlaceNodes(results, results.Where(f => f.Geometry is Polygon).ToList()); Assert.AreEqual(1, results.Count); var geoLocation = results.First().Attributes[FeatureAttributes.GEOLOCATION] as AttributesTable; Assert.IsNotNull(geoLocation); Assert.AreEqual(0.5, geoLocation[FeatureAttributes.LAT]); Assert.AreEqual(0.6, geoLocation[FeatureAttributes.LON]); Assert.IsTrue(results.First().Geometry is Polygon); }
/// <inheritdoc /> public override async Task <List <Feature> > GetPointsForIndexing() { _logger.LogInformation("Starting getting OSM points of interetes"); using (var stream = _latestFileFetcherExecutor.Get()) { var osmNamesDictionary = await _osmRepository.GetElementsWithName(stream); var relevantTagsDictionary = _tagsHelper.GetAllTags(); var namelessNodes = await _osmRepository.GetPointsWithNoNameByTags(stream, relevantTagsDictionary); osmNamesDictionary.Add(string.Empty, namelessNodes.Cast <ICompleteOsmGeo>().ToList()); var features = _osmGeoJsonPreprocessorExecutor.Preprocess(osmNamesDictionary); var containers = features.Where(f => f.IsValidContainer()).OrderBy(f => f.Geometry.Area).ToList(); features = _osmGeoJsonPreprocessorExecutor.MergePlaceNodes(features, containers); _logger.LogInformation("Finished getting OSM points of interetes: " + features.Count); return(features); } }