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.");
        }
Exemplo n.º 2
0
        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.");
        }
Exemplo n.º 3
0
        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> >());
        }