Esempio n. 1
0
        public DefaultPosMappingScanNode(PosMapper2 posMapper, IList <IGrouping <long, IDScanItem> > moonGroups,
                                         IList <IDScanItem> leftBorderScan, IList <IDScanItem> rightBorderScan)
            : base(posMapper, leftBorderScan, rightBorderScan)
        {
            _moonGroups = moonGroups;

            var towerCount = ItemsOnScan.Count(PosMappingUtils.IsTower);

            IsLeaf = towerCount == 0 || (towerCount == 1 && moonGroups.Count < 2);

            if (!IsLeaf)
            {
                PivotalScanRangeInKm =
                    PosMappingUtils.GetLowerBoundInKm(_moonGroups.Skip(_moonGroups.Count / 2).First().First().Distance);
            }
        }
Esempio n. 2
0
        private static IPosMappingScanNode CreateNode(PosMapper2 posMapper, IList <IDScanItem> leftBorderItems,
                                                      IList <IDScanItem> rightBorderItems)
        {
            var itemsAtNode = rightBorderItems.Without(leftBorderItems).ToList();
            var moonGroups  = PosMappingUtils.GetMoonGroups(itemsAtNode);

            if (IsCluster(moonGroups))
            {
                var moonGroup = moonGroups.First().First();

                return(new MoonClusterNode(posMapper, PosMappingUtils.GetLowerBoundInKm(moonGroup.Distance),
                                           PosMappingUtils.GetUpperBoundInKm(moonGroup.Distance), leftBorderItems,
                                           rightBorderItems));
            }

            return(new DefaultPosMappingScanNode(posMapper, moonGroups, leftBorderItems, rightBorderItems));
        }
Esempio n. 3
0
        private void InitialScan(IList <IDScanItem> obj)
        {
            CheckForOfflineTowers(obj);

            _currentNodeToScan = new DefaultPosMappingScanNode(this, PosMappingUtils.GetMoonGroups(obj),
                                                               new IDScanItem[0], obj);
            if (_currentNodeToScan.IsLeaf)
            {
                var moonItems = _currentNodeToScan.GetMoonItems();
                if (moonItems.Any())
                {
                    OnMoonsScanned(moonItems);
                }
                OnScanDone();
                return;
            }

            OnNextScanRequest(_currentNodeToScan.PivotalScanRangeInKm);
        }