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

📄 avc_e00parse.c

📁 GIS系统支持库Geospatial Data Abstraction Library代码.GDAL is a translator library for raster geospatial dat
💻 C
📖 第 1 页 / 共 5 页
字号:
            else if (iCurCoord >= 8 && iCurCoord < 11 &&                     (iVertex = (iCurCoord-8) % 3) < psTxt->numVerticesArrow)            {                psTxt->pasVertices[iVertex+psTxt->numVerticesLine].x =                                                    atof(pszLine+i*nItemSize);            }            else if (iCurCoord >= 11 && iCurCoord < 14 &&                     (iVertex = (iCurCoord-8) % 3) < psTxt->numVerticesArrow)            {                psTxt->pasVertices[iVertex+psTxt->numVerticesLine].y =                                                    atof(pszLine+i*nItemSize);            }            else if (iCurCoord == 14)            {                psTxt->dHeight = atof(pszLine+i*nItemSize);            }        }        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&             psInfo->iCurItem == numFixedLines-1  && nLen >=14)    {        /*-------------------------------------------------------------         * Line with a -1.000E+02 value, ALWAYS SINGLE PRECISION !!!         *------------------------------------------------------------*/        psTxt->f_1e2 = (float)atof(pszLine);        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&             psInfo->iCurItem >= numFixedLines)    {        /*-------------------------------------------------------------         * Last line, contains the text string         * Note that text can be split in 80 chars chunk and that buffer         * has been previously initialized with spaces and '\0'-terminated         *------------------------------------------------------------*/        int numLines, iLine;        numLines = (psTxt->numChars-1)/80 + 1;        iLine = numLines - (psInfo->numItems - psInfo->iCurItem);        if (iLine == numLines-1)        {            strncpy(psTxt->pszText+(iLine*80), pszLine,                     MIN( nLen, (psTxt->numChars - (iLine*80)) ) );        }        else        {            strncpy(psTxt->pszText+(iLine*80), pszLine, MIN(nLen, 80));        }        psInfo->iCurItem++;    }    else    {        CPLError(CE_Failure, CPLE_AppDefined,                  "Error parsing E00 TXT line: \"%s\"", pszLine);        psInfo->numItems = psInfo->iCurItem = 0;        return NULL;    }    /*-----------------------------------------------------------------     * If we're done parsing this TXT, then reset the ParseInfo,     * and return a reference to the TXT structure     * Otherwise return NULL, which means that we are expecting more     * more lines of input.     *----------------------------------------------------------------*/    if (psInfo->iCurItem >= psInfo->numItems)    {        psInfo->numItems = psInfo->iCurItem = 0;        return psTxt;    }    return NULL;}/********************************************************************** *                          AVCE00ParseNextTx6Line() * * Take the next line of E00 input for an TX6/TX7 object and parse it. * * Returns NULL if the current object is not complete yet (expecting * more lines of input) or a reference to a complete object if it * is complete. * * The returned object is a reference to an internal data structure. * It should not be modified or freed by the caller. * * If the input is invalid or other problems happen, then a CPLError() * will be generated.  CPLGetLastErrorNo() should be called to check * that the line was parsed succesfully. **********************************************************************/AVCTxt   *AVCE00ParseNextTx6Line(AVCE00ParseInfo *psInfo, const char *pszLine){    AVCTxt *psTxt;    int     i, nLen;    CPLAssert(psInfo->eFileType == AVCFileTX6);    psTxt = psInfo->cur.psTxt;    nLen = strlen(pszLine);    if (psInfo->numItems == 0)    {        /*-------------------------------------------------------------         * Begin processing a new object, read header line:         *------------------------------------------------------------*/        if (nLen < 70)        {            CPLError(CE_Failure, CPLE_AppDefined,                      "Error parsing E00 TX6/TX7 line: \"%s\"", pszLine);            return NULL;        }        else        {            int numVertices;            /*---------------------------------------------------------             * System Id is not stored in the E00 file.  Annotations are             * stored in increasing order of System Id, starting at 1...             * so we just increment the previous value.             *--------------------------------------------------------*/            psTxt->nTxtId = ++psInfo->nCurObjectId;            psTxt->nUserId         = AVCE00Str2Int(pszLine, 10);            psTxt->nLevel          = AVCE00Str2Int(pszLine+10, 10);            psTxt->numVerticesLine = AVCE00Str2Int(pszLine+20, 10);            psTxt->numVerticesArrow= AVCE00Str2Int(pszLine+30, 10);            psTxt->nSymbol         = AVCE00Str2Int(pszLine+40, 10);            psTxt->n28             = AVCE00Str2Int(pszLine+50, 10);            psTxt->numChars        = AVCE00Str2Int(pszLine+60, 10);            /*---------------------------------------------------------             * Realloc the string buffer and array of vertices             *--------------------------------------------------------*/            psTxt->pszText = (char *)CPLRealloc(psTxt->pszText,                                                (psTxt->numChars+1)*                                                sizeof(char));            numVertices = ABS(psTxt->numVerticesLine) +                                  ABS(psTxt->numVerticesArrow);            if (numVertices > 0)                psTxt->pasVertices = (AVCVertex*)CPLRealloc(psTxt->pasVertices,                                              numVertices*sizeof(AVCVertex));            /*---------------------------------------------------------             * Fill the whole string buffer with spaces we'll just             * paste lines in it using strncpy()             *--------------------------------------------------------*/            memset(psTxt->pszText, ' ', psTxt->numChars);            psTxt->pszText[psTxt->numChars] = '\0';            /*---------------------------------------------------------             * psInfo->iCurItem is the index of the last line that was read.             * psInfo->numItems is the number of lines to read.             *--------------------------------------------------------*/            psInfo->iCurItem = 0;            psInfo->numItems = 8 + numVertices + ((psTxt->numChars-1)/80 + 1);        }    }    else if (psInfo->iCurItem < psInfo->numItems &&              psInfo->iCurItem < 6 && nLen >=60)    {        /*-------------------------------------------------------------         * Text Justification stuff... 2 sets of 20 int16 values.         *------------------------------------------------------------*/        GInt16  *pValue;        int     numValPerLine=7;        if (psInfo->iCurItem < 3)            pValue = psTxt->anJust2 + psInfo->iCurItem * 7;        else            pValue = psTxt->anJust1 + (psInfo->iCurItem-3) * 7;        /* Last line of each set contains only 6 values instead of 7 */        if (psInfo->iCurItem == 2 || psInfo->iCurItem == 5)            numValPerLine = 6;        for(i=0; i<numValPerLine; i++)            pValue[i] = AVCE00Str2Int(pszLine + i*10, 10);        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&              psInfo->iCurItem == 6 && nLen >=14)    {        /*-------------------------------------------------------------         * Line with a -1.000E+02 value, ALWAYS SINGLE PRECISION !!!         *------------------------------------------------------------*/        psTxt->f_1e2 = (float)atof(pszLine);        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems &&              psInfo->iCurItem == 7 && nLen >=42)    {        /*-------------------------------------------------------------         * Line with 3 values, 1st value is text height.         *------------------------------------------------------------*/        psTxt->dHeight = atof(pszLine);        if (psInfo->nPrecision == AVC_SINGLE_PREC)        {            psTxt->dV2     = atof(pszLine+14);            psTxt->dV3     = atof(pszLine+28);        }        else        {            psTxt->dV2     = atof(pszLine+21);            psTxt->dV3     = atof(pszLine+42);        }        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < (8 + ABS(psTxt->numVerticesLine) +                                    ABS(psTxt->numVerticesArrow)) && nLen >= 28)    {        /*-------------------------------------------------------------         * One line for each pair of X,Y coordinates         * (Lines 8 to 8+numVertices-1)         *------------------------------------------------------------*/        psTxt->pasVertices[ psInfo->iCurItem-8 ].x = atof(pszLine);        if (psInfo->nPrecision == AVC_SINGLE_PREC)            psTxt->pasVertices[ psInfo->iCurItem-8 ].y = atof(pszLine+14);        else            psTxt->pasVertices[ psInfo->iCurItem-8 ].y = atof(pszLine+21);        psInfo->iCurItem++;    }    else if (psInfo->iCurItem < psInfo->numItems)    {        /*-------------------------------------------------------------         * Last line, contains the text string         * Note that text can be split in 80 chars chunk and that buffer         * has been previously initialized with spaces and '\0'-terminated         *------------------------------------------------------------*/        int numLines, iLine;        numLines = (psTxt->numChars-1)/80 + 1;        iLine = numLines - (psInfo->numItems - psInfo->iCurItem);        if (iLine == numLines-1)        {            strncpy(psTxt->pszText+(iLine*80), pszLine,                     MIN( nLen, (psTxt->numChars - (iLine*80)) ) );        }        else        {            strncpy(psTxt->pszText+(iLine*80), pszLine, MIN(nLen, 80));        }        psInfo->iCurItem++;    }    else    {        CPLError(CE_Failure, CPLE_AppDefined,                  "Error parsing E00 TX6/TX7 line: \"%s\"", pszLine);        psInfo->numItems = psInfo->iCurItem = 0;        return NULL;    }    /*-----------------------------------------------------------------     * If we're done parsing this TX6/TX7, then reset the ParseInfo,     * and return a reference to the TXT structure     * Otherwise return NULL, which means that we are expecting more     * more lines of input.     *----------------------------------------------------------------*/    if (psInfo->iCurItem >= psInfo->numItems)    {        psInfo->numItems = psInfo->iCurItem = 0;        return psTxt;    }    return NULL;}/********************************************************************** *                          AVCE00ParseNextRxpLine() * * Take the next line of E00 input for an RXP object and parse it. * * Returns NULL if the current object is not complete yet (expecting * more lines of input) or a reference to a complete object if it * is complete. * * The returned object is a reference to an internal data structure. * It should not be modified or freed by the caller. * * If the input is invalid or other problems happen, then a CPLError() * will be generated.  CPLGetLastErrorNo() should be called to check * that the line was parsed succesfully. **********************************************************************/AVCRxp   *AVCE00ParseNextRxpLine(AVCE00ParseInfo *psInfo, const char *pszLine){    AVCRxp *psRxp;    int     nLen;    CPLAssert(psInfo->eFileType == AVCFileRXP);    psRxp = psInfo->cur.psRxp;    nLen = strlen(pszLine);    if (nLen >= 20)    {        /*-------------------------------------------------------------         * RXP Entries are only one line each:         *   Value1, Value2 (meaning of the value??? Don't know!!!)         *------------------------------------------------------------*/        psRxp->n1 = AVCE00Str2Int(pszLine, 10);        psRxp->n2 = AVCE00Str2Int(pszLine + 10, 10);    }    else    {        CPLError(CE_Failure, CPLE_AppDefined,                  "Error parsing E00 RXP line: \"%s\"", pszLine);        psInfo->numItems = psInfo->iCurItem = 0;        return NULL;    }    /*-----------------------------------------------------------------     * If we're done parsing this RXP, then reset the ParseInfo,     * and return a reference to the RXP structure     * Otherwise return NULL, which means that we are expecting more     * more lines of input.     *----------------------------------------------------------------*/    if (psInfo->iCurItem >= psInfo->numItems)    {        psInfo->numItems = psInfo->iCurItem = 0;        return psRxp;    }    return NULL;}/*=====================================================================                            TABLE stuff =====================================================================*//********************************************************************** *                          AVCE00ParseNextTableDefLine() * * Take the next line of E00

⌨️ 快捷键说明

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