Пример #1
0
 /// <summary>
 /// Controller's constructor
 /// </summary>
 /// <param name="elasticSearchGateway"></param>
 /// <param name="itmWgs84MathTransfromFactory"></param>
 public SearchController(IElasticSearchGateway elasticSearchGateway,
                         IItmWgs84MathTransfromFactory itmWgs84MathTransfromFactory)
 {
     _elasticSearchGateway = elasticSearchGateway;
     _coordinatesParsers   = new List <ICoordinatesParser>
     {
         new ReverseDegreesMinutesSecondsLatLonParser(),
         new DegreesMinutesSecondsLatLonParser(),
         new DecimalLatLonParser(),
         new UtmParser(itmWgs84MathTransfromFactory.Create())
     };
 }
Пример #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="elasticSearchGateway"></param>
 /// <param name="itmWgs84MathTransfromFactory"></param>
 /// <param name="options"></param>
 /// <param name="geoJsonPreprocessorExecutor"></param>
 /// <param name="httpGatewayFactory"></param>
 public OsmLineAdderService(IElasticSearchGateway elasticSearchGateway,
                            IItmWgs84MathTransfromFactory itmWgs84MathTransfromFactory,
                            IOptions <ConfigurationData> options,
                            IOsmGeoJsonPreprocessorExecutor geoJsonPreprocessorExecutor,
                            IHttpGatewayFactory httpGatewayFactory)
 {
     _elasticSearchGateway  = elasticSearchGateway;
     _itmWgs84MathTransform = itmWgs84MathTransfromFactory.Create();
     _wgs84ItmMathTransform = itmWgs84MathTransfromFactory.CreateInverse();
     _options = options.Value;
     _geoJsonPreprocessorExecutor = geoJsonPreprocessorExecutor;
     _httpGatewayFactory          = httpGatewayFactory;
 }
Пример #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="gpxLoopsSplitterExecutor"></param>
 /// <param name="gpxProlongerExecutor"></param>
 /// <param name="itmWgs84MathTransfromFactory"></param>
 /// <param name="elasticSearchGateway"></param>
 /// <param name="options"></param>
 /// <param name="geometryFactory"></param>
 /// <param name="logger"></param>
 public AddibleGpxLinesFinderService(IGpxLoopsSplitterExecutor gpxLoopsSplitterExecutor,
                                     IGpxProlongerExecutor gpxProlongerExecutor,
                                     IItmWgs84MathTransfromFactory itmWgs84MathTransfromFactory,
                                     IElasticSearchGateway elasticSearchGateway,
                                     IOptions <ConfigurationData> options,
                                     GeometryFactory geometryFactory,
                                     ILogger logger)
 {
     _gpxLoopsSplitterExecutor = gpxLoopsSplitterExecutor;
     _gpxProlongerExecutor     = gpxProlongerExecutor;
     _itmWgs84MathTransform    = itmWgs84MathTransfromFactory.Create();
     _wgs84ItmMathTransform    = itmWgs84MathTransfromFactory.CreateInverse();
     _elasticSearchGateway     = elasticSearchGateway;
     _geometryFactory          = geometryFactory;
     _logger  = logger;
     _options = options.Value;
 }
Пример #4
0
        /// <inheritdoc />
        public override async Task <List <Feature> > GetPointsForIndexing()
        {
            _logger.LogInformation("Start getting wikipedia pages for indexing");
            var startCoordinate = new Coordinate(34, 29);
            var endCoordinate   = new Coordinate(36, 34);

            var    itmToWgs84 = _itmWgs84MathTransfromFactory.Create();
            var    wgs84ToItm = _itmWgs84MathTransfromFactory.CreateInverse();
            double step       = 10000 * 2 / Math.Sqrt(2);
            var    tasksList  = new List <Task <List <Feature> > >();

            foreach (var language in Languages.Array)
            {
                var currentCoordinate = new Coordinate(startCoordinate);
                while (currentCoordinate.X < endCoordinate.X && currentCoordinate.Y < endCoordinate.Y)
                {
                    var itm = wgs84ToItm.Transform(currentCoordinate);
                    itm.X            += step;
                    currentCoordinate = itmToWgs84.Transform(itm);
                    if (currentCoordinate.X > endCoordinate.X)
                    {
                        currentCoordinate.X = startCoordinate.X;
                        itm               = wgs84ToItm.Transform(currentCoordinate);
                        itm.Y            += step;
                        currentCoordinate = itmToWgs84.Transform(itm);
                    }
                    tasksList.Add(_wikipediaGateway.GetByLocation(currentCoordinate, language));
                }
            }

            _logger.LogInformation($"Created {tasksList.Count} tasks to fetch wikipedia data.");
            var lists = await Task.WhenAll(tasksList);

            var wikiFeatures = lists.SelectMany(l => l)
                               .GroupBy(f => f.Attributes[FeatureAttributes.ID])
                               .Select(g => g.First())
                               .ToList();

            _logger.LogInformation($"Finished getting Wikipedia pages for indexing, got {wikiFeatures.Count} pages.");
            return(wikiFeatures);
        }
Пример #5
0
 /// <summary>
 /// Controller's constructor
 /// </summary>
 /// <param name="httpGatewayFactory"></param>
 /// <param name="dataContainerConverterService"></param>
 /// <param name="itmWgs84MathTransfromFactory"></param>
 /// <param name="elasticSearchGateway"></param>
 /// <param name="addibleGpxLinesFinderService"></param>
 /// <param name="osmLineAdderService"></param>
 /// <param name="options"></param>
 /// <param name="geometryFactory"></param>
 /// <param name="cache"></param>
 public OsmController(IHttpGatewayFactory httpGatewayFactory,
                      IDataContainerConverterService dataContainerConverterService,
                      IItmWgs84MathTransfromFactory itmWgs84MathTransfromFactory,
                      IElasticSearchGateway elasticSearchGateway,
                      IAddibleGpxLinesFinderService addibleGpxLinesFinderService,
                      IOsmLineAdderService osmLineAdderService,
                      IOptions <ConfigurationData> options,
                      IGeometryFactory geometryFactory,
                      LruCache <string, TokenAndSecret> cache)
 {
     _httpGatewayFactory            = httpGatewayFactory;
     _dataContainerConverterService = dataContainerConverterService;
     _itmWgs84MathTransform         = itmWgs84MathTransfromFactory.Create();
     _wgs84ItmMathTransform         = itmWgs84MathTransfromFactory.CreateInverse();
     _elasticSearchGateway          = elasticSearchGateway;
     _addibleGpxLinesFinderService  = addibleGpxLinesFinderService;
     _osmLineAdderService           = osmLineAdderService;
     _options         = options.Value;
     _geometryFactory = geometryFactory;
     _cache           = cache;
 }
Пример #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="itmWgs84MathTransformFactory"></param>
 public UtmParser(IItmWgs84MathTransfromFactory itmWgs84MathTransformFactory)
 {
     _itmWgs84MathTransform = itmWgs84MathTransformFactory.Create();
 }