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

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

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

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

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

示例1: while

int ILI1Reader::ReadTable(CPL_UNUSED const char *layername) {    char **tokens = NULL;    int ret = TRUE;    int warned = FALSE;    int geomIdx = -1;    OGRFeatureDefn *featureDef = curLayer->GetLayerDefn();    OGRFeature *feature = NULL;    bool bFeatureAdded = false;    while (ret && (tokens = ReadParseLine()) != NULL)    {      const char *firsttok = CSLGetField(tokens, 0);      if (EQUAL(firsttok, "OBJE"))      {        if (featureDef->GetFieldCount() == 0)        {          CPLError( CE_Warning, CPLE_AppDefined,                    "No field definition found for table: %s",                    featureDef->GetName() );          // Model not read - use heuristics.          for( int fIndex=1; fIndex<CSLCount(tokens); fIndex++ )          {            char szFieldName[32];            snprintf(szFieldName, sizeof(szFieldName), "Field%02d", fIndex);            OGRFieldDefn oFieldDefn(szFieldName, OFTString);            featureDef->AddFieldDefn(&oFieldDefn);          }        }        //start new feature        if( !bFeatureAdded )            delete feature;        feature = new OGRFeature(featureDef);        for( int fIndex=1, fieldno = 0;             fIndex<CSLCount(tokens) && fieldno < featureDef->GetFieldCount();             fIndex++, fieldno++ )        {          if (!(tokens[fIndex][0] == codeUndefined && tokens[fIndex][1] == '/0')) {#ifdef DEBUG_VERBOSE            CPLDebug( "READ TABLE OGR_ILI", "Setting Field %d (Type %d): %s",                      fieldno, featureDef->GetFieldDefn(fieldno)->GetType(),                      tokens[fIndex] );#endif            if (featureDef->GetFieldDefn(fieldno)->GetType() == OFTString) {                // Interlis 1 encoding is ISO 8859-1 (Latin1) -> Recode to UTF-8                char* pszRecoded = CPLRecode(                    tokens[fIndex], CPL_ENC_ISO8859_1, CPL_ENC_UTF8);                // Replace space marks                for( char* pszString = pszRecoded;                     *pszString != '/0';                     pszString++ ) {                    if (*pszString == codeBlank) *pszString = ' ';                }                feature->SetField(fieldno, pszRecoded);                CPLFree(pszRecoded);            } else {              feature->SetField(fieldno, tokens[fIndex]);            }            if (featureDef->GetFieldDefn(fieldno)->GetType() == OFTReal                && fieldno > 0                && featureDef->GetFieldDefn(fieldno-1)->GetType() == OFTReal) {              // Check for Point geometry (Coord type).              // If there is no ili model read,              // we have no chance to detect the              // geometry column.              CPLString geomfldname                  = featureDef->GetFieldDefn(fieldno)->GetNameRef();              // Check if name ends with _1.              if (geomfldname.size() >= 2 && geomfldname[geomfldname.size()-2]                  == '_') {                geomfldname = geomfldname.substr(0, geomfldname.size()-2);                geomIdx = featureDef->GetGeomFieldIndex(geomfldname.c_str());                if (geomIdx == -1)                {                  CPLError( CE_Warning, CPLE_AppDefined,                            "No matching definition for field '%s' of "                            "table %s found",                            geomfldname.c_str(), featureDef->GetName() );                }              } else {                geomIdx = -1;              }              if (geomIdx >= 0) {                if (featureDef->GetGeomFieldDefn(geomIdx)->GetType() ==                    wkbPoint) {                  // Add Point geometry.                  OGRPoint *ogrPoint = new OGRPoint(                      CPLAtof(tokens[fIndex-1]), CPLAtof(tokens[fIndex]));                  feature->SetGeomFieldDirectly(geomIdx, ogrPoint);                } else if (featureDef->GetGeomFieldDefn(geomIdx)->GetType() ==                           wkbPoint25D && fieldno > 1 &&                           featureDef->GetFieldDefn(fieldno-2)->GetType() ==                           OFTReal) {                  // Add 3D Point geometry.                  OGRPoint *ogrPoint = new OGRPoint(                      CPLAtof(tokens[fIndex-2]), CPLAtof(tokens[fIndex-1]),                      CPLAtof(tokens[fIndex]) );                  feature->SetGeomFieldDirectly(geomIdx, ogrPoint);                }//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,


示例2: CPLAssert

OGRErr OGRSpatialReference::exportToPanorama( long *piProjSys, long *piDatum,                                              long *piEllips, long *piZone,                                              double *padfPrjParams ) const{    CPLAssert( padfPrjParams );    const char  *pszProjection = GetAttrValue("PROJECTION");/* -------------------------------------------------------------------- *//*      Fill all projection parameters with zero.                       *//* -------------------------------------------------------------------- */    int     i;    *piDatum = 0L;    *piEllips = 0L;    *piZone = 0L;    for ( i = 0; i < 7; i++ )        padfPrjParams[i] = 0.0;/* ==================================================================== *//*      Handle the projection definition.                               *//* ==================================================================== */    if( IsLocal() )        *piProjSys = PAN_PROJ_NONE;    else if( pszProjection == NULL )    {#ifdef DEBUG        CPLDebug( "OSR_Panorama",                  "Empty projection definition, considered as Geographic" );#endif        *piProjSys = PAN_PROJ_NONE;    }    else if( EQUAL(pszProjection, SRS_PT_MERCATOR_1SP) )    {        *piProjSys = PAN_PROJ_MERCAT;        padfPrjParams[3] =            TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 );        padfPrjParams[0] =            TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 );        padfPrjParams[4] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 );        padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 );        padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 );    }    else if( EQUAL(pszProjection, SRS_PT_POLAR_STEREOGRAPHIC) )    {        *piProjSys = PAN_PROJ_PS;        padfPrjParams[3] =            TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 );        padfPrjParams[2] =            TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 );        padfPrjParams[4] = GetNormProjParm( SRS_PP_SCALE_FACTOR, 1.0 );        padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 );        padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 );    }    else if( EQUAL(pszProjection, SRS_PT_POLYCONIC) )    {        *piProjSys = PAN_PROJ_POLYC;        padfPrjParams[3] =            TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 );        padfPrjParams[2] =            TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 );        padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 );        padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 );    }    else if( EQUAL(pszProjection, SRS_PT_EQUIDISTANT_CONIC) )    {        *piProjSys = PAN_PROJ_EC;        padfPrjParams[0] =            TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 );        padfPrjParams[1] =            TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 );        padfPrjParams[3] =            TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 );        padfPrjParams[2] =            TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 );        padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 );        padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 );    }    else if( EQUAL(pszProjection, SRS_PT_LAMBERT_CONFORMAL_CONIC_2SP) )    {        *piProjSys = PAN_PROJ_LCC;        padfPrjParams[0] =            TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_1, 0.0 );        padfPrjParams[1] =            TO_RADIANS * GetNormProjParm( SRS_PP_STANDARD_PARALLEL_2, 0.0 );        padfPrjParams[3] =            TO_RADIANS * GetNormProjParm( SRS_PP_CENTRAL_MERIDIAN, 0.0 );        padfPrjParams[2] =            TO_RADIANS * GetNormProjParm( SRS_PP_LATITUDE_OF_ORIGIN, 0.0 );        padfPrjParams[5] = GetNormProjParm( SRS_PP_FALSE_EASTING, 0.0 );        padfPrjParams[6] = GetNormProjParm( SRS_PP_FALSE_NORTHING, 0.0 );    }//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,


示例3: RPCInverseTransformPoint

static void RPCInverseTransformPoint( GDALRPCTransformInfo *psTransform,                          double dfPixel, double dfLine, double dfHeight,                           double *pdfLong, double *pdfLat ){    double dfResultX, dfResultY;    int    iIter;    GDALRPCInfo *psRPC = &(psTransform->sRPC);/* -------------------------------------------------------------------- *//*      Compute an initial approximation based on linear                *//*      interpolation from our reference point.                         *//* -------------------------------------------------------------------- */    dfResultX = psTransform->adfPLToLatLongGeoTransform[0]        + psTransform->adfPLToLatLongGeoTransform[1] * dfPixel        + psTransform->adfPLToLatLongGeoTransform[2] * dfLine;    dfResultY = psTransform->adfPLToLatLongGeoTransform[3]        + psTransform->adfPLToLatLongGeoTransform[4] * dfPixel        + psTransform->adfPLToLatLongGeoTransform[5] * dfLine;/* -------------------------------------------------------------------- *//*      Now iterate, trying to find a closer LL location that will      *//*      back transform to the indicated pixel and line.                 *//* -------------------------------------------------------------------- */    double dfPixelDeltaX=0.0, dfPixelDeltaY=0.0;    for( iIter = 0; iIter < 10; iIter++ )    {        double dfBackPixel, dfBackLine;        RPCTransformPoint( psRPC, dfResultX, dfResultY, dfHeight,                            &dfBackPixel, &dfBackLine );        dfPixelDeltaX = dfBackPixel - dfPixel;        dfPixelDeltaY = dfBackLine - dfLine;        dfResultX = dfResultX             - dfPixelDeltaX * psTransform->adfPLToLatLongGeoTransform[1]            - dfPixelDeltaY * psTransform->adfPLToLatLongGeoTransform[2];        dfResultY = dfResultY             - dfPixelDeltaX * psTransform->adfPLToLatLongGeoTransform[4]            - dfPixelDeltaY * psTransform->adfPLToLatLongGeoTransform[5];        if( ABS(dfPixelDeltaX) < psTransform->dfPixErrThreshold            && ABS(dfPixelDeltaY) < psTransform->dfPixErrThreshold )        {            iIter = -1;            //CPLDebug( "RPC", "Converged!" );            break;        }    }    if( iIter != -1 )        CPLDebug( "RPC", "Iterations %d: Got: %g,%g  Offset=%g,%g",                   iIter,                   dfResultX, dfResultY,                  dfPixelDeltaX, dfPixelDeltaY );        *pdfLong = dfResultX;    *pdfLat = dfResultY;}
开发者ID:afarnham,项目名称:gdal,代码行数:64,


示例4: CPLFree

CPLErr OGRMSSQLSpatialTableLayer::Initialize( const char *pszSchema,                                              const char *pszLayerName,                                               const char *pszGeomCol,                                              int nCoordDimension,                                               int nSRId,                                              OGRwkbGeometryType eType ){    CPLODBCSession *poSession = poDS->GetSession();    CPLFree( pszFIDColumn );    pszFIDColumn = NULL;/* -------------------------------------------------------------------- *//*      Parse out schema name if present in layer.  We assume a         *//*      schema is provided if there is a dot in the name, and that      *//*      it is in the form <schema>.<tablename>                          *//* -------------------------------------------------------------------- */    const char *pszDot = strstr(pszLayerName,".");    if( pszDot != NULL )    {        pszTableName = CPLStrdup(pszDot + 1);        pszSchemaName = CPLStrdup(pszLayerName);        pszSchemaName[pszDot - pszLayerName] = '/0';    }    else    {        pszTableName = CPLStrdup(pszLayerName);        pszSchemaName = CPLStrdup(pszSchema);    }/* -------------------------------------------------------------------- *//*      Do we have a simple primary key?                                *//* -------------------------------------------------------------------- */    CPLODBCStatement oGetKey( poSession );        if( oGetKey.GetPrimaryKeys( pszTableName, poDS->GetCatalog(), pszSchemaName )         && oGetKey.Fetch() )    {        pszFIDColumn = CPLStrdup(oGetKey.GetColData( 3 ));                if( oGetKey.Fetch() ) // more than one field in key!         {            CPLFree( pszFIDColumn );            pszFIDColumn = NULL;            CPLDebug( "OGR_MSSQLSpatial", "Table %s has multiple primary key fields, "                      "ignoring them all.", pszTableName );        }    }/* -------------------------------------------------------------------- *//*      Have we been provided a geometry column?                        *//* -------------------------------------------------------------------- */    CPLFree( pszGeomColumn );    if( pszGeomCol == NULL )        pszGeomColumn = NULL;    else        pszGeomColumn = CPLStrdup( pszGeomCol );/* -------------------------------------------------------------------- *//*      Get the column definitions for this table.                      *//* -------------------------------------------------------------------- */    CPLODBCStatement oGetCol( poSession );    CPLErr eErr;    if( !oGetCol.GetColumns( pszTableName, poDS->GetCatalog(), pszSchemaName ) )        return CE_Failure;    eErr = BuildFeatureDefn( pszLayerName, &oGetCol );    if( eErr != CE_None )        return eErr;            poFeatureDefn->SetGeomType(eType);    if( poFeatureDefn->GetFieldCount() == 0 &&        pszFIDColumn == NULL && pszGeomColumn == NULL )    {        CPLError( CE_Failure, CPLE_AppDefined,                   "No column definitions found for table '%s', layer not usable.",                   pszLayerName );        return CE_Failure;    }        /* -------------------------------------------------------------------- *//*      If we got a geometry column, does it exist?  Is it binary?      *//* -------------------------------------------------------------------- */    if( pszGeomColumn != NULL )    {        int iColumn = oGetCol.GetColId( pszGeomColumn );        if( iColumn < 0 )        {            CPLError( CE_Failure, CPLE_AppDefined,                       "Column %s requested for geometry, but it does not exist.",                       pszGeomColumn );            CPLFree( pszGeomColumn );            pszGeomColumn = NULL;        }        else        {//.........这里部分代码省略.........
开发者ID:agrismart,项目名称:gdal-1.9.2,代码行数:101,


示例5: CPLDebug

GvData *gv_shapes_from_ogr_layer(void *ogr_layer){    CPLDebug( "OpenEV", "gv_shapes_from_ogr_layer() called, "              "but OGR not configured" );    return NULL;}
开发者ID:midendian,项目名称:openev2,代码行数:6,


示例6: AcquireMutex

size_t VSICurlStreamingHandle::Read( void *pBuffer, size_t nSize, size_t nMemb ){    GByte* pabyBuffer = (GByte*)pBuffer;    size_t nBufferRequestSize = nSize * nMemb;    if (nBufferRequestSize == 0)        return 0;    size_t nRemaining = nBufferRequestSize;    AcquireMutex();    int bHastComputedFileSizeLocal = bHastComputedFileSize;    vsi_l_offset fileSizeLocal = fileSize;    ReleaseMutex();    if (bHastComputedFileSizeLocal && curOffset >= fileSizeLocal)    {        CPLDebug("VSICURL", "Read attempt beyond end of file");        bEOF = TRUE;    }    if (bEOF)        return 0;    if (curOffset < nRingBufferFileOffset)        PutRingBufferInCache();    if (ENABLE_DEBUG)        CPLDebug("VSICURL", "Read [" CPL_FRMT_GUIB ", " CPL_FRMT_GUIB "[ in %s",                 curOffset, curOffset + nBufferRequestSize, pszURL);#ifdef notdef    if( pCachedData != NULL && nCachedSize >= 1024 &&        nRecomputedChecksumOfFirst1024Bytes == 0 )    {        for(size_t i = 0; i < 1024 / sizeof(int); i ++)        {            int nVal;            memcpy(&nVal, pCachedData + i * sizeof(int), sizeof(int));            nRecomputedChecksumOfFirst1024Bytes += nVal;        }        if( bHastComputedFileSizeLocal )        {            poFS->AcquireMutex();            CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(pszURL);            if( cachedFileProp->nChecksumOfFirst1024Bytes == 0 )            {                cachedFileProp->nChecksumOfFirst1024Bytes = nRecomputedChecksumOfFirst1024Bytes;            }            else if( nRecomputedChecksumOfFirst1024Bytes != cachedFileProp->nChecksumOfFirst1024Bytes )            {                CPLDebug("VSICURL", "Invalidating previously cached file size. First bytes of file have changed!");                AcquireMutex();                bHastComputedFileSize = FALSE;                cachedFileProp->bHastComputedFileSize = FALSE;                cachedFileProp->nChecksumOfFirst1024Bytes = 0;                ReleaseMutex();            }            poFS->ReleaseMutex();        }    }#endif    /* Can we use the cache ? */    if( pCachedData != NULL && curOffset < nCachedSize )    {        size_t nSz = MIN(nRemaining, (size_t)(nCachedSize - curOffset));        if (ENABLE_DEBUG)            CPLDebug("VSICURL", "Using cache for [%d, %d[ in %s",                     (int)curOffset, (int)(curOffset + nSz), pszURL);        memcpy(pabyBuffer, pCachedData + curOffset, nSz);        pabyBuffer += nSz;        curOffset += nSz;        nRemaining -= nSz;    }    /* Is the request partially covered by the cache and going beyond file size ? */    if ( pCachedData != NULL && bHastComputedFileSizeLocal &&         curOffset <= nCachedSize &&         curOffset + nRemaining > fileSizeLocal &&         fileSize == nCachedSize )    {        size_t nSz = (size_t) (nCachedSize - curOffset);        if (ENABLE_DEBUG && nSz != 0)            CPLDebug("VSICURL", "Using cache for [%d, %d[ in %s",                    (int)curOffset, (int)(curOffset + nSz), pszURL);        memcpy(pabyBuffer, pCachedData + curOffset, nSz);        pabyBuffer += nSz;        curOffset += nSz;        nRemaining -= nSz;        bEOF = TRUE;    }    /* Has a Seek() being done since the last Read() ? */    if (!bEOF && nRemaining > 0 && curOffset != nRingBufferFileOffset)    {        /* Backward seek : we need to restart the download from the start */        if (curOffset < nRingBufferFileOffset)            StopDownload();        StartDownload();//.........这里部分代码省略.........
开发者ID:0004c,项目名称:node-gdal,代码行数:101,


示例7: CPLDebug

int VSICurlStreamingHandle::ReceivedBytes(GByte *buffer, size_t count, size_t nmemb){    size_t nSize = count * nmemb;    nBodySize += nSize;    if (ENABLE_DEBUG)        CPLDebug("VSICURL", "Receiving %d bytes...", (int)nSize);    if( bHasCandidateFileSize && bCanTrustCandidateFileSize && !bHastComputedFileSize )    {        poFS->AcquireMutex();        CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(pszURL);        cachedFileProp->fileSize = fileSize = nCandidateFileSize;        cachedFileProp->bHastComputedFileSize = bHastComputedFileSize = TRUE;        if (ENABLE_DEBUG)            CPLDebug("VSICURL", "File size = " CPL_FRMT_GUIB, fileSize);        poFS->ReleaseMutex();    }    AcquireMutex();    if (eExists == EXIST_UNKNOWN)    {        poFS->AcquireMutex();        CachedFileProp* cachedFileProp = poFS->GetCachedFileProp(pszURL);        cachedFileProp->eExists = eExists = EXIST_YES;        poFS->ReleaseMutex();    }    else if (eExists == EXIST_NO)    {        ReleaseMutex();        return 0;    }    while(TRUE)    {        size_t nFree = oRingBuffer.GetCapacity() - oRingBuffer.GetSize();        if (nSize <= nFree)        {            oRingBuffer.Write(buffer, nSize);            /* Signal to the consumer that we have added bytes to the buffer */            CPLCondSignal(hCondProducer);            if (bAskDownloadEnd)            {                if (ENABLE_DEBUG)                    CPLDebug("VSICURL", "Download interruption asked");                ReleaseMutex();                return 0;            }            break;        }        else        {            oRingBuffer.Write(buffer, nFree);            buffer += nFree;            nSize -= nFree;            /* Signal to the consumer that we have added bytes to the buffer */            CPLCondSignal(hCondProducer);            if (ENABLE_DEBUG)                CPLDebug("VSICURL", "Waiting for reader to consume some bytes...");            while(oRingBuffer.GetSize() == oRingBuffer.GetCapacity() && !bAskDownloadEnd)            {                CPLCondWait(hCondConsumer, hRingBufferMutex);            }            if (bAskDownloadEnd)            {                if (ENABLE_DEBUG)                    CPLDebug("VSICURL", "Download interruption asked");                ReleaseMutex();                return 0;            }        }    }    ReleaseMutex();    return nmemb;}
开发者ID:0004c,项目名称:node-gdal,代码行数:85,


示例8: strstr

//.........这里部分代码省略.........    /***********   Grab SEMI-MAJOR ************/    semi_major =         atof(poDS->GetKeyword( "QUBE.IMAGE_MAP_PROJECTION.A_AXIS_RADIUS")) * 1000.0;    /***********   Grab semi-minor ************/    semi_minor =         atof(poDS->GetKeyword( "QUBE.IMAGE_MAP_PROJECTION.C_AXIS_RADIUS")) * 1000.0;    /***********   Grab CENTER_LAT ************/    center_lat =         atof(poDS->GetKeyword( "QUBE.IMAGE_MAP_PROJECTION.CENTER_LATITUDE"));    /***********   Grab CENTER_LON ************/    center_lon =         atof(poDS->GetKeyword( "QUBE.IMAGE_MAP_PROJECTION.CENTER_LONGITUDE"));    /***********   Grab 1st std parallel ************/    first_std_parallel =         atof(poDS->GetKeyword( "QUBE.IMAGE_MAP_PROJECTION.FIRST_STANDARD_PARALLEL"));    /***********   Grab 2nd std parallel ************/    second_std_parallel =         atof(poDS->GetKeyword( "QUBE.IMAGE_MAP_PROJECTION.SECOND_STANDARD_PARALLEL"));         /*** grab  PROJECTION_LATITUDE_TYPE = "PLANETOCENTRIC" ****/    // Need to further study how ocentric/ographic will effect the gdal library.    // So far we will use this fact to define a sphere or ellipse for some projections    // Frank - may need to talk this over    char bIsGeographic = TRUE;    value = poDS->GetKeyword("CUBE.IMAGE_MAP_PROJECTION.PROJECTION_LATITUDE_TYPE");    if (EQUAL( value, "/"PLANETOCENTRIC/"" ))        bIsGeographic = FALSE;          CPLDebug("ISIS2","using projection %s", map_proj_name.c_str() );    //Set oSRS projection and parameters    if ((EQUAL( map_proj_name, "EQUIRECTANGULAR_CYLINDRICAL" )) ||        (EQUAL( map_proj_name, "EQUIRECTANGULAR" )) ||        (EQUAL( map_proj_name, "SIMPLE_CYLINDRICAL" )) ) {        oSRS.OGRSpatialReference::SetEquirectangular2 ( 0.0, center_lon, center_lat, 0, 0 );    } else if (EQUAL( map_proj_name, "ORTHOGRAPHIC" )) {         oSRS.OGRSpatialReference::SetOrthographic ( center_lat, center_lon, 0, 0 );    } else if ((EQUAL( map_proj_name, "SINUSOIDAL" )) ||               (EQUAL( map_proj_name, "SINUSOIDAL_EQUAL-AREA" ))) {        oSRS.OGRSpatialReference::SetSinusoidal ( center_lon, 0, 0 );    } else if (EQUAL( map_proj_name, "MERCATOR" )) {        oSRS.OGRSpatialReference::SetMercator ( center_lat, center_lon, 1, 0, 0 );    } else if (EQUAL( map_proj_name, "POLAR_STEREOGRAPHIC" )) {        oSRS.OGRSpatialReference::SetPS ( center_lat, center_lon, 1, 0, 0 );    } else if (EQUAL( map_proj_name, "TRANSVERSE_MERCATOR" )) {        oSRS.OGRSpatialReference::SetTM ( center_lat, center_lon, 1, 0, 0 );    } else if (EQUAL( map_proj_name, "LAMBERT_CONFORMAL_CONIC" )) {        oSRS.OGRSpatialReference::SetLCC ( first_std_parallel, second_std_parallel, center_lat, center_lon, 0, 0 );    } else {        CPLDebug( "ISIS2",                  "Dataset projection %s is not supported. Continuing...",                  map_proj_name.c_str() );        bProjectionSet = FALSE;    }    if (bProjectionSet) {        //Create projection name, i.e. MERCATOR MARS and set as ProjCS keyword        CPLString proj_target_name = map_proj_name + " " + target_name;        oSRS.SetProjCS(proj_target_name); //set ProjCS keyword             //The geographic/geocentric name will be the same basic name as the body name
开发者ID:Chaduke,项目名称:bah.mod,代码行数:67,


示例9: CPLStrdup

int OGRSVGDataSource::Open( const char * pszFilename ){#ifdef HAVE_EXPAT    pszName = CPLStrdup( pszFilename );/* -------------------------------------------------------------------- *//*      Try to open the file.                                           *//* -------------------------------------------------------------------- */    CPLString osFilename(pszFilename);    if (EQUAL(CPLGetExtension(pszFilename), "svgz") &&        strstr(pszFilename, "/vsigzip/") == NULL)    {        osFilename = CPLString("/vsigzip/") + pszFilename;        pszFilename = osFilename.c_str();    }    VSILFILE* fp = VSIFOpenL(pszFilename, "r");    if (fp == NULL)        return FALSE;        eValidity = SVG_VALIDITY_UNKNOWN;    XML_Parser oParser = OGRCreateExpatXMLParser();    oCurrentParser = oParser;    XML_SetUserData(oParser, this);    XML_SetElementHandler(oParser, ::startElementValidateCbk, NULL);    XML_SetCharacterDataHandler(oParser, ::dataHandlerValidateCbk);        char aBuf[BUFSIZ];    int nDone;    unsigned int nLen;    int nCount = 0;        /* Begin to parse the file and look for the <svg> element */    /* It *MUST* be the first element of an XML file */    /* So once we have read the first element, we know if we can */    /* handle the file or not with that driver */    do    {        nDataHandlerCounter = 0;        nLen = (unsigned int) VSIFReadL( aBuf, 1, sizeof(aBuf), fp );        nDone = VSIFEofL(fp);        if (XML_Parse(oParser, aBuf, nLen, nDone) == XML_STATUS_ERROR)        {            if (nLen <= BUFSIZ-1)                aBuf[nLen] = 0;            else                aBuf[BUFSIZ-1] = 0;            if (strstr(aBuf, "<?xml") && strstr(aBuf, "<svg"))            {                CPLError(CE_Failure, CPLE_AppDefined,                        "XML parsing of SVG file failed : %s at line %d, column %d",                        XML_ErrorString(XML_GetErrorCode(oParser)),                        (int)XML_GetCurrentLineNumber(oParser),                        (int)XML_GetCurrentColumnNumber(oParser));            }            eValidity = SVG_VALIDITY_INVALID;            break;        }        if (eValidity == SVG_VALIDITY_INVALID)        {            break;        }        else if (eValidity == SVG_VALIDITY_VALID)        {            break;        }        else        {            /* After reading 50 * BUFSIZE bytes, and not finding whether the file */            /* is SVG or not, we give up and fail silently */            nCount ++;            if (nCount == 50)                break;        }    } while (!nDone && nLen > 0 );    XML_ParserFree(oParser);    VSIFCloseL(fp);    if (eValidity == SVG_VALIDITY_VALID)    {        if (bIsCloudmade)        {            nLayers = 3;            papoLayers =(OGRSVGLayer **) CPLRealloc(papoLayers,                                            nLayers * sizeof(OGRSVGLayer*));            papoLayers[0] = new OGRSVGLayer( pszFilename, "points", SVG_POINTS, this );            papoLayers[1] = new OGRSVGLayer( pszFilename, "lines", SVG_LINES, this );            papoLayers[2] = new OGRSVGLayer( pszFilename, "polygons", SVG_POLYGONS, this );        }        else        {            CPLDebug("SVG",                     "%s seems to be a SVG file, but not a Cloudmade vector one.",                     pszFilename);        }    }//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,


示例10: atoi

//.........这里部分代码省略.........            double dfEndAngle;            double dfRotation;            double dfRatio;            int    bCounterClockwise = FALSE;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 10 )                dfCenterX = atof(szLineBuf);            else                break;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 20 )                dfCenterY = atof(szLineBuf);            else                break;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 11 )                dfMajorX = atof(szLineBuf);            else                break;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 21 )                dfMajorY = atof(szLineBuf);            else                break;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 40 )                dfRatio = atof(szLineBuf) / 100.0;            else                break;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 50 )                dfStartAngle = -1 * atof(szLineBuf);            else                break;            if( poDS->ReadValue(szLineBuf,sizeof(szLineBuf)) == 51 )                dfEndAngle = -1 * atof(szLineBuf);            else                break;            if( (nCode = poDS->ReadValue(szLineBuf,sizeof(szLineBuf))) == 73 )                bCounterClockwise = atoi(szLineBuf);            else if (nCode >= 0)                poDS->UnreadValue();            if( bCounterClockwise )            {                double dfTemp = dfStartAngle;                dfStartAngle = dfEndAngle;                dfEndAngle = dfTemp;            }            if( dfStartAngle > dfEndAngle )                dfEndAngle += 360.0;            dfMajorRadius = sqrt( dfMajorX * dfMajorX + dfMajorY * dfMajorY );            dfMinorRadius = dfMajorRadius * dfRatio;            dfRotation = -1 * atan2( dfMajorY, dfMajorX ) * 180 / PI;            OGRGeometry *poArc = OGRGeometryFactory::approximateArcAngles(                 dfCenterX, dfCenterY, 0.0,                dfMajorRadius, dfMinorRadius, dfRotation,                dfStartAngle, dfEndAngle, 0.0 );            poArc->flattenTo2D();            poGC->addGeometryDirectly( poArc );        }        else        {            CPLDebug( "DXF", "Unsupported HATCH boundary line type:%d",                      nEdgeType );            return OGRERR_UNSUPPORTED_OPERATION;        }    }/* -------------------------------------------------------------------- *//*      Skip through source boundary objects if present.                *//* -------------------------------------------------------------------- */    nCode = poDS->ReadValue(szLineBuf,sizeof(szLineBuf));    if( nCode != 97 )    {        if (nCode < 0)            return OGRERR_FAILURE;        poDS->UnreadValue();    }    else    {        int iObj, nObjCount = atoi(szLineBuf);        for( iObj = 0; iObj < nObjCount; iObj++ )        {            if (poDS->ReadValue( szLineBuf, sizeof(szLineBuf) ) < 0)                return OGRERR_FAILURE;        }    }    return OGRERR_NONE;}
开发者ID:sylvainallard,项目名称:gdal,代码行数:101,


示例11: CPLMalloc

static GDALDataset *OGRSEGYDriverOpen( GDALOpenInfo* poOpenInfo ){    if( poOpenInfo->eAccess == GA_Update ||        poOpenInfo->fpL == NULL ||        !poOpenInfo->TryToIngest(3200+400) ||        poOpenInfo->nHeaderBytes < 3200+400 )    {        return NULL;    }    if( STARTS_WITH_CI((const char*)poOpenInfo->pabyHeader, "%PDF"))    {        return NULL;    }// --------------------------------------------------------------------//      Try to decode the header encoded as EBCDIC and then ASCII// --------------------------------------------------------------------    int i, j, k;    const GByte* pabyTextHeader = poOpenInfo->pabyHeader;    GByte* pabyASCIITextHeader = (GByte*) CPLMalloc(3200 + 40 + 1);    for( k=0; k<2; k++)    {        for( i=0, j=0;i<3200;i++)        {            GByte chASCII = (k == 0) ? EBCDICToASCII[pabyTextHeader[i]] :                                       pabyTextHeader[i];            if (chASCII < 32 && chASCII != '/t' &&                chASCII != '/n' && chASCII != '/r')            {                break;            }            pabyASCIITextHeader[j++] = chASCII;            if (chASCII != '/n' && ((i + 1) % 80) == 0)                pabyASCIITextHeader[j++] = '/n';        }        pabyASCIITextHeader[j] = '/0';        if (i == 3200)            break;        if (k == 1)        {            CPLFree(pabyASCIITextHeader);            return NULL;        }    }    CPLDebug("SIGY", "Header = /n%s", pabyASCIITextHeader);    CPLFree(pabyASCIITextHeader);    pabyASCIITextHeader = NULL;// --------------------------------------------------------------------//      Read the next 400 bytes, where the Binary File Header is//      located// --------------------------------------------------------------------    const GByte* abyFileHeader = poOpenInfo->pabyHeader + 3200;// --------------------------------------------------------------------//      First check that this binary header is not EBCDIC nor ASCII// --------------------------------------------------------------------    for( k=0;k<2;k++ )    {        for( i=0;i<400;i++)        {            GByte chASCII = (k == 0) ? abyFileHeader[i] :                                       EBCDICToASCII[abyFileHeader[i]];            /* A translated 0 value, when source value is not 0, means an invalid */            /* EBCDIC value. Bail out also for control characters */            if (chASCII < 32 && chASCII != '/t' &&                chASCII != '/n' && chASCII != '/r')            {                break;            }        }        if (i == 400)        {            CPLFree(pabyASCIITextHeader);            return NULL;        }    }    OGRSEGYDataSource   *poDS = new OGRSEGYDataSource();    if( !poDS->Open( poOpenInfo->pszFilename, (const char*)pabyASCIITextHeader ) )    {        CPLFree(pabyASCIITextHeader);        delete poDS;        poDS = NULL;    }    CPLFree(pabyASCIITextHeader);    return poDS;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:94,


示例12: osSQL

json_object* OGRCARTODBDataSource::RunSQL(const char* pszUnescapedSQL){    CPLString osSQL("POSTFIELDS=q=");    /* Do post escaping */    for(int i=0;pszUnescapedSQL[i] != 0;i++)    {        const int ch = ((unsigned char*)pszUnescapedSQL)[i];        if (ch != '&' && ch >= 32 && ch < 128)            osSQL += (char)ch;        else            osSQL += CPLSPrintf("%%%02X", ch);    }/* -------------------------------------------------------------------- *//*      Provide the API Key                                             *//* -------------------------------------------------------------------- */    if( osAPIKey.size() )    {        osSQL += "&api_key=";        osSQL += osAPIKey;    }/* -------------------------------------------------------------------- *//*      Collection the header options and execute request.              *//* -------------------------------------------------------------------- */    const char* pszAPIURL = GetAPIURL();    char** papszOptions = CSLAddString(        strncmp(pszAPIURL, "/vsimem/", strlen("/vsimem/")) != 0 ? AddHTTPOptions(): NULL, osSQL);    CPLHTTPResult * psResult = CPLHTTPFetch( GetAPIURL(), papszOptions);    CSLDestroy(papszOptions);/* -------------------------------------------------------------------- *//*      Check for some error conditions and report.  HTML Messages      *//*      are transformed info failure.                                   *//* -------------------------------------------------------------------- */    if (psResult && psResult->pszContentType &&        strncmp(psResult->pszContentType, "text/html", 9) == 0)    {        CPLDebug( "CARTODB", "RunSQL HTML Response:%s", psResult->pabyData );        CPLError(CE_Failure, CPLE_AppDefined,                  "HTML error page returned by server");        CPLHTTPDestroyResult(psResult);        return NULL;    }    if (psResult && psResult->pszErrBuf != NULL)     {        CPLDebug( "CARTODB", "RunSQL Error Message:%s", psResult->pszErrBuf );    }    else if (psResult && psResult->nStatus != 0)     {        CPLDebug( "CARTODB", "RunSQL Error Status:%d", psResult->nStatus );    }    if( psResult->pabyData == NULL )    {        CPLHTTPDestroyResult(psResult);        return NULL;    }        if( strlen((const char*)psResult->pabyData) < 1000 )        CPLDebug( "CARTODB", "RunSQL Response:%s", psResult->pabyData );        json_tokener* jstok = NULL;    json_object* poObj = NULL;    jstok = json_tokener_new();    poObj = json_tokener_parse_ex(jstok, (const char*) psResult->pabyData, -1);    if( jstok->err != json_tokener_success)    {        CPLError( CE_Failure, CPLE_AppDefined,                    "JSON parsing error: %s (at offset %d)",                    json_tokener_error_desc(jstok->err), jstok->char_offset);        json_tokener_free(jstok);        CPLHTTPDestroyResult(psResult);        return NULL;    }    json_tokener_free(jstok);    CPLHTTPDestroyResult(psResult);    if( poObj != NULL )    {        if( json_object_get_type(poObj) == json_type_object )        {            json_object* poError = json_object_object_get(poObj, "error");            if( poError != NULL && json_object_get_type(poError) == json_type_array &&                json_object_array_length(poError) > 0 )            {                poError = json_object_array_get_idx(poError, 0);                if( poError != NULL && json_object_get_type(poError) == json_type_string )                {                    CPLError(CE_Failure, CPLE_AppDefined,                             "Error returned by server : %s", json_object_get_string(poError));                    json_object_put(poObj);                    return NULL;                }            }        }        else        {//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,


示例13: CPLDebug

OGRBoolean OGRLinearRing::isPointInRing(const OGRPoint* poPoint, int bTestEnvelope) const{    if ( NULL == poPoint )    {        CPLDebug( "OGR", "OGRLinearRing::isPointInRing(const  OGRPoint* poPoint) - passed point is NULL!" );        return 0;    }    const int iNumPoints = getNumPoints();    // Simple validation    if ( iNumPoints < 4 )        return 0;    const double dfTestX = poPoint->getX();    const double dfTestY = poPoint->getY();    // Fast test if point is inside extent of the ring    if (bTestEnvelope)    {        OGREnvelope extent;        getEnvelope(&extent);        if ( !( dfTestX >= extent.MinX && dfTestX <= extent.MaxX            && dfTestY >= extent.MinY && dfTestY <= extent.MaxY ) )        {            return 0;        }    }	// For every point p in ring,    // test if ray starting from given point crosses segment (p - 1, p)    int iNumCrossings = 0;    double prev_diff_x = getX(0) - dfTestX;    double prev_diff_y = getY(0) - dfTestY;    for ( int iPoint = 1; iPoint < iNumPoints; iPoint++ )     {        const double x1 = getX(iPoint) - dfTestX;        const double y1 = getY(iPoint) - dfTestY;        const double x2 = prev_diff_x;        const double y2 = prev_diff_y;        if( ( ( y1 > 0 ) && ( y2 <= 0 ) ) || ( ( y2 > 0 ) && ( y1 <= 0 ) ) )        {            // Check if ray intersects with segment of the ring            const double dfIntersection = ( x1 * y2 - x2 * y1 ) / (y2 - y1);            if ( 0.0 < dfIntersection )            {                // Count intersections                iNumCrossings++;            }        }        prev_diff_x = x1;        prev_diff_y = y1;    }    // If iNumCrossings number is even, given point is outside the ring,    // when the crossings number is odd, the point is inside the ring.    return ( ( iNumCrossings % 2 ) == 1 ? 1 : 0 );}
开发者ID:0004c,项目名称:node-gdal,代码行数:63,


示例14: CPLDebug

void ILI1Reader::ReadGeom( char **stgeom, int geomIdx, OGRwkbGeometryType eType,                           OGRFeature *feature ) {#ifdef DEBUG_VERBOSE    CPLDebug( "OGR_ILI",              "ILI1Reader::ReadGeom geomIdx: %d OGRGeometryType: %s",              geomIdx, OGRGeometryTypeToName(eType) );#endif    if (eType == wkbNone)    {      CPLError( CE_Warning, CPLE_AppDefined,                "Calling ILI1Reader::ReadGeom with wkbNone" );    }    // Initialize geometry.    OGRCompoundCurve *ogrCurve = new OGRCompoundCurve();    OGRCurvePolygon *ogrPoly = NULL; //current polygon    OGRMultiCurve *ogrMultiLine = NULL; //current multi line    if (eType == wkbMultiCurve || eType == wkbMultiLineString)    {      ogrMultiLine = new OGRMultiCurve();    }    else if (eType == wkbPolygon || eType == wkbCurvePolygon)    {      ogrPoly = new OGRCurvePolygon();    }    OGRPoint ogrPoint; // Current point.    ogrPoint.setX(CPLAtof(stgeom[1])); ogrPoint.setY(CPLAtof(stgeom[2]));    OGRLineString *ogrLine = new OGRLineString();    ogrLine->addPoint(&ogrPoint);    // Parse geometry.    char **tokens = NULL;    bool end = false;    OGRCircularString *arc = NULL; //current arc    while (!end && (tokens = ReadParseLine()) != NULL)    {      const char *firsttok = CSLGetField(tokens, 0);      if (EQUAL(firsttok, "LIPT"))      {        ogrPoint.setX(CPLAtof(tokens[1])); ogrPoint.setY(CPLAtof(tokens[2]));        if (arc) {          arc->addPoint(&ogrPoint);          OGRErr error =  ogrCurve->addCurveDirectly(arc);          if (error != OGRERR_NONE) {            CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", arc->exportToJson() );          }          arc = NULL;        }        ogrLine->addPoint(&ogrPoint);      }      else if (EQUAL(firsttok, "ARCP"))      {        //Finish line and start arc        if (ogrLine->getNumPoints() > 1) {          OGRErr error = ogrCurve->addCurveDirectly(ogrLine);          if (error != OGRERR_NONE) {            CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrLine->exportToJson() );          }          ogrLine = new OGRLineString();        } else {          ogrLine->empty();        }        arc = new OGRCircularString();        arc->addPoint(&ogrPoint);        ogrPoint.setX(CPLAtof(tokens[1])); ogrPoint.setY(CPLAtof(tokens[2]));        arc->addPoint(&ogrPoint);      }      else if (EQUAL(firsttok, "ELIN"))      {        if (ogrLine->getNumPoints() > 1) { // Ignore single LIPT after ARCP          OGRErr error = ogrCurve->addCurveDirectly(ogrLine);          if (error != OGRERR_NONE) {            CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrLine->exportToJson() );          }          ogrLine = NULL;        }        if (!ogrCurve->IsEmpty()) {          if (ogrMultiLine)          {            OGRErr error = ogrMultiLine->addGeometryDirectly(ogrCurve);            if (error != OGRERR_NONE) {              CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrCurve->exportToJson() );            }            ogrCurve = NULL;          }          if (ogrPoly)          {            OGRErr error = ogrPoly->addRingDirectly(ogrCurve);            if (error != OGRERR_NONE) {              CPLError(CE_Warning, CPLE_AppDefined, "Added geometry: %s", ogrCurve->exportToJson() );            }            ogrCurve = NULL;          }        }//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,


示例15: CPLError

int OGRGeoRSSDataSource::Open( const char * pszFilename, int bUpdateIn){    if (bUpdateIn)    {        CPLError(CE_Failure, CPLE_NotSupported,                    "OGR/GeoRSS driver does not support opening a file in update mode");        return FALSE;    }#ifdef HAVE_EXPAT    pszName = CPLStrdup( pszFilename );/* -------------------------------------------------------------------- *//*      Try to open the file.                                           *//* -------------------------------------------------------------------- */    VSILFILE* fp = VSIFOpenL(pszFilename, "r");    if (fp == NULL)        return FALSE;        validity = GEORSS_VALIDITY_UNKNOWN;        XML_Parser oParser = OGRCreateExpatXMLParser();    XML_SetUserData(oParser, this);    XML_SetElementHandler(oParser, ::startElementValidateCbk, NULL);    XML_SetCharacterDataHandler(oParser, ::dataHandlerValidateCbk);    oCurrentParser = oParser;        char aBuf[BUFSIZ];    int nDone;    unsigned int nLen;    int nCount = 0;        /* Begin to parse the file and look for the <rss> or <feed> element */    /* It *MUST* be the first element of an XML file */    /* So once we have read the first element, we know if we can */    /* handle the file or not with that driver */    do    {        nDataHandlerCounter = 0;        nLen = (unsigned int) VSIFReadL( aBuf, 1, sizeof(aBuf), fp );        nDone = VSIFEofL(fp);        if (XML_Parse(oParser, aBuf, nLen, nDone) == XML_STATUS_ERROR)        {            if (nLen <= BUFSIZ-1)                aBuf[nLen] = 0;            else                aBuf[BUFSIZ-1] = 0;            if (strstr(aBuf, "<?xml") && (strstr(aBuf, "<rss") || strstr(aBuf, "<feed")))            {                CPLError(CE_Failure, CPLE_AppDefined,                        "XML parsing of GeoRSS file failed : %s at line %d, column %d",                        XML_ErrorString(XML_GetErrorCode(oParser)),                        (int)XML_GetCurrentLineNumber(oParser),                        (int)XML_GetCurrentColumnNumber(oParser));            }            validity = GEORSS_VALIDITY_INVALID;            break;        }        if (validity == GEORSS_VALIDITY_INVALID)        {            break;        }        else if (validity == GEORSS_VALIDITY_VALID)        {            break;        }        else        {            /* After reading 50 * BUFSIZ bytes, and not finding whether the file */            /* is GeoRSS or not, we give up and fail silently */            nCount ++;            if (nCount == 50)                break;        }    } while (!nDone && nLen > 0 );        XML_ParserFree(oParser);        VSIFCloseL(fp);        if (validity == GEORSS_VALIDITY_VALID)    {        CPLDebug("GeoRSS", "%s seems to be a GeoRSS file.", pszFilename);        nLayers = 1;        papoLayers = (OGRGeoRSSLayer **) CPLRealloc(papoLayers, nLayers * sizeof(OGRGeoRSSLayer*));        papoLayers[0] = new OGRGeoRSSLayer( pszName, "georss", this, NULL, FALSE );    }    return (validity == GEORSS_VALIDITY_VALID);#else    char aBuf[256];    VSILFILE* fp = VSIFOpenL(pszFilename, "r");    if (fp)    {        unsigned int nLen = (unsigned int)VSIFReadL( aBuf, 1, 255, fp );        aBuf[nLen] = 0;        if (strstr(aBuf, "<?xml") && (strstr(aBuf, "<rss") || strstr(aBuf, "<feed")))        {            CPLError(CE_Failure, CPLE_NotSupported,//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,


示例16: FindSRS

int FindSRS( const char *pszInput, OGRSpatialReference &oSRS ){    int            bGotSRS = FALSE;    VSILFILE      *fp = NULL;    GDALDataset	  *poGDALDS = NULL;     OGRLayer      *poLayer = NULL;    const char    *pszProjection = NULL;    CPLErrorHandler oErrorHandler = NULL;    int bIsFile = FALSE;    OGRErr eErr = OGRERR_NONE;    int bDebug  = FALSE;    /* temporarily suppress error messages we may get from xOpen() */    bDebug = CSLTestBoolean(CPLGetConfigOption("CPL_DEBUG", "OFF"));    if ( ! bDebug )        oErrorHandler = CPLSetErrorHandler ( CPLQuietErrorHandler );    /* Test if argument is a file */    fp = VSIFOpenL( pszInput, "r" );    if ( fp )  {        bIsFile = TRUE;        VSIFCloseL( fp );        CPLDebug( "gdalsrsinfo", "argument is a file" );    }            /* try to open with GDAL */    if( strncmp(pszInput, "http://spatialreference.org/",                strlen("http://spatialreference.org/")) != 0 )    {        CPLDebug( "gdalsrsinfo", "trying to open with GDAL" );        poGDALDS = (GDALDataset *) GDALOpenEx( pszInput, 0, NULL, NULL, NULL );    }    if ( poGDALDS != NULL ) {        pszProjection = poGDALDS->GetProjectionRef( );        if( pszProjection != NULL && pszProjection[0] != '/0' )        {            char* pszProjectionTmp = (char*) pszProjection;            if( oSRS.importFromWkt( &pszProjectionTmp ) == OGRERR_NONE ) {                CPLDebug( "gdalsrsinfo", "got SRS from GDAL" );                bGotSRS = TRUE;            }        }        else if( poGDALDS->GetLayerCount() > 0 )        {            poLayer = poGDALDS->GetLayer( 0 );            if ( poLayer != NULL ) {                OGRSpatialReference *poSRS = poLayer->GetSpatialRef( );                if ( poSRS != NULL ) {                    CPLDebug( "gdalsrsinfo", "got SRS from OGR" );                    bGotSRS = TRUE;                    OGRSpatialReference* poSRSClone = poSRS->Clone();                    oSRS = *poSRSClone;                    OGRSpatialReference::DestroySpatialReference( poSRSClone );                }            }        }        GDALClose( (GDALDatasetH) poGDALDS );        if ( ! bGotSRS )             CPLDebug( "gdalsrsinfo", "did not open with GDAL" );    }            /* Try ESRI file */    if ( ! bGotSRS && bIsFile && (strstr(pszInput,".prj") != NULL) ) {        CPLDebug( "gdalsrsinfo",                   "trying to get SRS from ESRI .prj file [%s]", pszInput );        char **pszTemp;        if ( strstr(pszInput,"ESRI::") != NULL )            pszTemp = CSLLoad( pszInput+6 );        else             pszTemp = CSLLoad( pszInput );        if( pszTemp ) {            eErr = oSRS.importFromESRI( pszTemp );            CSLDestroy( pszTemp );        }        else             eErr = OGRERR_UNSUPPORTED_SRS;        if( eErr != OGRERR_NONE ) {            CPLDebug( "gdalsrsinfo", "did not get SRS from ESRI .prj file" );        }        else {            CPLDebug( "gdalsrsinfo", "got SRS from ESRI .prj file" );            bGotSRS = TRUE;        }    }    /* Last resort, try OSRSetFromUserInput() */    if ( ! bGotSRS ) {        CPLDebug( "gdalsrsinfo",                   "trying to get SRS from user input [%s]", pszInput );        eErr = oSRS.SetFromUserInput( pszInput );        if(  eErr != OGRERR_NONE ) {            CPLDebug( "gdalsrsinfo", "did not get SRS from user input" );        }        else {//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,


示例17: VSIFTellL

int GDALJP2Box::ReadBox(){    GUInt32   nLBox;    GUInt32   nTBox;    nBoxOffset = VSIFTellL( fpVSIL );    if( VSIFReadL( &nLBox, 4, 1, fpVSIL ) != 1        || VSIFReadL( &nTBox, 4, 1, fpVSIL ) != 1 )    {        return FALSE;    }    memcpy( szBoxType, &nTBox, 4 );    szBoxType[4] = '/0';    nLBox = CPL_MSBWORD32( nLBox );    if( nLBox != 1 )    {        nBoxLength = nLBox;        nDataOffset = nBoxOffset + 8;    }    else    {        GByte abyXLBox[8];        if( VSIFReadL( abyXLBox, 8, 1, fpVSIL ) != 1 )            return FALSE;                if( sizeof(nBoxLength) == 8 )        {            CPL_MSBPTR64( abyXLBox );            memcpy( &nBoxLength, abyXLBox, 8 );        }        else        {            CPL_MSBPTR32( abyXLBox+4 );            memcpy( &nBoxLength, abyXLBox+4, 4 );        }        nDataOffset = nBoxOffset + 16;    }    if( nBoxLength == 0 )    {        VSIFSeekL( fpVSIL, 0, SEEK_END );        nBoxLength = VSIFTellL( fpVSIL ) - nBoxOffset;    }    if( EQUAL(szBoxType,"uuid") )    {        VSIFReadL( abyUUID, 16, 1, fpVSIL );        nDataOffset += 16;    }    if( GetDataLength() < 0 )    {        CPLDebug("GDALJP2", "Invalid length for box %s", szBoxType);        return FALSE;    }    return TRUE;}
开发者ID:0004c,项目名称:node-gdal,代码行数:65,


示例18: PrintSRS

CPLErr PrintSRS( const OGRSpatialReference &oSRS,                  const char * pszOutputType,                  int bPretty, int bPrintSep ){    if ( ! pszOutputType || EQUAL(pszOutputType,""))        return CE_None;    CPLDebug( "gdalsrsinfo", "PrintSRS( oSRS, %s, %d, %d )/n",              pszOutputType, bPretty, bPrintSep );        char *pszOutput = NULL;    if ( EQUAL("proj4", pszOutputType ) ) {        if ( bPrintSep ) printf( "PROJ.4 : ");        oSRS.exportToProj4( &pszOutput );        printf( "/'%s/'/n", pszOutput );    }    else if ( EQUAL("wkt", pszOutputType ) ) {        if ( bPrintSep ) printf("OGC WKT :/n");        if ( bPretty )             oSRS.exportToPrettyWkt( &pszOutput, FALSE );        else            oSRS.exportToWkt( &pszOutput );        printf("%s/n",pszOutput);    }            else if (  EQUAL("wkt_simple", pszOutputType ) ) {        if ( bPrintSep ) printf("OGC WKT (simple) :/n");        oSRS.exportToPrettyWkt( &pszOutput, TRUE );        printf("%s/n",pszOutput);    }            else if ( EQUAL("wkt_noct", pszOutputType ) ) {        if (  bPrintSep ) printf("OGC WKT (no CT) :/n");        OGRSpatialReference *poSRS = oSRS.Clone();        poSRS->StripCTParms( );        if ( bPretty )             poSRS->exportToPrettyWkt( &pszOutput, FALSE );        else            poSRS->exportToWkt( &pszOutput );        OGRSpatialReference::DestroySpatialReference( poSRS );        printf("%s/n",pszOutput);    }            else if ( EQUAL("wkt_esri", pszOutputType ) ) {        if ( bPrintSep ) printf("ESRI WKT :/n");        OGRSpatialReference *poSRS = oSRS.Clone();        poSRS->morphToESRI( );        if ( bPretty )             poSRS->exportToPrettyWkt( &pszOutput, FALSE );        else            poSRS->exportToWkt( &pszOutput );        OGRSpatialReference::DestroySpatialReference( poSRS );        printf("%s/n",pszOutput);    }            else if ( EQUAL("mapinfo", pszOutputType ) ) {        if ( bPrintSep ) printf("MAPINFO : ");        oSRS.exportToMICoordSys( &pszOutput );        printf("/'%s/'/n",pszOutput);    }            else if ( EQUAL("xml", pszOutputType ) ) {        if ( bPrintSep ) printf("XML :/n");        oSRS.exportToXML( &pszOutput, NULL );        printf("%s/n",pszOutput);    }    else {        CPLError( CE_Failure, CPLE_AppDefined,                  "ERROR - %s output not supported",                  pszOutputType );        return CE_Failure;    }    CPLFree( pszOutput );        return CE_None;}
开发者ID:garnertb,项目名称:gdal,代码行数:81,


示例19: SearchCSVForWKT

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


示例20: main

int main( int argc, char ** argv ) {    int            i;    int            bGotSRS = FALSE;    int            bPretty = FALSE;    int            bValidate = FALSE;    int            bFindEPSG = FALSE;    int            nEPSGCode = -1;    const char     *pszInput = NULL;    const char     *pszOutputType = "default";    OGRSpatialReference  oSRS;    /* Check strict compilation and runtime library version as we use C++ API */    if (! GDAL_CHECK_VERSION(argv[0]))        exit(1);    EarlySetConfigOptions(argc, argv);/* -------------------------------------------------------------------- *//*      Register standard GDAL and OGR drivers.                         *//* -------------------------------------------------------------------- */    GDALAllRegister();#ifdef OGR_ENABLED    OGRRegisterAll();#endif/* -------------------------------------------------------------------- *//*      Register standard GDAL drivers, and process generic GDAL        *//*      command options.                                                *//* -------------------------------------------------------------------- */    argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 );    if( argc < 1 )        exit( -argc );/* -------------------------------------------------------------------- *//*      Parse arguments.                                                *//* -------------------------------------------------------------------- */    for( i = 1; i < argc; i++ )    {        CPLDebug( "gdalsrsinfo", "got arg #%d : [%s]", i, argv[i] );        if( EQUAL(argv[i], "--utility_version") )        {            printf("%s was compiled against GDAL %s and is running against GDAL %s/n",                   argv[0], GDAL_RELEASE_NAME, GDALVersionInfo("RELEASE_NAME"));            return 0;        }        else if( EQUAL(argv[i], "-h") || EQUAL(argv[i], "--help") )            Usage();        else if( EQUAL(argv[i], "-e") )            bFindEPSG = TRUE;        else if( EQUAL(argv[i], "-o") )        {            CHECK_HAS_ENOUGH_ADDITIONAL_ARGS(1);            pszOutputType = argv[++i];        }        else if( EQUAL(argv[i], "-p") )            bPretty = TRUE;        else if( EQUAL(argv[i], "-V") )            bValidate = TRUE;        else if( argv[i][0] == '-' )        {            Usage(CPLSPrintf("Unknown option name '%s'", argv[i]));        }        else              pszInput = argv[i];    }    if ( pszInput == NULL ) {        CSLDestroy( argv );        Usage("No input specified.");    }    /* Search for SRS */    bGotSRS = FindSRS( pszInput, oSRS );    CPLDebug( "gdalsrsinfo",               "bGotSRS: %d bValidate: %d pszOutputType: %s bPretty: %d",              bGotSRS, bValidate, pszOutputType, bPretty  );          /* Make sure we got a SRS */    if ( ! bGotSRS ) {        CPLError( CE_Failure, CPLE_AppDefined,                  "ERROR - failed to load SRS definition from %s",                  pszInput );    }    else {        /* Find EPSG code - experimental */        if ( EQUAL(pszOutputType,"epsg") )            bFindEPSG = TRUE;        if ( bFindEPSG ) {            CPLError( CE_Warning, CPLE_AppDefined,                      "EPSG detection is experimental and requires new data files (see bug #4345)" );            nEPSGCode = FindEPSG( oSRS );            /* If found, replace oSRS based on EPSG code */            if(nEPSGCode != -1) {//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,


示例21: CPLODBCStatement

CPLODBCStatement* OGRMSSQLSpatialTableLayer::BuildStatement(const char* pszColumns){    CPLODBCStatement* poStatement = new CPLODBCStatement( poDS->GetSession() );    poStatement->Append( "select " );    poStatement->Append( pszColumns );    poStatement->Append( " from " );    poStatement->Append( pszSchemaName );    poStatement->Append( "." );    poStatement->Append( pszTableName );    /* Append attribute query if we have it */    if( pszQuery != NULL )        poStatement->Appendf( " where (%s)", pszQuery );    /* If we have a spatial filter, query on it */    if ( m_poFilterGeom != NULL )    {        if (nGeomColumnType == MSSQLCOLTYPE_GEOMETRY             || nGeomColumnType == MSSQLCOLTYPE_GEOGRAPHY)        {            if( pszQuery == NULL )                poStatement->Append( " where" );            else                poStatement->Append( " and" );            poStatement->Appendf(" [%s].STIntersects(", pszGeomColumn );            if (nGeomColumnType == MSSQLCOLTYPE_GEOGRAPHY)                poStatement->Append( "geography::" );            else                poStatement->Append( "geometry::" );                        if ( m_sFilterEnvelope.MinX == m_sFilterEnvelope.MaxX ||                  m_sFilterEnvelope.MinY == m_sFilterEnvelope.MaxY)                poStatement->Appendf("STGeomFromText('POINT(%.15g %.15g)',%d)) = 1",                             m_sFilterEnvelope.MinX, m_sFilterEnvelope.MinY, nSRSId >= 0? nSRSId : 0);            else                poStatement->Appendf( "STGeomFromText('POLYGON((%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g,%.15g %.15g))',%d)) = 1",                                             m_sFilterEnvelope.MinX, m_sFilterEnvelope.MinY,                                            m_sFilterEnvelope.MaxX, m_sFilterEnvelope.MinY,                                             m_sFilterEnvelope.MaxX, m_sFilterEnvelope.MaxY,                                            m_sFilterEnvelope.MinX, m_sFilterEnvelope.MaxY,                                            m_sFilterEnvelope.MinX, m_sFilterEnvelope.MinY,                                            nSRSId >= 0? nSRSId : 0 );        }        else        {            CPLError( CE_Failure, CPLE_AppDefined,                       "Spatial filter is supported only on geometry and geography column types." );                        delete poStatement;            return NULL;        }    }    CPLDebug( "OGR_MSSQLSpatial", "ExecuteSQL(%s)", poStatement->GetCommand() );    if( poStatement->ExecuteSQL() )        return poStatement;    else    {        delete poStatement;        return NULL;    }}
开发者ID:agrismart,项目名称:gdal-1.9.2,代码行数:65,


示例22: 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:afarnham,项目名称:gdal,代码行数:101,


示例23: Clear

//.........这里部分代码省略.........        case PAN_PROJ_LAEA:            SetLAEA( TO_DEGREES * padfPrjParams[0],                     TO_DEGREES * padfPrjParams[3],                     padfPrjParams[5], padfPrjParams[6] );            break;        case PAN_PROJ_EQC:            SetEquirectangular( TO_DEGREES * padfPrjParams[0],                                TO_DEGREES * padfPrjParams[3],                                padfPrjParams[5], padfPrjParams[6] );            break;        case PAN_PROJ_CEA:            SetCEA( TO_DEGREES * padfPrjParams[0],                    TO_DEGREES * padfPrjParams[3],                    padfPrjParams[5], padfPrjParams[6] );            break;        case PAN_PROJ_IMWP:            SetIWMPolyconic( TO_DEGREES * padfPrjParams[0],                             TO_DEGREES * padfPrjParams[1],                             TO_DEGREES * padfPrjParams[3],                             padfPrjParams[5], padfPrjParams[6] );            break;        case PAN_PROJ_MILLER:            SetMC(TO_DEGREES * padfPrjParams[5],                TO_DEGREES * padfPrjParams[4],                padfPrjParams[6], padfPrjParams[7]);            break;        default:            CPLDebug( "OSR_Panorama", "Unsupported projection: %ld", iProjSys );            SetLocalCS( CPLString().Printf("/"Panorama/" projection number %ld",                                   iProjSys) );            break;    }/* -------------------------------------------------------------------- *//*      Try to translate the datum/spheroid.                            *//* -------------------------------------------------------------------- */    if ( !IsLocal() )    {        if ( iDatum > 0 && iDatum < NUMBER_OF_DATUMS && aoDatums[iDatum] )        {            OGRSpatialReference oGCS;            oGCS.importFromEPSG( aoDatums[iDatum] );            CopyGeogCSFrom( &oGCS );        }        else if ( iEllips > 0                  && iEllips < NUMBER_OF_ELLIPSOIDS                  && aoEllips[iEllips] )        {            char    *pszName = NULL;            double  dfSemiMajor, dfInvFlattening;            if ( OSRGetEllipsoidInfo( aoEllips[iEllips], &pszName,                            &dfSemiMajor, &dfInvFlattening ) == OGRERR_NONE )            {                SetGeogCS( CPLString().Printf(                            "Unknown datum based upon the %s ellipsoid",                            pszName ),
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:67,


示例24: GTIFFBuildOverviews

//.........这里部分代码省略.........            /* the added overview levels won't be more than 1/2 of */            /* the size of the base image. The theory says 1/3 of the */            /* base image size if the overview levels are 2, 4, 8, 16... */            /* Thus take 1/2 as the security margin for 1/3 */            double dfUncompressedImageSize =                        nXSize * ((double)nYSize) * nBands * nDataTypeSize;            if( dfUncompressedImageSize * .5 > 4200000000.0 )                bCreateBigTIFF = TRUE;        }        else        {            bCreateBigTIFF = CSLTestBoolean( pszBIGTIFF );            if (!bCreateBigTIFF && nCompression == COMPRESSION_NONE                 && dfUncompressedOverviewSize > 4200000000.0 )            {                CPLError( CE_Failure, CPLE_NotSupported,                     "The overview file will be larger than 4GB, so BigTIFF is necessary./n"                    "Creation failed.");                return CE_Failure;            }        }    #ifndef BIGTIFF_SUPPORT        if( bCreateBigTIFF )        {            CPLError( CE_Warning, CPLE_NotSupported,                    "BigTIFF requested, but GDAL built without BigTIFF/n"                    "enabled libtiff, request ignored." );            bCreateBigTIFF = FALSE;        }    #endif        if( bCreateBigTIFF )            CPLDebug( "GTiff", "File being created as a BigTIFF." );        hOTIFF = VSI_TIFFOpen( pszFilename, (bCreateBigTIFF) ? "w+8" : "w+" );        if( hOTIFF == NULL )        {            if( CPLGetLastErrorNo() == 0 )                CPLError( CE_Failure, CPLE_OpenFailed,                          "Attempt to create new tiff file `%s'/n"                          "failed in VSI_TIFFOpen()./n",                          pszFilename );            return CE_Failure;        }    }/* -------------------------------------------------------------------- *//*      Otherwise just open it for update access.                       *//* -------------------------------------------------------------------- */    else     {        hOTIFF = VSI_TIFFOpen( pszFilename, "r+" );        if( hOTIFF == NULL )        {            if( CPLGetLastErrorNo() == 0 )                CPLError( CE_Failure, CPLE_OpenFailed,                          "Attempt to create new tiff file `%s'/n"                          "failed in VSI_TIFFOpen()./n",                          pszFilename );            return CE_Failure;        }    }/* -------------------------------------------------------------------- */
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:67,


示例25: OGRSQLiteRegisterSQLFunctions

staticvoid* OGRSQLiteRegisterSQLFunctions(sqlite3* hDB){    OGRSQLiteExtensionData* pData = new OGRSQLiteExtensionData(hDB);    sqlite3_create_function(hDB, "ogr_version", 0, SQLITE_ANY, NULL,                           OGR2SQLITE_ogr_version, NULL, NULL);    sqlite3_create_function(hDB, "ogr_version", 1, SQLITE_ANY, NULL,                           OGR2SQLITE_ogr_version, NULL, NULL);    sqlite3_create_function(hDB, "ogr_deflate", 1, SQLITE_ANY, NULL,                            OGR2SQLITE_ogr_deflate, NULL, NULL);    sqlite3_create_function(hDB, "ogr_deflate", 2, SQLITE_ANY, NULL,                            OGR2SQLITE_ogr_deflate, NULL, NULL);    sqlite3_create_function(hDB, "ogr_inflate", 1, SQLITE_ANY, NULL,                            OGR2SQLITE_ogr_inflate, NULL, NULL);    sqlite3_create_function(hDB, "ogr_geocode", -1, SQLITE_ANY, pData,                            OGR2SQLITE_ogr_geocode, NULL, NULL);    sqlite3_create_function(hDB, "ogr_geocode_reverse", -1, SQLITE_ANY, pData,                            OGR2SQLITE_ogr_geocode_reverse, NULL, NULL);    sqlite3_create_function(hDB, "ogr_datasource_load_layers", 1, SQLITE_ANY, hDB,                            OGR2SQLITE_ogr_datasource_load_layers, NULL, NULL);    sqlite3_create_function(hDB, "ogr_datasource_load_layers", 2, SQLITE_ANY, hDB,                            OGR2SQLITE_ogr_datasource_load_layers, NULL, NULL);    sqlite3_create_function(hDB, "ogr_datasource_load_layers", 3, SQLITE_ANY, hDB,                            OGR2SQLITE_ogr_datasource_load_layers, NULL, NULL);#if notdef    sqlite3_create_function(hDB, "ogr_GetConfigOption", 1, SQLITE_ANY, NULL,                            OGR2SQLITE_ogr_GetConfigOption, NULL, NULL);    sqlite3_create_function(hDB, "ogr_SetConfigOption", 2, SQLITE_ANY, NULL,                            OGR2SQLITE_ogr_SetConfigOption, NULL, NULL);#endif    // Custom and undocumented function, not sure I'll keep it.    sqlite3_create_function(hDB, "Transform3", 3, SQLITE_ANY, pData,                            OGR2SQLITE_Transform, NULL, NULL);    // HSTORE functions    sqlite3_create_function(hDB, "hstore_get_value", 2, SQLITE_ANY, NULL,                            OGRSQLITE_hstore_get_value, NULL, NULL);#ifdef MINIMAL_SPATIAL_FUNCTIONS    /* Check if spatialite is available */    int rc = sqlite3_exec(hDB, "SELECT spatialite_version()", NULL, NULL, NULL);        /* Reset error flag */    sqlite3_exec(hDB, "SELECT 1", NULL, NULL, NULL);        if( rc != SQLITE_OK &&        CSLTestBoolean(CPLGetConfigOption("OGR_SQLITE_SPATIAL_FUNCTIONS", "YES")) )    {        CPLDebug("SQLITE",                 "Spatialite not available. Implementing a few functions");#define REGISTER_ST_op(argc, op) /        sqlite3_create_function(hDB, #op, argc, SQLITE_ANY, NULL, /                                OGR2SQLITE_ST_##op, NULL, NULL); /        sqlite3_create_function(hDB, "ST_" #op, argc, SQLITE_ANY, NULL, /                                OGR2SQLITE_ST_##op, NULL, NULL);        REGISTER_ST_op(1, AsText);        REGISTER_ST_op(1, AsBinary);        REGISTER_ST_op(1, GeomFromText);        REGISTER_ST_op(2, GeomFromText);        REGISTER_ST_op(1, GeomFromWKB);        REGISTER_ST_op(2, GeomFromWKB);        REGISTER_ST_op(1, IsEmpty);        REGISTER_ST_op(1, IsSimple);        REGISTER_ST_op(1, IsValid);        REGISTER_ST_op(2, Intersects);        REGISTER_ST_op(2, Equals);        REGISTER_ST_op(2, Disjoint);        REGISTER_ST_op(2, Touches);        REGISTER_ST_op(2, Crosses);        REGISTER_ST_op(2, Within);        REGISTER_ST_op(2, Contains);        REGISTER_ST_op(2, Overlaps);        REGISTER_ST_op(2, Intersection);        REGISTER_ST_op(2, Difference);        // Union() is invalid        sqlite3_create_function(hDB, "ST_Union", 2, SQLITE_ANY, NULL,                                OGR2SQLITE_ST_Union, NULL, NULL);        REGISTER_ST_op(2, SymDifference);        REGISTER_ST_op(1, SRID);        REGISTER_ST_op(1, Area);        REGISTER_ST_op(2, Buffer);//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,


示例26: GetLayerByName

void OGRDWGDataSource::ReadBlocksSection(){    OGRDWGLayer *poReaderLayer = (OGRDWGLayer *) GetLayerByName( "Entities" );    int bMergeBlockGeometries = CSLTestBoolean(        CPLGetConfigOption( "DWG_MERGE_BLOCK_GEOMETRIES", "TRUE" ) );/* -------------------------------------------------------------------- *//*      Loop over all the block tables, skipping *Model_Space which     *//*      we assume is primary entities.                                  *//* -------------------------------------------------------------------- */    OdDbBlockTableRecordPtr  poModelSpace, poBlock;    OdDbBlockTablePtr pTable = GetDB()->getBlockTableId().safeOpenObject();    OdDbSymbolTableIteratorPtr pBlkIter = pTable->newIterator();        for (pBlkIter->start(); ! pBlkIter->done(); pBlkIter->step())    {        poBlock = pBlkIter->getRecordId().safeOpenObject();        CPLString osBlockName = (const char *) poBlock->getName();        if( EQUAL(osBlockName,"*Model_Space") )        {            poModelSpace = poBlock;            continue;        }        poReaderLayer->SetBlockTable( poBlock );        // Now we will process entities till we run out.        // We aggregate the geometries of the features into a multi-geometry,        // but throw away other stuff attached to the features.        OGRFeature *poFeature;        OGRGeometryCollection *poColl = new OGRGeometryCollection();        std::vector<OGRFeature*> apoFeatures;        while( (poFeature = poReaderLayer->GetNextUnfilteredFeature()) != NULL )        {            if( (poFeature->GetStyleString() != NULL                 && strstr(poFeature->GetStyleString(),"LABEL") != NULL)                || !bMergeBlockGeometries )            {                apoFeatures.push_back( poFeature );            }            else            {                poColl->addGeometryDirectly( poFeature->StealGeometry() );                delete poFeature;            }        }        if( poColl->getNumGeometries() == 0 )            delete poColl;        else            oBlockMap[osBlockName].poGeometry = SimplifyBlockGeometry(poColl);        if( apoFeatures.size() > 0 )            oBlockMap[osBlockName].apoFeatures = apoFeatures;    }    CPLDebug( "DWG", "Read %d blocks with meaningful geometry.",               (int) oBlockMap.size() );    poReaderLayer->SetBlockTable( poModelSpace );}
开发者ID:drownedout,项目名称:datamap,代码行数:65,


示例27: GetState

void NASReader::SetFeatureProperty( const char *pszElement,                                     const char *pszValue ){    GMLFeature *poFeature = GetState()->m_poFeature;    CPLAssert( poFeature  != NULL );/* -------------------------------------------------------------------- *//*      Does this property exist in the feature class?  If not, add     *//*      it.                                                             *//* -------------------------------------------------------------------- */    GMLFeatureClass *poClass = poFeature->GetClass();    int      iProperty;    for( iProperty=0; iProperty < poClass->GetPropertyCount(); iProperty++ )    {        if( EQUAL(poClass->GetProperty( iProperty )->GetSrcElement(),                  pszElement ) )            break;    }        if( iProperty == poClass->GetPropertyCount() )    {        if( poClass->IsSchemaLocked() )        {            CPLDebug("GML","Encountered property missing from class schema.");            return;        }        CPLString osFieldName;                if( strchr(pszElement,'|') == NULL )            osFieldName = pszElement;        else        {            osFieldName = strrchr(pszElement,'|') + 1;            if( poClass->GetPropertyIndex(osFieldName) != -1 )                osFieldName = pszElement;        }        // Does this conflict with an existing property name?         while( poClass->GetProperty(osFieldName) != NULL )        {            osFieldName += "_";        }        GMLPropertyDefn *poPDefn = new GMLPropertyDefn(osFieldName,pszElement);        if( EQUAL(CPLGetConfigOption( "GML_FIELDTYPES", ""), "ALWAYS_STRING") )            poPDefn->SetType( GMLPT_String );        poClass->AddProperty( poPDefn );    }/* -------------------------------------------------------------------- *//*      Set the property                                                *//* -------------------------------------------------------------------- */    poFeature->SetProperty( iProperty, pszValue );/* -------------------------------------------------------------------- *//*      Do we need to update the property type?                         *//* -------------------------------------------------------------------- */    if( !poClass->IsSchemaLocked() )    {        poClass->GetProperty(iProperty)->AnalysePropertyValue(                             poFeature->GetProperty(iProperty));    }}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:69,


示例28: CPLStrdup

int ILI1Reader::ReadFeatures() {    char **tokens = NULL;    const char *pszLine = NULL;    char *topic = CPLStrdup("(null)");    int ret = TRUE;    while (ret && (tokens = ReadParseLine()) != NULL)    {      const char *firsttok = tokens[0];      if (EQUAL(firsttok, "SCNT"))      {        //read description        do        {          pszLine = CPLReadLine( fpItf );        }        while (pszLine && !STARTS_WITH_CI(pszLine, "////"));        ret = (pszLine != NULL);      }      else if (EQUAL(firsttok, "MOTR"))      {        //read model        do        {          pszLine = CPLReadLine( fpItf );        }        while (pszLine && !STARTS_WITH_CI(pszLine, "////"));        ret = (pszLine != NULL);      }      else if (EQUAL(firsttok, "MTID"))      {      }      else if (EQUAL(firsttok, "MODL"))      {      }      else if (EQUAL(firsttok, "TOPI") && CSLCount(tokens) >= 2)      {        CPLFree(topic);        topic = CPLStrdup(CSLGetField(tokens, 1));      }      else if (EQUAL(firsttok, "TABL") && CSLCount(tokens) >= 2)      {        const char *layername            = GetLayerNameString(topic, CSLGetField(tokens, 1));        CPLDebug( "OGR_ILI", "Reading table '%s'", layername );        curLayer = GetLayerByName(layername);        if (curLayer == NULL) { //create one          CPLError( CE_Warning, CPLE_AppDefined,                    "No model definition for table '%s' found, "                    "using default field names.", layername );          OGRFeatureDefn* poFeatureDefn            = new OGRFeatureDefn(                GetLayerNameString(topic, CSLGetField(tokens, 1)));          poFeatureDefn->SetGeomType( wkbUnknown );          GeomFieldInfos oGeomFieldInfos;          curLayer = new OGRILI1Layer(poFeatureDefn, oGeomFieldInfos, NULL);          AddLayer(curLayer);        }        if(curLayer != NULL) {          for (int i=0; i < curLayer->GetLayerDefn()->GetFieldCount(); i++) {            CPLDebug( "OGR_ILI", "Field %d: %s", i,                      curLayer->GetLayerDefn()->GetFieldDefn(i)->GetNameRef());          }        }        ret = ReadTable(layername);      }      else if (EQUAL(firsttok, "ETOP"))      {      }      else if (EQUAL(firsttok, "EMOD"))      {      }      else if (EQUAL(firsttok, "ENDE"))      {        CSLDestroy(tokens);        CPLFree(topic);        return TRUE;      }      else      {        CPLError( CE_Warning, CPLE_AppDefined,                  "Unexpected token: %s", firsttok );      }      CSLDestroy(tokens);      tokens = NULL;    }    CSLDestroy(tokens);    CPLFree(topic);    return ret;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:94,



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


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