private async Task Updatehighways(OsmChange changes)
        {
            var deleteTasks = new List <Task>();

            foreach (var highwaysToRemove in changes.Delete.OfType <Way>())
            {
                var task = _elasticSearchGateway.DeleteHighwaysById(highwaysToRemove.Id.ToString());
                deleteTasks.Add(task);
            }
            await Task.WhenAll(deleteTasks);

            var updateTasks = new List <Task <CompleteWay> >();

            foreach (var highwaysToUpdate in changes.Modify
                     .Concat(changes.Create)
                     .OfType <Way>()
                     .Where(w => w.Tags != null && w.Tags.ContainsKey("highway")))
            {
                var task = _osmGateway.GetCompleteWay(highwaysToUpdate.Id.ToString());
                updateTasks.Add(task);
            }
            var updatedWays = await Task.WhenAll(updateTasks);

            var geoJsonHighways = _osmGeoJsonPreprocessorExecutor.Preprocess(updatedWays.ToList());
            await _elasticSearchGateway.UpdateHighwaysData(geoJsonHighways);
        }
Esempio n. 2
0
        private async Task AddWaysToElasticSearch(List <long?> wayIds)
        {
            var tasksList      = wayIds.Select(wayId => _osmGateway.GetCompleteWay(wayId.Value)).ToList();
            var newlyaddedWays = await Task.WhenAll(tasksList);

            var newlyHighwaysFeatures = _geoJsonPreprocessorExecutor.Preprocess(newlyaddedWays.ToList());
            await _elasticSearchGateway.UpdateHighwaysData(newlyHighwaysFeatures);
        }