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

📄 avc_binwr.c

📁 支持各种栅格图像和矢量图像读取的库
💻 C
📖 第 1 页 / 共 5 页
字号:
        AVCRawBinWriteDouble(psFile, psPal->sMax.x);        AVCRawBinWriteDouble(psFile, psPal->sMax.y);    }    AVCRawBinWriteInt32(psFile, psPal->numArcs);    for(i=0; i<psPal->numArcs; i++)    {        AVCRawBinWriteInt32(psFile, psPal->pasArcs[i].nArcId);        AVCRawBinWriteInt32(psFile, psPal->pasArcs[i].nFNode);        AVCRawBinWriteInt32(psFile, psPal->pasArcs[i].nAdjPoly);    }    /*-----------------------------------------------------------------     * Write index entry (pax.adf)     *----------------------------------------------------------------*/    if (psIndexFile)    {        _AVCBinWriteIndexEntry(psIndexFile, nCurPos, nRecSize);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          AVCBinWritePal() * * Write a PAL (Polygon Arc List) structure to the file. * * The contents of the psPal structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWritePal(AVCBinFile *psFile, AVCPal *psPal){    if (psFile->eFileType != AVCFilePAL && psFile->eFileType != AVCFileRPL)        return -1;    return _AVCBinWritePal(psFile->psRawBinFile, psPal,                           psFile->nPrecision, psFile->psIndexFile);}/*===================================================================== *                              CNT *====================================================================*//********************************************************************** *                          _AVCBinWriteCnt() * * (This function is for internal library use... external calls should * go to AVCBinWriteCnt() instead) * * Write a CNT (Polygon Centroid) structure to the file. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteCnt(AVCRawBinFile *psFile, AVCCnt *psCnt,                               int nPrecision, AVCRawBinFile *psIndexFile){    int i, nRecSize, nCurPos;    nCurPos = psFile->nCurPos/2;  /* Value in 2 byte words */    AVCRawBinWriteInt32(psFile, psCnt->nPolyId);    if (CPLGetLastErrorNo() != 0)        return -1;    /*-----------------------------------------------------------------     * Record size is expressed in 2 byte words, and does not count the     * first 8 bytes of the CNT entry.     *----------------------------------------------------------------*/    nRecSize = ( 4 + psCnt->numLabels * 4 +                  2 * ((nPrecision == AVC_SINGLE_PREC)? 4 : 8)) / 2;    AVCRawBinWriteInt32(psFile, nRecSize);    if (nPrecision == AVC_SINGLE_PREC)    {        AVCRawBinWriteFloat(psFile, (float)psCnt->sCoord.x);        AVCRawBinWriteFloat(psFile, (float)psCnt->sCoord.y);    }    else    {        AVCRawBinWriteDouble(psFile, psCnt->sCoord.x);        AVCRawBinWriteDouble(psFile, psCnt->sCoord.y);    }    AVCRawBinWriteInt32(psFile, psCnt->numLabels);    for(i=0; i<psCnt->numLabels; i++)    {        AVCRawBinWriteInt32(psFile, psCnt->panLabelIds[i]);    }    /*-----------------------------------------------------------------     * Write index entry (cnx.adf)     *----------------------------------------------------------------*/    if (psIndexFile)    {        _AVCBinWriteIndexEntry(psIndexFile, nCurPos, nRecSize);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          AVCBinWriteCnt() * * Write a CNT (Polygon Centroid) structure to the file. * * The contents of the psCnt structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWriteCnt(AVCBinFile *psFile, AVCCnt *psCnt){    if (psFile->eFileType != AVCFileCNT)        return -1;    return _AVCBinWriteCnt(psFile->psRawBinFile, psCnt,                           psFile->nPrecision, psFile->psIndexFile);}/*===================================================================== *                              LAB *====================================================================*//********************************************************************** *                          _AVCBinWriteLab() * * (This function is for internal library use... external calls should * go to AVCBinWriteLab() instead) * * Write a LAB (Centroid Label) structure to the file. * * The contents of the psLab structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteLab(AVCRawBinFile *psFile, AVCLab *psLab,                     int nPrecision){    AVCRawBinWriteInt32(psFile, psLab->nValue);    if (CPLGetLastErrorNo() != 0)        return -1;    AVCRawBinWriteInt32(psFile, psLab->nPolyId);    if (nPrecision == AVC_SINGLE_PREC)    {        AVCRawBinWriteFloat(psFile, (float)psLab->sCoord1.x);        AVCRawBinWriteFloat(psFile, (float)psLab->sCoord1.y);        AVCRawBinWriteFloat(psFile, (float)psLab->sCoord2.x);        AVCRawBinWriteFloat(psFile, (float)psLab->sCoord2.y);        AVCRawBinWriteFloat(psFile, (float)psLab->sCoord3.x);        AVCRawBinWriteFloat(psFile, (float)psLab->sCoord3.y);    }    else    {        AVCRawBinWriteDouble(psFile, psLab->sCoord1.x);        AVCRawBinWriteDouble(psFile, psLab->sCoord1.y);        AVCRawBinWriteDouble(psFile, psLab->sCoord2.x);        AVCRawBinWriteDouble(psFile, psLab->sCoord2.y);        AVCRawBinWriteDouble(psFile, psLab->sCoord3.x);        AVCRawBinWriteDouble(psFile, psLab->sCoord3.y);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          AVCBinWriteLab() * * Write a LAB (Centroid Label) structure to the file. * * The contents of the psLab structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWriteLab(AVCBinFile *psFile, AVCLab *psLab){    if (psFile->eFileType != AVCFileLAB)        return -1;    return _AVCBinWriteLab(psFile->psRawBinFile, psLab,                           psFile->nPrecision);}/*===================================================================== *                              TOL *====================================================================*//********************************************************************** *                          _AVCBinWriteTol() * * (This function is for internal library use... external calls should * go to AVCBinWriteTol() instead) * * Write a TOL (tolerance) structure to the file. * * The contents of the psTol structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteTol(AVCRawBinFile *psFile, AVCTol *psTol,                     int nPrecision){    AVCRawBinWriteInt32(psFile, psTol->nIndex);    if (CPLGetLastErrorNo() != 0)        return -1;    AVCRawBinWriteInt32(psFile, psTol->nFlag);    if (nPrecision == AVC_SINGLE_PREC)    {        AVCRawBinWriteFloat(psFile, (float)psTol->dValue);    }    else    {        AVCRawBinWriteDouble(psFile, psTol->dValue);    }    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/********************************************************************** *                          AVCBinWriteTol() * * Write a TOL (tolerance) structure to the file. * * The contents of the psTol structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWriteTol(AVCBinFile *psFile, AVCTol *psTol){    if (psFile->eFileType != AVCFileTOL)        return -1;    return _AVCBinWriteTol(psFile->psRawBinFile, psTol,                           psFile->nPrecision);}/*===================================================================== *                              PRJ *====================================================================*//********************************************************************** *                          AVCBinWritePrj() * * Write a PRJ (Projection info) to the file. * * Since a PRJ file is a simple text file and there is only ONE projection * info per prj.adf file, this function behaves differently from the  * other ones... all the job is done here, including creating and closing * the output file. * * The contents of the papszPrj is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. * * If a problem happens, then CPLError() will be called by the lower-level * functions and CPLGetLastErrorNo() can be used to find out what happened. **********************************************************************/int AVCBinWritePrj(AVCBinFile *psFile, char **papszPrj){    if (psFile->eFileType != AVCFilePRJ)        return -1;    CSLSave(papszPrj, psFile->pszFilename);    if (CPLGetLastErrorNo() != 0)        return -1;    return 0;}/*===================================================================== *                              TXT/TX6/TX7 *====================================================================*//********************************************************************** *                          _AVCBinWriteTxt() * * (This function is for internal library use... external calls should * go to AVCBinWriteTxt() instead) * * Write a TXT/TX6/TX7 (Annotation) structure to the file. * * The contents of the psTxt structure is assumed to be valid... this * function performs no validation on the consistency of what it is  * given as input. * * Returns 0 on success or -1 on error. **********************************************************************/int _AVCBinWriteTxt(AVCRawBinFile *psFile, AVCTxt *psTxt,                               int nPrecision, AVCRawBinFile *psIndexFile){    int i, nRecSize, nCurPos, nStrLen, numVertices;    nCurPos = psFile->nCurPos/2;  /* Value in 2 byte words */    AVCRawBinWriteInt32(psFile, psTxt->nTxtId);    if (CPLGetLastErrorNo() != 0)        return -1;    /*-----------------------------------------------------------------     * Record size is expressed in 2 byte words, and does not count the     * first 8 bytes of the TXT entry.     *----------------------------------------------------------------*/    /* String uses a multiple of 4 bytes of storage */    if (psTxt->pszText)        nStrLen = ((strlen(psTxt->pszText) + 3)/4)*4;    else        nStrLen = 0;    numVertices = ABS(psTxt->numVerticesLine) + ABS(psTxt->numVerticesArrow);    nRecSize = (112 + 8 + nStrLen +                 (numVertices*2+3)* ((nPrecision == AVC_SINGLE_PREC)?4:8)) / 2;    AVCRawBinWriteInt32(psFile, nRecSize);

⌨️ 快捷键说明

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