您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ CPLReadLine2L函数代码示例

51自学网 2021-06-01 20:04:47
  C++
这篇教程C++ CPLReadLine2L函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中CPLReadLine2L函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLReadLine2L函数的具体用法?C++ CPLReadLine2L怎么用?C++ CPLReadLine2L使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了CPLReadLine2L函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: E00ReadNextLine

const char* E00GRIDDataset::ReadLine(){    if (e00ReadPtr)        return E00ReadNextLine(e00ReadPtr);    return CPLReadLine2L(fp, 81, NULL);}
开发者ID:ryandavid,项目名称:rotobox,代码行数:7,


示例2: ResetReading

int OGRHTFSoundingLayer::GetFeatureCount(int bForce){    if (m_poFilterGeom != NULL || m_poAttrQuery != NULL)        return OGRHTFLayer::GetFeatureCount(bForce);    if (nTotalSoundings != 0)        return nTotalSoundings;    ResetReading();    if (fpHTF == NULL)        return 0;    int nCount = 0;    const char* pszLine;    while( (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL)    {        if (pszLine[0] == ';')        {            /* comment */ ;        }        else if (pszLine[0] == 0)            break;        else if (strcmp(pszLine, "END OF SOUNDING DATA") == 0)            break;        else            nCount ++;    }    ResetReading();    return nCount;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:31,


示例3: while

OGRFeature *OGROpenAirLabelLayer::GetNextRawFeature(){    const char* pszLine;    double dfLat = 0, dfLon = 0;    int bHasCoord = FALSE;    while(TRUE)    {        pszLine = CPLReadLine2L(fpOpenAir, 1024, NULL);        if (pszLine == NULL)            return NULL;        if (pszLine[0] == '*' || pszLine[0] == '/0')            continue;        if (EQUALN(pszLine, "AC ", 3))        {            if (osCLASS.size() != 0)            {                osNAME = "";                osCEILING = "";                osFLOOR = "";            }            osCLASS = pszLine + 3;        }        else if (EQUALN(pszLine, "AN ", 3))            osNAME = pszLine + 3;        else if (EQUALN(pszLine, "AH ", 3))            osCEILING = pszLine + 3;        else if (EQUALN(pszLine, "AL ", 3))            osFLOOR = pszLine + 3;        else if (EQUALN(pszLine, "AT ", 3))        {            bHasCoord = OGROpenAirGetLatLon(pszLine + 3, dfLat, dfLon);            break;        }    }    OGRFeature* poFeature = new OGRFeature(poFeatureDefn);    poFeature->SetField(0, osCLASS.c_str());    poFeature->SetField(1, osNAME.c_str());    poFeature->SetField(2, osFLOOR.c_str());    poFeature->SetField(3, osCEILING.c_str());    CPLString osStyle;    osStyle.Printf("LABEL(t:/"%s/")", osNAME.c_str());    poFeature->SetStyleString(osStyle.c_str());    if (bHasCoord)    {        OGRPoint* poPoint = new OGRPoint(dfLon, dfLat);        poPoint->assignSpatialReference(poSRS);        poFeature->SetGeometryDirectly(poPoint);    }    poFeature->SetFID(nNextFID++);    return poFeature;}
开发者ID:samalone,项目名称:gdal-ios,代码行数:59,


示例4: while

void OGRHTFSoundingLayer::ResetReading(){    OGRHTFLayer::ResetReading();    if (fpHTF)    {        const char* pszLine;        while( (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL)        {            if (strcmp(pszLine, "SOUNDING DATA") == 0)            {                if (bHasFPK)                    pszLine = CPLReadLine2L(fpHTF, 1024, NULL);                break;            }        }        if (pszLine == NULL)            bEOF = TRUE;    }}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:20,


示例5: while

OGRFeature *OGRAeronavFAANAVAIDLayer::GetNextRawFeature(){    char szBuffer[134];    while( true )    {        const char* pszLine = CPLReadLine2L(fpAeronavFAA, 134, nullptr);        if (pszLine == nullptr)        {            bEOF = true;            return nullptr;        }        if (strlen(pszLine) != 132)            continue;        if ( !(pszLine[psRecordDesc->nLatStartCol-1] == 'N' ||               pszLine[psRecordDesc->nLatStartCol-1] == 'S') )            continue;        if ( !(pszLine[psRecordDesc->nLonStartCol-1] == 'E' ||               pszLine[psRecordDesc->nLonStartCol-1] == 'W') )            continue;        OGRFeature* poFeature = new OGRFeature(poFeatureDefn);        poFeature->SetFID(nNextFID ++);        for( int i=0; i < psRecordDesc->nFields; i++ )        {            int nWidth = psRecordDesc->pasFields[i].nLastCol - psRecordDesc->pasFields[i].nStartCol + 1;            strncpy(szBuffer, pszLine + psRecordDesc->pasFields[i].nStartCol - 1, nWidth);            szBuffer[nWidth] = 0;            while(nWidth > 0 && szBuffer[nWidth - 1] == ' ')            {                szBuffer[nWidth - 1] = 0;                nWidth --;            }            if (nWidth != 0)                poFeature->SetField(i, szBuffer);        }        double dfLat = 0.0;        double dfLon = 0.0;        GetLatLon(pszLine + psRecordDesc->nLatStartCol - 1,                  pszLine + psRecordDesc->nLonStartCol - 1,                  dfLat,                  dfLon);        OGRGeometry* poGeom = new OGRPoint(dfLon, dfLat);        poGeom->assignSpatialReference(poSRS);        poFeature->SetGeometryDirectly( poGeom );        return poFeature;    }}
开发者ID:koordinates,项目名称:gdal,代码行数:51,


示例6: VSIFSeekL

void OGRSEGP1Layer::ResetReading(){    nNextFID = 0;    bEOF = FALSE;    VSIFSeekL( fp, 0, SEEK_SET );    /* Skip first 20 header lines */    const char* pszLine = NULL;    for(int i=0; i<20;i++)    {        pszLine = CPLReadLine2L(fp,81,NULL);        if (pszLine == NULL)        {            bEOF = TRUE;            break;        }    }}
开发者ID:drownedout,项目名称:datamap,代码行数:19,


示例7: VSIFSeekL

void OGRSEGP1Layer::ResetReading(){    nNextFID = 0;    bEOF = false;    VSIFSeekL( fp, 0, SEEK_SET );    /* Skip first 20 header lines */    const char* pszLine = nullptr;    for(int i=0; i<20;i++)    {        pszLine = CPLReadLine2L(fp,81,nullptr);        if (pszLine == nullptr)        {            bEOF = true;            break;        }    }}
开发者ID:OSGeo,项目名称:gdal,代码行数:19,


示例8: VSIFOpenL

GDALDataset *E00GRIDDataset::Open( GDALOpenInfo * poOpenInfo ){    if (!Identify(poOpenInfo))        return NULL;/* -------------------------------------------------------------------- *//*      Find dataset characteristics                                    *//* -------------------------------------------------------------------- */    VSILFILE* fp = VSIFOpenL(poOpenInfo->pszFilename, "rb");    if (fp == NULL)        return NULL;    if (poOpenInfo->eAccess == GA_Update)    {        CPLError( CE_Failure, CPLE_NotSupported,                  "The E00GRID driver does not support update access to existing"                  " datasets./n" );        VSIFCloseL(fp);        return NULL;    }/* -------------------------------------------------------------------- *//*      Create a corresponding GDALDataset.                             *//* -------------------------------------------------------------------- */    E00GRIDDataset *poDS = new E00GRIDDataset();    if (strstr((const char*)poOpenInfo->pabyHeader, "/r/n") != NULL)        poDS->nBytesEOL = 2;    poDS->fp = fp;    /* read EXP  0 or EXP  1 line */    const char* pszLine = CPLReadLine2L(fp, 81, NULL);    if (pszLine == NULL)    {        CPLDebug("E00GRID", "Bad 1st line");        delete poDS;        return NULL;    }    bool bCompressed = STARTS_WITH_CI(pszLine, "EXP  1");    E00ReadPtr e00ReadPtr = NULL;    if (bCompressed)    {        VSIRewindL(fp);        e00ReadPtr = E00ReadCallbackOpen(poDS,                                         E00GRIDDataset::ReadNextLine,                                         E00GRIDDataset::Rewind);        if (e00ReadPtr == NULL)        {            delete poDS;            return NULL;        }        E00ReadNextLine(e00ReadPtr);        poDS->e00ReadPtr = e00ReadPtr;    }    /* skip GRD  2 line */    if (e00ReadPtr)        pszLine = E00ReadNextLine(e00ReadPtr);    else        pszLine = CPLReadLine2L(fp, 81, NULL);    if (pszLine == NULL || !STARTS_WITH_CI(pszLine, "GRD  2"))    {        CPLDebug("E00GRID", "Bad 2nd line");        delete poDS;        return NULL;    }    /* read ncols, nrows and nodata value */    if (e00ReadPtr)        pszLine = E00ReadNextLine(e00ReadPtr);    else        pszLine = CPLReadLine2L(fp, 81, NULL);    if (pszLine == NULL || strlen(pszLine) <                E00_INT_SIZE+E00_INT_SIZE+2+E00_DOUBLE_SIZE)    {        CPLDebug("E00GRID", "Bad 3rd line");        delete poDS;        return NULL;    }    const int nRasterXSize = atoi(pszLine);    const int nRasterYSize = atoi(pszLine + E00_INT_SIZE);    if (!GDALCheckDatasetDimensions(nRasterXSize, nRasterYSize))    {        delete poDS;        return NULL;    }    GDALDataType eDT = GDT_Float32;    if (STARTS_WITH_CI(pszLine + E00_INT_SIZE + E00_INT_SIZE, " 1"))        eDT = GDT_Int32;    else if (STARTS_WITH_CI(pszLine + E00_INT_SIZE + E00_INT_SIZE, " 2"))        eDT = GDT_Float32;    else    {        CPLDebug("E00GRID", "Unknown data type : %s", pszLine);    }//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,


示例9: VSIFTellL

const char* E00GRIDDataset::ReadNextLine(void * ptr){    E00GRIDDataset* poDS = (E00GRIDDataset*) ptr;    poDS->nPosBeforeReadLine = VSIFTellL(poDS->fp);    return CPLReadLine2L(poDS->fp, 256, NULL);}
开发者ID:ryandavid,项目名称:rotobox,代码行数:6,


示例10: while

OGRFeature *OGRSEGP1Layer::GetNextRawFeature(){    if( bEOF )        return nullptr;    const char* pszLine = nullptr;    while( true )    {        pszLine = CPLReadLine2L(fp,81,nullptr);        if (pszLine == nullptr || STARTS_WITH_CI(pszLine, "EOF"))        {            bEOF = true;            return nullptr;        }        int nLineLen = static_cast<int>(strlen(pszLine));        while(nLineLen > 0 && pszLine[nLineLen-1] == ' ')        {            ((char*)pszLine)[nLineLen-1] = '/0';            nLineLen --;        }        char* pszExpandedLine = ExpandTabs(pszLine);        pszLine = pszExpandedLine;        nLineLen = static_cast<int>(strlen(pszLine));        OGRFeature* poFeature = new OGRFeature(poFeatureDefn);        poFeature->SetFID(nNextFID ++);        OGRGeometry* poGeom = nullptr;        if (nLatitudeCol-1 + 19 <= nLineLen)        {            char szDeg[3+1];            char szMin[2+1];            char szSec[4+1];            ExtractField(szDeg, pszLine, nLatitudeCol-1, 2);            ExtractField(szMin, pszLine, nLatitudeCol+2-1, 2);            ExtractField(szSec, pszLine, nLatitudeCol+2+2-1, 4);            double dfLat = atoi(szDeg) + atoi(szMin) / 60.0 + atoi(szSec) / 100.0 / 3600.0;            if (pszLine[nLatitudeCol+2+2+4-1] == 'S')                dfLat = -dfLat;            poFeature->SetField(SEGP1_FIELD_LATITUDE, dfLat);            ExtractField(szDeg, pszLine, nLatitudeCol+9-1, 3);            ExtractField(szMin, pszLine, nLatitudeCol+9+3-1, 2);            ExtractField(szSec, pszLine, nLatitudeCol+9+3+2-1, 4);            double dfLon = atoi(szDeg) + atoi(szMin) / 60.0 + atoi(szSec) / 100.0 / 3600.0;            if (pszLine[nLatitudeCol+9+3+2+4-1] == 'W')                dfLon = -dfLon;            poFeature->SetField(SEGP1_FIELD_LONGITUDE, dfLon);            if (!bUseEastingNorthingAsGeometry)                poGeom = new OGRPoint(dfLon, dfLat);        }        /* Normal layout -> extract other fields */        if (nLatitudeCol == 27 && nLineLen >= 26-1+1)        {            char szLineName[16 + 1];            ExtractField(szLineName, pszLine, 2-1, 16);            int i = 15;            while (i >= 0)            {                if (szLineName[i] == ' ')                    szLineName[i] = '/0';                else                    break;                i --;            }            poFeature->SetField(SEGP1_FIELD_LINENAME, szLineName);            char szPointNumber[8+1];            ExtractField(szPointNumber, pszLine, 18-1, 8);            poFeature->SetField(SEGP1_FIELD_POINTNUMBER, atoi(szPointNumber));            char szReshootCode[1+1];            ExtractField(szReshootCode, pszLine, 26-1, 1);            poFeature->SetField(SEGP1_FIELD_RESHOOTCODE, szReshootCode);            if (nLineLen >= 61)            {                char szEasting[8+1];                ExtractField(szEasting, pszLine, 46-1, 8);                double dfEasting = CPLAtof(szEasting);                poFeature->SetField(SEGP1_FIELD_EASTING, dfEasting);                char szNorthing[8+1];                ExtractField(szNorthing, pszLine, 54-1, 8);                double dfNorthing = CPLAtof(szNorthing);                poFeature->SetField(SEGP1_FIELD_NORTHING, dfNorthing);                if (bUseEastingNorthingAsGeometry)                    poGeom = new OGRPoint(dfEasting, dfNorthing);            }            if (nLineLen >= 66)            {                char szDepth[5+1];//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,


示例11: OGRHTFLayer

OGRHTFSoundingLayer::OGRHTFSoundingLayer( const char* pszFilename, int nZone, int bIsNorth, int nTotalSoundings ) :                                        OGRHTFLayer(pszFilename, nZone, bIsNorth){    poFeatureDefn = new OGRFeatureDefn( "sounding" );    poFeatureDefn->Reference();    poFeatureDefn->SetGeomType( wkbPoint  );    this->nTotalSoundings = nTotalSoundings;    bHasFPK = FALSE;    nFieldsPresent = 0;    panFieldPresence = NULL;    nEastingIndex = -1;    nNorthingIndex = -1;    const char* pszLine;    int bSoundingHeader = FALSE;    while( fpHTF != NULL &&           (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL)    {        if (strncmp(pszLine, "SOUNDING HEADER", strlen("SOUNDING HEADER")) == 0)            bSoundingHeader = TRUE;        else if (bSoundingHeader && strlen(pszLine) > 10 &&                 pszLine[0] == '[' && pszLine[3] == ']' &&                 pszLine[4] == ' ' &&                 strstr(pszLine + 5, " =") != NULL)        {            char* pszName = CPLStrdup(pszLine + 5);            *strstr(pszName, " =") = 0;            char* pszPtr = pszName;            for(;*pszPtr;pszPtr++)            {                if (*pszPtr == ' ')                    *pszPtr = '_';            }            OGRFieldType eType;            if (strcmp(pszName, "REJECTED_SOUNDING") == 0 ||                strcmp(pszName, "FIX_NUMBER") == 0 ||                strcmp(pszName, "NBA_FLAG") == 0 ||                strcmp(pszName, "SOUND_VELOCITY") == 0 ||                strcmp(pszName, "PLOTTED_SOUNDING") == 0)                eType = OFTInteger;            else if (strcmp(pszName, "LATITUDE") == 0 ||                     strcmp(pszName, "LONGITUDE") == 0 ||                     strcmp(pszName, "EASTING") == 0 ||                     strcmp(pszName, "NORTHING") == 0 ||                     strcmp(pszName, "DEPTH") == 0 ||                     strcmp(pszName, "TPE_POSITION") == 0 ||                     strcmp(pszName, "TPE_DEPTH") == 0 ||                     strcmp(pszName, "TIDE") == 0 ||                     strcmp(pszName, "DEEP_WATER_CORRECTION") == 0 ||                     strcmp(pszName, "VERTICAL_BIAS_CORRECTION") == 0)                eType = OFTReal;            else                eType = OFTString;            OGRFieldDefn    oField( pszName, eType);            poFeatureDefn->AddFieldDefn( &oField);            CPLFree(pszName);        }        else if (strcmp(pszLine, "END OF SOUNDING HEADER") == 0)        {            bSoundingHeader = FALSE;        }        else if (strcmp(pszLine, "SOUNDING DATA") == 0)        {            pszLine = CPLReadLine2L(fpHTF, 1024, NULL);            if (pszLine == NULL)                break;            if (pszLine[0] == '[' &&                (int)strlen(pszLine) == 2 + poFeatureDefn->GetFieldCount())            {                bHasFPK = TRUE;                panFieldPresence = (int*)CPLMalloc(sizeof(int) *                                            poFeatureDefn->GetFieldCount());                int i;                for(i=0;i<poFeatureDefn->GetFieldCount();i++)                {                    panFieldPresence[i] = pszLine[1 + i] != '0';                    nFieldsPresent += panFieldPresence[i];                }            }            break;        }    }    if (!bHasFPK)    {        panFieldPresence = (int*)CPLMalloc(sizeof(int) *                                           poFeatureDefn->GetFieldCount());        int i;        for(i=0;i<poFeatureDefn->GetFieldCount();i++)            panFieldPresence[i] = TRUE;        nFieldsPresent = poFeatureDefn->GetFieldCount();    }    int nIndex;    nIndex = poFeatureDefn->GetFieldIndex("EASTING");    if (nIndex < 0 || !panFieldPresence[nIndex])    {        CPLError(CE_Failure, CPLE_NotSupported, "Cannot find EASTING field");//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例12: VSIFSeekL

CPLErr XYZRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff,                                  void * pImage ){    XYZDataset *poGDS = (XYZDataset *) poDS;        if (poGDS->fp == NULL)        return CE_Failure;    int nLineInFile = nBlockYOff * nBlockXSize;    if (poGDS->nDataLineNum > nLineInFile)    {        poGDS->nDataLineNum = 0;        VSIFSeekL(poGDS->fp, 0, SEEK_SET);        for(int i=0;i<poGDS->nCommentLineCount;i++)            CPLReadLine2L(poGDS->fp, 100, NULL);        if (poGDS->bHasHeaderLine)        {            const char* pszLine = CPLReadLine2L(poGDS->fp, 100, 0);            if (pszLine == NULL)            {                memset(pImage, 0, nBlockXSize * (GDALGetDataTypeSize(eDataType) / 8));                return CE_Failure;            }            poGDS->nLineNum ++;        }    }    while(poGDS->nDataLineNum < nLineInFile)    {        const char* pszLine = CPLReadLine2L(poGDS->fp, 100, 0);        if (pszLine == NULL)        {            memset(pImage, 0, nBlockXSize * (GDALGetDataTypeSize(eDataType) / 8));            return CE_Failure;        }        poGDS->nLineNum ++;        const char* pszPtr = pszLine;        char ch;        int nCol = 0;        int bLastWasSep = TRUE;        while((ch = *pszPtr) != '/0')        {            if (ch == ' ' || ch == ',' || ch == '/t' || ch == ';')            {                if (!bLastWasSep)                    nCol ++;                bLastWasSep = TRUE;            }            else            {                bLastWasSep = FALSE;            }            pszPtr ++;        }        /* Skip empty line */        if (nCol == 0 && bLastWasSep)            continue;        poGDS->nDataLineNum ++;    }    int i;    for(i=0;i<nBlockXSize;i++)    {        int nCol;        int bLastWasSep;        do        {            const char* pszLine = CPLReadLine2L(poGDS->fp, 100, 0);            if (pszLine == NULL)            {                memset(pImage, 0, nBlockXSize * (GDALGetDataTypeSize(eDataType) / 8));                return CE_Failure;            }            poGDS->nLineNum ++;            const char* pszPtr = pszLine;            char ch;            nCol = 0;            bLastWasSep = TRUE;            while((ch = *pszPtr) != '/0')            {                if (ch == ' ' || ch == ',' || ch == '/t' || ch == ';')                {                    if (!bLastWasSep)                        nCol ++;                    bLastWasSep = TRUE;                }                else                {                    if (bLastWasSep && nCol == poGDS->nZIndex)                    {                        double dfZ = CPLAtofM(pszPtr);                        if (eDataType == GDT_Float32)                        {//.........这里部分代码省略.........
开发者ID:afarnham,项目名称:gdal,代码行数:101,


示例13: while

void OGRUKOOAP190Layer::ParseHeaders(){    while(TRUE)    {        const char* pszLine = CPLReadLine2L(fp,81,NULL);        if (pszLine == NULL || EQUALN(pszLine, "EOF", 3))        {            break;        }        int nLineLen = strlen(pszLine);        while(nLineLen > 0 && pszLine[nLineLen-1] == ' ')        {            ((char*)pszLine)[nLineLen-1] = '/0';            nLineLen --;        }        if (pszLine[0] != 'H')            break;        if (nLineLen < 33)            continue;        if (!bUseEastingNorthingAsGeometry &&            strncmp(pszLine, "H1500", 5) == 0 && poSRS == NULL)        {            if (strncmp(pszLine + 33 - 1, "WGS84", 5) == 0 ||                strncmp(pszLine + 33 - 1, "WGS-84", 6) == 0)            {                poSRS = new OGRSpatialReference(SRS_WKT_WGS84);            }            else if (strncmp(pszLine + 33 - 1, "WGS72", 5) == 0)            {                poSRS = new OGRSpatialReference();                poSRS->SetFromUserInput("WGS72");            }        }        else if (!bUseEastingNorthingAsGeometry &&                 strncmp(pszLine, "H1501", 5) == 0 && poSRS != NULL &&                 nLineLen >= 32 + 6 * 6 + 10)        {            char aszParams[6][6+1];            char szZ[10+1];            int i;            for(i=0;i<6;i++)            {                ExtractField(aszParams[i], pszLine, 33 - 1 + i * 6, 6);            }            ExtractField(szZ, pszLine, 33 - 1 + 6 * 6, 10);            poSRS->SetTOWGS84(CPLAtof(aszParams[0]),                              CPLAtof(aszParams[1]),                              CPLAtof(aszParams[2]),                              CPLAtof(aszParams[3]),                              CPLAtof(aszParams[4]),                              CPLAtof(aszParams[5]),                              CPLAtof(szZ));        }        else if (strncmp(pszLine, "H0200", 5) == 0)        {            char** papszTokens = CSLTokenizeString(pszLine + 33 - 1);            for(int i = 0; papszTokens[i] != NULL; i++)            {                if (strlen(papszTokens[i]) == 4)                {                    int nVal = atoi(papszTokens[i]);                    if (nVal >= 1900)                    {                        if (nYear != 0 && nYear != nVal)                        {                            CPLDebug("SEGUKOOA",                                     "Several years found in H0200. Ignoring them!");                            nYear = 0;                            break;                        }                        nYear = nVal;                    }                }            }            CSLDestroy(papszTokens);        }    }    VSIFSeekL( fp, 0, SEEK_SET );}
开发者ID:drownedout,项目名称:datamap,代码行数:83,


示例14: while

OGRFeature *OGRARCGENLayer::GetNextRawFeature(){    if (bEOF)        return NULL;    const char* pszLine;    OGRwkbGeometryType eType = poFeatureDefn->GetGeomType();    if (wkbFlatten(eType) == wkbPoint)    {        while(TRUE)        {            pszLine = CPLReadLine2L(fp,256,NULL);            if (pszLine == NULL || EQUAL(pszLine, "END"))            {                bEOF = TRUE;                return NULL;            }            char** papszTokens = CSLTokenizeString2( pszLine, " ,", 0 );            int nTokens = CSLCount(papszTokens);            if (nTokens == 3 || nTokens == 4)            {                OGRFeature* poFeature = new OGRFeature(poFeatureDefn);                poFeature->SetFID(nNextFID ++);                poFeature->SetField(0, papszTokens[0]);                if (nTokens == 3)                    poFeature->SetGeometryDirectly(                        new OGRPoint(CPLAtof(papszTokens[1]),                                     CPLAtof(papszTokens[2])));                else                    poFeature->SetGeometryDirectly(                        new OGRPoint(CPLAtof(papszTokens[1]),                                     CPLAtof(papszTokens[2]),                                     CPLAtof(papszTokens[3])));                CSLDestroy(papszTokens);                return poFeature;            }            else                CSLDestroy(papszTokens);        }    }    CPLString osID;    OGRLinearRing* poLR =        (wkbFlatten(eType) == wkbPolygon) ? new OGRLinearRing() : NULL;    OGRLineString* poLS =        (wkbFlatten(eType) == wkbLineString) ? new OGRLineString() : poLR;    while(TRUE)    {        pszLine = CPLReadLine2L(fp,256,NULL);        if (pszLine == NULL)            break;        if (EQUAL(pszLine, "END"))        {            if (osID.size() == 0)                break;            OGRFeature* poFeature = new OGRFeature(poFeatureDefn);            poFeature->SetFID(nNextFID ++);            poFeature->SetField(0, osID.c_str());            if (wkbFlatten(eType) == wkbPolygon)            {                OGRPolygon* poPoly = new OGRPolygon();                poPoly->addRingDirectly(poLR);                poFeature->SetGeometryDirectly(poPoly);            }            else                poFeature->SetGeometryDirectly(poLS);            return poFeature;        }        char** papszTokens = CSLTokenizeString2( pszLine, " ,", 0 );        int nTokens = CSLCount(papszTokens);        if (osID.size() == 0)        {            if (nTokens >= 1)                osID = papszTokens[0];            else            {                CSLDestroy(papszTokens);                break;            }        }        else        {            if (nTokens == 2)            {                poLS->addPoint(CPLAtof(papszTokens[0]),                               CPLAtof(papszTokens[1]));            }            else if (nTokens == 3)            {                poLS->addPoint(CPLAtof(papszTokens[0]),                               CPLAtof(papszTokens[1]),                               CPLAtof(papszTokens[2]));            }            else            {                CSLDestroy(papszTokens);//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,


示例15: osFilename

GDALDataset *XYZDataset::Open( GDALOpenInfo * poOpenInfo ){    int         i;    int         bHasHeaderLine;    int         nCommentLineCount = 0;    if (!IdentifyEx(poOpenInfo, bHasHeaderLine, nCommentLineCount))        return NULL;    CPLString osFilename(poOpenInfo->pszFilename);    /*  GZipped .xyz files are common, so automagically open them */    /*  if the /vsigzip/ has not been explicitly passed */    if (strlen(poOpenInfo->pszFilename) > 6 &&        EQUAL(poOpenInfo->pszFilename + strlen(poOpenInfo->pszFilename) - 6, "xyz.gz") &&        !EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9))    {        osFilename = "/vsigzip/";        osFilename += poOpenInfo->pszFilename;    }/* -------------------------------------------------------------------- *//*      Find dataset characteristics                                    *//* -------------------------------------------------------------------- */    VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb");    if (fp == NULL)        return NULL;    /* For better performance of CPLReadLine2L() we create a buffered reader */    /* (except for /vsigzip/ since it has one internally) */    if (!EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9))        fp = (VSILFILE*) VSICreateBufferedReaderHandle((VSIVirtualHandle*)fp);        const char* pszLine;    int nXIndex = -1, nYIndex = -1, nZIndex = -1;    int nMinTokens = 0;    for(i=0;i<nCommentLineCount;i++)        CPLReadLine2L(fp, 100, NULL);/* -------------------------------------------------------------------- *//*      Parse header line                                               *//* -------------------------------------------------------------------- */    if (bHasHeaderLine)    {        pszLine = CPLReadLine2L(fp, 100, NULL);        if (pszLine == NULL)        {            VSIFCloseL(fp);            return NULL;        }        char** papszTokens = CSLTokenizeString2( pszLine, " ,/t;",                                                 CSLT_HONOURSTRINGS );        int nTokens = CSLCount(papszTokens);        if (nTokens < 3)        {            CPLError(CE_Failure, CPLE_AppDefined,                     "At line %d, found %d tokens. Expected 3 at least",                      1, nTokens);            CSLDestroy(papszTokens);            VSIFCloseL(fp);            return NULL;        }        int i;        for(i=0;i<nTokens;i++)        {            if (EQUAL(papszTokens[i], "x") ||                EQUALN(papszTokens[i], "lon", 3) ||                EQUALN(papszTokens[i], "east", 4))                nXIndex = i;            else if (EQUAL(papszTokens[i], "y") ||                     EQUALN(papszTokens[i], "lat", 3) ||                     EQUALN(papszTokens[i], "north", 5))                nYIndex = i;            else if (EQUAL(papszTokens[i], "z") ||                     EQUALN(papszTokens[i], "alt", 3) ||                     EQUAL(papszTokens[i], "height"))                nZIndex = i;        }        CSLDestroy(papszTokens);        papszTokens = NULL;        if (nXIndex < 0 || nYIndex < 0 || nZIndex < 0)        {            CPLError(CE_Warning, CPLE_AppDefined,                     "Could not find one of the X, Y or Z column names in header line. Defaulting to the first 3 columns");            nXIndex = 0;            nYIndex = 1;            nZIndex = 2;        }        nMinTokens = 1 + MAX(MAX(nXIndex, nYIndex), nZIndex);    }    else    {        nXIndex = 0;        nYIndex = 1;        nZIndex = 2;        nMinTokens = 3;    }    //.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,


示例16: GetNoDataValue

CPLErr XYZRasterBand::IReadBlock( CPL_UNUSED int nBlockXOff,                                  int nBlockYOff,                                  void * pImage ){    XYZDataset *poGDS = (XYZDataset *) poDS;    if (poGDS->fp == NULL)        return CE_Failure;    if( pImage )    {        int bSuccess = FALSE;        double dfNoDataValue = GetNoDataValue(&bSuccess);        if( !bSuccess )            dfNoDataValue = 0.0;        GDALCopyWords(&dfNoDataValue, GDT_Float64, 0,                      pImage, eDataType, GDALGetDataTypeSize(eDataType) / 8,                      nRasterXSize);    }    int nLineInFile = nBlockYOff * nBlockXSize; // only valid if bSameNumberOfValuesPerLine    if ( (poGDS->bSameNumberOfValuesPerLine && poGDS->nDataLineNum > nLineInFile) ||         (!poGDS->bSameNumberOfValuesPerLine && (nLastYOff == -1 || nBlockYOff == 0)) )    {        poGDS->nDataLineNum = 0;        poGDS->nLineNum = 0;        VSIFSeekL(poGDS->fp, 0, SEEK_SET);        for(int i=0;i<poGDS->nCommentLineCount;i++)        {            CPLReadLine2L(poGDS->fp, 100, NULL);            poGDS->nLineNum ++;        }        if (poGDS->bHasHeaderLine)        {            const char* pszLine = CPLReadLine2L(poGDS->fp, 100, 0);            if (pszLine == NULL)                return CE_Failure;            poGDS->nLineNum ++;        }    }    if( !poGDS->bSameNumberOfValuesPerLine && nBlockYOff != nLastYOff + 1 )    {        int iY;        if( nBlockYOff < nLastYOff )        {            nLastYOff = -1;            for(iY = 0; iY < nBlockYOff; iY++)            {                if( IReadBlock(0, iY, NULL) != CE_None )                    return CE_Failure;            }        }        else        {            for(iY = nLastYOff + 1; iY < nBlockYOff; iY++)            {                if( IReadBlock(0, iY, NULL) != CE_None )                    return CE_Failure;            }        }    }    else if( poGDS->bSameNumberOfValuesPerLine )    {        while(poGDS->nDataLineNum < nLineInFile)        {            const char* pszLine = CPLReadLine2L(poGDS->fp, 100, 0);            if (pszLine == NULL)                return CE_Failure;            poGDS->nLineNum ++;            const char* pszPtr = pszLine;            char ch;            int nCol = 0;            int bLastWasSep = TRUE;            while((ch = *pszPtr) != '/0')            {                if (ch == ' ')                {                    if (!bLastWasSep)                        nCol ++;                    bLastWasSep = TRUE;                }                else if ((ch == ',' && poGDS->chDecimalSep != ',') || ch == '/t' || ch == ';')                {                    nCol ++;                    bLastWasSep = TRUE;                }                else                {                    bLastWasSep = FALSE;                }                pszPtr ++;            }            /* Skip empty line */            if (nCol == 0 && bLastWasSep)                continue;//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,


示例17: CPLStrdup

int OGRPDSDataSource::Open( const char * pszFilename ){    pszName = CPLStrdup( pszFilename );// --------------------------------------------------------------------//      Does this appear to be a .PDS table file?// --------------------------------------------------------------------    VSILFILE* fp = VSIFOpenL(pszFilename, "rb");    if (fp == NULL)        return FALSE;    char szBuffer[512];    int nbRead = (int)VSIFReadL(szBuffer, 1, sizeof(szBuffer) - 1, fp);    szBuffer[nbRead] = '/0';    const char* pszPos = strstr(szBuffer, "PDS_VERSION_ID");    int bIsPDS = (pszPos != NULL);    if (!bIsPDS)    {        VSIFCloseL(fp);        return FALSE;    }    if (!oKeywords.Ingest(fp, pszPos - szBuffer))    {        VSIFCloseL(fp);        return FALSE;    }    VSIFCloseL(fp);    CPLString osRecordType = oKeywords.GetKeyword( "RECORD_TYPE", "" );    CPLString osFileRecords = oKeywords.GetKeyword( "FILE_RECORDS", "" );    CPLString osRecordBytes = oKeywords.GetKeyword( "RECORD_BYTES", "" );    int nRecordSize = atoi(osRecordBytes);    if (osRecordType.size() == 0 || osFileRecords.size() == 0 ||        osRecordBytes.size() == 0 || nRecordSize <= 0)    {        CPLError(CE_Failure, CPLE_NotSupported,                 "One of RECORD_TYPE, FILE_RECORDS or RECORD_BYTES is missing");        return FALSE;    }    CleanString(osRecordType);    if (osRecordType.compare("FIXED_LENGTH") != 0)    {        CPLError(CE_Failure, CPLE_NotSupported,                 "Only RECORD_TYPE=FIXED_LENGTH is supported");        return FALSE;    }    CPLString osTable = oKeywords.GetKeyword( "^TABLE", "" );    if (osTable.size() != 0)        LoadTable(pszFilename, nRecordSize, "TABLE");    else    {        VSILFILE* fp = VSIFOpenL(pszFilename, "rb");        if (fp == NULL)            return FALSE;        while(TRUE)        {            CPLPushErrorHandler(CPLQuietErrorHandler);            const char* pszLine = CPLReadLine2L(fp, 256, NULL);            CPLPopErrorHandler();            CPLErrorReset();            if (pszLine == NULL)                break;            char** papszTokens =                CSLTokenizeString2( pszLine, " =", CSLT_HONOURSTRINGS );            int nTokens = CSLCount(papszTokens);            if (nTokens == 2 &&                papszTokens[0][0] == '^' &&                strstr(papszTokens[0], "TABLE") != NULL)            {                LoadTable(pszFilename, nRecordSize, papszTokens[0] + 1);            }            CSLDestroy(papszTokens);            papszTokens = NULL;        }        VSIFCloseL(fp);    }    return nLayers != 0;}
开发者ID:samalone,项目名称:gdal-ios,代码行数:86,


示例18: VSIFOpenL

GDALDataset *SNODASDataset::Open( GDALOpenInfo * poOpenInfo ){    if( !Identify(poOpenInfo) )        return NULL;    VSILFILE    *fp;    fp = VSIFOpenL( poOpenInfo->pszFilename, "r" );    if( fp == NULL )    {        return NULL;    }    const char *    pszLine;    int             nRows = -1, nCols = -1;    CPLString       osDataFilename;    int             bIsInteger = FALSE, bIs2Bytes = FALSE;    double          dfNoData = 0;    int             bHasNoData = FALSE;    double          dfMin = 0;    int             bHasMin = FALSE;    double          dfMax = 0;    int             bHasMax = FALSE;    double          dfMinX = 0.0, dfMinY = 0.0, dfMaxX = 0.0, dfMaxY = 0.0;    int             bHasMinX = FALSE, bHasMinY = FALSE, bHasMaxX = FALSE, bHasMaxY = FALSE;    int             bNotProjected = FALSE, bIsWGS84 = FALSE;    CPLString       osDescription, osDataUnits;    int             nStartYear = -1, nStartMonth = -1, nStartDay = -1,                    nStartHour = -1, nStartMinute = -1, nStartSecond = -1;    int             nStopYear = -1, nStopMonth = -1, nStopDay = -1,                    nStopHour = -1, nStopMinute = -1, nStopSecond = -1;    while( (pszLine = CPLReadLine2L( fp, 256, NULL )) != NULL )    {        char** papszTokens = CSLTokenizeStringComplex( pszLine, ":", TRUE, FALSE );        if( CSLCount( papszTokens ) != 2 )        {            CSLDestroy( papszTokens );            continue;        }        if( papszTokens[1][0] == ' ' )            memmove(papszTokens[1], papszTokens[1] + 1, strlen(papszTokens[1] + 1) + 1);        if( EQUAL(papszTokens[0],"Data file pathname") )        {            osDataFilename = papszTokens[1];        }        else if( EQUAL(papszTokens[0],"Description") )        {            osDescription = papszTokens[1];        }        else if( EQUAL(papszTokens[0],"Data units") )        {            osDataUnits= papszTokens[1];        }        else if( EQUAL(papszTokens[0],"Start year") )            nStartYear = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Start month") )            nStartMonth = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Start day") )            nStartDay = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Start hour") )            nStartHour = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Start minute") )            nStartMinute = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Start second") )            nStartSecond = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Stop year") )            nStopYear = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Stop month") )            nStopMonth = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Stop day") )            nStopDay = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Stop hour") )            nStopHour = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Stop minute") )            nStopMinute = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Stop second") )            nStopSecond = atoi(papszTokens[1]);        else if( EQUAL(papszTokens[0],"Number of columns") )        {            nCols = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"Number of rows") )        {            nRows = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"Data type"))        {            bIsInteger = EQUAL(papszTokens[1],"integer");        }        else if( EQUAL(papszTokens[0],"Data bytes per pixel"))        {            bIs2Bytes = EQUAL(papszTokens[1],"2");        }//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,


示例19: CPLStrdup

int OGRSEGUKOOADataSource::Open( const char * pszFilename ){    pszName = CPLStrdup( pszFilename );    VSILFILE* fp = VSIFOpenL(pszFilename, "rb");    if (fp == nullptr)        return FALSE;    CPLPushErrorHandler(CPLQuietErrorHandler);    const char* pszLine = CPLReadLine2L(fp,81,nullptr);    CPLPopErrorHandler();    CPLErrorReset();    /* Both UKOOA P1/90 and SEG-P1 begins by a H character */    if (pszLine == nullptr || pszLine[0] != 'H')    {        VSIFCloseL(fp);        return FALSE;    }// --------------------------------------------------------------------//      Does this appear to be a UKOOA P1/90 file?// --------------------------------------------------------------------    if (STARTS_WITH(pszLine, "H0100 "))    {        VSIFSeekL( fp, 0, SEEK_SET );        VSILFILE* fp2 = VSIFOpenL(pszFilename, "rb");        if (fp2 == nullptr)        {            VSIFCloseL(fp);            return FALSE;        }        nLayers = 2;        papoLayers = (OGRLayer**) CPLMalloc(2 * sizeof(OGRLayer*));        papoLayers[0] = new OGRUKOOAP190Layer(pszName, fp);        papoLayers[1] = new OGRSEGUKOOALineLayer(pszName,                                         new OGRUKOOAP190Layer(pszName, fp2));        return TRUE;    }// --------------------------------------------------------------------//      Does this appear to be a SEG-P1 file?// --------------------------------------------------------------------    /* Check first 20 header lines, and fetch the first point */    for(int iLine = 0; iLine < 21; iLine ++)    {        const char* szPtr = pszLine;        for(;*szPtr != '/0';szPtr++)        {            if (*szPtr != 9 && *szPtr < 32)            {                VSIFCloseL(fp);                return FALSE;            }        }        if (iLine == 20)            break;        CPLPushErrorHandler(CPLQuietErrorHandler);        pszLine = CPLReadLine2L(fp,81,nullptr);        CPLPopErrorHandler();        CPLErrorReset();        if (pszLine == nullptr)        {            VSIFCloseL(fp);            return FALSE;        }    }    char* pszExpandedLine = OGRSEGP1Layer::ExpandTabs(pszLine);    int nLatitudeCol = OGRSEGP1Layer::DetectLatitudeColumn(pszExpandedLine);    CPLFree(pszExpandedLine);    if (nLatitudeCol > 0)    {        VSIFSeekL( fp, 0, SEEK_SET );        VSILFILE* fp2 = VSIFOpenL(pszFilename, "rb");        if (fp2 == nullptr)        {            VSIFCloseL(fp);            return FALSE;        }        nLayers = 2;        papoLayers = (OGRLayer**) CPLMalloc(2 * sizeof(OGRLayer*));        papoLayers[0] = new OGRSEGP1Layer(pszName, fp, nLatitudeCol);        papoLayers[1] = new OGRSEGUKOOALineLayer(pszName,                                         new OGRSEGP1Layer(pszName, fp2,                                                           nLatitudeCol));        return TRUE;    }//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,


示例20: osFilename

GDALDataset *XYZDataset::Open( GDALOpenInfo * poOpenInfo ){    int         i;    int         bHasHeaderLine;    int         nCommentLineCount = 0;    if (!IdentifyEx(poOpenInfo, bHasHeaderLine, nCommentLineCount))        return NULL;    CPLString osFilename(poOpenInfo->pszFilename);    /*  GZipped .xyz files are common, so automagically open them */    /*  if the /vsigzip/ has not been explicitely passed */    if (strlen(poOpenInfo->pszFilename) > 6 &&        EQUAL(poOpenInfo->pszFilename + strlen(poOpenInfo->pszFilename) - 6, "xyz.gz") &&        !EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9))    {        osFilename = "/vsigzip/";        osFilename += poOpenInfo->pszFilename;    }/* -------------------------------------------------------------------- *//*      Find dataset characteristics                                    *//* -------------------------------------------------------------------- */    VSILFILE* fp = VSIFOpenL(osFilename.c_str(), "rb");    if (fp == NULL)        return NULL;    /* For better performance of CPLReadLine2L() we create a buffered reader */    /* (except for /vsigzip/ since it has one internally) */    if (!EQUALN(poOpenInfo->pszFilename, "/vsigzip/", 9))        fp = (VSILFILE*) VSICreateBufferedReaderHandle((VSIVirtualHandle*)fp);        const char* pszLine;    int nXIndex = -1, nYIndex = -1, nZIndex = -1;    int nMinTokens = 0;    for(i=0;i<nCommentLineCount;i++)        CPLReadLine2L(fp, 100, NULL);/* -------------------------------------------------------------------- *//*      Parse header line                                               *//* -------------------------------------------------------------------- */    if (bHasHeaderLine)    {        pszLine = CPLReadLine2L(fp, 100, NULL);        if (pszLine == NULL)        {            VSIFCloseL(fp);            return NULL;        }        char** papszTokens = CSLTokenizeString2( pszLine, " ,/t;",                                                 CSLT_HONOURSTRINGS );        int nTokens = CSLCount(papszTokens);        if (nTokens < 3)        {            CPLError(CE_Failure, CPLE_AppDefined,                     "At line %d, found %d tokens. Expected 3 at least",                      1, nTokens);            CSLDestroy(papszTokens);            VSIFCloseL(fp);            return NULL;        }        int i;        for(i=0;i<nTokens;i++)        {            if (EQUAL(papszTokens[i], "x") ||                EQUALN(papszTokens[i], "lon", 3) ||                EQUALN(papszTokens[i], "east", 4))                nXIndex = i;            else if (EQUAL(papszTokens[i], "y") ||                     EQUALN(papszTokens[i], "lat", 3) ||                     EQUALN(papszTokens[i], "north", 5))                nYIndex = i;            else if (EQUAL(papszTokens[i], "z") ||                     EQUALN(papszTokens[i], "alt", 3) ||                     EQUAL(papszTokens[i], "height"))                nZIndex = i;        }        CSLDestroy(papszTokens);        papszTokens = NULL;        if (nXIndex < 0 || nYIndex < 0 || nZIndex < 0)        {            CPLError(CE_Warning, CPLE_AppDefined,                     "Could not find one of the X, Y or Z column names in header line. Defaulting to the first 3 columns");            nXIndex = 0;            nYIndex = 1;            nZIndex = 2;        }        nMinTokens = 1 + MAX(MAX(nXIndex, nYIndex), nZIndex);    }    else    {        nXIndex = 0;        nYIndex = 1;        nZIndex = 2;        nMinTokens = 3;    }//.........这里部分代码省略.........
开发者ID:afarnham,项目名称:gdal,代码行数:101,


示例21: while

OGRFeature *OGRSUALayer::GetNextRawFeature(){    if( bEOF )        return nullptr;    CPLString osTYPE;    CPLString osCLASS;    CPLString osTITLE;    CPLString osTOPS;    CPLString osBASE;    OGRLinearRing oLR;    double dfLastLat = 0.0;    double dfLastLon = 0.0;    bool bFirst = true;    while( true )    {        const char* pszLine = nullptr;        if( bFirst && bHasLastLine )        {            pszLine = osLastLine.c_str();            bFirst = false;        }        else        {            pszLine = CPLReadLine2L(fpSUA, 1024, nullptr);            if (pszLine == nullptr)            {                bEOF = true;                if (oLR.getNumPoints() == 0)                    return nullptr;                break;            }            osLastLine = pszLine;            bHasLastLine = true;        }        if (pszLine[0] == '#' || pszLine[0] == '/0')            continue;        if (STARTS_WITH_CI(pszLine, "TYPE="))        {            if (!osTYPE.empty())                break;            osTYPE = pszLine + 5;        }        else if (STARTS_WITH_CI(pszLine, "CLASS="))        {            if (!osCLASS.empty())                break;            osCLASS = pszLine + 6;        }        else if (STARTS_WITH_CI(pszLine, "TITLE="))        {            if (!osTITLE.empty())                break;            osTITLE = pszLine + 6;        }        else if (STARTS_WITH_CI(pszLine, "TOPS="))            osTOPS = pszLine + 5;        else if (STARTS_WITH_CI(pszLine, "BASE="))            osBASE = pszLine + 5;        else if (STARTS_WITH_CI(pszLine, "POINT="))        {            pszLine += 6;            if (strlen(pszLine) != 16)                continue;            double dfLat = 0.0;            double dfLon = 0.0;            if (!GetLatLon(pszLine, dfLat, dfLon))                continue;            oLR.addPoint(dfLon, dfLat);            dfLastLat = dfLat;            dfLastLon = dfLon;        }        else if (STARTS_WITH_CI(pszLine, "CLOCKWISE") || STARTS_WITH_CI(pszLine, "ANTI-CLOCKWISE"))        {            if (oLR.getNumPoints() == 0)                continue;            int bClockWise = STARTS_WITH_CI(pszLine, "CLOCKWISE");            /*const char* pszRADIUS = strstr(pszLine, "RADIUS=");            if (pszRADIUS == NULL)                continue;            double dfRADIUS = CPLAtof(pszRADIUS + 7) * 1852;*/            const char* pszCENTRE = strstr(pszLine, "CENTRE=");            if (pszCENTRE == nullptr)                continue;            pszCENTRE += 7;            if (strlen(pszCENTRE) < 17 || pszCENTRE[16] != ' ')                continue;            double dfCenterLat = 0.0;            double dfCenterLon = 0.0;            if (!GetLatLon(pszCENTRE, dfCenterLat, dfCenterLon))                continue;//.........这里部分代码省略.........
开发者ID:koordinates,项目名称:gdal,代码行数:101,


示例22: OGRFeature

OGRFeature *OGRHTFPolygonLayer::GetNextRawFeature(){    OGRFeature* poFeature = new OGRFeature(poFeatureDefn);    const char* pszLine;    OGRLinearRing oLR;    int bHastFirstCoord = FALSE;    double dfFirstEasting = 0, dfFirstNorthing = 0;    double dfIslandEasting = 0, dfIslandNorthing = 0;    int bInIsland = FALSE;    OGRPolygon* poPoly = new OGRPolygon();    while( (pszLine = CPLReadLine2L(fpHTF, 1024, NULL)) != NULL)    {        if (pszLine[0] == ';')        {            /* comment */ ;        }        else if (pszLine[0] == 0)        {            /* end of polygon is marked by a blank line */            break;        }        else if (strncmp(pszLine, "POLYGON DESCRIPTION: ",                         strlen("POLYGON DESCRIPTION: ")) == 0)        {            poFeature->SetField(0, pszLine + strlen("POLYGON DESCRIPTION: "));        }        else if (strncmp(pszLine, "POLYGON IDENTIFIER: ",                         strlen("POLYGON IDENTIFIER: ")) == 0)        {            poFeature->SetField(1, pszLine + strlen("POLYGON IDENTIFIER: "));        }        else if (strncmp(pszLine, "SEAFLOOR COVERAGE: ",                         strlen("SEAFLOOR COVERAGE:")) == 0)        {            const char* pszVal = pszLine + strlen("SEAFLOOR COVERAGE: ");            if (*pszVal != '*')                poFeature->SetField(2, pszVal);        }        else if (strncmp(pszLine, "POSITION ACCURACY: ",                         strlen("POSITION ACCURACY:")) == 0)        {            const char* pszVal = pszLine + strlen("POSITION ACCURACY: ");            if (*pszVal != '*')                poFeature->SetField(3, pszVal);        }        else if (strncmp(pszLine, "DEPTH ACCURACY: ",                         strlen("DEPTH ACCURACY:")) == 0)        {            const char* pszVal = pszLine + strlen("DEPTH ACCURACY: ");            if (*pszVal != '*')                poFeature->SetField(4, pszVal);        }        else if (strcmp(pszLine, "END OF POLYGON DATA") == 0)        {            bEOF = TRUE;            break;        }        else        {            char** papszTokens = CSLTokenizeString(pszLine);            if (CSLCount(papszTokens) == 4)            {                double dfEasting = atof(papszTokens[2]);                double dfNorthing = atof(papszTokens[3]);                if (!bHastFirstCoord)                {                    bHastFirstCoord = TRUE;                    dfFirstEasting = dfEasting;                    dfFirstNorthing = dfNorthing;                    oLR.addPoint(dfEasting, dfNorthing);                }                else if (dfFirstEasting == dfEasting &&                         dfFirstNorthing == dfNorthing)                {                    if (!bInIsland)                    {                        oLR.addPoint(dfEasting, dfNorthing);                        poPoly->addRing(&oLR);                        oLR.empty();                        bInIsland = TRUE;                    }                }                else if (bInIsland && oLR.getNumPoints() == 0)                {                    dfIslandEasting = dfEasting;                    dfIslandNorthing = dfNorthing;                    oLR.addPoint(dfEasting, dfNorthing);                }                else if (bInIsland && dfIslandEasting == dfEasting &&                         dfIslandNorthing == dfNorthing)                {                    oLR.addPoint(dfEasting, dfNorthing);                    poPoly->addRing(&oLR);                    oLR.empty();                }                else                {//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例23: VSIFOpenL

GDALDataset *ZMapDataset::Open( GDALOpenInfo * poOpenInfo ){    if (!Identify(poOpenInfo))        return NULL;/* -------------------------------------------------------------------- *//*      Find dataset characteristics                                    *//* -------------------------------------------------------------------- */    VSILFILE* fp = VSIFOpenL(poOpenInfo->pszFilename, "rb");    if (fp == NULL)        return NULL;    const char* pszLine;    while((pszLine = CPLReadLine2L(fp, 100, NULL)) != NULL)    {        if (*pszLine == '!')        {            continue;        }        else            break;    }    if (pszLine == NULL)    {        VSIFCloseL(fp);        return NULL;    }    /* Parse first header line */    char** papszTokens = CSLTokenizeString2( pszLine, ",", 0 );    if (CSLCount(papszTokens) != 3)    {        CSLDestroy(papszTokens);        VSIFCloseL(fp);        return NULL;    }    int nValuesPerLine = atoi(papszTokens[2]);    if (nValuesPerLine <= 0)    {        CSLDestroy(papszTokens);        VSIFCloseL(fp);        return NULL;    }    CSLDestroy(papszTokens);    papszTokens = NULL;    /* Parse second header line */    pszLine = CPLReadLine2L(fp, 100, NULL);    if (pszLine == NULL)    {        VSIFCloseL(fp);        return NULL;    }    papszTokens = CSLTokenizeString2( pszLine, ",", 0 );    if (CSLCount(papszTokens) != 5)    {        CSLDestroy(papszTokens);        VSIFCloseL(fp);        return NULL;    }    int nFieldSize = atoi(papszTokens[0]);    double dfNoDataValue = CPLAtofM(papszTokens[1]);    int nDecimalCount = atoi(papszTokens[3]);    int nColumnNumber = atoi(papszTokens[4]);    CSLDestroy(papszTokens);    papszTokens = NULL;    if (nFieldSize <= 0 || nFieldSize >= 40 ||        nDecimalCount <= 0 || nDecimalCount >= nFieldSize ||        nColumnNumber != 1)    {        CPLDebug("ZMap", "nFieldSize=%d, nDecimalCount=%d, nColumnNumber=%d",                 nFieldSize, nDecimalCount, nColumnNumber);        VSIFCloseL(fp);        return NULL;    }    /* Parse third header line */    pszLine = CPLReadLine2L(fp, 100, NULL);    if (pszLine == NULL)    {        VSIFCloseL(fp);        return NULL;    }    papszTokens = CSLTokenizeString2( pszLine, ",", 0 );    if (CSLCount(papszTokens) != 6)    {        CSLDestroy(papszTokens);        VSIFCloseL(fp);        return NULL;    }    int nRows = atoi(papszTokens[0]);    int nCols = atoi(papszTokens[1]);//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,


示例24: while

OGRFeature *OGROpenAirLayer::GetNextRawFeature(){    const char* pszLine;    CPLString osCLASS, osNAME, osFLOOR, osCEILING;    OGRLinearRing oLR;    /* double dfLastLat = 0, dfLastLon = 0; */    int bFirst = TRUE;    int bClockWise = TRUE;    double dfCenterLat = 0, dfCenterLon = 0;    int bHasCenter = FALSE;    OpenAirStyle sStyle;    sStyle.penStyle = -1;    sStyle.penWidth = -1;    sStyle.penR = sStyle.penG = sStyle.penB = -1;    sStyle.fillR = sStyle.fillG = sStyle.fillB = -1;    if (bEOF)        return NULL;    while(TRUE)    {        if (bFirst && bHasLastLine)        {            pszLine = osLastLine.c_str();            bFirst = FALSE;        }        else        {            pszLine = CPLReadLine2L(fpOpenAir, 1024, NULL);            if (pszLine == NULL)            {                bEOF = TRUE;                if (oLR.getNumPoints() == 0)                    return NULL;                if (osCLASS.size() != 0 &&                    oStyleMap.find(osCLASS) != oStyleMap.end())                {                    memcpy(&sStyle, oStyleMap[osCLASS], sizeof(sStyle));                }                break;            }            osLastLine = pszLine;            bHasLastLine = TRUE;        }        if (pszLine[0] == '*' || pszLine[0] == '/0')            continue;        if (EQUALN(pszLine, "AC ", 3) || EQUALN(pszLine, "AC,", 3))        {            if (osCLASS.size() != 0)            {                if (sStyle.penStyle != -1 || sStyle.fillR != -1)                {                    if (oLR.getNumPoints() == 0)                    {                        OpenAirStyle* psStyle;                        if (oStyleMap.find(osCLASS) == oStyleMap.end())                        {                            psStyle = (OpenAirStyle*)CPLMalloc(                                                    sizeof(OpenAirStyle));                            oStyleMap[osCLASS] = psStyle;                        }                        else                            psStyle = oStyleMap[osCLASS];                        memcpy(psStyle, &sStyle, sizeof(sStyle));                    }                    else                        break;                }                else if (oStyleMap.find(osCLASS) != oStyleMap.end())                {                    memcpy(&sStyle, oStyleMap[osCLASS], sizeof(sStyle));                    break;                }                else                    break;            }            sStyle.penStyle = -1;            sStyle.penWidth = -1;            sStyle.penR = sStyle.penG = sStyle.penB = -1;            sStyle.fillR = sStyle.fillG = sStyle.fillB = -1;            osCLASS = pszLine + 3;            bClockWise = TRUE;            bHasCenter = FALSE;        }        else if (EQUALN(pszLine, "AN ", 3))        {            if (osNAME.size() != 0)                break;            osNAME = pszLine + 3;        }        else if (EQUALN(pszLine, "AH ", 3))            osCEILING = pszLine + 3;        else if (EQUALN(pszLine, "AL ", 3))            osFLOOR = pszLine + 3;        else if (EQUALN(pszLine, "AT ", 3))        {            /* Ignored for that layer*///.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,


示例25: SearchCSVForWKT

int SearchCSVForWKT( const char *pszFileCSV, const char *pszTarget ){    const char *pszFilename = NULL;    const char *pszWKT = NULL;    char szTemp[1024];    int nPos = 0;    const char *pszTemp = NULL;    VSILFILE *fp = NULL;    OGRSpatialReference oSRS;    int nCode = 0;    int nFound = -1;    CPLDebug( "gdalsrsinfo",               "SearchCSVForWKT()/nfile=%s/nWKT=%s/n",              pszFileCSV, pszTarget);/* -------------------------------------------------------------------- *//*      Find and open file.                                             *//* -------------------------------------------------------------------- */    // pszFilename = pszFileCSV;    pszFilename = CPLFindFile( "gdal", pszFileCSV );    if( pszFilename == NULL )    {        CPLDebug( "gdalsrsinfo", "could not find support file %s",                   pszFileCSV );        // return OGRERR_UNSUPPORTED_SRS;        return -1;    }    /* support gzipped file */    if ( strstr( pszFileCSV,".gz") != NULL )        sprintf( szTemp, "/vsigzip/%s", pszFilename);    else        sprintf( szTemp, "%s", pszFilename);    CPLDebug( "gdalsrsinfo", "SearchCSVForWKT() using file %s",              szTemp );    fp = VSIFOpenL( szTemp, "r" );    if( fp == NULL )     {        CPLDebug( "gdalsrsinfo", "could not open support file %s",                  pszFilename );        // return OGRERR_UNSUPPORTED_SRS;        return -1;    }/* -------------------------------------------------------------------- *//*      Process lines.                                                  *//* -------------------------------------------------------------------- */    const char *pszLine;    while( (pszLine = CPLReadLine2L(fp,-1,NULL)) != NULL )    {        // CPLDebug( "gdalsrsinfo", "read line %s", pszLine );        if( pszLine[0] == '#' )            continue;            /* do nothing */;        // else if( EQUALN(pszLine,"include ",8) )        // {        //     eErr = importFromDict( pszLine + 8, pszCode );        //     if( eErr != OGRERR_UNSUPPORTED_SRS )        //         break;        // }        // else if( strstr(pszLine,",") == NULL )        //     /* do nothing */;        pszTemp = strstr(pszLine,",");        if (pszTemp)        {            nPos = pszTemp - pszLine;            if ( nPos == 0 )                continue;                        strncpy( szTemp, pszLine, nPos );            szTemp[nPos] = '/0';            nCode = atoi(szTemp);            pszWKT = (char *) pszLine + nPos +1;            // CPLDebug( "gdalsrsinfo",             //           "code=%d/nWKT=/n[%s]/ntarget=/n[%s]/n",            //           nCode,pszWKT, pszTarget );            if ( EQUAL(pszTarget,pszWKT) )            {                nFound = nCode;                CPLDebug( "gdalsrsinfo", "found EPSG:%d/n"                          "current=%s/ntarget= %s/n",                          nCode, pszWKT, pszTarget );                break;            }        }//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,



注:本文中的CPLReadLine2L函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ CPLRealloc函数代码示例
C++ CPLPushErrorHandler函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。