⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avc_e00gen.c

📁 用于读取TAB、MIF、SHP文件的类
💻 C
📖 第 1 页 / 共 4 页
字号:
 * This function should be called once with bCont=FALSE to get the * first E00 line for the current ARC, and then call with bCont=TRUE * to get all the other lines for this ARC. * * The function returns NULL when there are no more lines to generate * for this ARC. **********************************************************************/const char *AVCE00GenArc(AVCE00GenInfo *psInfo, AVCArc *psArc, GBool bCont){    if (bCont == FALSE)    {        /* Initialize the psInfo structure with info about the         * current ARC.         */        psInfo->iCurItem = 0;        if (psInfo->nPrecision == AVC_DOUBLE_PREC)            psInfo->numItems = psArc->numVertices;        else            psInfo->numItems = (psArc->numVertices+1)/2;        /* And return the ARC header line         */        sprintf(psInfo->pszBuf, "%10d%10d%10d%10d%10d%10d%10d",                psArc->nArcId, psArc->nUserId,                psArc->nFNode, psArc->nTNode,                psArc->nLPoly, psArc->nRPoly,                psArc->numVertices);    }    else if (psInfo->iCurItem < psInfo->numItems)    {        int iVertex;        /* return the next set of vertices for the ARC.         */        if (psInfo->nPrecision == AVC_DOUBLE_PREC)        {            iVertex = psInfo->iCurItem;            psInfo->pszBuf[0] = '\0';            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileARC,                            psArc->pasVertices[iVertex].x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileARC,                            psArc->pasVertices[iVertex].y);        }        else        {            iVertex = psInfo->iCurItem*2;            psInfo->pszBuf[0] = '\0';            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileARC,                            psArc->pasVertices[iVertex].x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileARC,                            psArc->pasVertices[iVertex].y);            /* Check because if we have a odd number of vertices then             * the last line contains only one pair of vertices.             */            if (iVertex+1 < psArc->numVertices)            {                AVCPrintRealValue(psInfo->pszBuf,psInfo->nPrecision,AVCFileARC,                                psArc->pasVertices[iVertex+1].x);                AVCPrintRealValue(psInfo->pszBuf,psInfo->nPrecision,AVCFileARC,                                psArc->pasVertices[iVertex+1].y);            }        }        psInfo->iCurItem++;    }    else    {        /* No more lines to generate for this ARC.         */        return NULL;    }    return psInfo->pszBuf;}/*=====================================================================                            PAL stuff =====================================================================*//********************************************************************** *                          AVCE00GenPal() * * Generate the next line of an E00 PAL (Polygon Arc List) entry. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current PAL, and then call with bCont=TRUE * to get all the other lines for this PAL. * * The function returns NULL when there are no more lines to generate * for this PAL entry. **********************************************************************/const char *AVCE00GenPal(AVCE00GenInfo *psInfo, AVCPal *psPal, GBool bCont){    if (bCont == FALSE)    {        /* Initialize the psInfo structure with info about the         * current PAL.  (Number of lines excluding header)         */        psInfo->numItems = (psPal->numArcs+1)/2;        /* And return the PAL header line.         */        sprintf(psInfo->pszBuf, "%10d", psPal->numArcs);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFilePAL,                        psPal->sMin.x);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFilePAL,                        psPal->sMin.y);        /* Double precision PAL entries have their header on 2 lines!         */        if (psInfo->nPrecision == AVC_DOUBLE_PREC)        {            psInfo->iCurItem = -1;      /* Means 1 line left in header */        }        else        {            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFilePAL,                            psPal->sMax.x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFilePAL,                            psPal->sMax.y);            psInfo->iCurItem = 0;       /* Next thing = first Arc entry */        }    }    else if (psInfo->iCurItem == -1)    {        /* Second (and last) header line for double precision coverages         */        psInfo->pszBuf[0] = '\0';        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFilePAL,                        psPal->sMax.x);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFilePAL,                        psPal->sMax.y);        if ( psInfo->numItems == 0 )        {           psInfo->iCurItem = -2;      /* We have a 0-arc polygon, which needs                                          an arc list with one "0 0 0" element */        }        else        {           psInfo->iCurItem = 0;       /* Next thing = first Arc entry */        }    }    else if (psInfo->iCurItem == -2)    {        sprintf(psInfo->pszBuf, "%10d%10d%10d", 0, 0, 0);        psInfo->iCurItem = 0;       /* Next thing = first Arc entry */    }    else if (psInfo->iCurItem < psInfo->numItems)    {        /* Return PAL Arc entries...         */        int iArc;        iArc = psInfo->iCurItem*2;        /* If we have a odd number of arcs then         * the last line contains only one arc entry.         */        if (iArc+1 < psPal->numArcs)        {            sprintf(psInfo->pszBuf, "%10d%10d%10d%10d%10d%10d",                                    psPal->pasArcs[iArc].nArcId,                                    psPal->pasArcs[iArc].nFNode,                                    psPal->pasArcs[iArc].nAdjPoly,                                    psPal->pasArcs[iArc+1].nArcId,                                    psPal->pasArcs[iArc+1].nFNode,                                    psPal->pasArcs[iArc+1].nAdjPoly);        }        else        {            sprintf(psInfo->pszBuf, "%10d%10d%10d",                                     psPal->pasArcs[iArc].nArcId,                                    psPal->pasArcs[iArc].nFNode,                                    psPal->pasArcs[iArc].nAdjPoly);        }        psInfo->iCurItem++;    }    else    {        /* No more lines to generate for this PAL.         */        return NULL;    }    return psInfo->pszBuf;}/*=====================================================================                            CNT stuff =====================================================================*//********************************************************************** *                          AVCE00GenCnt() * * Generate the next line of an E00 CNT (Polygon Centroid) entry. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current CNT, and then call with bCont=TRUE * to get all the other lines for this CNT. * * The function returns NULL when there are no more lines to generate * for this CNT entry. **********************************************************************/const char *AVCE00GenCnt(AVCE00GenInfo *psInfo, AVCCnt *psCnt, GBool bCont){    if (bCont == FALSE)    {        /* Initialize the psInfo structure with info about the         * current CNT.         */        psInfo->iCurItem = 0;        psInfo->numItems = (psCnt->numLabels+7)/8;        /* And return the CNT header line.         */        sprintf(psInfo->pszBuf, "%10d", psCnt->numLabels);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileCNT,                        psCnt->sCoord.x);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileCNT,                        psCnt->sCoord.y);    }    else if (psInfo->iCurItem < psInfo->numItems)    {        /* Return CNT Label Ids, 8 label Ids per line...          */        int i, nFirstLabel, numLabels;        nFirstLabel = psInfo->iCurItem * 8;        numLabels = MIN(8, (psCnt->numLabels-nFirstLabel));        psInfo->pszBuf[0] = '\0';        for(i=0; i < numLabels; i++)        {            sprintf(psInfo->pszBuf + strlen(psInfo->pszBuf), "%10d",                                         psCnt->panLabelIds[nFirstLabel+i] );        }        psInfo->iCurItem++;    }    else    {        /* No more lines to generate for this CNT.         */        return NULL;    }    return psInfo->pszBuf;}/*=====================================================================                            LAB stuff =====================================================================*//********************************************************************** *                          AVCE00GenLab() * * Generate the next line of an E00 LAB (Label) entry. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current LAB, and then call with bCont=TRUE * to get all the other lines for this LAB. * * The function returns NULL when there are no more lines to generate * for this LAB entry. **********************************************************************/const char *AVCE00GenLab(AVCE00GenInfo *psInfo, AVCLab *psLab, GBool bCont){    if (bCont == FALSE)    {        /* Initialize the psInfo structure with info about the         * current LAB. (numItems = Number of lines excluding header)         */        psInfo->iCurItem = 0;        if (psInfo->nPrecision == AVC_DOUBLE_PREC)            psInfo->numItems = 2;        else            psInfo->numItems = 1;        /* And return the LAB header line.         */        sprintf(psInfo->pszBuf, "%10d%10d", psLab->nValue, psLab->nPolyId);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                        psLab->sCoord1.x);        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                        psLab->sCoord1.y);    }    else if (psInfo->iCurItem < psInfo->numItems)    {        /* Return next Label coordinates...          */        if (psInfo->nPrecision != AVC_DOUBLE_PREC)        {            /* Single precision, all on the same line             */            psInfo->pszBuf[0] = '\0';            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord2.x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord2.y);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord3.x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord3.y);        }        else if (psInfo->iCurItem == 0)        {            /* 2nd line, in a double precision coverage             */            psInfo->pszBuf[0] = '\0';            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord2.x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord2.y);        }        else        {            /* 3rd line, in a double precision coverage             */            psInfo->pszBuf[0] = '\0';            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord3.x);            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileLAB,                            psLab->sCoord3.y);        }        psInfo->iCurItem++;    }    else    {        /* No more lines to generate for this LAB.         */        return NULL;    }    return psInfo->pszBuf;}/*=====================================================================                            TOL stuff =====================================================================*//********************************************************************** *                          AVCE00GenTol() * * Generate the next line of an E00 TOL (Tolerance) entry. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current TOL, and then call with bCont=TRUE

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -