private async Task RebuildPointsOfInterest() { _logger.LogInformation("Starting rebuilding POIs database."); var osmSource = _pointsOfInterestAdapterFactory.GetBySource(Sources.OSM); var osmFeaturesTask = osmSource.GetPointsForIndexing(); var sources = _pointsOfInterestAdapterFactory.GetAll().Where(s => s.Source != Sources.OSM).Select(s => s.Source); var otherTasks = sources.Select(s => _elasticSearchGateway.GetExternalPoisBySource(s)); await Task.WhenAll(new Task[] { osmFeaturesTask }.Concat(otherTasks)); var features = _featuresMergeExecutor.Merge(osmFeaturesTask.Result.Concat(otherTasks.SelectMany(t => t.Result)).ToList()); foreach (var feature in features) { var geoLocation = feature.Attributes[FeatureAttributes.POI_GEOLOCATION] as AttributesTable; feature.Attributes.AddOrUpdate(FeatureAttributes.POI_ALT, await _elevationDataStorage.GetElevation( new Coordinate((double)geoLocation[FeatureAttributes.LON], (double)geoLocation[FeatureAttributes.LAT])) ); var northEast = _mathTransform.Transform((double)geoLocation[FeatureAttributes.LON], (double)geoLocation[FeatureAttributes.LAT]); feature.Attributes.AddOrUpdate(FeatureAttributes.POI_ITM_EAST, (int)northEast.x); feature.Attributes.AddOrUpdate(FeatureAttributes.POI_ITM_NORTH, (int)northEast.y); } await _elasticSearchGateway.UpdatePointsOfInterestZeroDownTime(features); _logger.LogInformation("Finished rebuilding POIs database."); }
private async Task RebuildPointsOfInterest() { _logger.LogInformation("Starting rebuilding POIs database."); var fetchTasks = _pointsOfInterestAdapterFactory.GetAll().Select(a => a.GetPointsForIndexing()).ToArray(); var features = (await Task.WhenAll(fetchTasks)).SelectMany(v => v).ToList(); features = _featuresMergeExecutor.Merge(features); await _elasticSearchGateway.UpdatePointsOfInterestZeroDownTime(features); _logger.LogInformation("Finished rebuilding POIs database."); }
private async Task RebuildPointsOfInterest() { _logger.LogInformation("Starting rebuilding POIs database."); var osmSource = _pointsOfInterestAdapterFactory.GetBySource(Sources.OSM); var osmFeaturesTask = osmSource.GetPointsForIndexing(); var sources = _pointsOfInterestAdapterFactory.GetAll().Where(s => s.Source != Sources.OSM).Select(s => s.Source); var otherTasks = sources.Select(s => _elasticSearchGateway.GetExternalPoisBySource(s)).ToArray(); await Task.WhenAll(new Task[] { osmFeaturesTask }.Concat(otherTasks)); var features = _featuresMergeExecutor.Merge(osmFeaturesTask.Result.Concat(otherTasks.SelectMany(t => t.Result)).ToList()); await _elasticSearchGateway.UpdatePointsOfInterestZeroDownTime(features); _logger.LogInformation("Finished rebuilding POIs database."); }
public void TestRebuild_ShouldRebuildHighwaysAndPoints() { var adapter = Substitute.For <IPointsOfInterestAdapter>(); adapter.GetPointsForIndexing().Returns(new List <Feature>()); _pointsOfInterestAdapterFactory.GetBySource(Arg.Any <string>()).Returns(adapter); _elasticSearchGateway.GetExternalPoisBySource(Arg.Any <string>()).Returns(new List <Feature>()); _featuresMergeExecutor.Merge(Arg.Any <List <Feature> >()).Returns(new List <Feature>()); _service.Rebuild(new UpdateRequest { Highways = true, PointsOfInterest = true, SiteMap = true }).Wait(); _elasticSearchGateway.Received(1).UpdateHighwaysZeroDownTime(Arg.Any <List <Feature> >()); _elasticSearchGateway.Received(1).UpdatePointsOfInterestZeroDownTime(Arg.Any <List <Feature> >()); _pointsOfInterestFilesCreatorExecutor.Received(1).Create(Arg.Any <List <Feature> >()); }
public void MergeFeatures_HasSameTitleOSMSource_ShouldMergeWithoutLink() { var feature1 = CreateFeature("1", 0, 0); feature1.Attributes.AddOrUpdate(FeatureAttributes.NAME, "1"); feature1.Attributes.AddOrUpdate(FeatureAttributes.NAME + ":he", "11"); feature1.Attributes.AddOrUpdate(FeatureAttributes.WEBSITE, "website"); feature1.SetTitles(); var feature2 = CreateFeature("2", 0, 0); feature2.Attributes.AddOrUpdate(FeatureAttributes.NAME, "2"); feature2.Attributes.AddOrUpdate(FeatureAttributes.NAME + ":en", "11"); feature2.Attributes.AddOrUpdate(FeatureAttributes.NAME + ":en", "11"); feature2.SetTitles(); var results = _executor.Merge(new List <Feature> { feature1, feature2 }); Assert.AreEqual(1, results.Count); Assert.AreEqual(0, results.First().GetIdsFromCombinedPoi().Count); }