private void ExtractFromProfileAndStore()
        {
            if (_edgeFactor != null)
            {
                return;
            }

            var attributes = _enumerator.GetAttributes();

            _edgeFactor = _profile.Factor(attributes);

            _length         = _enumerator.EdgeLength();
            _weightForward  = 0;
            _weightBackward = 0;

            // WARNING: always store forward and reverse when we have the actual direction, the edge won't always be accessed in the same direction.
            if (_edgeFactor.Value.ForwardFactor != _edgeFactor.Value.BackwardFactor)
            {
                if (_edgeFactor.Value.ForwardFactor == 0)
                {
                    _weightBackward = _edgeFactor.Value.BackwardFactor * _length;
                    _coder.Set(_enumerator.Enumerator, _weightBackward.Value + (1 << 25));
                    return;
                }
                else if (_edgeFactor.Value.BackwardFactor == 0)
                {
                    _weightForward = _edgeFactor.Value.ForwardFactor * _length;
                    _coder.Set(_enumerator.Enumerator, _weightForward.Value + (1 << 26));
                    return;
                }
                else
                {
                    Console.WriteLine($"Cannot store weight for {_enumerator.GetAttributes()}");
                    return;
                }
            }

            _weightForward  = _edgeFactor.Value.ForwardFactor * _length;
            _weightBackward = _weightForward;
            if (_weightForward > (1 << 24))
            {
                Console.WriteLine($"Cannot store weight for {_enumerator.GetAttributes()}: > {1 << 24}");
                return;
            }

            _coder.Set(_enumerator.Enumerator, _weightForward.Value);
        }
Example #2
0
        public override void MoveTo(RouterDbEdgeEnumerator enumerator)
        {
            _edgeFactor = enumerator.FactorInEdgeDirection(_profile);

            _length = enumerator.EdgeLength();
        }