Beispiel #1
0
        /// <summary>
        /// Moves the PBF reader to the next primitive or returns one of the cached ones.
        /// </summary>
        /// <returns></returns>
        private KeyValuePair <PrimitiveBlock, object> MoveToNextPrimitive(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
        {
            var next = this.DeQueuePrimitive();

            if (next.Value == null)
            { // decode another block.
                // move to first way/relation position if they are known and nodes and or ways are to be skipped.
                if (_firstWayPosition != -1 && ignoreNodes && !ignoreWays)
                {     // if nodes have to be ignored, there was already a first pass and ways are not to be ignored jump to the first way.
                    if (_stream.Position <= _firstWayPosition)
                    { // only just to the first way if that hasn't happened yet.
                        _stream.Seek(_firstWayPosition, SeekOrigin.Begin);
                    }
                }
                if (_firstRelationPosition != -1 && ignoreNodes && ignoreWays && !ignoreRelations)
                {     // if nodes and ways have to be ignored, there was already a first pass and ways are not be ignored jump to the first relation.
                    if (_stream.Position < _firstRelationPosition)
                    { // only just to the first relation if that hasn't happened yet.
                        _stream.Seek(_firstRelationPosition, SeekOrigin.Begin);
                    }
                }

                // just to the next block.
                var  beforeBlockPosition = _stream.Position;
                var  block = _reader.MoveNext();
                bool hasNodes = false, hasWays = false, hasRelations = false;
                while (block != null && !Encoder.Decode(block, this, ignoreNodes, ignoreWays, ignoreRelations,
                                                        out hasNodes, out hasWays, out hasRelations))
                {
                    if (hasWays && _firstWayPosition == -1)
                    {
                        _firstWayPosition = beforeBlockPosition;
                    }
                    if (hasRelations && _firstRelationPosition == -1)
                    {
                        _firstRelationPosition = beforeBlockPosition;
                    }
                    beforeBlockPosition = _stream.Position;
                    block = _reader.MoveNext();
                }
                if (hasWays && _firstWayPosition == -1)
                {
                    _firstWayPosition = beforeBlockPosition;
                }
                if (hasRelations && _firstRelationPosition == -1)
                {
                    _firstRelationPosition = beforeBlockPosition;
                }
                next = this.DeQueuePrimitive();
            }
            return(next);
        }
Beispiel #2
0
        /// <summary>
        /// Moves the PBF reader to the next primitive or returns one of the cached ones.
        /// </summary>
        /// <returns></returns>
        private KeyValuePair <PrimitiveBlock, object> MoveToNextPrimitive(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
        {
            var next = this.DeQueuePrimitive();

            if (next.Value == null)
            {
                var block = _reader.MoveNext();
                while (block != null && !PBF.Encoder.Decode(block, this, ignoreNodes, ignoreWays, ignoreRelations))
                {
                    block = _reader.MoveNext();
                }
                next = this.DeQueuePrimitive();
            }
            return(next);
        }
Beispiel #3
0
        /// <summary>
        /// Moves the PBF reader to the next primitive or returns one of the cached ones.
        /// </summary>
        /// <returns></returns>
        private KeyValuePair <PrimitiveBlock, object> MoveToNextPrimitive(bool ignoreNodes, bool ignoreWays, bool ignoreRelations)
        {
            KeyValuePair <PrimitiveBlock, object> next = this.DeQueuePrimitive();

            if (next.Value == null)
            {
                PrimitiveBlock block = _reader.MoveNext();
                if (block != null)
                {
                    while (!_decompressor.ProcessPrimitiveBlock(block, ignoreNodes, ignoreWays, ignoreRelations))
                    {
                        block = _reader.MoveNext();
                    }
                    next = this.DeQueuePrimitive();
                }
            }
            return(next);
        }
        /// <summary>
        /// Moves the PBF reader to the next primitive or returns one of the cached ones.
        /// </summary>
        /// <returns></returns>
        private KeyValuePair <PrimitiveBlock, object> MoveToNextPrimitive()
        {
            KeyValuePair <PrimitiveBlock, object> next = this.DeQueuePrimitive();

            if (next.Value == null)
            {
                PrimitiveBlock block = _reader.MoveNext();
                if (block != null)
                {
                    _decompressor.ProcessPrimitiveBlock(block);
                    next = this.DeQueuePrimitive();
                }
            }
            return(next);
        }