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

📄 avc_e00gen.c

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 C
📖 第 1 页 / 共 4 页
字号:
 * 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 * to get all the other lines for this TOL. * * The function returns NULL when there are no more lines to generate * for this TOL entry. **********************************************************************/const char *AVCE00GenTol(AVCE00GenInfo *psInfo, AVCTol *psTol, GBool bCont){    if (bCont == TRUE)    {        /*---------------------------------------------------------          * TOL entries are only 1 line, we support the bCont flag         * only for compatibility with the other AVCE00Gen*() functions.         *--------------------------------------------------------*/        return NULL;    }    sprintf(psInfo->pszBuf, "%10d%10d", psTol->nIndex, psTol->nFlag);    AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTOL,                    psTol->dValue);    return psInfo->pszBuf;}/*=====================================================================                            PRJ stuff =====================================================================*//********************************************************************** *                          AVCE00GenPrj() * * Generate the next line of an E00 PRJ (Projection) section. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current PRJ, and then call with bCont=TRUE * to get all the other lines for this PRJ. * * The function returns NULL when there are no more lines to generate * for this PRJ entry. **********************************************************************/const char *AVCE00GenPrj(AVCE00GenInfo *psInfo, char **papszPrj, GBool bCont){    if (bCont == FALSE)    {        /*---------------------------------------------------------          * Initialize the psInfo structure with info about the         * current PRJ. (numItems = Number of lines to output)         *--------------------------------------------------------*/        psInfo->iCurItem = 0;        psInfo->numItems = CSLCount(papszPrj) * 2;    }    if (psInfo->iCurItem < psInfo->numItems)    {        /*---------------------------------------------------------          * Return the next PRJ section line.  Note that every         * second line of the output is only a "~".         *--------------------------------------------------------*/        if (psInfo->iCurItem % 2 == 0)        {            /*-----------------------------------------------------             * In theory we should split lines longer than 80 chars on             * several lines, but I won't do it for now since I never             * saw any projection line longer than 80 chars.             *----------------------------------------------------*/            sprintf(psInfo->pszBuf, "%s", papszPrj[psInfo->iCurItem/2]);        }        else        {            /*-----------------------------------------------------             * Every second line in a PRJ section contains only a "~",             * this is a way to tell that the previous line was complete.             *----------------------------------------------------*/            sprintf(psInfo->pszBuf, "~");        }        psInfo->iCurItem++;    }    else    {        /* No more lines to generate for this PRJ.         */        return NULL;    }    return psInfo->pszBuf;}/*=====================================================================                            TXT stuff =====================================================================*//********************************************************************** *                          AVCE00GenTxt() * * Generate the next line of an E00 TXT (Annotation) entry. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current TXT, and then call with bCont=TRUE * to get all the other lines for this TXT. * * The function returns NULL when there are no more lines to generate * for this TXT entry. **********************************************************************/const char *AVCE00GenTxt(AVCE00GenInfo *psInfo, AVCTxt *psTxt, GBool bCont){    int numFixedLines;    /* numFixedLines is the number of lines to generate before the line(s)     * with the text string      */    if (psInfo->nPrecision == AVC_SINGLE_PREC)        numFixedLines = 4;    else        numFixedLines = 6;    if (bCont == FALSE)    {        /*-------------------------------------------------------------         * Initialize the psInfo structure with info about the         * current TXT. (numItems = Number of lines excluding header)         *------------------------------------------------------------*/        psInfo->iCurItem = 0;        psInfo->numItems = numFixedLines + ((psTxt->numChars-1)/80 + 1);        /* And return the TXT header line.         */        sprintf(psInfo->pszBuf, "%10d%10d%10d%10d%10d",                 psTxt->nLevel, psTxt->numVerticesLine - 1,                 psTxt->numVerticesArrow, psTxt->nSymbol, psTxt->numChars);    }    else if (psInfo->iCurItem < psInfo->numItems &&             psInfo->iCurItem < numFixedLines-1)    {        /*-------------------------------------------------------------         * Return next line of coordinates... start by placing the coord.          * values in the order that they should appear, and then generate the          * current line         * (This is a little bit less efficient, but will give much easier         *  code to read ;-)         *------------------------------------------------------------*/        double  dXY[15];        int     i, nFirstValue, numValuesPerLine;        for(i=0; i<14; i++)            dXY[i] = 0.0;        dXY[14] = psTxt->dHeight;        /* note that the first vertex in the vertices list is never exported         */        for(i=0; i < 4 && i< (psTxt->numVerticesLine-1); i++)        {            dXY[i] = psTxt->pasVertices[i+1].x;            dXY[i+4] = psTxt->pasVertices[i+1].y;        }        for(i=0; i < 3 && i<ABS(psTxt->numVerticesArrow); i++)        {            dXY[i+8] = psTxt->pasVertices[i+psTxt->numVerticesLine].x;            dXY[i+11] = psTxt->pasVertices[i+psTxt->numVerticesLine].y;        }        /* OK, now that we prepared the coord. values, return the next line         * of coordinates.  The only difference between double and single         * precision is the number of coordinates per line.         */        if (psInfo->nPrecision != AVC_DOUBLE_PREC)        {            /* Single precision             */            numValuesPerLine = 5;        }        else        {            /* Double precision             */            numValuesPerLine = 3;        }                    nFirstValue = psInfo->iCurItem*numValuesPerLine;         psInfo->pszBuf[0] = '\0';        for(i=0; i<numValuesPerLine; i++)        {            AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTXT,                            dXY[nFirstValue+i] );        }        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&             psInfo->iCurItem == numFixedLines-1)    {        /*-------------------------------------------------------------         * Line with a -1.000E+02 value, ALWAYS SINGLE PRECISION !!!         *------------------------------------------------------------*/        psInfo->pszBuf[0] = '\0';        AVCPrintRealValue(psInfo->pszBuf, AVC_SINGLE_PREC, AVCFileTXT,                        psTxt->f_1e2 );        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&             psInfo->iCurItem >= numFixedLines )    {        /*-------------------------------------------------------------         * Last line, contains the text string         * Strings longer than 80 chars have to be in 80 chars chunks         *------------------------------------------------------------*/        int numLines, iLine;        numLines = (psTxt->numChars-1)/80 + 1;        iLine = numLines - (psInfo->numItems - psInfo->iCurItem);        if ((int)strlen(psTxt->pszText) > (iLine*80))            sprintf(psInfo->pszBuf, "%-.80s", psTxt->pszText + (iLine*80) );        else             psInfo->pszBuf[0] = '\0';        psInfo->iCurItem++;    }    else    {        /* No more lines to generate for this TXT.         */        return NULL;    }    return psInfo->pszBuf;}/*=====================================================================                            TX6 stuff =====================================================================*//********************************************************************** *                          AVCE00GenTx6() * * Generate the next line of an E00 TX6 (Annotation) entry. * * This function should be called once with bCont=FALSE to get the * first E00 line for the current TX6, and then call with bCont=TRUE * to get all the other lines for this TX6. * * Note that E00 files can also contain TX7 sections, they seem identical * to TX6 sections, except for one value in each entry, and it was * impossible to find where this value comes from... so we will always * generate TX6 sections and not bother with TX7. * * The function returns NULL when there are no more lines to generate * for this TX6 entry. **********************************************************************/const char *AVCE00GenTx6(AVCE00GenInfo *psInfo, AVCTxt *psTxt, GBool bCont){    if (bCont == FALSE)    {        /*-------------------------------------------------------------         * Initialize the psInfo structure with info about the         * current TX6. (numItems = Number of lines excluding header)         *------------------------------------------------------------*/        psInfo->iCurItem = 0;        psInfo->numItems = 8 + psTxt->numVerticesLine +                                ABS(psTxt->numVerticesArrow) +                                          ((psTxt->numChars-1)/80 + 1);        /* And return the TX6 header line.         */        sprintf(psInfo->pszBuf, "%10d%10d%10d%10d%10d%10d%10d",                 psTxt->nUserId, psTxt->nLevel, psTxt->numVerticesLine,                 psTxt->numVerticesArrow, psTxt->nSymbol, psTxt->n28,                psTxt->numChars);    }    else if (psInfo->iCurItem < psInfo->numItems &&              psInfo->iCurItem < 6)    {        /*-------------------------------------------------------------         * Text Justification stuff... 2 sets of 20 int16 values.         *------------------------------------------------------------*/        GInt16  *pValue;        if (psInfo->iCurItem < 3)            pValue = psTxt->anJust2 + psInfo->iCurItem * 7;        else            pValue = psTxt->anJust1 + (psInfo->iCurItem-3) * 7;        if (psInfo->iCurItem == 2 || psInfo->iCurItem == 5)        {            sprintf(psInfo->pszBuf, "%10d%10d%10d%10d%10d%10d",                                pValue[0], pValue[1], pValue[2],                                 pValue[3], pValue[4], pValue[5]);        }        else        {            sprintf(psInfo->pszBuf, "%10d%10d%10d%10d%10d%10d%10d",                                pValue[0], pValue[1], pValue[2],                                 pValue[3], pValue[4], pValue[5], pValue[6]);        }        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&              psInfo->iCurItem == 6)    {        /*-------------------------------------------------------------         * Line with a -1.000E+02 value, ALWAYS SINGLE PRECISION !!!         *------------------------------------------------------------*/        psInfo->pszBuf[0] = '\0';        AVCPrintRealValue(psInfo->pszBuf, AVC_SINGLE_PREC, AVCFileTX6,                        psTxt->f_1e2 );        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&              psInfo->iCurItem == 7)    {        /*-------------------------------------------------------------         * Line with 3 values, 1st value is probably text height.         *------------------------------------------------------------*/        psInfo->pszBuf[0] = '\0';        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTX6,                        psTxt->dHeight );        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTX6,                        psTxt->dV2 );        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTX6,                        psTxt->dV3 );        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems-((psTxt->numChars-1)/80 + 1))    {        /*-------------------------------------------------------------         * One line for each pair of X,Y coordinates         *------------------------------------------------------------*/        psInfo->pszBuf[0] = '\0';        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTX6,                        psTxt->pasVertices[ psInfo->iCurItem-8 ].x );        AVCPrintRealValue(psInfo->pszBuf, psInfo->nPrecision, AVCFileTX6,                        psTxt->pasVertices[ psInfo->iCurItem-8 ].y );        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&             psInfo->iCurItem >= psInfo->numItems-((psTxt->numChars-1)/80 + 1))    {        /*-------------------------------------------------------------         * Last line, contains the text string         * Strings longer than 80 chars have to be in 80 chars chunks         *------------------------------------------------------------*/        int numLines, iLine;        numLines = (psTxt->numChars-1)/80 + 1;        iLine = numLines - (psInfo->numItems - psInfo->iCurItem);        if ((int)strlen(psTxt->pszText) > (iLine*80))            sprintf(psInfo->pszBuf, "%-.80s", psTxt->pszText + (iLine*80) );        else             psInfo->pszBuf[0] = '\0';

⌨️ 快捷键说明

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