亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mitab_mapindexblock.cpp

?? mitab,讀取MapInfo的地圖文件
?? CPP
?? 第 1 頁 / 共 4 頁
字號:
{
    GBool bFound = FALSE;

    if (m_eAccess != TABWrite && m_eAccess != TABReadWrite)
    {
        CPLError(CE_Failure, CPLE_AssertionFailed,
               "Failed adding index entry: File not opened for write access.");
        return -1;
    }

    /*-----------------------------------------------------------------
     * Look for the best candidate to contain the new entry
     *----------------------------------------------------------------*/

    /*-----------------------------------------------------------------
     * If bAddInThisNodeOnly=TRUE then we add the entry only locally
     * and do not need to look for the proper leaf to insert it.
     *----------------------------------------------------------------*/
    if (bAddInThisNodeOnly)
        bFound = TRUE;

    if (!bFound && m_numEntries > 0)
    {
        // Make sure blocks currently in memory are written to disk.
        if (m_poCurChild)
        {
            m_poCurChild->CommitToFile();
            delete m_poCurChild;
            m_poCurChild = NULL;
            m_nCurChildIndex = -1;
        }

        int nBestCandidate = ChooseSubEntryForInsert(nXMin,nYMin,nXMax,nYMax);
       
        CPLAssert(nBestCandidate != -1);

        if (nBestCandidate != -1)
        {
            // Try to load corresponding child... if it fails then we are
            // likely in a leaf node, so we'll add the new entry in the current
            // node.
            TABRawBinBlock *poBlock = NULL;

            // Prevent error message if referred block not committed yet.
            CPLPushErrorHandler(CPLQuietErrorHandler);

            if ((poBlock = TABCreateMAPBlockFromFile(m_fp, 
                                       m_asEntries[nBestCandidate].nBlockPtr,
                                       512, TRUE, TABReadWrite)) &&
                poBlock->GetBlockClass() == TABMAP_INDEX_BLOCK)
            {
                m_poCurChild = (TABMAPIndexBlock*)poBlock;
                poBlock = NULL;
                m_nCurChildIndex = nBestCandidate;
                m_poCurChild->SetParentRef(this);
                m_poCurChild->SetMAPBlockManagerRef(m_poBlockManagerRef);
                bFound = TRUE;
            }
                
            if (poBlock)
                delete poBlock;
            
            CPLPopErrorHandler();
            CPLErrorReset();
        }
    }

    if (bFound && !bAddInThisNodeOnly)
    {
        /*-------------------------------------------------------------
         * Found a child leaf... pass the call to it.
         *------------------------------------------------------------*/
        if (m_poCurChild->AddEntry(nXMin, nYMin, nXMax, nYMax, nBlockPtr) != 0)
            return -1;
    }
    else
    {
        /*-------------------------------------------------------------
         * Found no child to store new object... we're likely at the leaf
         * level so we'll store new object in current node
         *------------------------------------------------------------*/

        /*-------------------------------------------------------------
         * First thing to do is make sure that there is room for a new
         * entry in this node, and to split it if necessary.
         *------------------------------------------------------------*/
        if (GetNumFreeEntries() < 1)
        {
            if (m_poParentRef == NULL)
            {
                /*-----------------------------------------------------
                 * Splitting the root node adds one level to the tree, so
                 * after splitting we just redirect the call to the new
                 * child that's just been created.
                 *----------------------------------------------------*/
                if (SplitRootNode(nXMin, nYMin, nXMax, nYMax) != 0)
                    return -1;  // Error happened and has already been reported

                CPLAssert(m_poCurChild);
                return m_poCurChild->AddEntry(nXMin, nYMin, nXMax, nYMax,
                                              nBlockPtr, TRUE);
            }
            else
            {
                /*-----------------------------------------------------
                 * Splitting a regular node
                 *----------------------------------------------------*/
                if (SplitNode(nXMin, nYMin, nXMax, nYMax) != 0)
                    return -1; 
            }
        }

        if (InsertEntry(nXMin, nYMin, nXMax, nYMax, nBlockPtr) != 0)
            return -1;
    }

    /*-----------------------------------------------------------------
     * Update current node MBR and the reference to it in our parent.
     *----------------------------------------------------------------*/
    RecomputeMBR();

    return 0;
}

/**********************************************************************
 *                   TABMAPIndexBlock::ComputeAreaDiff()
 *
 * (static method, also used by the TABMAPObjBlock class)
 *
 * Compute the area difference between two MBRs. Used in the SplitNode
 * algorithm to decide to which of the two nodes an entry should be added.
 *
 * The returned AreaDiff value is positive if NodeMBR has to be enlarged
 * and negative if new Entry is fully contained in the NodeMBR.
 **********************************************************************/
double  TABMAPIndexBlock::ComputeAreaDiff(GInt32 nNodeXMin, GInt32 nNodeYMin,
                                          GInt32 nNodeXMax, GInt32 nNodeYMax,
                                          GInt32 nEntryXMin, GInt32 nEntryYMin,
                                          GInt32 nEntryXMax, GInt32 nEntryYMax)
{

    double dAreaDiff=0;

    double dNodeAreaBefore = MITAB_AREA(nNodeXMin,
                                        nNodeYMin,
                                        nNodeXMax,
                                        nNodeYMax);

    /* Does the node fully contain the new entry's MBR ?
     */
    GBool bIsContained = (nEntryXMin >= nNodeXMin &&
                          nEntryYMin >= nNodeYMin &&
                          nEntryXMax <= nNodeXMax &&
                          nEntryYMax <= nNodeYMax );

    if (bIsContained)
    {
        /* If new entry is fully contained in this entry then
         * the area difference will be the difference between the area
         * of the entry to insert and the area of the node
         */
        dAreaDiff = MITAB_AREA(nEntryXMin, nEntryYMin, 
                               nEntryXMax, nEntryYMax) - dNodeAreaBefore;
    }
    else
    {
        /* Need to calculate the expanded MBR to calculate the area
         * difference.
         */
        nNodeXMin = MIN(nNodeXMin, nEntryXMin);
        nNodeYMin = MIN(nNodeYMin, nEntryYMin);
        nNodeXMax = MAX(nNodeXMax, nEntryXMax);
        nNodeYMax = MAX(nNodeYMax, nEntryYMax);

        dAreaDiff = MITAB_AREA(nNodeXMin,nNodeYMin,
                               nNodeXMax,nNodeYMax) - dNodeAreaBefore;
    }

    return dAreaDiff;
}



/**********************************************************************
 *                   TABMAPIndexBlock::PickSeedsForSplit()
 *
 * (static method, also used by the TABMAPObjBlock class)
 *
 * Pick two seeds to use to start splitting this node.
 *
 * Guttman's LinearPickSeed:
 * - Along each dimension find the entry whose rectangle has the 
 *   highest low side, and the one with the lowest high side
 * - Calculate the separation for each pair
 * - Normalize the separation by dividing by the extents of the 
 *   corresponding dimension
 * - Choose the pair with the greatest normalized separation along
 *   any dimension
 **********************************************************************/
int  TABMAPIndexBlock::PickSeedsForSplit(TABMAPIndexEntry *pasEntries,
                                         int numEntries,
                                         int nSrcCurChildIndex,
                                         GInt32 nNewEntryXMin, 
                                         GInt32 nNewEntryYMin,
                                         GInt32 nNewEntryXMax, 
                                         GInt32 nNewEntryYMax,
                                         int &nSeed1, int &nSeed2)
{
    GInt32 nSrcMinX=0, nSrcMinY=0, nSrcMaxX=0, nSrcMaxY=0;
    int nLowestMaxX=-1, nHighestMinX=-1, nLowestMaxY=-1, nHighestMinY=-1;
    GInt32 nLowestMaxXId=-1, nHighestMinXId=-1, nLowestMaxYId=-1, nHighestMinYId=-1;

    nSeed1=-1;
    nSeed2=-1;

    // Along each dimension find the entry whose rectangle has the 
    // highest low side, and the one with the lowest high side
    for(int iEntry=0; iEntry<numEntries; iEntry++)
    {
        if (nLowestMaxXId == -1 ||
            pasEntries[iEntry].XMax < nLowestMaxX)
        {
            nLowestMaxX = pasEntries[iEntry].XMax;
            nLowestMaxXId = iEntry;
        }

        if (nHighestMinXId == -1 ||
            pasEntries[iEntry].XMin > nHighestMinX)
        {
            nHighestMinX = pasEntries[iEntry].XMin;
            nHighestMinXId = iEntry;
        }

        if (nLowestMaxYId == -1 ||
            pasEntries[iEntry].YMax < nLowestMaxY)
        {
            nLowestMaxY = pasEntries[iEntry].YMax;
            nLowestMaxYId = iEntry;
        }

        if (nHighestMinYId == -1 ||
            pasEntries[iEntry].YMin > nHighestMinY)
        {
            nHighestMinY = pasEntries[iEntry].YMin;
            nHighestMinYId = iEntry;
        }

        // Also keep track of MBR of all entries
        if (iEntry == 0)
        {
            nSrcMinX = pasEntries[iEntry].XMin;
            nSrcMinY = pasEntries[iEntry].YMin;
            nSrcMaxX = pasEntries[iEntry].XMax;
            nSrcMaxY = pasEntries[iEntry].YMax;
        }
        else
        {
            nSrcMinX = MIN(nSrcMinX, pasEntries[iEntry].XMin);
            nSrcMinY = MIN(nSrcMinY ,pasEntries[iEntry].YMin);
            nSrcMaxX = MAX(nSrcMaxX ,pasEntries[iEntry].XMax);
            nSrcMaxY = MAX(nSrcMaxY ,pasEntries[iEntry].YMax);
        }
    }

    int nSrcWidth, nSrcHeight;
    nSrcWidth = ABS(nSrcMaxX - nSrcMinX);
    nSrcHeight = ABS(nSrcMaxY - nSrcMinY);

    // Calculate the separation for each pair (note that it may be negative
    // in case of overlap)
    // Normalize the separation by dividing by the extents of the 
    // corresponding dimension
    double dX, dY;

    dX = (double)(nHighestMinX - nLowestMaxX) / nSrcWidth;
    dY = (double)(nHighestMinY - nLowestMaxY) / nSrcHeight;

    // Choose the pair with the greatest normalized separation along
    // any dimension
    if (dX > dY)
    {
        nSeed1 = nHighestMinXId;
        nSeed2 = nLowestMaxXId;
    }
    else
    {
        nSeed1 = nHighestMinYId;
        nSeed2 = nLowestMaxYId;
    }

    // If nSeed1==nSeed2 then just pick any two (giving pref to current child)
    if (nSeed1 == nSeed2)
    {
        if (nSeed1 != nSrcCurChildIndex && nSrcCurChildIndex != -1)
            nSeed1 = nSrcCurChildIndex;
        else if (nSeed1 != 0)
            nSeed1 = 0;
        else
            nSeed1 = 1;
    }

    // Decide which of the two seeds best matches the new entry. That seed and
    // the new entry will stay in current node (new entry will be added by the
    // caller later). The other seed will go in the 2nd node
    double dAreaDiff1, dAreaDiff2;
    dAreaDiff1 = ComputeAreaDiff(pasEntries[nSeed1].XMin, 
                                 pasEntries[nSeed1].YMin,
                                 pasEntries[nSeed1].XMax,
                                 pasEntries[nSeed1].YMax,
                                 nNewEntryXMin, nNewEntryYMin,
                                 nNewEntryXMax, nNewEntryYMax);

    dAreaDiff2 = ComputeAreaDiff(pasEntries[nSeed2].XMin, 
                                 pasEntries[nSeed2].YMin,
                                 pasEntries[nSeed2].XMax,
                                 pasEntries[nSeed2].YMax,
                                 nNewEntryXMin, nNewEntryYMin,
                                 nNewEntryXMax, nNewEntryYMax);

    /* Note that we want to keep this node's current child in here.
     * Since splitting happens only during an addentry() operation and 
     * then both the current child and the New Entry should fit in the same
     * area.
     */
    if (nSeed1 != nSrcCurChildIndex && 
        (dAreaDiff1 > dAreaDiff2 || nSeed2 == nSrcCurChildIndex))
    {
        // Seed2 stays in this node, Seed1 moves to new node
        // ... swap Seed1 and Seed2 indices
        int nTmp = nSeed1;
        nSeed1 = nSeed2;
        nSeed2 = nTmp;
    }

    return 0;
}


/**********************************************************************
 *                   TABMAPIndexBlock::SplitNode()
 *
 * Split current Node, update the references in the parent node, etc.
 * Note that Root Nodes cannot be split using this method... SplitRootNode()
 * should be used instead.
 *
 * nNewEntry* are the coord. of the new entry that 
 * will be added after the split.  The split is done so that the current
 * node will be the one in which the new object should be stored.
 *
 * Returns 0 on success, -1 on error.
 **********************************************************************/
int     TABMAPIndexBlock::SplitNode(GInt32 nNewEntryXMin, GInt32 nNewEntryYMin,
                                    GInt32 nNewEntryXMax, GInt32 nNewEntryYMax)
{
    CPLAssert(m_poBlockManagerRef);

    /*-----------------------------------------------------------------
     * Create a 2nd node
     *----------------------------------------------------------------*/
    TABMAPIndexBlock *poNewNode = new TABMAPIndexBlock(m_eAccess);
    if (poNewNode->InitNewBlock(m_fp, 512, 
                                m_poBlockManagerRef->AllocNewBlock()) != 0)
    {
        return -1;
    }
    poNewNode->SetMAPBlockManagerRef(m_poBlockManagerRef);

    /*-----------------------------------------------------------------
     * Make a temporary copy of the entries in current node
     *----------------------------------------------------------------*/
    int nSrcEntries = m_numEntries;
    TABMAPIndexEntry *pasSrcEntries = (TABMAPIndexEntry*)CPLMalloc(m_numEntries*sizeof(TABMAPIndexEntry));
    memcpy(pasSrcEntries, &m_asEntries, m_numEntries*sizeof(TABMAPIndexEntry));

    int nSrcCurChildIndex = m_nCurChildIndex;

    /*-----------------------------------------------------------------
     * Pick Seeds for each node
     *----------------------------------------------------------------*/
    int nSeed1, nSeed2;
    PickSeedsForSplit(pasSrcEntries, nSrcEntries, nSrcCurChildIndex,
                      nNewEntryXMin, nNewEntryYMin, 
                      nNewEntryXMax, nNewEntryYMax,
                      nSeed1, nSeed2);

    /*-----------------------------------------------------------------
     * Reset number of entries in this node and start moving new entries
     *----------------------------------------------------------------*/

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人动漫av在线| 国产婷婷色一区二区三区| 视频一区在线视频| 日韩三级在线观看| www.亚洲免费av| 爽好久久久欧美精品| 久久久久久久久久久电影| 色婷婷精品大视频在线蜜桃视频| 日韩精品国产精品| 国产精品视频第一区| 欧美日韩激情一区二区| 成人黄色777网| 国产精品资源网站| 日韩不卡一区二区| 亚洲欧美在线aaa| 精品国产伦一区二区三区观看体验| 色诱视频网站一区| 成人国产亚洲欧美成人综合网| 老司机精品视频导航| 三级精品在线观看| 日本va欧美va瓶| 奇米精品一区二区三区在线观看一| 7777精品伊人久久久大香线蕉经典版下载| 91麻豆精品国产91久久久更新时间 | 欧美色爱综合网| 91福利在线播放| 欧美亚洲一区三区| 56国语精品自产拍在线观看| 欧美日本免费一区二区三区| 日本韩国精品在线| 欧美人狂配大交3d怪物一区| 精品视频一区二区不卡| 欧美日韩一区二区三区视频| 欧美美女视频在线观看| 欧美最猛性xxxxx直播| 日韩精品亚洲专区| 精品一区二区在线观看| 国产一区二区三区免费在线观看| 狠狠色狠狠色综合| 不卡的av中国片| 欧美亚洲国产一区二区三区va| 欧美日韩亚洲综合在线 | 欧美色网站导航| 久久久影院官网| 亚洲一线二线三线视频| 免费在线视频一区| 成人av网在线| 精品久久五月天| 亚洲第一激情av| 高清视频一区二区| 欧美一二三在线| 亚洲乱码国产乱码精品精可以看| 亚洲一区二区三区四区在线观看| 午夜精品福利一区二区三区蜜桃| 久久精品国产成人一区二区三区 | 国产精品免费看片| 美腿丝袜一区二区三区| 在线观看日韩精品| 1000精品久久久久久久久| 韩国一区二区视频| 欧美v日韩v国产v| 久久精品国产久精国产| 欧美日韩国产区一| 亚洲一级二级三级| 在线观看亚洲a| 一个色在线综合| 欧美性大战久久久久久久蜜臀| 中文字幕不卡的av| 懂色一区二区三区免费观看| 久久综合狠狠综合| 加勒比av一区二区| 国产亚洲欧美日韩俺去了| 精品一区二区国语对白| 欧美一区二区三区人| 久久99精品国产麻豆婷婷| 日韩欧美的一区二区| 风间由美一区二区av101| 国产亚洲欧美日韩日本| 99久久久国产精品| 亚洲国产精品一区二区www在线| 欧美在线不卡视频| 丝瓜av网站精品一区二区| 日韩三级伦理片妻子的秘密按摩| 美女被吸乳得到大胸91| 国产午夜精品福利| 91久久线看在观草草青青| 亚洲国产精品一区二区www| 欧美一级在线观看| 99re这里都是精品| 久久精品免费看| 怡红院av一区二区三区| 欧美一级欧美一级在线播放| 国产精品中文字幕日韩精品| 樱桃国产成人精品视频| 欧美高清在线视频| 日韩欧美久久久| 99久久777色| 天堂一区二区在线免费观看| 欧美图片一区二区三区| 免费观看在线色综合| 国产精品高清亚洲| 91精品久久久久久蜜臀| 99re6这里只有精品视频在线观看| 亚洲激情自拍视频| 一区二区三区精品久久久| 国产欧美一区二区三区在线看蜜臀| 国产精品一区二区不卡| 秋霞午夜鲁丝一区二区老狼| 亚洲午夜视频在线| 亚洲综合小说图片| 一区二区三区四区不卡视频| 久久人人97超碰com| 欧美日韩视频在线观看一区二区三区| 国产成人免费在线视频| 国产一区二区三区在线观看精品| 亚洲一区二区综合| 亚洲成av人影院| 亚洲成人动漫一区| 美日韩一区二区| 久久国产视频网| 久色婷婷小香蕉久久| 全国精品久久少妇| 日韩成人一区二区三区在线观看| 亚洲午夜久久久久久久久电影网| 亚洲成人av电影| 一区二区高清视频在线观看| 日韩国产成人精品| 成人激情综合网站| 欧美亚洲综合另类| 日韩亚洲国产中文字幕欧美| 日韩欧美一二区| 国产精品成人在线观看| 亚洲成人av福利| 久久99精品久久久久婷婷| 99国产精品视频免费观看| 欧美中文一区二区三区| 日韩一级完整毛片| 亚洲女爱视频在线| 久久成人18免费观看| 欧美另类久久久品| 国产精品国产自产拍高清av王其| 国内成+人亚洲+欧美+综合在线| 国产iv一区二区三区| 欧美高清一级片在线| 亚洲综合区在线| 国产xxx精品视频大全| 欧美一区二区在线观看| 尤物在线观看一区| 91天堂素人约啪| 久久久青草青青国产亚洲免观| 日本最新不卡在线| 色菇凉天天综合网| 亚洲天堂av一区| av电影一区二区| 国产日韩综合av| 高清av一区二区| 综合色天天鬼久久鬼色| 高清日韩电视剧大全免费| 日韩一区二区三区电影在线观看| 国产精品久久久久永久免费观看| 久久99深爱久久99精品| 欧美一区二区女人| 久久97超碰色| 中文字幕成人av| 91亚洲精品一区二区乱码| 亚洲一区二区三区四区的| 色久优优欧美色久优优| 亚洲第一会所有码转帖| 2020国产成人综合网| 国产成人福利片| 国产精品欧美精品| 91亚洲精品一区二区乱码| 亚洲成人自拍一区| 久久夜色精品一区| 色八戒一区二区三区| 图片区小说区国产精品视频| 精品久久久久av影院| 欧美亚洲综合一区| 国产中文字幕精品| 五月综合激情日本mⅴ| 欧美激情艳妇裸体舞| 欧美日韩一级二级三级| 国产成人精品亚洲777人妖 | 国内外精品视频| 国产精品伦一区二区三级视频| 色综合久久久久久久久久久| 国产1区2区3区精品美女| 日本一区二区三级电影在线观看| 成人激情动漫在线观看| 日韩伦理免费电影| 欧美丰满嫩嫩电影| 91视频在线观看| 国产精品一区二区男女羞羞无遮挡| 日韩毛片高清在线播放| 国产亚洲精品免费| 久久久精品国产99久久精品芒果 | 亚洲国产精品成人综合| 欧美精品一二三| 九九视频精品免费| 洋洋成人永久网站入口|