Esempio n. 1
0
 public RouteManager()
 {
     _distanceProvider = new DistanceProvider();
     _pathfinder       = new PathFinder(_distanceProvider);
     _tlService        = new TLService();
     _oaService        = new OAService();
     _storedRoutes     = new Dictionary <int, RouteInfo>();
     _runningKey       = 0;
     _orderManager     = new OrderManager();
     ConstructGraph();
 }
Esempio n. 2
0
        /// <param name="provider">Используемый провайдер данных</param>
        /// <param name="points">Точки для первоначального заполенения из базы.</param>
        /// <param name="statisticsTxtAction">Функция для буфера для отображения статистики</param>
        /// <param name="multiThreadLoad">Если <c>true</c> включается моногопоточная загрузка.</param>
        public ExtDistanceCalculator(DistanceProvider provider, DeliveryPoint[] points, Action <string> statisticsTxtAction, bool multiThreadLoad = true)
        {
            this.statisticsTxtAction = statisticsTxtAction;
            UoW.Session.SetBatchSize(SaveBy);
            Provider      = provider;
            MultiTaskLoad = multiThreadLoad;
            Canceled      = false;
            var basesHashes = _geographicGroupRepository.GeographicGroupsWithCoordinates(UoW).Select(CachedDistance.GetHash);

            hashes = points.Select(CachedDistance.GetHash)
                     .Concat(basesHashes)
                     .Distinct()
                     .ToArray();

            cQueue = new ConcurrentQueue <long>(hashes);

            totalPoints       = hashes.Length;
            proposeNeedCached = hashes.Length * (hashes.Length - 1);

            hashPos = hashes.Select((hash, index) => new { hash, index })
                      .ToDictionary(x => x.hash, x => x.index);
#if DEBUG
            matrix      = new CachedDistance[hashes.Length, hashes.Length];
            matrixcount = new int[hashes.Length, hashes.Length];
#endif
            var fromDB = _cachedDistanceRepository.GetCache(UoW, hashes);
            startCached = fromDB.Count;
            foreach (var distance in fromDB)
            {
#if DEBUG
                matrix[hashPos[distance.FromGeoHash], hashPos[distance.ToGeoHash]] = distance;
#endif
                AddNewCacheDistance(distance);
            }
            UpdateText();
#if DEBUG
            StringBuilder matrixText = new StringBuilder(" ");
            for (int x = 0; x < matrix.GetLength(1); x++)
            {
                matrixText.Append(x % 10);
            }

            for (int y = 0; y < matrix.GetLength(0); y++)
            {
                matrixText.Append("\n" + y % 10);
                for (int x = 0; x < matrix.GetLength(1); x++)
                {
                    matrixText.Append(matrix[y, x] != null ? 1 : 0);
                }
            }
            logger.Debug(matrixText);

            logger.Debug(string.Join(";", hashes.Select(CachedDistance.GetTextLonLat)));
#endif

            if (MultiTaskLoad && fromDB.Count < proposeNeedCached)
            {
                RunPreCalculation();
            }
            else
            {
                MultiTaskLoad = false;
            }
        }
Esempio n. 3
0
 public RouteGeometryCalculator(DistanceProvider provider)
 {
     Provider = provider;
 }