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

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

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

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

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

示例1: return

char *GXFGetMapProjectionAsPROJ4( GXFHandle hGXF ){    GXFInfo_t	*psGXF = (GXFInfo_t *) hGXF;    char	**papszMethods = NULL;    char	szPROJ4[512];/* -------------------------------------------------------------------- *//*      If there was nothing in the file return "unknown".              *//* -------------------------------------------------------------------- */    if( CSLCount(psGXF->papszMapProjection) < 2 )        return( CPLStrdup( "unknown" ) );    szPROJ4[0] = '/0';/* -------------------------------------------------------------------- *//*      Parse the third line, looking for known projection methods.     *//* -------------------------------------------------------------------- */    if( psGXF->papszMapProjection[2] != NULL )    {        if( strlen(psGXF->papszMapProjection[2]) > 80 )            return( CPLStrdup( "" ) );        papszMethods = CSLTokenizeStringComplex(psGXF->papszMapProjection[2],                                                ",", TRUE, TRUE );    }#ifdef DBMALLOC    malloc_chain_check(1);#endif    if( papszMethods == NULL        || papszMethods[0] == NULL        || EQUAL(papszMethods[0],"Geographic") )    {        SAFE_strcat( szPROJ4, "+proj=longlat" );    }#ifdef notdef    else if( EQUAL(papszMethods[0],"Lambert Conic Conformal (1SP)")             && CSLCount(papszMethods) > 5 )    {        /* notdef: It isn't clear that this 1SP + scale method is even           supported by PROJ.4           Later note: It is not. */        SAFE_strcat( szPROJ4, "+proj=lcc" );        SAFE_strcat( szPROJ4, " +lat_0=" );        SAFE_strcat( szPROJ4, papszMethods[1] );        SAFE_strcat( szPROJ4, " +lon_0=" );        SAFE_strcat( szPROJ4, papszMethods[2] );        SAFE_strcat( szPROJ4, " +k=" );        SAFE_strcat( szPROJ4, papszMethods[3] );        SAFE_strcat( szPROJ4, " +x_0=" );        SAFE_strcat( szPROJ4, papszMethods[4] );        SAFE_strcat( szPROJ4, " +y_0=" );        SAFE_strcat( szPROJ4, papszMethods[5] );    }#endif    else if( EQUAL(papszMethods[0],"Lambert Conic Conformal (2SP)")             || EQUAL(papszMethods[0],"Lambert Conformal (2SP Belgium)") )    {        /* notdef: Note we are apparently losing whatever makes the           Belgium variant different than normal LCC, but hopefully           they are close! */        SAFE_strcat( szPROJ4, "+proj=lcc" );        if( CSLCount(papszMethods) > 1 )        {            SAFE_strcat( szPROJ4, " +lat_1=" );            SAFE_strcat( szPROJ4, papszMethods[1] );        }        if( CSLCount(papszMethods) > 2 )        {            SAFE_strcat( szPROJ4, " +lat_2=" );            SAFE_strcat( szPROJ4, papszMethods[2] );        }        if( CSLCount(papszMethods) > 3 )        {            SAFE_strcat( szPROJ4, " +lat_0=" );            SAFE_strcat( szPROJ4, papszMethods[3] );        }        if( CSLCount(papszMethods) > 4 )        {            SAFE_strcat( szPROJ4, " +lon_0=" );            SAFE_strcat( szPROJ4, papszMethods[4] );        }        if( CSLCount(papszMethods) > 5 )        {            SAFE_strcat( szPROJ4, " +x_0=" );            SAFE_strcat( szPROJ4, papszMethods[5] );//.........这里部分代码省略.........
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,


示例2: Clear

OGRErr OGRSpatialReference::importFromOzi( const char *pszDatum,                                           const char *pszProj,                                           const char *pszProjParms ){    Clear();/* -------------------------------------------------------------------- *//*      Operate on the basis of the projection name.                    *//* -------------------------------------------------------------------- */    char    **papszProj = CSLTokenizeStringComplex( pszProj, ",", TRUE, TRUE );    char    **papszProjParms = CSLTokenizeStringComplex( pszProjParms, ",",                                                          TRUE, TRUE );    char    **papszDatum = NULL;                                                             if (CSLCount(papszProj) < 2)    {        goto not_enough_data;    }    if ( EQUALN(papszProj[1], "Latitude/Longitude", 18) )    {    }    else if ( EQUALN(papszProj[1], "Mercator", 8) )    {        if (CSLCount(papszProjParms) < 6) goto not_enough_data;        double dfScale = CPLAtof(papszProjParms[3]);        if (papszProjParms[3][0] == 0) dfScale = 1; /* if unset, default to scale = 1 */        SetMercator( CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),                     dfScale,                     CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]) );    }    else if ( EQUALN(papszProj[1], "Transverse Mercator", 19) )    {        if (CSLCount(papszProjParms) < 6) goto not_enough_data;        SetTM( CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),               CPLAtof(papszProjParms[3]),               CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]) );    }    else if ( EQUALN(papszProj[1], "Lambert Conformal Conic", 23) )    {        if (CSLCount(papszProjParms) < 8) goto not_enough_data;        SetLCC( CPLAtof(papszProjParms[6]), CPLAtof(papszProjParms[7]),                CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),                CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]) );    }    else if ( EQUALN(papszProj[1], "Sinusoidal", 10) )    {        if (CSLCount(papszProjParms) < 6) goto not_enough_data;        SetSinusoidal( CPLAtof(papszProjParms[2]),                       CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]) );    }    else if ( EQUALN(papszProj[1], "Albers Equal Area", 17) )    {        if (CSLCount(papszProjParms) < 8) goto not_enough_data;        SetACEA( CPLAtof(papszProjParms[6]), CPLAtof(papszProjParms[7]),                 CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),                 CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]) );    }    else    {        CPLDebug( "OSR_Ozi", "Unsupported projection: /"%s/"", papszProj[1] );        SetLocalCS( CPLString().Printf("/"Ozi/" projection /"%s/"",                                       papszProj[1]) );    }/* -------------------------------------------------------------------- *//*      Try to translate the datum/spheroid.                            *//* -------------------------------------------------------------------- */    papszDatum = CSLTokenizeString2( pszDatum, ",",                                               CSLT_ALLOWEMPTYTOKENS                                               | CSLT_STRIPLEADSPACES                                               | CSLT_STRIPENDSPACES );    if ( papszDatum == NULL)        goto not_enough_data;            if ( !IsLocal() )    {/* -------------------------------------------------------------------- *//*      Verify that we can find the CSV file containing the datums      *//* -------------------------------------------------------------------- */        if( CSVScanFileByName( CSVFilename( "ozi_datum.csv" ),                            "EPSG_DATUM_CODE",                            "4326", CC_Integer ) == NULL )        {            CPLError( CE_Failure, CPLE_OpenFailed,                    "Unable to open OZI support file %s./n"                    "Try setting the GDAL_DATA environment variable to point/n"                    "to the directory containing OZI csv files.",                    CSVFilename( "ozi_datum.csv" ) );            goto other_error;        }//.........这里部分代码省略.........
开发者ID:sylvainallard,项目名称:gdal,代码行数:101,


示例3: VSIFOpenL

GDALDataset *EIRDataset::Open( GDALOpenInfo * poOpenInfo ){    int     i;    VSILFILE    *fp;    const char *    pszLine;            if( !Identify( poOpenInfo ) )        return NULL;                      fp = VSIFOpenL( poOpenInfo->pszFilename, "r" );    if( fp == NULL )        return NULL;        /* header example and description        IMAGINE_RAW_FILE // must be on first line, by itself    WIDTH 581        // number of columns in the image    HEIGHT 695       // number of rows in the image    NUM_LAYERS 3     // number of spectral bands in the image; default 1    PIXEL_FILES raw8_3n_ui_sanjack.bl // raster file                                      // default: same name with no extension    FORMAT BIL       // BIL BIP BSQ; default BIL    DATATYPE U8      // U1 U2 U4 U8 U16 U32 S16 S32 F32 F64; default U8    BYTE_ORDER       // LSB MSB; required for U16 U32 S16 S32 F32 F64    DATA_OFFSET      // start of image data in raster file; default 0 bytes    END_RAW_FILE     // end RAW file - stop reading        For a true color image with three bands (R, G, B) stored using 8 bits    for each pixel in each band, DATA_TYPE equals U8 and NUM_LAYERS equals    3 for a total of 24 bits per pixel.        Note that the current version of ERDAS Raw Raster Reader/Writer does    not support the LAYER_SKIP_BYTES, RECORD_SKIP_BYTES, TILE_WIDTH and     TILE_HEIGHT directives. Since the reader does not read the PIXEL_FILES     directive, the reader always assumes that the raw binary file is the     dataset, and the name of this file is the name of the header without the     extension. Currently, the reader does not support multiple raw binary    files in one dataset or a single file with both the header and the raw     binary data at the same time.    */        bool         bDone = FALSE;    int          nRows = -1, nCols = -1, nBands = 1;    int          nSkipBytes = 0;    int          nLineCount = 0;    GDALDataType eDataType = GDT_Byte;    int          nBits = 8;    char         chByteOrder = 'M';    char         szLayout[10] = "BIL";    char         **papszHDR = NULL;        // default raster file: same name with no extension    CPLString osPath = CPLGetPath( poOpenInfo->pszFilename );    CPLString osName = CPLGetBasename( poOpenInfo->pszFilename );    CPLString osRasterFilename = CPLFormCIFilename( osPath, osName, "" );        // parse the header file    while( !bDone && (pszLine = CPLReadLineL( fp )) != NULL )    {        char    **papszTokens;        nLineCount++;                if ( (nLineCount == 1) && !EQUAL(pszLine,"IMAGINE_RAW_FILE") ) {            return NULL;        }                    if ( (nLineCount > 50) || EQUAL(pszLine,"END_RAW_FILE") ) {            bDone = TRUE;            break;        }                if( strlen(pszLine) > 1000 )            break;        papszHDR = CSLAddString( papszHDR, pszLine );        papszTokens = CSLTokenizeStringComplex( pszLine, " /t", TRUE, FALSE );        if( CSLCount( papszTokens ) < 2 )        {            CSLDestroy( papszTokens );            continue;        }                if( EQUAL(papszTokens[0],"WIDTH") )        {            nCols = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"HEIGHT") )        {            nRows = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"NUM_LAYERS") )        {            nBands = atoi(papszTokens[1]);        }        else if( EQUAL(papszTokens[0],"PIXEL_FILES") )        {//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例4: CPLError

OGRLayer *OGRDGNDataSource::CreateLayer( const char *pszLayerName,                                          OGRSpatialReference *poSRS,                                          OGRwkbGeometryType eGeomType,                                          char **papszExtraOptions ){    const char *pszSeed, *pszMasterUnit = "m", *pszSubUnit = "cm";    const char *pszValue;    int nUORPerSU=1, nSUPerMU=100;    int nCreationFlags = 0, b3DRequested;    double dfOriginX = -21474836.0,  /* default origin centered on zero */           dfOriginY = -21474836.0,  /* with two decimals of precision */           dfOriginZ = -21474836.0;/* -------------------------------------------------------------------- *//*      Ensure only one layer gets created.                             *//* -------------------------------------------------------------------- */    if( nLayers > 0 )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "DGN driver only supports one layer will all the elements in it." );        return NULL;    }/* -------------------------------------------------------------------- *//*      If the coordinate system is geographic, we should use a         *//*      localized default origin and resolution.                        *//* -------------------------------------------------------------------- */    if( poSRS != NULL && poSRS->IsGeographic() )    {        dfOriginX = -200.0;        dfOriginY = -200.0;                pszMasterUnit = "d";        pszSubUnit = "s";        nSUPerMU = 3600;        nUORPerSU = 1000;    }/* -------------------------------------------------------------------- *//*      Parse out various creation options.                             *//* -------------------------------------------------------------------- */    CSLInsertStrings( papszOptions, 0, papszExtraOptions );    b3DRequested = CSLFetchBoolean( papszOptions, "3D",                                     (((int) eGeomType) & wkb25DBit) );    pszSeed = CSLFetchNameValue( papszOptions, "SEED" );    if( pszSeed )        nCreationFlags |= DGNCF_USE_SEED_ORIGIN | DGNCF_USE_SEED_UNITS;    else if( b3DRequested )        pszSeed = CPLFindFile( "gdal", "seed_3d.dgn" );    else        pszSeed = CPLFindFile( "gdal", "seed_2d.dgn" );    if( pszSeed == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "No seed file provided, and unable to find seed_2d.dgn." );        return NULL;    }        if( CSLFetchBoolean( papszOptions, "COPY_WHOLE_SEED_FILE", TRUE ) )        nCreationFlags |= DGNCF_COPY_WHOLE_SEED_FILE;    if( CSLFetchBoolean( papszOptions, "COPY_SEED_FILE_COLOR_TABLE", TRUE ) )        nCreationFlags |= DGNCF_COPY_SEED_FILE_COLOR_TABLE;        pszValue = CSLFetchNameValue( papszOptions, "MASTER_UNIT_NAME" );    if( pszValue != NULL )    {        nCreationFlags &= ~DGNCF_USE_SEED_UNITS;        pszMasterUnit = pszValue;    }        pszValue = CSLFetchNameValue( papszOptions, "SUB_UNIT_NAME" );    if( pszValue != NULL )    {        nCreationFlags &= ~DGNCF_USE_SEED_UNITS;        pszSubUnit = pszValue;    }    pszValue = CSLFetchNameValue( papszOptions, "SUB_UNITS_PER_MASTER_UNIT" );    if( pszValue != NULL )    {        nCreationFlags &= ~DGNCF_USE_SEED_UNITS;        nSUPerMU = atoi(pszValue);    }    pszValue = CSLFetchNameValue( papszOptions, "UOR_PER_SUB_UNIT" );    if( pszValue != NULL )    {        nCreationFlags &= ~DGNCF_USE_SEED_UNITS;        nUORPerSU = atoi(pszValue);    }    pszValue = CSLFetchNameValue( papszOptions, "ORIGIN" );    if( pszValue != NULL )    {        char **papszTuple = CSLTokenizeStringComplex( pszValue, " ,", //.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,


示例5: CPLAssert

int OGROCIDataSource::Open( const char * pszNewName,                            char** papszOpenOptionsIn,                            int bUpdate,                            int bTestOpen ){    CPLAssert( nLayers == 0 && poSession == NULL );/* -------------------------------------------------------------------- *//*      Verify Oracle prefix.                                           *//* -------------------------------------------------------------------- */    if( !STARTS_WITH_CI(pszNewName,"OCI:") )    {        if( !bTestOpen )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s does not conform to Oracle OCI driver naming convention,"                      " OCI:*/n", pszNewName );        }        return FALSE;    }/* -------------------------------------------------------------------- *//*      Try to parse out name, password and database name.              *//* -------------------------------------------------------------------- */    char *pszUserid;    const char *pszPassword = "";    const char *pszDatabase = "";    char **papszTableList = NULL;    const char *pszWorkspace = "";    int   i;    if( pszNewName[4] == '/0' )    {        pszUserid = CPLStrdup(CSLFetchNameValueDef(papszOpenOptionsIn, "USER", ""));        pszPassword = CSLFetchNameValueDef(papszOpenOptionsIn, "PASSWORD", "");        pszDatabase = CSLFetchNameValueDef(papszOpenOptionsIn, "DBNAME", "");        const char* pszTables = CSLFetchNameValue(papszOpenOptionsIn, "TABLES");        if( pszTables )            papszTableList = CSLTokenizeStringComplex(pszTables, ",", TRUE, FALSE );        pszWorkspace = CSLFetchNameValueDef(papszOpenOptions, "WORKSPACE", "");    }    else    {        pszUserid = CPLStrdup( pszNewName + 4 );        // Is there a table list?        for( i = static_cast<int>(strlen(pszUserid))-1; i > 1; i-- )        {            if( pszUserid[i] == ':' )            {                papszTableList = CSLTokenizeStringComplex( pszUserid+i+1, ",",                                                        TRUE, FALSE );                pszUserid[i] = '/0';                break;            }            if( pszUserid[i] == '/' || pszUserid[i] == '@' )                break;        }        for( i = 0;            pszUserid[i] != '/0' && pszUserid[i] != '/' && pszUserid[i] != '@';            i++ ) {}        if( pszUserid[i] == '/' )        {            pszUserid[i++] = '/0';            pszPassword = pszUserid + i;            for( ; pszUserid[i] != '/0' && pszUserid[i] != '@'; i++ ) {}        }        if( pszUserid[i] == '@' )        {            pszUserid[i++] = '/0';            pszDatabase = pszUserid + i;        }    }/* -------------------------------------------------------------------- *//*      Try to establish connection.                                    *//* -------------------------------------------------------------------- */    CPLDebug( "OCI", "Userid=%s, Password=%s, Database=%s",              pszUserid, pszPassword, pszDatabase );    if( EQUAL(pszDatabase, "") &&        EQUAL(pszPassword, "") &&        EQUAL(pszUserid, "") )    {        /* Use username/password OS Authentication and ORACLE_SID database */        poSession = OGRGetOCISession( "/", "", "" );    }    else    {        poSession = OGRGetOCISession( pszUserid, pszPassword, pszDatabase );    }    if( poSession == NULL )//.........这里部分代码省略.........
开发者ID:ryandavid,项目名称:rotobox,代码行数:101,


示例6: CPLStrdup

CPLErr VRTDataset::XMLInit( CPLXMLNode *psTree, const char *pszVRTPath ){    if( pszVRTPath != NULL )        this->pszVRTPath = CPLStrdup(pszVRTPath);/* -------------------------------------------------------------------- *//*      Check for an SRS node.                                          *//* -------------------------------------------------------------------- */    if( strlen(CPLGetXMLValue(psTree, "SRS", "")) > 0 )    {        OGRSpatialReference oSRS;        CPLFree( pszProjection );        pszProjection = NULL;        if( oSRS.SetFromUserInput( CPLGetXMLValue(psTree, "SRS", "") )            == OGRERR_NONE )            oSRS.exportToWkt( &pszProjection );    }/* -------------------------------------------------------------------- *//*      Check for a GeoTransform node.                                  *//* -------------------------------------------------------------------- */    if( strlen(CPLGetXMLValue(psTree, "GeoTransform", "")) > 0 )    {        const char *pszGT = CPLGetXMLValue(psTree, "GeoTransform", "");        char	**papszTokens;        papszTokens = CSLTokenizeStringComplex( pszGT, ",", FALSE, FALSE );        if( CSLCount(papszTokens) != 6 )        {            CPLError( CE_Warning, CPLE_AppDefined,                      "GeoTransform node does not have expected six values.");        }        else        {            for( int iTA = 0; iTA < 6; iTA++ )                adfGeoTransform[iTA] = atof(papszTokens[iTA]);            bGeoTransformSet = TRUE;        }        CSLDestroy( papszTokens );    }/* -------------------------------------------------------------------- *//*      Check for GCPs.                                                 *//* -------------------------------------------------------------------- */    CPLXMLNode *psGCPList = CPLGetXMLNode( psTree, "GCPList" );    if( psGCPList != NULL )    {        CPLXMLNode *psXMLGCP;        OGRSpatialReference oSRS;        const char *pszRawProj = CPLGetXMLValue(psGCPList, "Projection", "");        CPLFree( pszGCPProjection );        if( strlen(pszRawProj) > 0             && oSRS.SetFromUserInput( pszRawProj ) == OGRERR_NONE )            oSRS.exportToWkt( &pszGCPProjection );        else            pszGCPProjection = CPLStrdup("");        // Count GCPs.        int  nGCPMax = 0;                 for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL;              psXMLGCP = psXMLGCP->psNext )            nGCPMax++;                 pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),nGCPMax);                 for( psXMLGCP = psGCPList->psChild; psXMLGCP != NULL;              psXMLGCP = psXMLGCP->psNext )        {            GDAL_GCP *psGCP = pasGCPList + nGCPCount;            if( !EQUAL(psXMLGCP->pszValue,"GCP") ||                 psXMLGCP->eType != CXT_Element )                continue;                         GDALInitGCPs( 1, psGCP );                         CPLFree( psGCP->pszId );            psGCP->pszId = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Id",""));                         CPLFree( psGCP->pszInfo );            psGCP->pszInfo = CPLStrdup(CPLGetXMLValue(psXMLGCP,"Info",""));                         psGCP->dfGCPPixel = atof(CPLGetXMLValue(psXMLGCP,"Pixel","0.0"));            psGCP->dfGCPLine = atof(CPLGetXMLValue(psXMLGCP,"Line","0.0"));                         psGCP->dfGCPX = atof(CPLGetXMLValue(psXMLGCP,"X","0.0"));            psGCP->dfGCPY = atof(CPLGetXMLValue(psXMLGCP,"Y","0.0"));            psGCP->dfGCPZ = atof(CPLGetXMLValue(psXMLGCP,"Z","0.0"));            nGCPCount++;        }    }//.........这里部分代码省略.........
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,


示例7: GXFOpen

//.........这里部分代码省略.........        {            psGXF->dfXOrigin = CPLAtof(papszList[0]);        }        else if( EQUALN(szTitle,"#YORI",5) )        {            psGXF->dfYOrigin = CPLAtof(papszList[0]);        }        else if( EQUALN(szTitle,"#ZMIN",5) )        {            psGXF->dfZMinimum = CPLAtof(papszList[0]);        }        else if( EQUALN(szTitle,"#ZMAX",5) )        {            psGXF->dfZMaximum = CPLAtof(papszList[0]);        }        else if( EQUALN(szTitle,"#SENS",5) )        {            psGXF->nSense = atoi(papszList[0]);        }        else if( EQUALN(szTitle,"#MAP_PROJECTION",8) )        {            psGXF->papszMapProjection = papszList;            papszList = NULL;        }        else if( EQUALN(szTitle,"#MAP_D",5) )        {            psGXF->papszMapDatumTransform = papszList;            papszList = NULL;        }        else if( EQUALN(szTitle,"#UNIT",5) )        {            char	**papszFields;            papszFields = CSLTokenizeStringComplex( papszList[0], ", ",                                                    TRUE, TRUE );            if( CSLCount(papszFields) > 1 )            {                psGXF->pszUnitName = VSIStrdup( papszFields[0] );                psGXF->dfUnitToMeter = CPLAtof( papszFields[1] );                if( psGXF->dfUnitToMeter == 0.0 )                    psGXF->dfUnitToMeter = 1.0;            }            CSLDestroy( papszFields );        }        else if( EQUALN(szTitle,"#TRAN",5) )        {            char	**papszFields;            papszFields = CSLTokenizeStringComplex( papszList[0], ", ",                                                    TRUE, TRUE );            if( CSLCount(papszFields) > 1 )            {                psGXF->dfTransformScale = CPLAtof(papszFields[0]);                psGXF->dfTransformOffset = CPLAtof(papszFields[1]);            }            if( CSLCount(papszFields) > 2 )                psGXF->pszTransformName = CPLStrdup( papszFields[2] );            CSLDestroy( papszFields );        }        else if( EQUALN(szTitle,"#GTYPE",5) )        {
开发者ID:garnertb,项目名称:gdal,代码行数:67,


示例8: MITABCoordSys2TABProjInfo

/********************************************************************** *                     MITABCoordSys2TABProjInfo() * * Convert a MIF COORDSYS string into a TABProjInfo structure. * * Returns 0 on success, -1 on error. **********************************************************************/int MITABCoordSys2TABProjInfo(const char * pszCoordSys, TABProjInfo *psProj){    char        **papszFields;    // Set all fields to zero, equivalent of NonEarth Units "mi"    memset(psProj, 0, sizeof(TABProjInfo));    if( pszCoordSys == NULL )        return -1;        /*-----------------------------------------------------------------     * Parse the passed string into words.     *----------------------------------------------------------------*/    while(*pszCoordSys == ' ') pszCoordSys++;  // Eat leading spaces    if( EQUALN(pszCoordSys,"CoordSys",8) )        pszCoordSys += 9;        papszFields = CSLTokenizeStringComplex( pszCoordSys, " ,", TRUE, FALSE );    /*-----------------------------------------------------------------     * Clip off Bounds information.     *----------------------------------------------------------------*/    int         iBounds = CSLFindString( papszFields, "Bounds" );    while( iBounds != -1 && papszFields[iBounds] != NULL )    {        CPLFree( papszFields[iBounds] );        papszFields[iBounds] = NULL;        iBounds++;    }    /*-----------------------------------------------------------------     * Fetch the projection.     *----------------------------------------------------------------*/    char        **papszNextField;    if( CSLCount( papszFields ) >= 3        && EQUAL(papszFields[0],"Earth")        && EQUAL(papszFields[1],"Projection") )    {        int nProjId = atoi(papszFields[2]);        if (nProjId>=3000) nProjId -=3000;        else if (nProjId>=2000) nProjId -=2000;        else if (nProjId>=1000) nProjId -=1000;        psProj->nProjId = (GByte)nProjId;        papszNextField = papszFields + 3;    }    else if (CSLCount( papszFields ) >= 2             && EQUAL(papszFields[0],"NonEarth") )    {        // NonEarth Units "..." Bounds (x, y) (x, y)        psProj->nProjId = 0;        papszNextField = papszFields + 2;        if( papszNextField[0] != NULL && EQUAL(papszNextField[0],"Units") )            papszNextField++;    }    else    {        // Invalid projection string ???        if (CSLCount(papszFields) > 0)            CPLError(CE_Warning, CPLE_IllegalArg,                     "Failed parsing CoordSys: '%s'", pszCoordSys);        CSLDestroy(papszFields);        return -1;    }    /*-----------------------------------------------------------------     * Fetch the datum information.     *----------------------------------------------------------------*/    int         nDatum = 0;    if( psProj->nProjId != 0 && CSLCount(papszNextField) > 0 )    {        nDatum = atoi(papszNextField[0]);        papszNextField++;    }    if( (nDatum == 999 || nDatum == 9999)        && CSLCount(papszNextField) >= 4 )    {        psProj->nEllipsoidId = (GByte)atoi(papszNextField[0]);        psProj->dDatumShiftX = CPLAtof(papszNextField[1]);        psProj->dDatumShiftY = CPLAtof(papszNextField[2]);        psProj->dDatumShiftZ = CPLAtof(papszNextField[3]);        papszNextField += 4;        if( nDatum == 9999            && CSLCount(papszNextField) >= 5 )        {            psProj->adDatumParams[0] = CPLAtof(papszNextField[0]);//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,


示例9: Clear

OGRErr OGRSpatialReference::importFromOzi(const char *pszDatum,                                          const char *pszProj,                                          const char *pszProjParms){    Clear();/* -------------------------------------------------------------------- *//*      Operate on the basis of the projection name.                    *//* -------------------------------------------------------------------- */    char **papszProj      = CSLTokenizeStringComplex(pszProj, ",", TRUE, TRUE);    char **papszProjParms = CSLTokenizeStringComplex(pszProjParms, ",",                                                     TRUE, TRUE);    char **papszDatum = NULL;    if (CSLCount(papszProj) < 2)    {        goto not_enough_data;    }    if (EQUALN(papszProj[1], "Latitude/Longitude", 18))    {}    else if (EQUALN(papszProj[1], "Mercator", 8))    {        if (CSLCount(papszProjParms) < 6)            goto not_enough_data;        double dfScale = CPLAtof(papszProjParms[3]);        if (papszProjParms[3][0] == 0)            dfScale = 1;                            /* if unset, default to scale = 1 */        SetMercator(CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),                    dfScale,                    CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]));    }    else if (EQUALN(papszProj[1], "Transverse Mercator", 19))    {        if (CSLCount(papszProjParms) < 6)            goto not_enough_data;        SetTM(CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),              CPLAtof(papszProjParms[3]),              CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]));    }    else if (EQUALN(papszProj[1], "Lambert Conformal Conic", 23))    {        if (CSLCount(papszProjParms) < 8)            goto not_enough_data;        SetLCC(CPLAtof(papszProjParms[6]), CPLAtof(papszProjParms[7]),               CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),               CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]));    }    else if (EQUALN(papszProj[1], "Sinusoidal", 10))    {        if (CSLCount(papszProjParms) < 6)            goto not_enough_data;        SetSinusoidal(CPLAtof(papszProjParms[2]),                      CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]));    }    else if (EQUALN(papszProj[1], "Albers Equal Area", 17))    {        if (CSLCount(papszProjParms) < 8)            goto not_enough_data;        SetACEA(CPLAtof(papszProjParms[6]), CPLAtof(papszProjParms[7]),                CPLAtof(papszProjParms[1]), CPLAtof(papszProjParms[2]),                CPLAtof(papszProjParms[4]), CPLAtof(papszProjParms[5]));    }    else    {        CPLDebug("OSR_Ozi", "Unsupported projection: /"%s/"", papszProj[1]);        SetLocalCS(CPLString().Printf("/"Ozi/" projection /"%s/"",                                      papszProj[1]));    }/* -------------------------------------------------------------------- *//*      Try to translate the datum/spheroid.                            *//* -------------------------------------------------------------------- */    papszDatum = CSLTokenizeString2(pszDatum, ",",                                    CSLT_ALLOWEMPTYTOKENS                                    | CSLT_STRIPLEADSPACES                                    | CSLT_STRIPENDSPACES);    if (papszDatum == NULL)        goto not_enough_data;    if (!IsLocal())    {        const OZIDatums *paoDatum = aoDatums;        // Search for matching datum        while (paoDatum->pszOziDatum)        {//.........这里部分代码省略.........
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:101,


示例10: GDALSimpleImageWarp

//.........这里部分代码省略........./* -------------------------------------------------------------------- */    const int nDstXSize = GDALGetRasterXSize( hDstDS );    const int nDstYSize = GDALGetRasterYSize( hDstDS );    GByte **papabyDstLine = static_cast<GByte **>(        CPLCalloc(nBandCount, sizeof(GByte*)) );    for( int iBand = 0; iBand < nBandCount; iBand++ )        papabyDstLine[iBand] = static_cast<GByte *>(CPLMalloc( nDstXSize ));/* -------------------------------------------------------------------- *//*      Allocate x,y,z coordinate arrays for transformation ... one     *//*      scanlines worth of positions.                                   *//* -------------------------------------------------------------------- */    double *padfX = static_cast<double *>(        CPLMalloc(sizeof(double) * nDstXSize) );    double *padfY = static_cast<double *>(        CPLMalloc(sizeof(double) * nDstXSize) );    double *padfZ = static_cast<double *>(        CPLMalloc(sizeof(double) * nDstXSize) );    int *pabSuccess = static_cast<int *>( CPLMalloc(sizeof(int) * nDstXSize) );/* -------------------------------------------------------------------- *//*      Establish the value we will use to initialize the bands.  We    *//*      default to -1 indicating the initial value should be read       *//*      and preserved from the source file, but allow this to be        *//*      overridden by passed                                            *//*      option(s).                                                      *//* -------------------------------------------------------------------- */    int * const panBandInit =        static_cast<int *>( CPLCalloc(sizeof(int), nBandCount) );    if( CSLFetchNameValue( papszWarpOptions, "INIT" ) )    {        char **papszTokens =            CSLTokenizeStringComplex( CSLFetchNameValue( papszWarpOptions,                                                         "INIT" ),                                      " ,", FALSE, FALSE );        const int nTokenCount = CSLCount(papszTokens);        for( int iBand = 0; iBand < nBandCount; iBand++ )        {            if( nTokenCount == 0 )                panBandInit[iBand] = 0;            else                panBandInit[iBand] =                    atoi(papszTokens[MIN(iBand,nTokenCount-1)]);        }        CSLDestroy(papszTokens);    }/* -------------------------------------------------------------------- *//*      Loop over all the scanlines in the output image.                *//* -------------------------------------------------------------------- */    for( int iDstY = 0; iDstY < nDstYSize; iDstY++ )    {        // Clear output buffer to "transparent" value.  Should not we        // really be reading from the destination file to support overlay?        for( int iBand = 0; iBand < nBandCount; iBand++ )        {            if( panBandInit[iBand] == -1 )            {                if( GDALRasterIO( GDALGetRasterBand(hDstDS,iBand+1), GF_Read,                              0, iDstY, nDstXSize, 1,                              papabyDstLine[iBand], nDstXSize, 1, GDT_Byte,                              0, 0 ) != CE_None )
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:67,


示例11: VSIMalloc

CPLErr VRTWarpedDataset::ProcessBlock( int iBlockX, int iBlockY ){    if( poWarper == NULL )        return CE_Failure;    const GDALWarpOptions *psWO = poWarper->GetOptions();/* -------------------------------------------------------------------- *//*      Allocate block of memory large enough to hold all the bands     *//*      for this block.                                                 *//* -------------------------------------------------------------------- */    int iBand;    GByte *pabyDstBuffer;    int   nDstBufferSize;    int   nWordSize = (GDALGetDataTypeSize(psWO->eWorkingDataType) / 8);    // FIXME? : risk of overflow in multiplication if nBlockXSize or nBlockYSize are very large    nDstBufferSize = nBlockXSize * nBlockYSize * psWO->nBandCount * nWordSize;    pabyDstBuffer = (GByte *) VSIMalloc(nDstBufferSize);    if( pabyDstBuffer == NULL )    {        CPLError( CE_Failure, CPLE_OutOfMemory,                  "Out of memory allocating %d byte buffer in VRTWarpedDataset::ProcessBlock()",                  nDstBufferSize );        return CE_Failure;    }				    memset( pabyDstBuffer, 0, nDstBufferSize );/* -------------------------------------------------------------------- *//*      Process INIT_DEST option to initialize the buffer prior to      *//*      warping into it.                                                *//* NOTE:The following code is 99% similar in gdalwarpoperation.cpp and  *//*      vrtwarped.cpp. Be careful to keep it in sync !                  *//* -------------------------------------------------------------------- */    const char *pszInitDest = CSLFetchNameValue( psWO->papszWarpOptions,                                                 "INIT_DEST" );    if( pszInitDest != NULL && !EQUAL(pszInitDest, "") )    {        char **papszInitValues =             CSLTokenizeStringComplex( pszInitDest, ",", FALSE, FALSE );        int nInitCount = CSLCount(papszInitValues);                                                                   for( iBand = 0; iBand < psWO->nBandCount; iBand++ )        {            double adfInitRealImag[2];            GByte *pBandData;            int nBandSize = nBlockXSize * nBlockYSize * nWordSize;            const char *pszBandInit = papszInitValues[MIN(iBand,nInitCount-1)];            if( EQUAL(pszBandInit,"NO_DATA")                && psWO->padfDstNoDataReal != NULL )            {                adfInitRealImag[0] = psWO->padfDstNoDataReal[iBand];                adfInitRealImag[1] = psWO->padfDstNoDataImag[iBand];            }            else            {                CPLStringToComplex( pszBandInit,                                    adfInitRealImag + 0, adfInitRealImag + 1);            }            pBandData = ((GByte *) pabyDstBuffer) + iBand * nBandSize;                        if( psWO->eWorkingDataType == GDT_Byte )                memset( pBandData,                         MAX(0,MIN(255,(int)adfInitRealImag[0])),                         nBandSize);            else if( adfInitRealImag[0] == 0.0 && adfInitRealImag[1] == 0 )            {                memset( pBandData, 0, nBandSize );            }            else if( adfInitRealImag[1] == 0.0 )            {                GDALCopyWords( &adfInitRealImag, GDT_Float64, 0,                                pBandData,psWO->eWorkingDataType,nWordSize,                               nBlockXSize * nBlockYSize );            }            else            {                GDALCopyWords( &adfInitRealImag, GDT_CFloat64, 0,                                pBandData,psWO->eWorkingDataType,nWordSize,                               nBlockXSize * nBlockYSize );            }        }        CSLDestroy( papszInitValues );    }/* -------------------------------------------------------------------- *//*      Warp into this buffer.                                          *//* -------------------------------------------------------------------- */    CPLErr eErr;    eErr =         poWarper->WarpRegionToBuffer( //.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,


示例12: CSLTokenizeStringComplex

void ERSDataset::ReadGCPs(){    const char *pszCP =         poHeader->Find( "RasterInfo.WarpControl.ControlPoints", NULL );    if( pszCP == NULL )        return;/* -------------------------------------------------------------------- *//*      Parse the control points.  They will look something like:       *//*                                                                      *//*   "1035" Yes No 2344.650885 3546.419458 483270.73 3620906.21 3.105   *//* -------------------------------------------------------------------- */    char **papszTokens = CSLTokenizeStringComplex( pszCP, "{ /t}", TRUE,FALSE);    int nItemsPerLine;    int nItemCount = CSLCount(papszTokens);/* -------------------------------------------------------------------- *//*      Work out if we have elevation values or not.                    *//* -------------------------------------------------------------------- */    if( nItemCount == 7 )        nItemsPerLine = 7;    else if( nItemCount == 8 )        nItemsPerLine = 8;    else if( nItemCount < 14 )    {        CPLAssert( FALSE );        return;    }    else if( EQUAL(papszTokens[8],"Yes") || EQUAL(papszTokens[8],"No") )        nItemsPerLine = 7;    else if( EQUAL(papszTokens[9],"Yes") || EQUAL(papszTokens[9],"No") )        nItemsPerLine = 8;    else    {        CPLAssert( FALSE );        return;    }/* -------------------------------------------------------------------- *//*      Setup GCPs.                                                     *//* -------------------------------------------------------------------- */    int iGCP;    CPLAssert( nGCPCount == 0 );    nGCPCount = nItemCount / nItemsPerLine;    pasGCPList = (GDAL_GCP *) CPLCalloc(nGCPCount,sizeof(GDAL_GCP));    GDALInitGCPs( nGCPCount, pasGCPList );    for( iGCP = 0; iGCP < nGCPCount; iGCP++ )    {        GDAL_GCP *psGCP = pasGCPList + iGCP;        CPLFree( psGCP->pszId );        psGCP->pszId = CPLStrdup(papszTokens[iGCP*nItemsPerLine+0]);        psGCP->dfGCPPixel = atof(papszTokens[iGCP*nItemsPerLine+3]);        psGCP->dfGCPLine  = atof(papszTokens[iGCP*nItemsPerLine+4]);        psGCP->dfGCPX     = atof(papszTokens[iGCP*nItemsPerLine+5]);        psGCP->dfGCPY     = atof(papszTokens[iGCP*nItemsPerLine+6]);        if( nItemsPerLine == 8 )            psGCP->dfGCPZ = atof(papszTokens[iGCP*nItemsPerLine+7]);    }        CSLDestroy( papszTokens );    /* -------------------------------------------------------------------- *//*      Parse the GCP projection.                                       *//* -------------------------------------------------------------------- */    OGRSpatialReference oSRS;    CPLString osProjection = poHeader->Find(         "RasterInfo.WarpControl.CoordinateSpace.Projection", "RAW" );    CPLString osDatum = poHeader->Find(         "RasterInfo.WarpControl.CoordinateSpace.Datum", "WGS84" );    CPLString osUnits = poHeader->Find(         "RasterInfo.WarpControl.CoordinateSpace.Units", "METERS" );    oSRS.importFromERM( osProjection, osDatum, osUnits );    CPLFree( pszGCPProjection );    oSRS.exportToWkt( &pszGCPProjection );}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:84,


示例13: ParseGMLCoordinates

int ParseGMLCoordinates( CPLXMLNode *psGeomNode, OGRGeometry *poGeometry ){    CPLXMLNode *psCoordinates = FindBareXMLChild( psGeomNode, "coordinates" );    int iCoord = 0;/* -------------------------------------------------------------------- *//*      Handle <coordinates> case.                                      *//* -------------------------------------------------------------------- */    if( psCoordinates != NULL )    {        const char *pszCoordString = GetElementText( psCoordinates );        if( pszCoordString == NULL )        {            CPLError( CE_Failure, CPLE_AppDefined,                       "<coordinates> element missing value." );            return FALSE;        }        while( *pszCoordString != '/0' )        {            double dfX, dfY, dfZ = 0.0;            int nDimension = 2;            // parse out 2 or 3 tuple.             dfX = atof( pszCoordString );            while( *pszCoordString != '/0'                   && *pszCoordString != ','                   && !isspace(*pszCoordString) )                pszCoordString++;            if( *pszCoordString == '/0' || isspace(*pszCoordString) )            {                CPLError( CE_Failure, CPLE_AppDefined,                           "Corrupt <coordinates> value." );                return FALSE;            }            pszCoordString++;            dfY = atof( pszCoordString );            while( *pszCoordString != '/0'                    && *pszCoordString != ','                   && !isspace(*pszCoordString) )                pszCoordString++;            if( *pszCoordString == ',' )            {                pszCoordString++;                dfZ = atof( pszCoordString );                nDimension = 3;                while( *pszCoordString != '/0'                        && *pszCoordString != ','                       && !isspace(*pszCoordString) )                pszCoordString++;            }            while( isspace(*pszCoordString) )                pszCoordString++;            if( !AddPoint( poGeometry, dfX, dfY, dfZ, nDimension ) )                return FALSE;            iCoord++;        }        return iCoord > 0;    }/* -------------------------------------------------------------------- *//*      Is this a "pos"?  I think this is a GML 3 construct.            *//* -------------------------------------------------------------------- */    CPLXMLNode *psPos = FindBareXMLChild( psGeomNode, "pos" );        if( psPos != NULL )    {        char **papszTokens = CSLTokenizeStringComplex(             GetElementText( psPos ), " ,", FALSE, FALSE );        int bSuccess = FALSE;        if( CSLCount( papszTokens ) > 2 )        {            bSuccess = AddPoint( poGeometry,                                  atof(papszTokens[0]),                                  atof(papszTokens[1]),                                 atof(papszTokens[2]), 3 );        }        else if( CSLCount( papszTokens ) > 1 )        {            bSuccess = AddPoint( poGeometry,                                  atof(papszTokens[0]),                                  atof(papszTokens[1]),                                 0.0, 2 );        }        else        {            CPLError( CE_Failure, CPLE_AppDefined,                      "Did not get 2+ values in <gml:pos>%s</gml:pos> tuple.",                      GetElementText( psPos ) );        }//.........这里部分代码省略.........
开发者ID:maowang,项目名称:sqlite-ogc,代码行数:101,


示例14: H5Dopen

void BAGDataset::LoadMetadata(){/* -------------------------------------------------------------------- *//*      Load the metadata from the file.                                *//* -------------------------------------------------------------------- */    hid_t hMDDS = H5Dopen( hHDF5, "/BAG_root/metadata" );    hid_t datatype     = H5Dget_type( hMDDS );    hid_t dataspace    = H5Dget_space( hMDDS );    hid_t native       = H5Tget_native_type( datatype, H5T_DIR_ASCEND );    hsize_t dims[3], maxdims[3];    H5Sget_simple_extent_dims( dataspace, dims, maxdims );    pszXMLMetadata = (char *) CPLCalloc(dims[0]+1,1);    H5Dread( hMDDS, native, H5S_ALL, dataspace, H5P_DEFAULT, pszXMLMetadata );    H5Sclose( dataspace );    H5Tclose( datatype );    H5Dclose( hMDDS );    if( strlen(pszXMLMetadata) == 0 )        return;/* -------------------------------------------------------------------- *//*      Try to get the geotransform.                                    *//* -------------------------------------------------------------------- */    CPLXMLNode *psRoot = CPLParseXMLString( pszXMLMetadata );    if( psRoot == NULL )        return;    CPLStripXMLNamespace( psRoot, NULL, TRUE );    CPLXMLNode *psGeo = CPLSearchXMLNode( psRoot, "=MD_Georectified" );    if( psGeo != NULL )    {        char **papszCornerTokens =             CSLTokenizeStringComplex(                 CPLGetXMLValue( psGeo, "cornerPoints.Point.coordinates", "" ),                " ,", FALSE, FALSE );        if( CSLCount(papszCornerTokens ) == 4 )        {            double dfLLX = atof( papszCornerTokens[0] );            double dfLLY = atof( papszCornerTokens[1] );            double dfURX = atof( papszCornerTokens[2] );            double dfURY = atof( papszCornerTokens[3] );            adfGeoTransform[0] = dfLLX;            adfGeoTransform[1] = (dfURX - dfLLX) / (GetRasterXSize()-1);            adfGeoTransform[3] = dfURY;            adfGeoTransform[5] = (dfLLY - dfURY) / (GetRasterYSize()-1);            adfGeoTransform[0] -= adfGeoTransform[1] * 0.5;            adfGeoTransform[3] -= adfGeoTransform[5] * 0.5;        }        CSLDestroy( papszCornerTokens );    }    CPLDestroyXMLNode( psRoot );/* -------------------------------------------------------------------- *//*      Try to get the coordinate system.                               *//* -------------------------------------------------------------------- */    OGRSpatialReference oSRS;    if( OGR_SRS_ImportFromISO19115( &oSRS, pszXMLMetadata )        == OGRERR_NONE )    {        oSRS.exportToWkt( &pszProjection );    }}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:75,


示例15: CPLGetPath

GDALDataset *SAGADataset::Open( GDALOpenInfo * poOpenInfo ){    /* -------------------------------------------------------------------- */    /*	We assume the user is pointing to the binary (ie. .sdat) file.	    */    /* -------------------------------------------------------------------- */    if( !EQUAL(CPLGetExtension( poOpenInfo->pszFilename ), "sdat"))    {        return NULL;    }    CPLString osPath = CPLGetPath( poOpenInfo->pszFilename );    CPLString osName = CPLGetBasename( poOpenInfo->pszFilename );    CPLString osHDRFilename;    osHDRFilename = CPLFormCIFilename( osPath, osName, ".sgrd" );    VSILFILE	*fp;    fp = VSIFOpenL( osHDRFilename, "r" );        if( fp == NULL )    {        return NULL;    }    /* -------------------------------------------------------------------- */    /*      Is this file a SAGA header file?  Read a few lines of text      */    /*      searching for something starting with nrows or ncols.           */    /* -------------------------------------------------------------------- */    const char		*pszLine;    int				nRows = -1, nCols = -1;    double			dXmin = 0.0, dYmin = 0.0, dCellsize = 0.0, dNoData = 0.0, dZFactor = 0.0;    int				nLineCount			= 0;    char			szDataFormat[20]	= "DOUBLE";    char            szByteOrderBig[10]	= "FALSE";    char			szTopToBottom[10]	= "FALSE";    char            **papszHDR			= NULL;    	    while( (pszLine = CPLReadLineL( fp )) != NULL )        {        char	**papszTokens;        nLineCount++;        if( nLineCount > 50 || strlen(pszLine) > 1000 )            break;        papszHDR = CSLAddString( papszHDR, pszLine );        papszTokens = CSLTokenizeStringComplex( pszLine, " =", TRUE, FALSE );        if( CSLCount( papszTokens ) < 2 )        {		            CSLDestroy( papszTokens );            continue;        }        if( EQUALN(papszTokens[0],"CELLCOUNT_X",strlen("CELLCOUNT_X")) )            nCols = atoi(papszTokens[1]);        else if( EQUALN(papszTokens[0],"CELLCOUNT_Y",strlen("CELLCOUNT_Y")) )            nRows = atoi(papszTokens[1]);        else if( EQUALN(papszTokens[0],"POSITION_XMIN",strlen("POSITION_XMIN")) )            dXmin = CPLAtofM(papszTokens[1]);        else if( EQUALN(papszTokens[0],"POSITION_YMIN",strlen("POSITION_YMIN")) )            dYmin = CPLAtofM(papszTokens[1]);        else if( EQUALN(papszTokens[0],"CELLSIZE",strlen("CELLSIZE")) )            dCellsize = CPLAtofM(papszTokens[1]);        else if( EQUALN(papszTokens[0],"NODATA_VALUE",strlen("NODATA_VALUE")) )            dNoData = CPLAtofM(papszTokens[1]);        else if( EQUALN(papszTokens[0],"DATAFORMAT",strlen("DATAFORMAT")) )            strncpy( szDataFormat, papszTokens[1], sizeof(szDataFormat)-1 );        else if( EQUALN(papszTokens[0],"BYTEORDER_BIG",strlen("BYTEORDER_BIG")) )            strncpy( szByteOrderBig, papszTokens[1], sizeof(szByteOrderBig)-1 );        else if( EQUALN(papszTokens[0],"TOPTOBOTTOM",strlen("TOPTOBOTTOM")) )            strncpy( szTopToBottom, papszTokens[1], sizeof(szTopToBottom)-1 );        else if( EQUALN(papszTokens[0],"Z_FACTOR",strlen("Z_FACTOR")) )            dZFactor = CPLAtofM(papszTokens[1]);        CSLDestroy( papszTokens );    }    VSIFCloseL( fp );    CSLDestroy( papszHDR );    /* -------------------------------------------------------------------- */    /*      Did we get the required keywords?  If not we return with        */    /*      this never having been considered to be a match. This isn't     */    /*      an error!                                                       */    /* -------------------------------------------------------------------- */    if( nRows == -1 || nCols == -1 )    {        return NULL;    }    if (!GDALCheckDatasetDimensions(nCols, nRows))    {        return NULL;//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,


示例16: CPLGetConfigOption

//.........这里部分代码省略.........           if( !FindFile( szTargetFile, pszDirectory, bReportErr, &fp ) )        return FALSE;/* -------------------------------------------------------------------- *//*      Skip the line defining the column titles.                       *//* -------------------------------------------------------------------- */    pszLine = ReadLine( fp );    if( !EQUAL(pszLine,          "/"Code/",/"Attribute/",/"Acronym/",/"Attributetype/",/"Class/"") )    {        CPLError( CE_Failure, CPLE_AppDefined,                  "s57attributes columns don't match expected format!/n" );        return FALSE;    }    /* -------------------------------------------------------------------- *//*      Prepare arrays for the per-attribute information.               *//* -------------------------------------------------------------------- */    nAttrMax = MAX_ATTRIBUTES-1;    papszAttrNames = (char **) CPLCalloc(sizeof(char *),MAX_ATTRIBUTES);    papszAttrAcronym = (char **) CPLCalloc(sizeof(char *),MAX_ATTRIBUTES);    //papapszAttrValues = (char ***) CPLCalloc(sizeof(char **),MAX_ATTRIBUTES);    pachAttrType = (char *) CPLCalloc(sizeof(char),MAX_ATTRIBUTES);    pachAttrClass = (char *) CPLCalloc(sizeof(char),MAX_ATTRIBUTES);    panAttrIndex = (GInt16 *) CPLCalloc(sizeof(GInt16),MAX_ATTRIBUTES);    /* -------------------------------------------------------------------- *//*      Read and form string list.                                      *//* -------------------------------------------------------------------- */    GInt16         iAttr;        while( (pszLine = ReadLine(fp)) != NULL )    {        char    **papszTokens = CSLTokenizeStringComplex( pszLine, ",",                                                          TRUE, TRUE );        if( CSLCount(papszTokens) < 5 )        {            CPLAssert( FALSE );            continue;        }                iAttr = (GInt16) atoi(papszTokens[0]);        if( iAttr < 0 || iAttr >= nAttrMax            || papszAttrNames[iAttr] != NULL )        {            CPLDebug( "S57", "Duplicate definition for attribute %d:%s",                       iAttr, papszTokens[2] );            continue;        }                papszAttrNames[iAttr] = CPLStrdup(papszTokens[1]);        papszAttrAcronym[iAttr] = CPLStrdup(papszTokens[2]);        pachAttrType[iAttr] = papszTokens[3][0];        pachAttrClass[iAttr] = papszTokens[4][0];        CSLDestroy( papszTokens );    }    if( fp != NULL )        VSIFClose( fp );    /* -------------------------------------------------------------------- *//*      Build unsorted index of attributes.                             *//* -------------------------------------------------------------------- */    nAttrCount = 0;    for( iAttr = 0; iAttr < nAttrMax; iAttr++ )    {        if( papszAttrAcronym[iAttr] != NULL )            panAttrIndex[nAttrCount++] = iAttr;    }/* -------------------------------------------------------------------- *//*      Sort index by acronym.                                          *//* -------------------------------------------------------------------- */    int         bModified;    do    {        bModified = FALSE;        for( iAttr = 0; iAttr < nAttrCount-1; iAttr++ )        {            if( strcmp(papszAttrAcronym[panAttrIndex[iAttr]],                       papszAttrAcronym[panAttrIndex[iAttr+1]]) > 0 )            {                GInt16     nTemp;                nTemp = panAttrIndex[iAttr];                panAttrIndex[iAttr] = panAttrIndex[iAttr+1];                panAttrIndex[iAttr+1] = nTemp;                bModified = TRUE;            }        }    } while( bModified );        return TRUE;}
开发者ID:dlsyaim,项目名称:osgEarthX,代码行数:101,


示例17: GDALWriteRPBFile

CPLErr GDALWriteRPBFile( const char *pszFilename, char **papszMD ){    CPLString osRPBFilename = CPLResetExtension( pszFilename, "RPB" );/* -------------------------------------------------------------------- *//*      Read file and parse.                                            *//* -------------------------------------------------------------------- */    VSILFILE *fp = VSIFOpenL( osRPBFilename, "w" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Unable to create %s for writing./n%s",                  osRPBFilename.c_str(), CPLGetLastErrorMsg() );        return CE_Failure;    }/* -------------------------------------------------------------------- *//*      Write the prefix information.                                   *//* -------------------------------------------------------------------- */    bool bOK = VSIFPrintfL( fp, "%s", "satId = /"QB02/";/n" ) > 0;    bOK &= VSIFPrintfL( fp, "%s", "bandId = /"P/";/n" ) > 0;    bOK &= VSIFPrintfL( fp, "%s", "SpecId = /"RPC00B/";/n" ) > 0;    bOK &= VSIFPrintfL( fp, "%s", "BEGIN_GROUP = IMAGE/n" ) > 0;    bOK &= VSIFPrintfL( fp, "%s", "/terrBias = 0.0;/n" ) > 0;    bOK &= VSIFPrintfL( fp, "%s", "/terrRand = 0.0;/n" ) > 0;/* -------------------------------------------------------------------- *//*      Write RPC values from our RPC metadata.                         *//* -------------------------------------------------------------------- */    for( int i = 0; apszRPBMap[i] != NULL; i += 2 )    {        const char *pszRPBVal = CSLFetchNameValue( papszMD, apszRPBMap[i] );        const char *pszRPBTag;        if( pszRPBVal == NULL )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s field missing in metadata, %s file not written.",                      apszRPBMap[i], osRPBFilename.c_str() );            CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));            VSIUnlink( osRPBFilename );            return CE_Failure;        }        pszRPBTag = apszRPBMap[i+1];        if( STARTS_WITH_CI(pszRPBTag, "IMAGE.") )            pszRPBTag += 6;        if( strstr(apszRPBMap[i], "COEF" ) == NULL )        {            bOK &= VSIFPrintfL( fp, "/t%s = %s;/n", pszRPBTag, pszRPBVal ) > 0;        }        else        {            // Reformat in brackets with commas over multiple lines.            bOK &= VSIFPrintfL( fp, "/t%s = (/n", pszRPBTag ) > 0;            char **papszItems = CSLTokenizeStringComplex( pszRPBVal, " ,",                                                          FALSE, FALSE );            if( CSLCount(papszItems) != 20 )            {                CPLError( CE_Failure, CPLE_AppDefined,                          "%s field is corrupt (not 20 values), %s file not "                          "written./n%s = %s",                          apszRPBMap[i], osRPBFilename.c_str(),                          apszRPBMap[i], pszRPBVal );                CPL_IGNORE_RET_VAL(VSIFCloseL( fp ));                VSIUnlink( osRPBFilename );                CSLDestroy( papszItems );                return CE_Failure;            }            for( int j = 0; j < 20; j++ )            {                if( j < 19 )                    bOK &= VSIFPrintfL( fp, "/t/t/t%s,/n", papszItems[j] ) > 0;                else                    bOK &= VSIFPrintfL( fp, "/t/t/t%s);/n", papszItems[j] ) > 0;            }            CSLDestroy( papszItems );        }    }/* -------------------------------------------------------------------- *//*      Write end part                                                  *//* -------------------------------------------------------------------- */    bOK &= VSIFPrintfL( fp, "%s", "END_GROUP = IMAGE/n" ) > 0;    bOK &= VSIFPrintfL( fp, "END;/n" ) > 0;    if( VSIFCloseL( fp ) != 0 )        bOK = false;    return bOK ? CE_None : CE_Failure;}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:97,


示例18: CSLFetchNameValue

//.........这里部分代码省略.........            new VRTRawRasterBand( this, GetRasterCount() + 1, eType );        eErr =             poBand->SetRawLink( pszFilename, NULL, FALSE,                                 nImageOffset, nPixelOffset, nLineOffset,                                 pszByteOrder );        if( eErr != CE_None )        {            delete poBand;            return eErr;        }        SetBand( GetRasterCount() + 1, poBand );        return CE_None;    }/* ==================================================================== *//*      Handle a new "sourced" band.                                    *//* ==================================================================== */    else    {        VRTSourcedRasterBand *poBand;	/* ---- Check for our sourced band 'derived' subclass ---- */        if(pszSubClass != NULL && EQUAL(pszSubClass,"VRTDerivedRasterBand")) {            /* We'll need a pointer to the subclass in case we need */            /* to set the new band's pixel function below. */            VRTDerivedRasterBand* poDerivedBand;            poDerivedBand = new VRTDerivedRasterBand                (this, GetRasterCount() + 1, eType,                 GetRasterXSize(), GetRasterYSize());            /* Set the pixel function options it provided. */            const char* pszFuncName =                CSLFetchNameValue(papszOptions, "PixelFunctionType");            if (pszFuncName != NULL)                poDerivedBand->SetPixelFunctionName(pszFuncName);            const char* pszTransferTypeName =                CSLFetchNameValue(papszOptions, "SourceTransferType");            if (pszTransferTypeName != NULL) {                GDALDataType eTransferType =                    GDALGetDataTypeByName(pszTransferTypeName);                if (eTransferType == GDT_Unknown) {                    CPLError( CE_Failure, CPLE_AppDefined,                              "invalid SourceTransferType: /"%s/".",                              pszTransferTypeName);                    delete poDerivedBand;                    return CE_Failure;                }                poDerivedBand->SetSourceTransferType(eTransferType);            }            /* We're done with the derived band specific stuff, so */            /* we can assigned the base class pointer now. */            poBand = poDerivedBand;        }	else {	    /* ---- Standard sourced band ---- */	    poBand = new VRTSourcedRasterBand		(this, GetRasterCount() + 1, eType, 		 GetRasterXSize(), GetRasterYSize());	}        SetBand( GetRasterCount() + 1, poBand );        for( i=0; papszOptions != NULL && papszOptions[i] != NULL; i++ )        {            if( EQUALN(papszOptions[i],"AddFuncSource=", 14) )            {                VRTImageReadFunc pfnReadFunc = NULL;                void             *pCBData = NULL;                double           dfNoDataValue = VRT_NODATA_UNSET;                char **papszTokens = CSLTokenizeStringComplex( papszOptions[i]+14,                                                               ",", TRUE, FALSE );                if( CSLCount(papszTokens) < 1 )                {                    CPLError( CE_Failure, CPLE_AppDefined,                               "AddFuncSource() ... required argument missing." );                }                sscanf( papszTokens[0], "%p", &pfnReadFunc );                if( CSLCount(papszTokens) > 1 )                    sscanf( papszTokens[1], "%p", &pCBData );                if( CSLCount(papszTokens) > 2 )                    dfNoDataValue = atof( papszTokens[2] );                poBand->AddFuncSource( pfnReadFunc, pCBData, dfNoDataValue );            }        }        return CE_None;    }}
开发者ID:Joe-xXx,项目名称:gdal,代码行数:101,


示例19: VSIFOpenL

//.........这里部分代码省略.........        {            CPLError( CE_Failure, CPLE_AppDefined,                       "Failed to open band file: %s",                       osFilename.c_str() );            delete poDS;            return NULL;        }        poDS->papszExtraFiles =             CSLAddString( poDS->papszExtraFiles,                           osFilename );        RawRasterBand *poBand =             new RawRasterBand( poDS, iBand+1, fpRaw, 0, 1, poDS->nRasterXSize,                               GDT_Byte, TRUE, TRUE );                sprintf( szKey, "BAND%d_NAME", iBand+1 );        poBand->SetDescription( poDS->Get(szKey, "") );        sprintf( szKey, "BAND%d_WAVELENGTHS", iBand+1 );        poBand->SetMetadataItem( "WAVELENGTHS", poDS->Get(szKey,"") );        sprintf( szKey, "BAND%d_RADIOMETRIC_GAINS/BIAS", iBand+1 );        poBand->SetMetadataItem( "RADIOMETRIC_GAINS_BIAS",                                  poDS->Get(szKey,"") );        poDS->SetBand( iBand+1, poBand );    }/* -------------------------------------------------------------------- *//*      Fetch and parse USGS projection parameters.                     *//* -------------------------------------------------------------------- */    double adfUSGSParms[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};    char **papszParmTokens =         CSLTokenizeStringComplex( poDS->Get( "USGS_PROJECTION_NUMBER", "" ),                                  ",", FALSE, TRUE );    if( CSLCount( papszParmTokens ) >= 15 )    {        int i;        for( i = 0; i < 15; i++ )            adfUSGSParms[i] = CPLAtof(papszParmTokens[i]);    }    CSLDestroy(papszParmTokens);    papszParmTokens = NULL;/* -------------------------------------------------------------------- *//*      Minimal georef support ... should add full USGS style           *//*      support at some point.                                          *//* -------------------------------------------------------------------- */    OGRSpatialReference oSRS;    int nUSGSProjection = atoi(poDS->Get( "USGS_PROJECTION_NUMBER", "" ));    int nZone = atoi(poDS->Get("USGS_MAP_ZONE","0"));    oSRS.importFromUSGS( nUSGSProjection, nZone, adfUSGSParms, 12 );    CPLString osDatum = poDS->Get( "HORIZONTAL_DATUM", "" );    if( EQUAL(osDatum,"WGS84") || EQUAL(osDatum,"NAD83")         || EQUAL(osDatum,"NAD27") )    {        oSRS.SetWellKnownGeogCS( osDatum );    }    else if( EQUALN(osDatum,"NAD27",5) )    {        oSRS.SetWellKnownGeogCS( "NAD27" );    }    else
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:67,


示例20: OGRParseRFC822DateTime

int OGRParseRFC822DateTime( const char* pszRFC822DateTime,                                  int *pnYear, int *pnMonth, int *pnDay,                                  int *pnHour, int *pnMinute, int *pnSecond, int *pnTZ){    /* Following http://asg.web.cmu.edu/rfc/rfc822.html#sec-5 : [Fri,] 28 Dec 2007 05:24[:17] GMT */    char** papszTokens = CSLTokenizeStringComplex( pszRFC822DateTime, " ,:", TRUE, FALSE );    char** papszVal = papszTokens;    int bRet = FALSE;    int nTokens = CSLCount(papszTokens);    if (nTokens >= 6)    {        if ( ! ((*papszVal)[0] >= '0' && (*papszVal)[0] <= '9') )        {            /* Ignore day of week */            papszVal ++;        }        int day = atoi(*papszVal);        papszVal ++;        int month = 0;        for(int i = 0; i < 12; i++)        {            if (EQUAL(*papszVal, aszMonthStr[i]))                month = i + 1;        }        papszVal ++;        int year = atoi(*papszVal);        papszVal ++;        if( year < 100 && year >= 30 )            year += 1900;        else if( year < 30 && year >= 0 )            year += 2000;        int hour = atoi(*papszVal);        papszVal ++;        int minute = atoi(*papszVal);        papszVal ++;        int second = 0;        if (*papszVal != NULL && (*papszVal)[0] >= '0' && (*papszVal)[0] <= '9')        {            second = atoi(*papszVal);            papszVal ++;        }        if (month != 0)        {            bRet = TRUE;            int TZ = 0;            if (*papszVal == NULL)            {            }            else if (strlen(*papszVal) == 5 &&                     ((*papszVal)[0] == '+' || (*papszVal)[0] == '-'))            {                char szBuf[3];                szBuf[0] = (*papszVal)[1];                szBuf[1] = (*papszVal)[2];                szBuf[2] = 0;                int TZHour = atoi(szBuf);                szBuf[0] = (*papszVal)[3];                szBuf[1] = (*papszVal)[4];                szBuf[2] = 0;                int TZMinute = atoi(szBuf);                TZ = 100 + (((*papszVal)[0] == '+') ? 1 : -1) * ((TZHour * 60 + TZMinute) / 15);            }            else            {                const char* aszTZStr[] = { "GMT", "UT", "Z", "EST", "EDT", "CST", "CDT", "MST", "MDT", "PST", "PDT" };                int anTZVal[] = { 0, 0, 0, -5, -4, -6, -5, -7, -6, -8, -7 };                for(int i = 0; i < 11; i++)                {                    if (EQUAL(*papszVal, aszTZStr[i]))                    {                        TZ =  100 + anTZVal[i] * 4;                        break;                    }                }            }            if (pnYear) *pnYear = year;            if (pnMonth) *pnMonth = month;            if (pnDay) *pnDay = day;            if (pnHour) *pnHour = hour;            if (pnMinute) *pnMinute = minute;            if (pnSecond) *pnSecond = second;            if (pnTZ) *pnTZ = TZ;        }    }    CSLDestroy(papszTokens);    return bRet;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:97,


示例21: 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,


示例22: return

char *GXFGetMapProjectionAsOGCWKT( GXFHandle hGXF ){    GXFInfo_t	*psGXF = (GXFInfo_t *) hGXF;    char	**papszMethods = NULL;    char	szWKT[1024];    char	szGCS[512];    char	szProjection[512];/* -------------------------------------------------------------------- *//*      If there was nothing in the file return "unknown".              *//* -------------------------------------------------------------------- */    if( CSLCount(psGXF->papszMapProjection) < 2 )        return( CPLStrdup( "" ) );    strcpy( szWKT, "" );    strcpy( szGCS, "" );    strcpy( szProjection, "" );/* -------------------------------------------------------------------- *//*      Parse the third line, looking for known projection methods.     *//* -------------------------------------------------------------------- */    if( psGXF->papszMapProjection[2] != NULL )    {        /* We allow more than 80 characters if the projection parameters */        /* are on 2 lines as allowed by GXF 3 */        if( strlen(psGXF->papszMapProjection[2]) > 120 )            return( CPLStrdup( "" ) );        papszMethods = CSLTokenizeStringComplex(psGXF->papszMapProjection[2],                                                ",", TRUE, TRUE );    }#ifdef DBMALLOC    malloc_chain_check(1);#endif/* -------------------------------------------------------------------- *//*      Create the PROJCS.                                              *//* -------------------------------------------------------------------- */    if( papszMethods == NULL        || papszMethods[0] == NULL        || EQUAL(papszMethods[0],"Geographic") )    {        /* do nothing */    }    else if( EQUAL(papszMethods[0],"Lambert Conic Conformal (1SP)") )    {        OGCWKTSetProj( szProjection, sizeof(szProjection), papszMethods,                       SRS_PT_LAMBERT_CONFORMAL_CONIC_1SP,                       SRS_PP_LATITUDE_OF_ORIGIN,                       SRS_PP_CENTRAL_MERIDIAN,                       SRS_PP_SCALE_FACTOR,                       SRS_PP_FALSE_EASTING,                       SRS_PP_FALSE_NORTHING,                       NULL,                       NULL );    }    else if( EQUAL(papszMethods[0],"Lambert Conic Conformal (2SP)") )    {        OGCWKTSetProj( szProjection, sizeof(szProjection), papszMethods,                       SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP,                       SRS_PP_STANDARD_PARALLEL_1,                       SRS_PP_STANDARD_PARALLEL_2,                       SRS_PP_LATITUDE_OF_ORIGIN,                       SRS_PP_CENTRAL_MERIDIAN,                       SRS_PP_FALSE_EASTING,                       SRS_PP_FALSE_NORTHING,                       NULL );    }    else if( EQUAL(papszMethods[0],"Lambert Conformal (2SP Belgium)") )    {        OGCWKTSetProj( szProjection, sizeof(szProjection), papszMethods,                       SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP_BELGIUM,                       SRS_PP_STANDARD_PARALLEL_1,                       SRS_PP_STANDARD_PARALLEL_2,                       SRS_PP_LATITUDE_OF_ORIGIN,                       SRS_PP_CENTRAL_MERIDIAN,                       SRS_PP_FALSE_EASTING,                       SRS_PP_FALSE_NORTHING,                       NULL );    }    else if( EQUAL(papszMethods[0],"Mercator (1SP)"))    {        OGCWKTSetProj( szProjection, sizeof(szProjection), papszMethods,                       SRS_PT_MERCATOR_1SP,                       SRS_PP_LATITUDE_OF_ORIGIN,                       SRS_PP_CENTRAL_MERIDIAN,                       SRS_PP_SCALE_FACTOR,                       SRS_PP_FALSE_EASTING,                       SRS_PP_FALSE_NORTHING,                       NULL,                       NULL );    }    else if( EQUAL(papszMethods[0],"Mercator (2SP)"))    {//.........这里部分代码省略.........
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,


示例23: RasterliteCreateCopy

GDALDataset *RasterliteCreateCopy( const char * pszFilename, GDALDataset *poSrcDS,                        int bStrict, char ** papszOptions,                        GDALProgressFunc pfnProgress, void * pProgressData ){    int nBands = poSrcDS->GetRasterCount();    if (nBands == 0)    {        CPLError(CE_Failure, CPLE_NotSupported, "nBands == 0");        return NULL;    }        const char* pszDriverName = CSLFetchNameValueDef(papszOptions, "DRIVER", "GTiff");    GDALDriverH hTileDriver = GDALGetDriverByName(pszDriverName);    if ( hTileDriver == NULL)    {        CPLError(CE_Failure, CPLE_AppDefined, "Cannot load GDAL %s driver", pszDriverName);        return NULL;    }        GDALDriverH hMemDriver = GDALGetDriverByName("MEM");    if (hMemDriver == NULL)    {        CPLError(CE_Failure, CPLE_AppDefined, "Cannot load GDAL MEM driver");        return NULL;    }       int nXSize = GDALGetRasterXSize(poSrcDS);    int nYSize = GDALGetRasterYSize(poSrcDS);        double adfGeoTransform[6];    if (poSrcDS->GetGeoTransform(adfGeoTransform) != CE_None)    {        adfGeoTransform[0] = 0;        adfGeoTransform[1] = 1;        adfGeoTransform[2] = 0;        adfGeoTransform[3] = 0;        adfGeoTransform[4] = 0;        adfGeoTransform[5] = -1;    }    else if (adfGeoTransform[2] != 0.0 || adfGeoTransform[4] != 0.0)    {        CPLError(CE_Failure, CPLE_AppDefined, "Cannot use geotransform with rotational terms");        return NULL;    }    int bTiled = CSLTestBoolean(CSLFetchNameValueDef(papszOptions, "TILED", "YES"));    int nBlockXSize, nBlockYSize;    if (bTiled)    {        nBlockXSize = atoi(CSLFetchNameValueDef(papszOptions, "BLOCKXSIZE", "256"));        nBlockYSize = atoi(CSLFetchNameValueDef(papszOptions, "BLOCKYSIZE", "256"));        if (nBlockXSize < 64) nBlockXSize = 64;        else if (nBlockXSize > 4096)  nBlockXSize = 4096;        if (nBlockYSize < 64) nBlockYSize = 64;        else if (nBlockYSize > 4096)  nBlockYSize = 4096;    }    else    {        nBlockXSize = nXSize;        nBlockYSize = nYSize;    }    /* -------------------------------------------------------------------- *//*      Analyze arguments                                               *//* -------------------------------------------------------------------- */        CPLString osDBName;    CPLString osTableName;    VSIStatBuf sBuf;    int bExists;    /* Skip optionnal RASTERLITE: prefix */    const char* pszFilenameWithoutPrefix = pszFilename;    if (EQUALN(pszFilename, "RASTERLITE:", 11))        pszFilenameWithoutPrefix += 11;        char** papszTokens = CSLTokenizeStringComplex(                 pszFilenameWithoutPrefix, ", ", FALSE, FALSE );    int nTokens = CSLCount(papszTokens);    if (nTokens == 0)    {        osDBName = pszFilenameWithoutPrefix;        osTableName = CPLGetBasename(pszFilenameWithoutPrefix);    }    else    {        osDBName = papszTokens[0];                int i;        for(i=1;i<nTokens;i++)        {            if (EQUALN(papszTokens[i], "table=", 6))                osTableName = papszTokens[i] + 6;            else            {                CPLError(CE_Warning, CPLE_AppDefined,                         "Invalid option : %s", papszTokens[i]);            }        }//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,


示例24: CPLCalloc

void PAuxDataset::ScanForGCPs(){    static const int MAX_GCP = 256;    nGCPCount = 0;    pasGCPList = reinterpret_cast<GDAL_GCP *>(        CPLCalloc( sizeof(GDAL_GCP), MAX_GCP ) );/* -------------------------------------------------------------------- *//*      Get the GCP coordinate system.                                  *//* -------------------------------------------------------------------- */    const char *pszMapUnits = CSLFetchNameValue( papszAuxLines, "GCP_1_MapUnits" );    const char *pszProjParms = CSLFetchNameValue( papszAuxLines, "GCP_1_ProjParms" );    if( pszMapUnits != NULL )        pszGCPProjection = PCI2WKT( pszMapUnits, pszProjParms );/* -------------------------------------------------------------------- *//*      Collect standalone GCPs.  They look like:                       *//*                                                                      *//*      GCP_1_n = row, col, x, y [,z [,"id"[, "desc"]]]                 *//* -------------------------------------------------------------------- */    for( int i = 0; nGCPCount < MAX_GCP; i++ )    {        char szName[50];        snprintf( szName, sizeof(szName), "GCP_1_%d", i+1 );        if( CSLFetchNameValue( papszAuxLines, szName ) == NULL )            break;        char **papszTokens = CSLTokenizeStringComplex(            CSLFetchNameValue( papszAuxLines, szName ),            " ", TRUE, FALSE );        if( CSLCount(papszTokens) >= 4 )        {            GDALInitGCPs( 1, pasGCPList + nGCPCount );            pasGCPList[nGCPCount].dfGCPX = CPLAtof(papszTokens[2]);            pasGCPList[nGCPCount].dfGCPY = CPLAtof(papszTokens[3]);            pasGCPList[nGCPCount].dfGCPPixel = CPLAtof(papszTokens[0]);            pasGCPList[nGCPCount].dfGCPLine = CPLAtof(papszTokens[1]);            if( CSLCount(papszTokens) > 4 )                pasGCPList[nGCPCount].dfGCPZ = CPLAtof(papszTokens[4]);            CPLFree( pasGCPList[nGCPCount].pszId );            if( CSLCount(papszTokens) > 5 )            {                pasGCPList[nGCPCount].pszId = CPLStrdup(papszTokens[5]);            }            else            {                snprintf( szName, sizeof(szName), "GCP_%d", i+1 );                pasGCPList[nGCPCount].pszId = CPLStrdup( szName );            }            if( CSLCount(papszTokens) > 6 )            {                CPLFree( pasGCPList[nGCPCount].pszInfo );                pasGCPList[nGCPCount].pszInfo = CPLStrdup(papszTokens[6]);            }            nGCPCount++;        }        CSLDestroy(papszTokens);    }}
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:69,


示例25: CSLTokenizeStringComplex

GDALDataset *SDEDataset::Open( GDALOpenInfo * poOpenInfo ){/* -------------------------------------------------------------------- *//*      If we aren't prefixed with SDE: then ignore this datasource.    *//* -------------------------------------------------------------------- */    if( !STARTS_WITH_CI(poOpenInfo->pszFilename, "SDE:") )        return NULL;/* -------------------------------------------------------------------- *//*      Parse arguments on comma.  We expect (layer is optional):       *//*        SDE:server,instance,database,username,password,layer          *//* -------------------------------------------------------------------- */    char **papszTokens = CSLTokenizeStringComplex(  poOpenInfo->pszFilename+4,                                                    ",",                                                    TRUE,                                                    TRUE );    CPLDebug(   "SDERASTER", "Open(/"%s/") revealed %d tokens.",                poOpenInfo->pszFilename,                CSLCount( papszTokens ) );    if( CSLCount( papszTokens ) < 5 || CSLCount( papszTokens ) > 7 )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "SDE connect string had wrong number of arguments./n"                  "Expected 'SDE:server,instance,database,username,password,layer'/n"                  "The layer name value is optional./n"                  "Got '%s'",                  poOpenInfo->pszFilename );        return NULL;    }/* -------------------------------------------------------------------- *//*      Create a corresponding GDALDataset.                             *//* -------------------------------------------------------------------- */    SDEDataset *poDS;    poDS = new SDEDataset();/* -------------------------------------------------------------------- *//*      Try to establish connection.                                    *//* -------------------------------------------------------------------- */    int         nSDEErr;    SE_ERROR    hSDEErrorInfo;    nSDEErr = SE_connection_create( papszTokens[0],                                    papszTokens[1],                                    papszTokens[2],                                    papszTokens[3],                                    papszTokens[4],                                    &(hSDEErrorInfo),                                    &(poDS->hConnection) );    if( nSDEErr != SE_SUCCESS )    {        IssueSDEError( nSDEErr, "SE_connection_create" );        return NULL;    }/* -------------------------------------------------------------------- *//*      Set unprotected concurrency policy, suitable for single         *//*      threaded access.                                                *//* -------------------------------------------------------------------- */    nSDEErr = SE_connection_set_concurrency( poDS->hConnection,                                             SE_UNPROTECTED_POLICY);    if( nSDEErr != SE_SUCCESS) {        IssueSDEError( nSDEErr, NULL );        return NULL;    }/* -------------------------------------------------------------------- *//*      If we were given a layer name, use that directly, otherwise     *//*      query for subdatasets.                                          *//* -------------------------------------------------------------------- */    // Get the RASTER column name if it was set    if (CSLCount (papszTokens) == 7) {        poDS->pszColumnName = CPLStrdup( papszTokens[6] );    }    else {        poDS->pszColumnName = CPLStrdup( "RASTER" );    }    CPLDebug ("SDERASTER", "SDE Column name is '%s'", poDS->pszColumnName);    if (CSLCount( papszTokens ) >= 6 ) {        poDS->pszLayerName = CPLStrdup( papszTokens[5] );        nSDEErr =   SE_rascolinfo_create  (&(poDS->hRasterColumn));        if( nSDEErr != SE_SUCCESS )        {            IssueSDEError( nSDEErr, "SE_rastercolumn_create" );            return NULL;        }        CPLDebug( "SDERASTER", "'%s' raster layer specified... "/                               "using it directly with '%s' as the raster column name.",//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,


示例26: CPLGetExtension

void BSBDataset::ScanForGCPsNos( const char *pszFilename ){    char **Tokens;    const char *geofile;    const char *extension;    int fileGCPCount=0;    extension = CPLGetExtension(pszFilename);    // pseudointelligently try and guess whether we want a .geo or a .GEO    if (extension[1] == 'O')    {        geofile = CPLResetExtension( pszFilename, "GEO");    } else {        geofile = CPLResetExtension( pszFilename, "geo");    }    FILE *gfp = VSIFOpen( geofile, "r" );  // Text files    if( gfp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Couldn't find a matching .GEO file: %s", geofile );        return;    }    char *thisLine = (char *) CPLMalloc( 80 ); // FIXME    // Count the GCPs (reference points) and seek the file pointer 'gfp' to the starting point    while (fgets(thisLine, 80, gfp))    {        if( EQUALN(thisLine, "Point", 5) )            fileGCPCount++;    }    VSIRewind( gfp );    // Memory has not been allocated to fileGCPCount yet    pasGCPList = (GDAL_GCP *) CPLCalloc(sizeof(GDAL_GCP),fileGCPCount+1);    while (fgets(thisLine, 80, gfp))    {        if( EQUALN(thisLine, "Point", 5) )        {            // got a point line, turn it into a gcp            Tokens = CSLTokenizeStringComplex(thisLine, "= ", FALSE, FALSE);            if (CSLCount(Tokens) >= 5)            {                GDALInitGCPs( 1, pasGCPList + nGCPCount );                pasGCPList[nGCPCount].dfGCPX = atof(Tokens[1]);                pasGCPList[nGCPCount].dfGCPY = atof(Tokens[2]);                pasGCPList[nGCPCount].dfGCPPixel = atof(Tokens[4]);                pasGCPList[nGCPCount].dfGCPLine = atof(Tokens[3]);                CPLFree( pasGCPList[nGCPCount].pszId );                char	szName[50];                sprintf( szName, "GCP_%d", nGCPCount+1 );                pasGCPList[nGCPCount].pszId = CPLStrdup( szName );                nGCPCount++;            }            CSLDestroy(Tokens);        }    }    CPLFree(thisLine);    VSIFClose(gfp);}
开发者ID:samalone,项目名称:gdal-ios,代码行数:66,


示例27: GDALWriteRPCTXTFile

CPLErr GDALWriteRPCTXTFile( const char *pszFilename, char **papszMD ){    CPLString osRPCFilename = pszFilename;    CPLString soPt(".");    size_t found = osRPCFilename.rfind(soPt);    if (found == CPLString::npos)        return CE_Failure;    osRPCFilename.replace (found, osRPCFilename.size() - found, "_RPC.TXT");/* -------------------------------------------------------------------- *//*      Read file and parse.                                            *//* -------------------------------------------------------------------- */    VSILFILE *fp = VSIFOpenL( osRPCFilename, "w" );    if( fp == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "Unable to create %s for writing./n%s",                  osRPCFilename.c_str(), CPLGetLastErrorMsg() );        return CE_Failure;    }/* -------------------------------------------------------------------- *//*      Write RPC values from our RPC metadata.                         *//* -------------------------------------------------------------------- */    int i;    for( i = 0; apszRPCTXTSingleValItems[i] != NULL; i ++ )    {        const char *pszRPCVal = CSLFetchNameValue( papszMD, apszRPCTXTSingleValItems[i] );        if( pszRPCVal == NULL )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s field missing in metadata, %s file not written.",                      apszRPCTXTSingleValItems[i], osRPCFilename.c_str() );            VSIFCloseL( fp );            VSIUnlink( osRPCFilename );            return CE_Failure;        }        VSIFPrintfL( fp, "%s: %s/n", apszRPCTXTSingleValItems[i], pszRPCVal );    }    for( i = 0; apszRPCTXT20ValItems[i] != NULL; i ++ )    {        const char *pszRPCVal = CSLFetchNameValue( papszMD, apszRPCTXT20ValItems[i] );        if( pszRPCVal == NULL )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s field missing in metadata, %s file not written.",                      apszRPCTXTSingleValItems[i], osRPCFilename.c_str() );            VSIFCloseL( fp );            VSIUnlink( osRPCFilename );            return CE_Failure;        }        char **papszItems = CSLTokenizeStringComplex( pszRPCVal, " ,",                                                          FALSE, FALSE );        if( CSLCount(papszItems) != 20 )        {            CPLError( CE_Failure, CPLE_AppDefined,                      "%s field is corrupt (not 20 values), %s file not written./n%s = %s",                      apszRPCTXT20ValItems[i], osRPCFilename.c_str(),                      apszRPCTXT20ValItems[i], pszRPCVal );            VSIFCloseL( fp );            VSIUnlink( osRPCFilename );            CSLDestroy( papszItems );            return CE_Failure;        }        int j;        for( j = 0; j < 20; j++ )        {            VSIFPrintfL( fp, "%s_%d: %s/n", apszRPCTXT20ValItems[i], j+1,                         papszItems[j] );        }        CSLDestroy( papszItems );    }    VSIFCloseL( fp );    return CE_None;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:88,


示例28: CPLAssert

int OGRIngresDataSource::Open( const char *pszFullName,                                char **papszOptions, int bUpdate ){    CPLAssert( nLayers == 0 );   #define MAX_TARGET_STRING_LENGTH 512    char pszDBTarget[MAX_TARGET_STRING_LENGTH];/* -------------------------------------------------------------------- *//*      Verify we have a dbname, this parameter is required.            *//* -------------------------------------------------------------------- */    const char *pszDBName = CSLFetchNameValue(papszOptions,"dbname");    if( pszDBName == NULL )    {        CPLError( CE_Failure, CPLE_OpenFailed,                  "No DBNAME item provided in INGRES datasource name." );        return FALSE;    }/* -------------------------------------------------------------------- *//*      Do we have a table list?                                        *//* -------------------------------------------------------------------- */    char **papszTableNames = NULL;    const char *pszTables = CSLFetchNameValue(papszOptions,"tables");    if( pszTables != NULL )        papszTableNames = CSLTokenizeStringComplex(pszTables,"/",TRUE,FALSE);   /* -------------------------------------------------------------------- *//*      Add support to dynamic vnode if passed                          *//* -------------------------------------------------------------------- */    const char *pszHost = CSLFetchNameValue(papszOptions,"host");    if (pszHost)    {        const char *pszInstance = CSLFetchNameValue(papszOptions,"instance");        if (pszInstance == NULL || strlen(pszInstance) != 2)        {            CPLError( CE_Failure, CPLE_OpenFailed,                  "instance name must be specified with host." );            return FALSE;        }                /*         ** make sure the user name and password are passed too,        ** note it could not be zero length.        */         const char *pszUsername = CSLFetchNameValue(papszOptions,"username");        const char *pszPassword = CSLFetchNameValue(papszOptions,"password");                if (pszUsername == NULL || strlen(pszUsername) == 0)        {            CPLError( CE_Failure, CPLE_OpenFailed,                  "user name must be specified in dynamic vnode." );                        return FALSE;        }                if (pszPassword == NULL || strlen(pszPassword) == 0)        {            CPLError( CE_Failure, CPLE_OpenFailed,                  "password must be specified in dynamic vnode." );                        return FALSE;        }                /*         ** construct the vnode string, like :         ** @host,protocol,port[;attribute=value{;attribute=value}][[user,password]],         ** visit for detail         ** http://docs.actian.com/ingres/10.0/command-reference-guide/1207-dynamic-vnode-specificationconnect-to-remote-node        */        sprintf(pszDBTarget, "@%s,%s,%s;%s[%s,%s]::%s ",             pszHost,        /* host, compute name or IP address */            "TCP_IP",       /* protocal, default with TCP/IP */            pszInstance,    /* instance Name */            "" ,            /* option, Null */            pszUsername,    /* user name, could not be empty */            pszPassword,    /* pwd */            pszDBName       /* database name */            );               CPLDebug("INGRES", pszDBTarget);    }    else    {        /* Remain the database name */        strcpy(pszDBTarget, pszDBName);    }    /* -------------------------------------------------------------------- *//*      Initialize the Ingres API. Should we only do this once per      *//*      program run?  Really we should also try to terminate the api    *//*      on program exit.                                                *//* -------------------------------------------------------------------- */    IIAPI_INITPARM  initParm;    initParm.in_version = IIAPI_VERSION_1;     initParm.in_timeout = -1;    IIapi_initialize( &initParm );//.........这里部分代码省略.........
开发者ID:0004c,项目名称:node-gdal,代码行数:101,



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


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