コード例 #1
0
// move the cursor to the position
void FdoRfpStreamReaderGdalByTile::_moveTo(int row, int col, int offset)
{
    if (row == m_row && col == m_col)    // remain in the same tile
        m_offset = offset;
    else
    {
        m_row = row;
        m_col = col;
        m_offset = offset;

        // get the new tile if it is valid
        if (m_row < m_numTileRows)
            _getTile();
    }

}
コード例 #2
0
FdoInt32 FdoRfpStreamReaderGdalByTile::ReadNext( FdoByte* buffer, 
                                    const FdoInt32 offset,
                                    const FdoInt32 count)
{
    if (count < -1 || offset < 0 || buffer == NULL)
        throw FdoException::Create(FdoException::NLSGetMessage(FDO_2_BADPARAMETER, "Bad parameter to method."));

    FdoInt32 countToRead = (FdoInt32)(count == -1 ? GetLength() - GetIndex() : count);

    FdoInt32 numRows = m_numTileRows;
    FdoInt32 countRead = 0;
    while (countToRead > 0 && m_row < m_numTileRows)
    {
        FdoInt32 numLeftInTile = m_numTileBytes - m_offset;
        FdoInt32 copyCount = countToRead < numLeftInTile ? countToRead : numLeftInTile;
        // copy data
        memcpy((void*)(buffer + offset + countRead), (const void*)(m_tileData + m_offset), copyCount);
        countRead += copyCount;
        countToRead -= copyCount;
        numLeftInTile -= copyCount;
        m_offset += copyCount;
        
        // if we reach the end of the tile, move to the next tile
        if (numLeftInTile == 0)
        {
            // calculate new tile
            m_offset = 0;
            m_col++;
            if (m_col == m_numTileCols)
            {
                m_col = 0;
                m_row++;
            }

            // check out new tile
            if (m_row < m_numTileRows)
                _getTile();
        }
    }

    return countRead;

}
コード例 #3
0
ファイル: VectorLayer.cpp プロジェクト: gfbipnet/amigoclient
void VectorLayer::_cull9( const iiCamera::Camera &camera )
{
    if(!_fgDataCache)
        return;

    _fgDataCache->clearQueue();

    Timestamp start;
    std::list<DrawablePatch> list = Globe::instance()->getGlobeSceneHandler()->getGlobeHandler()->getPatchList();
    if(list.size()==0)
    {
        AMIGO_LOG_I(TAG, "::cull() list is empty.\n");
        return;
    }

    DrawablePatch &dp = list.front();
    int level = dp.level;
    uint64 row = dp.row;
    uint64 col = dp.col;

    double lat;
    double lng;

    // Step 1 levels up
    Utils::levelRowColToLatLong(level, row, col, lat, lng );
    level-=1;
    if(level<2) level=2;
    Utils::levelLatLongToRowCol( level, lat, lng, row, col );

    int64 c1, c2, r1, r2;
    getSpanRowCol(row, col, c1, c2, r1, r2);
    
    bool allTilesExist = true;
    allTilesExist = _allTilesExist(level, c1, c2, r1, r2, true, _fgDataCache);
    if(allTilesExist)
    {
        _lastTiles.clear();
        for(uint64 c=c1; c<=c2; c++)
        {
            for(uint64 r=r1; r<=r2; r++)
            {
                VectorTileIdentity pa(level, r, c, _projectId, _datasetId);
                if(auto tile = _getTile( pa ))
                {
                    tile->cull(camera, OpaqueBin::instance());
                    _lastTiles.push_back( tile );
                }
            }
        }

        // Add Text  tile
        VectorTileIdentity pa(level, row, col, _projectId, _datasetId, true);
        auto tile = _getTile( pa );
        if(tile)
        {            
            tile->cull(camera, OpaqueBin::instance());
            _lastTiles.push_back( tile );
        } else
        {
            _fgDataCache->request( pa );
        }

    } else
    {
        for(auto t : _lastTiles)
        {
            int dl = level - t->getIdentity().level;
            if(dl < 7) // Don't render tiles if level is too far away
                t->cull(camera, OpaqueBin::instance());
        }   
    }

    _level = level;
}
コード例 #4
0
//-----------------------------------------------------------------------------
void
QGCCacheWorker::run()
{
    if(!_valid && !_failed) {
        _init();
    }
    if(_valid) {
        _db = new QSqlDatabase(QSqlDatabase::addDatabase("QSQLITE", kSession));
        _db->setDatabaseName(_databasePath);
        _db->setConnectOptions("QSQLITE_ENABLE_SHARED_CACHE");
        _valid = _db->open();
    }
    while(true) {
        QGCMapTask* task;
        if(_taskQueue.count()) {
            _mutex.lock();
            task = _taskQueue.dequeue();
            _mutex.unlock();
            switch(task->type()) {
                case QGCMapTask::taskInit:
                    break;
                case QGCMapTask::taskCacheTile:
                    _saveTile(task);
                    break;
                case QGCMapTask::taskFetchTile:
                    _getTile(task);
                    break;
                case QGCMapTask::taskFetchTileSets:
                    _getTileSets(task);
                    break;
                case QGCMapTask::taskCreateTileSet:
                    _createTileSet(task);
                    break;
                case QGCMapTask::taskGetTileDownloadList:
                    _getTileDownloadList(task);
                    break;
                case QGCMapTask::taskUpdateTileDownloadState:
                    _updateTileDownloadState(task);
                    break;
                case QGCMapTask::taskDeleteTileSet:
                    _deleteTileSet(task);
                    break;
                case QGCMapTask::taskPruneCache:
                    _pruneCache(task);
                    break;
                case QGCMapTask::taskReset:
                    _resetCacheDatabase(task);
                    break;
            }
            task->deleteLater();
            //-- Check for update timeout
            size_t count = _taskQueue.count();
            if(count > 100) {
                _updateTimeout = LONG_TIMEOUT;
            } else if(count < 25) {
                _updateTimeout = SHORT_TIMEOUT;
            }
            if(!count || (time(0) - _lastUpdate > _updateTimeout)) {
                _updateTotals();
            }
        } else {
            //-- Wait a bit before shutting things down
            _waitmutex.lock();
            int timeout = 5000;
            if(!_waitc.wait(&_waitmutex, timeout))
            {
                _waitmutex.unlock();
                _mutex.lock();
                //-- If nothing to do, close db and leave thread
                if(!_taskQueue.count()) {
                    _mutex.unlock();
                    break;
                }
                _mutex.unlock();
            }
            _waitmutex.unlock();
        }
    }
    if(_db) {
        delete _db;
        _db = NULL;
        QSqlDatabase::removeDatabase(kSession);
    }
}