这篇教程C++ CPLError函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLError函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLError函数的具体用法?C++ CPLError怎么用?C++ CPLError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLError函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CPLStrdupint DDFFieldDefn::Initialize( DDFModule * poModuleIn, const char * pszTagIn, int nFieldEntrySize, const char * pachFieldArea ){ int iFDOffset = poModuleIn->GetFieldControlLength(); int nCharsConsumed; poModule = poModuleIn; pszTag = CPLStrdup( pszTagIn );/* -------------------------------------------------------------------- *//* Set the data struct and type codes. *//* -------------------------------------------------------------------- */ switch( pachFieldArea[0] ) { case ' ': /* for ADRG, DIGEST USRP, DIGEST ASRP files */ case '0': _data_struct_code = dsc_elementary; break; case '1': _data_struct_code = dsc_vector; break; case '2': _data_struct_code = dsc_array; break; case '3': _data_struct_code = dsc_concatenated; break; default: CPLError( CE_Failure, CPLE_AppDefined, "Unrecognized data_struct_code value %c./n" "Field %s initialization incorrect.", pachFieldArea[0], pszTag ); _data_struct_code = dsc_elementary; } switch( pachFieldArea[1] ) { case ' ': /* for ADRG, DIGEST USRP, DIGEST ASRP files */ case '0': _data_type_code = dtc_char_string; break; case '1': _data_type_code = dtc_implicit_point; break; case '2': _data_type_code = dtc_explicit_point; break; case '3': _data_type_code = dtc_explicit_point_scaled; break; case '4': _data_type_code = dtc_char_bit_string; break; case '5': _data_type_code = dtc_bit_string; break; case '6': _data_type_code = dtc_mixed_data_type; break; default: CPLError( CE_Failure, CPLE_AppDefined, "Unrecognized data_type_code value %c./n" "Field %s initialization incorrect.", pachFieldArea[1], pszTag ); _data_type_code = dtc_char_string; }/* -------------------------------------------------------------------- *//* Capture the field name, description (sub field names), and *//* format statements. *//* -------------------------------------------------------------------- */ _fieldName = DDFFetchVariable( pachFieldArea + iFDOffset, nFieldEntrySize - iFDOffset, DDF_UNIT_TERMINATOR, DDF_FIELD_TERMINATOR, &nCharsConsumed ); iFDOffset += nCharsConsumed; _arrayDescr = DDFFetchVariable( pachFieldArea + iFDOffset, nFieldEntrySize - iFDOffset, DDF_UNIT_TERMINATOR, DDF_FIELD_TERMINATOR, &nCharsConsumed ); iFDOffset += nCharsConsumed;//.........这里部分代码省略.........
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例2: CPLRealloc//.........这里部分代码省略......... col_def->field_length = 1; } else if( strcasecmp(pszTypeName,"integer") == 0 ) { col_def->target_type = SWQ_INTEGER; } else if( strcasecmp(pszTypeName,"float") == 0 ) { col_def->target_type = SWQ_FLOAT; } else if( strcasecmp(pszTypeName,"numeric") == 0 ) { col_def->target_type = SWQ_FLOAT; parse_precision = 1; } else if( strcasecmp(pszTypeName,"timestamp") == 0 ) { col_def->target_type = SWQ_TIMESTAMP; } else if( strcasecmp(pszTypeName,"date") == 0 ) { col_def->target_type = SWQ_DATE; } else if( strcasecmp(pszTypeName,"time") == 0 ) { col_def->target_type = SWQ_TIME; } else if( strcasecmp(pszTypeName,"geometry") == 0 ) { col_def->target_type = SWQ_GEOMETRY; } else { CPLError( CE_Failure, CPLE_AppDefined, "Unrecognized typename %s in CAST operator.", pszTypeName ); CPLFree(col_def->field_name); col_def->field_name = NULL; CPLFree(col_def->field_alias); col_def->field_alias = NULL; result_columns--; return FALSE; } if( col_def->target_type == SWQ_GEOMETRY ) { if( poExpr->nSubExprCount > 2 ) { if( poExpr->papoSubExpr[2]->field_type != SWQ_STRING ) { CPLError( CE_Failure, CPLE_AppDefined, "First argument of CAST operator should be an geometry type identifier." ); CPLFree(col_def->field_name); col_def->field_name = NULL; CPLFree(col_def->field_alias); col_def->field_alias = NULL; result_columns--; return FALSE; } col_def->eGeomType = OGRFromOGCGeomType(poExpr->papoSubExpr[2]->string_value); // SRID if( poExpr->nSubExprCount > 3 ) {
开发者ID:0004c,项目名称:node-gdal,代码行数:67,
示例3: expand_wildcardCPLErr swq_select::parse( swq_field_list *field_list, CPL_UNUSED int parse_flags ){ int i; CPLErr eError; eError = expand_wildcard( field_list ); if( eError != CE_None ) return eError; /* -------------------------------------------------------------------- *//* Identify field information. *//* -------------------------------------------------------------------- */ for( i = 0; i < result_columns; i++ ) { swq_col_def *def = column_defs + i; if( def->expr != NULL && def->expr->eNodeType != SNT_COLUMN ) { def->field_index = -1; def->table_index = -1; if( def->expr->Check( field_list, TRUE ) == SWQ_ERROR ) return CE_Failure; def->field_type = def->expr->field_type; // If the field was changed from string constant to // column field then adopt the name. if( def->expr->eNodeType == SNT_COLUMN ) { def->field_index = def->expr->field_index; def->table_index = def->expr->table_index; CPLFree( def->field_name ); def->field_name = CPLStrdup(def->expr->string_value); } } else { swq_field_type this_type; /* identify field */ def->field_index = swq_identify_field( def->field_name, field_list, &this_type, &(def->table_index) ); /* record field type */ def->field_type = this_type; if( def->field_index == -1 && def->col_func != SWQCF_COUNT ) { CPLError( CE_Failure, CPLE_AppDefined, "Unrecognised field name %s.", def->field_name ); return CE_Failure; } } /* identify column function if present */ if( (def->col_func == SWQCF_MIN || def->col_func == SWQCF_MAX || def->col_func == SWQCF_AVG || def->col_func == SWQCF_SUM) && (def->field_type == SWQ_STRING || def->field_type == SWQ_GEOMETRY) ) { // possibly this is already enforced by the checker? const swq_operation *op = swq_op_registrar::GetOperator( (swq_op) def->col_func ); CPLError( CE_Failure, CPLE_AppDefined, "Use of field function %s() on %s field %s illegal.", op->pszName, SWQFieldTypeToString(def->field_type), def->field_name ); return CE_Failure; } }/* -------------------------------------------------------------------- *//* Check if we are producing a one row summary result or a set *//* of records. Generate an error if we get conflicting *//* indications. *//* -------------------------------------------------------------------- */ query_mode = -1; for( i = 0; i < result_columns; i++ ) { swq_col_def *def = column_defs + i; int this_indicator = -1; if( def->col_func == SWQCF_MIN || def->col_func == SWQCF_MAX || def->col_func == SWQCF_AVG || def->col_func == SWQCF_SUM || def->col_func == SWQCF_COUNT ) { this_indicator = SWQM_SUMMARY_RECORD; if( def->col_func == SWQCF_COUNT && def->distinct_flag &&//.........这里部分代码省略.........
开发者ID:0004c,项目名称:node-gdal,代码行数:101,
示例4: CPLErrorOGRErr GTMTrackLayer::ICreateFeature (OGRFeature *poFeature){ VSILFILE* fpTmpTrackpoints = poDS->getTmpTrackpointsFP(); if (fpTmpTrackpoints == NULL) return CE_Failure; VSILFILE* fpTmpTracks = poDS->getTmpTracksFP(); if (fpTmpTracks == NULL) return CE_Failure; OGRGeometry *poGeom = poFeature->GetGeometryRef(); if ( poGeom == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Features without geometry not supported by GTM writer in track layer." ); return OGRERR_FAILURE; } if (NULL != poCT) { poGeom = poGeom->clone(); poGeom->transform( poCT ); } switch( poGeom->getGeometryType() ) { case wkbLineString: case wkbLineString25D: { WriteFeatureAttributes(poFeature); OGRLineString* line = (OGRLineString*)poGeom; for(int i = 0; i < line->getNumPoints(); ++i) { double lat = line->getY(i); double lon = line->getX(i); float altitude = 0; CheckAndFixCoordinatesValidity(lat, lon); poDS->checkBounds((float)lat, (float)lon); if (line->getGeometryType() == wkbLineString25D) altitude = (float)line->getZ(i); WriteTrackpoint( lat, lon, altitude, i==0 ); } break; } case wkbMultiLineString: case wkbMultiLineString25D: { int nGeometries = ((OGRGeometryCollection*)poGeom)->getNumGeometries (); for(int j = 0; j < nGeometries; ++j) { WriteFeatureAttributes(poFeature); OGRLineString* line = (OGRLineString*) ( ((OGRGeometryCollection*)poGeom)->getGeometryRef(j) ); int n = (line) ? line->getNumPoints() : 0; for(int i = 0; i < n; ++i) { double lat = line->getY(i); double lon = line->getX(i); float altitude = 0; CheckAndFixCoordinatesValidity(lat, lon); if (line->getGeometryType() == wkbLineString25D) altitude = (float) line->getZ(i); WriteTrackpoint( lat, lon, altitude, i==0 ); } } break; } default: { CPLError( CE_Failure, CPLE_NotSupported, "Geometry type of `%s' not supported for 'track' element./n", OGRGeometryTypeToName(poGeom->getGeometryType()) ); if (NULL != poCT) delete poGeom; return OGRERR_FAILURE; } } if (NULL != poCT) delete poGeom; return OGRERR_NONE;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:84,
示例5: VSIFOpenL//.........这里部分代码省略......... const char *target_name; //planet name //projection parameters const char *map_proj_name; int bProjectionSet = TRUE; char proj_target_name[200]; char geog_name[60]; char datum_name[60]; char sphere_name[60]; char bIsGeographic = TRUE; double semi_major = 0.0; double semi_minor = 0.0; double iflattening = 0.0; float center_lat = 0.0; float center_lon = 0.0; float first_std_parallel = 0.0; float second_std_parallel = 0.0; double radLat, localRadius; FILE *fp; /************* Skipbytes *****************************/ nSkipBytes = atoi(poDS->GetKeyword("IsisCube.Core.StartByte","")) - 1; /******* Grab format type (BandSequential, Tiled) *******/ const char *value; value = poDS->GetKeyword( "IsisCube.Core.Format", "" ); if (EQUAL(value,"Tile") ) { //Todo strcpy(szLayout,"Tiled"); /******* Get Tile Sizes *********/ tileSizeX = atoi(poDS->GetKeyword("IsisCube.Core.TileSamples","")); tileSizeY = atoi(poDS->GetKeyword("IsisCube.Core.TileLines","")); if (tileSizeX <= 0 || tileSizeY <= 0) { CPLError( CE_Failure, CPLE_OpenFailed, "Wrong tile dimensions : %d x %d", tileSizeX, tileSizeY); delete poDS; return NULL; } } else if (EQUAL(value,"BandSequential") ) strcpy(szLayout,"BSQ"); else { CPLError( CE_Failure, CPLE_OpenFailed, "%s layout not supported. Abort/n/n", value); delete poDS; return NULL; } /*********** Grab samples lines band ************/ nCols = atoi(poDS->GetKeyword("IsisCube.Core.Dimensions.Samples","")); nRows = atoi(poDS->GetKeyword("IsisCube.Core.Dimensions.Lines","")); nBands = atoi(poDS->GetKeyword("IsisCube.Core.Dimensions.Bands","")); /****** Grab format type - ISIS3 only supports 8,U16,S16,32 *****/ const char *itype; itype = poDS->GetKeyword( "IsisCube.Core.Pixels.Type" ); if (EQUAL(itype,"UnsignedByte") ) { eDataType = GDT_Byte; dfNoData = NULL1; bNoDataSet = TRUE; } else if (EQUAL(itype,"UnsignedWord") ) { eDataType = GDT_UInt16; dfNoData = NULL1; bNoDataSet = TRUE;
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:67,
示例6: TerragenDatasetGDALDataset *TerragenDataset::Open( GDALOpenInfo * poOpenInfo ){ // The file should have at least 32 header bytes if( poOpenInfo->nHeaderBytes < 32 ) return NULL; if( !EQUALN((const char *) poOpenInfo->pabyHeader, "TERRAGENTERRAIN ", 16) ) return NULL;/* -------------------------------------------------------------------- *//* Create a corresponding GDALDataset. *//* -------------------------------------------------------------------- */ TerragenDataset *poDS; poDS = new TerragenDataset(); // Reopen for large file access. if( poOpenInfo->eAccess == GA_Update ) poDS->m_fp = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); else poDS->m_fp = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); if( poDS->m_fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to re-open %s within Terragen driver./n", poOpenInfo->pszFilename ); return NULL; } poDS->eAccess = poOpenInfo->eAccess; /* -------------------------------------------------------------------- *//* Read the file. *//* -------------------------------------------------------------------- */ if( !poDS->LoadFromFile() ) { delete poDS; return NULL; }/* -------------------------------------------------------------------- *//* Create band information objects. *//* -------------------------------------------------------------------- */ poDS->SetBand( 1, new TerragenRasterBand( poDS )); poDS->SetMetadataItem( GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT );/* -------------------------------------------------------------------- *//* Initialize any PAM information. *//* -------------------------------------------------------------------- */ poDS->SetDescription( poOpenInfo->pszFilename ); poDS->TryLoadXML();/* -------------------------------------------------------------------- *//* Support overviews. *//* -------------------------------------------------------------------- */ poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); return( poDS );}
开发者ID:drownedout,项目名称:datamap,代码行数:64,
示例7: switchOGRErr OGRPGeoLayer::createFromShapeBin( GByte *pabyShape, OGRGeometry **ppoGeom, int nBytes ){ *ppoGeom = NULL; if( nBytes < 1 ) return OGRERR_FAILURE; int nSHPType = pabyShape[0];// CPLDebug( "PGeo", // "Shape type read from PGeo data is nSHPType = %d", // nSHPType );/* -------------------------------------------------------------------- *//* type 50 appears to just be an alias for normal line *//* strings. (#1484) *//* Type 51 appears to just be an alias for normal polygon. (#3100) *//* TODO: These types include additional attributes including *//* non-linear segments and such. They should be handled. *//* -------------------------------------------------------------------- */ switch( nSHPType ) { case 50: nSHPType = SHPT_ARC; break; case 51: nSHPType = SHPT_POLYGON; break; case 52: nSHPType = SHPT_POINT; break; case 53: nSHPType = SHPT_MULTIPOINT; break; case 54: nSHPType = SHPT_MULTIPATCH; }/* ==================================================================== *//* Extract vertices for a Polygon or Arc. *//* ==================================================================== */ if( nSHPType == SHPT_ARC || nSHPType == SHPT_ARCZ || nSHPType == SHPT_ARCM || nSHPType == SHPT_ARCZM || nSHPType == SHPT_POLYGON || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_POLYGONZM || nSHPType == SHPT_MULTIPATCH || nSHPType == SHPT_MULTIPATCHM) { GInt32 nPoints, nParts; int i, nOffset; GInt32 *panPartStart; if (nBytes < 44) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nBytes=%d, nSHPType=%d", nBytes, nSHPType); return OGRERR_FAILURE; }/* -------------------------------------------------------------------- *//* Extract part/point count, and build vertex and part arrays *//* to proper size. *//* -------------------------------------------------------------------- */ memcpy( &nPoints, pabyShape + 40, 4 ); memcpy( &nParts, pabyShape + 36, 4 ); CPL_LSBPTR32( &nPoints ); CPL_LSBPTR32( &nParts ); if (nPoints < 0 || nParts < 0 || nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000) { CPLError(CE_Failure, CPLE_AppDefined, "Corrupted Shape : nPoints=%d, nParts=%d.", nPoints, nParts); return OGRERR_FAILURE; } int bHasZ = ( nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_POLYGONZM || nSHPType == SHPT_ARCZ || nSHPType == SHPT_ARCZM || nSHPType == SHPT_MULTIPATCH || nSHPType == SHPT_MULTIPATCHM ); int bIsMultiPatch = ( nSHPType == SHPT_MULTIPATCH || nSHPType == SHPT_MULTIPATCHM ); /* With the previous checks on nPoints and nParts, */ /* we should not overflow here and after */ /* since 50 M * (16 + 8 + 8) = 1 600 MB */ int nRequiredSize = 44 + 4 * nParts + 16 * nPoints; if ( bHasZ ) {//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例8: swq_identify_fieldswq_field_type swq_expr_node::Check( swq_field_list *poFieldList ){/* -------------------------------------------------------------------- *//* If something is a string constant, we must check if it is *//* actually a reference to a field in which case we will *//* convert it into a column type. *//* -------------------------------------------------------------------- */ if( eNodeType == SNT_CONSTANT && field_type == SWQ_STRING ) { int wrk_field_index, wrk_table_index; swq_field_type wrk_field_type; wrk_field_index = swq_identify_field( string_value, poFieldList, &wrk_field_type, &wrk_table_index ); if( wrk_field_index >= 0 ) { eNodeType = SNT_COLUMN; field_index = -1; table_index = -1; } }/* -------------------------------------------------------------------- *//* Otherwise we take constants literally. *//* -------------------------------------------------------------------- */ if( eNodeType == SNT_CONSTANT ) return field_type;/* -------------------------------------------------------------------- *//* If this is intended to be a field definition, but has not *//* yet been looked up, we do so now. *//* -------------------------------------------------------------------- */ if( eNodeType == SNT_COLUMN && field_index == -1 ) { field_index = swq_identify_field( string_value, poFieldList, &field_type, &table_index ); if( field_index < 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "'%s' not recognised as an available field.", string_value ); return SWQ_ERROR; } } if( eNodeType == SNT_COLUMN ) return field_type; /* -------------------------------------------------------------------- *//* We are dealing with an operation - fetch the definition. *//* -------------------------------------------------------------------- */ const swq_operation *poOp = swq_op_registrar::GetOperator((swq_op)nOperation); if( poOp == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Check(): Unable to find definition for operator %d.", nOperation ); return SWQ_ERROR; }/* -------------------------------------------------------------------- *//* Check subexpressions first. *//* -------------------------------------------------------------------- */ int i; for( i = 0; i < nSubExprCount; i++ ) { if( papoSubExpr[i]->Check(poFieldList) == SWQ_ERROR ) return SWQ_ERROR; } /* -------------------------------------------------------------------- *//* Check this node. *//* -------------------------------------------------------------------- */ field_type = poOp->pfnChecker( this ); return field_type;}
开发者ID:agrismart,项目名称:gdal-1.9.2,代码行数:87,
示例9: CPLAssertint OGRGPSBabelDataSource::Open( const char * pszDatasourceName, const char* pszGPSBabelDriverNameIn, char** papszOpenOptions ){ int bExplicitFeatures = FALSE; int bWaypoints = TRUE, bTracks = TRUE, bRoutes = TRUE; if (!EQUALN(pszDatasourceName, "GPSBABEL:", 9)) { CPLAssert(pszGPSBabelDriverNameIn); pszGPSBabelDriverName = CPLStrdup(pszGPSBabelDriverNameIn); pszFilename = CPLStrdup(pszDatasourceName); } else { if( CSLFetchNameValue(papszOpenOptions, "FILENAME") ) pszFilename = CPLStrdup(CSLFetchNameValue(papszOpenOptions, "FILENAME")); if( CSLFetchNameValue(papszOpenOptions, "GPSBABEL_DRIVER") ) { if( pszFilename == NULL ) { CPLError(CE_Failure, CPLE_AppDefined, "Missing FILENAME"); return FALSE; } pszGPSBabelDriverName = CPLStrdup(CSLFetchNameValue(papszOpenOptions, "DRIVER")); /* A bit of validation to avoid command line injection */ if (!IsValidDriverName(pszGPSBabelDriverName)) return FALSE; } } pszName = CPLStrdup( pszDatasourceName ); if (pszGPSBabelDriverName == NULL) { const char* pszSep = strchr(pszDatasourceName + 9, ':'); if (pszSep == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Wrong syntax. Expected GPSBabel:driver_name:file_name"); return FALSE; } pszGPSBabelDriverName = CPLStrdup(pszDatasourceName + 9); *(strchr(pszGPSBabelDriverName, ':')) = '/0'; /* A bit of validation to avoid command line injection */ if (!IsValidDriverName(pszGPSBabelDriverName)) return FALSE; /* Parse optionnal features= option */ if (EQUALN(pszSep+1, "features=", 9)) { const char* pszNextSep = strchr(pszSep+1, ':'); if (pszNextSep == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Wrong syntax. Expected GPSBabel:driver_name[,options]*:[features=waypoints,tracks,routes:]file_name"); return FALSE; } char* pszFeatures = CPLStrdup(pszSep+1+9); *strchr(pszFeatures, ':') = 0; char** papszTokens = CSLTokenizeString(pszFeatures); char** papszIter = papszTokens; int bErr = FALSE; bExplicitFeatures = TRUE; bWaypoints = bTracks = bRoutes = FALSE; while(papszIter && *papszIter) { if (EQUAL(*papszIter, "waypoints")) bWaypoints = TRUE; else if (EQUAL(*papszIter, "tracks")) bTracks = TRUE; else if (EQUAL(*papszIter, "routes")) bRoutes = TRUE; else { CPLError(CE_Failure, CPLE_AppDefined, "Wrong value for 'features' options"); bErr = TRUE; } papszIter ++; } CSLDestroy(papszTokens); CPLFree(pszFeatures); if (bErr) return FALSE; pszSep = pszNextSep; } if( pszFilename == NULL ) pszFilename = CPLStrdup(pszSep+1);//.........这里部分代码省略.........
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:101,
示例10: oStmtvoid OGRPGeoLayer::LookupSRID( int nSRID ){/* -------------------------------------------------------------------- *//* Fetch the corresponding WKT from the SpatialRef table. *//* -------------------------------------------------------------------- */ CPLODBCStatement oStmt( poDS->GetSession() ); oStmt.Appendf( "SELECT srtext FROM GDB_SpatialRefs WHERE srid = %d", nSRID ); if( !oStmt.ExecuteSQL() ) { CPLError( CE_Failure, CPLE_AppDefined, "'%s' failed./n%s", oStmt.GetCommand(), poDS->GetSession()->GetLastError() ); return; } if( !oStmt.Fetch() ) { CPLError( CE_Warning, CPLE_AppDefined, "SRID %d lookup failed./n%s", nSRID, poDS->GetSession()->GetLastError() ); return; }/* -------------------------------------------------------------------- *//* Check that it isn't just a GUID. We don't know how to *//* translate those. *//* -------------------------------------------------------------------- */ char *pszSRText = (char *) oStmt.GetColData(0); if( pszSRText[0] == '{' ) { CPLDebug( "PGEO", "Ignoreing GUID SRTEXT: %s", pszSRText ); return; }/* -------------------------------------------------------------------- *//* Turn it into an OGRSpatialReference. *//* -------------------------------------------------------------------- */ poSRS = new OGRSpatialReference(); if( poSRS->importFromWkt( &pszSRText ) != OGRERR_NONE ) { CPLError( CE_Failure, CPLE_AppDefined, "importFromWKT() failed on SRS '%s'.", pszSRText); delete poSRS; poSRS = NULL; } else if( poSRS->morphFromESRI() != OGRERR_NONE ) { CPLError( CE_Failure, CPLE_AppDefined, "morphFromESRI() failed on SRS." ); delete poSRS; poSRS = NULL; } else nSRSId = nSRID;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:63,
示例11: VSIFOpenL//.........这里部分代码省略......... { if ( EQUAL(papszTokens[1], "U1") || EQUAL(papszTokens[1], "U2") || EQUAL(papszTokens[1], "U4") || EQUAL(papszTokens[1], "U8") ) { nBits = 8; eDataType = GDT_Byte; } else if( EQUAL(papszTokens[1], "U16") ) { nBits = 16; eDataType = GDT_UInt16; } else if( EQUAL(papszTokens[1], "U32") ) { nBits = 32; eDataType = GDT_UInt32; } else if( EQUAL(papszTokens[1], "S16") ) { nBits = 16; eDataType = GDT_Int16; } else if( EQUAL(papszTokens[1], "S32") ) { nBits = 32; eDataType = GDT_Int32; } else if( EQUAL(papszTokens[1], "F32") ) { nBits = 32; eDataType = GDT_Float32; } else if( EQUAL(papszTokens[1], "F64") ) { nBits = 64; eDataType = GDT_Float64; } else { CPLError( CE_Failure, CPLE_NotSupported, "EIR driver does not support DATATYPE %s.", papszTokens[1] ); CSLDestroy( papszTokens ); CSLDestroy( papszHDR ); VSIFCloseL( fp ); return NULL; } } else if( EQUAL(papszTokens[0],"BYTE_ORDER") ) { // M for MSB, L for LSB chByteOrder = toupper(papszTokens[1][0]); } else if( EQUAL(papszTokens[0],"DATA_OFFSET") ) { nSkipBytes = atoi(papszTokens[1]); // TBD: is this mapping right? } CSLDestroy( papszTokens ); } VSIFCloseL( fp ); /* -------------------------------------------------------------------- *//* 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 ) { CSLDestroy( papszHDR );
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:67,
示例12: BNA_GetNextRecord//.........这里部分代码省略......... } else if (c == ' ' || c == '/t') { if (numField > NB_MIN_BNA_IDS + nbExtraId && ptrBeginningOfNumber != NULL) { do { ptrCurLine++; numChar = ptrCurLine - ptrBeginLine; c = *ptrCurLine; if (!(c == ' ' || c == '/t')) break; } while(c); if (c == 0) c = 10; if (interestFeatureType == BNA_READ_ALL || interestFeatureType == currentFeatureType) { char* pszComma = strchr(ptrBeginningOfNumber, ','); if (pszComma) *pszComma = '/0'; record->tabCoords[(numField - nbExtraId - NB_MIN_BNA_IDS - 1) / 2] [1 - ((numField - nbExtraId) % 2)] = CPLAtof(ptrBeginningOfNumber); if (pszComma) *pszComma = ','; } if (numField == NB_MIN_BNA_IDS + 1 + nbExtraId + 2 * record->nCoords - 1) { if (c != 10) { if (verbose) { CPLError(CE_Warning, CPLE_AppDefined, "At line %d, at char %d, extra data will be ignored!/n", *curLine, numChar+1); } } *ok = 1; return record; } ptrBeginningOfNumber = NULL; exponentFound = 0; exponentSignFound = 0; dotFound = 0; numField++; if (c == 10) break; if (c != ',') { /* don't increment ptrCurLine */ continue; } } else { /* ignore */ } } else if (c == 10 || c == ',') { /* Eat a comma placed at end of line */ if (c == ',')
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:67,
示例13: CPLErrorint DDFFieldDefn::ApplyFormats(){ char *pszFormatList; char **papszFormatItems;/* -------------------------------------------------------------------- *//* Verify that the format string is contained within brackets. *//* -------------------------------------------------------------------- */ if( strlen(_formatControls) < 2 || _formatControls[0] != '(' || _formatControls[strlen(_formatControls)-1] != ')' ) { CPLError( CE_Warning, (CPLErrorNum)CPLE_DiscardedFormat, "Format controls for `%s' field missing brackets:%s", pszTag, _formatControls ); return FALSE; }/* -------------------------------------------------------------------- *//* Duplicate the string, and strip off the brackets. *//* -------------------------------------------------------------------- */ pszFormatList = ExpandFormat( _formatControls );/* -------------------------------------------------------------------- *//* Tokenize based on commas. *//* -------------------------------------------------------------------- */ papszFormatItems = CSLTokenizeStringComplex(pszFormatList, ",", FALSE, FALSE ); CPLFree( pszFormatList );/* -------------------------------------------------------------------- *//* Apply the format items to subfields. *//* -------------------------------------------------------------------- */ int iFormatItem; for( iFormatItem = 0; papszFormatItems[iFormatItem] != NULL; iFormatItem++ ) { const char *pszPastPrefix; pszPastPrefix = papszFormatItems[iFormatItem]; while( *pszPastPrefix >= '0' && *pszPastPrefix <= '9' ) pszPastPrefix++; /////////////////////////////////////////////////////////////// // Did we get too many formats for the subfields created // by names? This may be legal by the 8211 specification, but // isn't encountered in any formats we care about so we just // blow. if( iFormatItem >= nSubfieldCount ) { CPLError( CE_Warning, (CPLErrorNum)CPLE_DiscardedFormat, "Got more formats than subfields for field `%s'.", pszTag ); break; } if( !papoSubfields[iFormatItem]->SetFormat(pszPastPrefix) ) { CSLDestroy( papszFormatItems ); return FALSE; } }/* -------------------------------------------------------------------- *//* Verify that we got enough formats, cleanup and return. *//* -------------------------------------------------------------------- */ CSLDestroy( papszFormatItems ); if( iFormatItem < nSubfieldCount ) { CPLError( CE_Warning, (CPLErrorNum)CPLE_DiscardedFormat, "Got less formats than subfields for field `%s'.", pszTag ); return FALSE; }/* -------------------------------------------------------------------- *//* If all the fields are fixed width, then we are fixed width *//* too. This is important for repeating fields. *//* -------------------------------------------------------------------- */ nFixedWidth = 0; for( int i = 0; i < nSubfieldCount; i++ ) { if( papoSubfields[i]->GetWidth() == 0 ) { nFixedWidth = 0; break; } else nFixedWidth += papoSubfields[i]->GetWidth(); } return TRUE;//.........这里部分代码省略.........
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例14: CPLAssertint ods_formula_node::EvaluateIF(IODSCellEvaluator* poEvaluator){ CPLAssert( eNodeType == SNT_OPERATION ); CPLAssert( eOp == ODS_IF ); CPLAssert(nSubExprCount == 2 || nSubExprCount == 3); if (!(papoSubExpr[0]->Evaluate(poEvaluator))) return FALSE; if (!(papoSubExpr[1]->Evaluate(poEvaluator))) return FALSE; if (nSubExprCount == 3 && !(papoSubExpr[2]->Evaluate(poEvaluator))) return FALSE; CPLAssert(papoSubExpr[0]->eNodeType == SNT_CONSTANT ); CPLAssert(papoSubExpr[1]->eNodeType == SNT_CONSTANT ); if (nSubExprCount == 3) { CPLAssert(papoSubExpr[2]->eNodeType == SNT_CONSTANT ); } int bCond = FALSE; if (papoSubExpr[0]->field_type == ODS_FIELD_TYPE_INTEGER) { bCond = (papoSubExpr[0]->int_value != 0); } else if (papoSubExpr[0]->field_type == ODS_FIELD_TYPE_FLOAT) { bCond = (papoSubExpr[0]->float_value != 0); } else { CPLError(CE_Failure, CPLE_NotSupported, "Bad argument type for %s", ODSGetOperatorName(eOp)); return FALSE; } if (bCond) { eNodeType = SNT_CONSTANT; field_type = papoSubExpr[1]->field_type; if (field_type == ODS_FIELD_TYPE_INTEGER) int_value = papoSubExpr[1]->int_value; else if (field_type == ODS_FIELD_TYPE_FLOAT) float_value = papoSubExpr[1]->float_value; else if (field_type == ODS_FIELD_TYPE_STRING) { string_value = papoSubExpr[1]->string_value; papoSubExpr[1]->string_value = NULL; } } else if (nSubExprCount == 3) { eNodeType = SNT_CONSTANT; field_type = papoSubExpr[2]->field_type; if (field_type == ODS_FIELD_TYPE_INTEGER) int_value = papoSubExpr[2]->int_value; else if (field_type == ODS_FIELD_TYPE_FLOAT) float_value = papoSubExpr[2]->float_value; else if (field_type == ODS_FIELD_TYPE_STRING) { string_value = papoSubExpr[2]->string_value; papoSubExpr[2]->string_value = NULL; } } else { eNodeType = SNT_CONSTANT; field_type = ODS_FIELD_TYPE_INTEGER; int_value = FALSE; } FreeSubExpr(); return TRUE;}
开发者ID:garnertb,项目名称:gdal,代码行数:74,
示例15: KEACopyRasterData// Copies GDAL Band to KEA Band if nOverview == -1// Otherwise it is assumed we are writing to the specified overviewstaticbool KEACopyRasterData( GDALRasterBand *pBand, kealib::KEAImageIO *pImageIO, int nBand, int nOverview, int nTotalBands, GDALProgressFunc pfnProgress, void *pProgressData){ // get some info kealib::KEADataType eKeaType = pImageIO->getImageBandDataType(nBand); unsigned int nBlockSize; if( nOverview == -1 ) nBlockSize = pImageIO->getImageBlockSize( nBand ); else nBlockSize = pImageIO->getOverviewBlockSize(nBand, nOverview); GDALDataType eGDALType = pBand->GetRasterDataType(); unsigned int nXSize = pBand->GetXSize(); unsigned int nYSize = pBand->GetYSize(); // allocate some space int nPixelSize = GDALGetDataTypeSize( eGDALType ) / 8; void *pData = VSIMalloc3( nPixelSize, nBlockSize, nBlockSize); if( pData == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Unable to allocate memory" ); return false; } // for progress int nTotalBlocks = static_cast<int>(std::ceil( (double)nXSize / (double)nBlockSize ) * std::ceil( (double)nYSize / (double)nBlockSize )); int nBlocksComplete = 0; double dLastFraction = -1; // go through the image for( unsigned int nY = 0; nY < nYSize; nY += nBlockSize ) { // adjust for edge blocks unsigned int nysize = nBlockSize; unsigned int nytotalsize = nY + nBlockSize; if( nytotalsize > nYSize ) nysize -= (nytotalsize - nYSize); for( unsigned int nX = 0; nX < nXSize; nX += nBlockSize ) { // adjust for edge blocks unsigned int nxsize = nBlockSize; unsigned int nxtotalsize = nX + nBlockSize; if( nxtotalsize > nXSize ) nxsize -= (nxtotalsize - nXSize); // read in from GDAL if( pBand->RasterIO( GF_Read, nX, nY, nxsize, nysize, pData, nxsize, nysize, eGDALType, nPixelSize, nPixelSize * nBlockSize, NULL) != CE_None ) { CPLError( CE_Failure, CPLE_AppDefined, "Unable to read block at %d %d/n", nX, nY ); return false; } // write out to KEA if( nOverview == -1 ) pImageIO->writeImageBlock2Band( nBand, pData, nX, nY, nxsize, nysize, nBlockSize, nBlockSize, eKeaType); else pImageIO->writeToOverview( nBand, nOverview, pData, nX, nY, nxsize, nysize, nBlockSize, nBlockSize, eKeaType); // progress nBlocksComplete++; if( nOverview == -1 ) { double dFraction = (((double)nBlocksComplete / (double)nTotalBlocks) / (double)nTotalBands) + ((double)(nBand-1) * (1.0 / (double)nTotalBands)); if( dFraction != dLastFraction ) { if( !pfnProgress( dFraction, NULL, pProgressData ) ) { CPLFree( pData ); return false; } dLastFraction = dFraction; } } } } CPLFree( pData ); return true;}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:81,
示例16: PrintSRSCPLErr PrintSRS( const OGRSpatialReference &oSRS, const char * pszOutputType, bool bPretty, bool bPrintSep ){ if ( ! pszOutputType || EQUAL(pszOutputType,"")) return CE_None; CPLDebug( "gdalsrsinfo", "PrintSRS( oSRS, %s, %d, %d )/n", pszOutputType, static_cast<int>(bPretty), static_cast<int>(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:Mavrx-inc,项目名称:gdal,代码行数:82,
示例17: memcpybool TerragenDataset::write_header(){ char szHeader[16]; memcpy(szHeader, "TERRAGENTERRAIN ", sizeof(szHeader)); if(1 != VSIFWriteL( (void *) szHeader, sizeof(szHeader), 1, m_fp )) { CPLError( CE_Failure, CPLE_FileIO, "Couldn't write to Terragen file %s./n" "Is file system full?", m_pszFilename ); VSIFCloseL( m_fp ); return false; } // -------------------------------------------------------------------- // Write out the heightfield dimensions, etc.// -------------------------------------------------------------------- const int nXSize = this->GetRasterXSize(); const int nYSize = this->GetRasterYSize(); this->write_next_tag("SIZE"); this->put((GInt16)(min(nXSize, nYSize)-1)); this->pad(sizeof(GInt16)); if(nXSize != nYSize) { this->write_next_tag("XPTS"); this->put((GInt16)nXSize); this->pad(sizeof(GInt16)); this->write_next_tag("YPTS"); this->put((GInt16)nYSize); this->pad(sizeof(GInt16)); } if(m_bIsGeo) { /* With a geographic projection (degrees), m_dGroundScale will be in degrees and m_dMetersPerGroundUnit is undefined. So we're going to estimate a m_dMetersPerGroundUnit value here (i.e., meters per degree). We figure out the degree size of one pixel, and then the latitude degrees of the heightfield's center. The circumference of the latitude's great circle lets us know how wide the pixel is in meters, and we average that with the pixel's meter breadth, which is based on the polar circumference. */ /*const double m_dDegLongPerPixel = fabs(m_adfTransform[1]);*/ const double m_dDegLatPerPixel = fabs(m_adfTransform[5]); /*const double m_dCenterLongitude = m_adfTransform[0] + (0.5 * m_dDegLongPerPixel * (nXSize-1));*/ const double m_dCenterLatitude = m_adfTransform[3] + (0.5 * m_dDegLatPerPixel * (nYSize-1)); const double dLatCircum = kdEarthCircumEquat * sin(degrees_to_radians(90.0 - m_dCenterLatitude)); const double dMetersPerDegLongitude = dLatCircum / 360; /*const double dMetersPerPixelX = (m_dDegLongPerPixel / 360) * dLatCircum;*/ const double dMetersPerDegLatitude = kdEarthCircumPolar / 360; /*const double dMetersPerPixelY = (m_dDegLatPerPixel / 360) * kdEarthCircumPolar;*/ m_dMetersPerGroundUnit = average(dMetersPerDegLongitude, dMetersPerDegLatitude); } m_dSCAL = m_dGroundScale * m_dMetersPerGroundUnit; if(m_dSCAL != 30.0) { const float sc = (float)m_dSCAL; this->write_next_tag("SCAL"); this->put(sc); this->put(sc); this->put(sc); } if(!this->write_next_tag("ALTW")) { CPLError( CE_Failure, CPLE_FileIO, //.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例18: mainint main( int argc, char ** argv ){ bool bGotSRS = false; bool bPretty = false; bool bValidate = false; bool 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();/* -------------------------------------------------------------------- *//* Register standard GDAL drivers, and process generic GDAL *//* command options. *//* -------------------------------------------------------------------- */ argc = GDALGeneralCmdLineProcessor( argc, &argv, 0 ); if( argc < 1 ) exit( -argc );/* -------------------------------------------------------------------- *//* Parse arguments. *//* -------------------------------------------------------------------- */ for( int 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")); CSLDestroy( argv ); 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 */ /* coverity[tainted_data] */ bGotSRS = FindSRS( pszInput, oSRS ) == TRUE; CPLDebug( "gdalsrsinfo", "bGotSRS: %d bValidate: %d pszOutputType: %s bPretty: %d", static_cast<int>(bGotSRS), static_cast<int>(bValidate), pszOutputType, static_cast<int>(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:Mavrx-inc,项目名称:gdal,代码行数:101,
示例19: CPLErrorOGRDataSource *OGRCSVDriver::CreateDataSource( const char * pszName, char **papszOptions ){/* -------------------------------------------------------------------- *//* First, ensure there isn't any such file yet. *//* -------------------------------------------------------------------- */ VSIStatBufL sStatBuf; if( VSIStatL( pszName, &sStatBuf ) == 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "It seems a file system object called '%s' already exists.", pszName ); return NULL; }/* -------------------------------------------------------------------- *//* If the target is not a simple .csv then create it as a *//* directory. *//* -------------------------------------------------------------------- */ CPLString osDirName; if( EQUAL(CPLGetExtension(pszName),"csv") ) { osDirName = CPLGetPath(pszName); if( osDirName == "" ) osDirName = "."; } else { if( strncmp(pszName, "/vsizip/", 8) == 0) { /* do nothing */ } else if( !EQUAL(pszName, "/vsistdout/") && VSIMkdir( pszName, 0755 ) != 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "Failed to create directory %s:/n%s", pszName, VSIStrerror( errno ) ); return NULL; } osDirName = pszName; }/* -------------------------------------------------------------------- *//* Force it to open as a datasource. *//* -------------------------------------------------------------------- */ OGRCSVDataSource *poDS = new OGRCSVDataSource(); if( !poDS->Open( osDirName, TRUE, TRUE ) ) { delete poDS; return NULL; } if( osDirName != pszName ) poDS->SetDefaultCSVName( CPLGetFilename(pszName) ); return poDS;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:63,
示例20: GDALGetDataTypeSize/***************************************************** * /brief Read a natural block of raster band data *****************************************************/CPLErr PostGISRasterTileRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff, CPL_UNUSED int nBlockYOff, void * pImage){ CPLString osCommand; PGresult * poResult = NULL; int nWKBLength = 0; int nPixelSize = GDALGetDataTypeSize(eDataType)/8; PostGISRasterTileDataset * poRTDS = (PostGISRasterTileDataset *)poDS; // Get by PKID if (poRTDS->poRDS->pszPrimaryKeyName) { //osCommand.Printf("select ST_AsBinary(st_band(%s, %d),TRUE) from %s.%s where " osCommand.Printf("select st_band(%s, %d) from %s.%s where " "%s = '%s'", poRTDS->poRDS->pszColumn, nBand, poRTDS->poRDS->pszSchema, poRTDS->poRDS->pszTable, poRTDS->poRDS->pszPrimaryKeyName, poRTDS->pszPKID); } // Get by upperleft else { osCommand.Printf("select st_band(%s, %d) from %s.%s where " "abs(ST_UpperLeftX(%s) - %.8f) < 1e-8 and abs(ST_UpperLeftY(%s) - %.8f) < 1e-8", poRTDS->poRDS->pszColumn, nBand, poRTDS->poRDS->pszSchema, poRTDS->poRDS->pszTable, poRTDS->poRDS->pszColumn, poRTDS->adfGeoTransform[GEOTRSFRM_TOPLEFT_X], poRTDS->poRDS->pszColumn, poRTDS->adfGeoTransform[GEOTRSFRM_TOPLEFT_Y]); } poResult = PQexec(poRTDS->poRDS->poConn, osCommand.c_str());#ifdef DEBUG_QUERY CPLDebug("PostGIS_Raster", "PostGISRasterTileRasterBand::IReadBlock(): " "Query = /"%s/" --> number of rows = %d", osCommand.c_str(), poResult ? PQntuples(poResult) : 0 );#endif if (poResult == NULL || PQresultStatus(poResult) != PGRES_TUPLES_OK || PQntuples(poResult) <= 0) { if (poResult) PQclear(poResult); ReportError(CE_Failure, CPLE_AppDefined, "Error getting block of data (upperpixel = %f, %f)", poRTDS->adfGeoTransform[GEOTRSFRM_TOPLEFT_X], poRTDS->adfGeoTransform[GEOTRSFRM_TOPLEFT_Y]); return CE_Failure; } // TODO: Check this if (bIsOffline) { CPLError(CE_Failure, CPLE_AppDefined, "This raster has outdb " "storage. This feature isn't still available"); PQclear(poResult); return CE_Failure; } /* Copy only data size, without payload */ int nExpectedDataSize = nBlockXSize * nBlockYSize * nPixelSize; GByte * pbyData = CPLHexToBinary(PQgetvalue(poResult, 0, 0), &nWKBLength); int nExpectedWKBLength = RASTER_HEADER_SIZE + BAND_SIZE(nPixelSize, nExpectedDataSize); CPLErr eRet = CE_None; if( nWKBLength != nExpectedWKBLength ) { CPLDebug("PostGIS_Raster", "nWKBLength=%d, nExpectedWKBLength=%d", nWKBLength, nExpectedWKBLength ); eRet = CE_Failure; } else { GByte * pbyDataToRead = (GByte*)GET_BAND_DATA(pbyData,1, nPixelSize, nExpectedDataSize); // Do byte-swapping if necessary */ int bIsLittleEndian = (pbyData[0] == 1);#ifdef CPL_LSB int bSwap = !bIsLittleEndian;#else int bSwap = bIsLittleEndian;#endif if( bSwap && nPixelSize > 1 ) { GDALSwapWords( pbyDataToRead, nPixelSize, nBlockXSize * nBlockYSize, nPixelSize ); }//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例21: OGRSpatialReferenceGTMTrackLayer::GTMTrackLayer( const char* pszName, OGRSpatialReference* poSRSIn, CPL_UNUSED int bWriterIn, OGRGTMDataSource* poDSIn ){ poCT = NULL; /* We are implementing just WGS84, although GTM supports other datum formats. */ if( poSRSIn != NULL ) { poSRS = new OGRSpatialReference(NULL); poSRS->SetWellKnownGeogCS( "WGS84" ); if (!poSRS->IsSame(poSRSIn)) { poCT = OGRCreateCoordinateTransformation( poSRSIn, poSRS ); if( poCT == NULL && poDSIn->isFirstCTError() ) { /* If we can't create a transformation, issue a warning - but continue the transformation*/ char *pszWKT = NULL; poSRSIn->exportToPrettyWkt( &pszWKT, FALSE ); CPLError( CE_Warning, CPLE_AppDefined, "Failed to create coordinate transformation between the/n" "input coordinate system and WGS84. This may be because they/n" "are not transformable, or because projection services/n" "(PROJ.4 DLL/.so) could not be loaded./n" "This message will not be issued any more. /n" "/nSource:/n%s/n", pszWKT ); CPLFree( pszWKT ); poDSIn->issuedFirstCTError(); } } } else { poSRS = NULL; } poDS = poDSIn; nNextFID = 0; nTotalFCount = poDS->getNTracks(); poFeatureDefn = new OGRFeatureDefn( pszName ); SetDescription( poFeatureDefn->GetName() ); poFeatureDefn->Reference(); poFeatureDefn->SetGeomType ( wkbLineString ); poFeatureDefn->GetGeomFieldDefn(0)->SetSpatialRef(poSRS); /* We implement just name, type, and color for tracks, if others needed feel free to append more parameters and implement the code */ OGRFieldDefn oFieldName( "name", OFTString ); poFeatureDefn->AddFieldDefn( &oFieldName ); OGRFieldDefn oFieldTrackType( "type", OFTInteger ); poFeatureDefn->AddFieldDefn( &oFieldTrackType ); OGRFieldDefn oFieldColor( "color", OFTInteger ); poFeatureDefn->AddFieldDefn( &oFieldColor ); this->pszName = CPLStrdup(pszName);}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:68,
示例22: oFieldOGRErr OGRMySQLTableLayer::CreateField( OGRFieldDefn *poFieldIn, int bApproxOK ){ MYSQL_RES *hResult=nullptr; CPLString osCommand; char szFieldType[256]; OGRFieldDefn oField( poFieldIn );/* -------------------------------------------------------------------- *//* Do we want to "launder" the column names into Postgres *//* friendly format? *//* -------------------------------------------------------------------- */ if( bLaunderColumnNames ) { char *pszSafeName = poDS->LaunderName( oField.GetNameRef() ); oField.SetName( pszSafeName ); CPLFree( pszSafeName ); }/* -------------------------------------------------------------------- *//* Work out the MySQL type. *//* -------------------------------------------------------------------- */ if( oField.GetType() == OFTInteger ) { if( oField.GetWidth() > 0 && bPreservePrecision ) snprintf( szFieldType, sizeof(szFieldType), "DECIMAL(%d,0)", oField.GetWidth() ); else strcpy( szFieldType, "INTEGER" ); } else if( oField.GetType() == OFTInteger64 ) { if( oField.GetWidth() > 0 && bPreservePrecision ) snprintf( szFieldType, sizeof(szFieldType), "DECIMAL(%d,0)", oField.GetWidth() ); else strcpy( szFieldType, "BIGINT" ); } else if( oField.GetType() == OFTReal ) { if( oField.GetWidth() > 0 && oField.GetPrecision() > 0 && bPreservePrecision ) snprintf( szFieldType, sizeof(szFieldType), "DOUBLE(%d,%d)", oField.GetWidth(), oField.GetPrecision() ); else strcpy( szFieldType, "DOUBLE" ); } else if( oField.GetType() == OFTDate ) { oField.SetDefault(nullptr); snprintf( szFieldType, sizeof(szFieldType), "DATE" ); } else if( oField.GetType() == OFTDateTime ) { if( oField.GetDefault() != nullptr && STARTS_WITH_CI(oField.GetDefault(), "CURRENT_TIMESTAMP") ) snprintf( szFieldType, sizeof(szFieldType), "TIMESTAMP" ); else snprintf( szFieldType, sizeof(szFieldType), "DATETIME" ); } else if( oField.GetType() == OFTTime ) { oField.SetDefault(nullptr); snprintf( szFieldType, sizeof(szFieldType), "TIME" ); } else if( oField.GetType() == OFTBinary ) { snprintf( szFieldType, sizeof(szFieldType), "LONGBLOB" ); } else if( oField.GetType() == OFTString ) { if( oField.GetWidth() == 0 || !bPreservePrecision ) { if( oField.GetDefault() != nullptr ) strcpy( szFieldType, "VARCHAR(256)" ); else strcpy( szFieldType, "TEXT" ); } else snprintf( szFieldType, sizeof(szFieldType), "VARCHAR(%d)", oField.GetWidth() ); } else if( bApproxOK ) { CPLError( CE_Warning, CPLE_NotSupported, "Can't create field %s with type %s on MySQL layers. Creating as TEXT.", oField.GetNameRef(), OGRFieldDefn::GetFieldTypeName(oField.GetType()) ); strcpy( szFieldType, "TEXT" ); oField.SetWidth(0); oField.SetPrecision(0); } else { CPLError( CE_Failure, CPLE_NotSupported,//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,
示例23: ifCPLErr swq_select::expand_wildcard( swq_field_list *field_list ){ int isrc;/* ==================================================================== *//* Check each pre-expansion field. *//* ==================================================================== */ for( isrc = 0; isrc < result_columns; isrc++ ) { const char *src_fieldname = column_defs[isrc].field_name; int itable, new_fields, i, iout; if( *src_fieldname == '/0' || src_fieldname[strlen(src_fieldname)-1] != '*' ) continue; /* We don't want to expand COUNT(*) */ if( column_defs[isrc].col_func == SWQCF_COUNT ) continue;/* -------------------------------------------------------------------- *//* Parse out the table name, verify it, and establish the *//* number of fields to insert from it. *//* -------------------------------------------------------------------- */ if( strcmp(src_fieldname,"*") == 0 ) { itable = -1; new_fields = field_list->count; } else if( strlen(src_fieldname) < 3 || src_fieldname[strlen(src_fieldname)-2] != '.' ) { CPLError( CE_Failure, CPLE_AppDefined, "Ill formatted field definition '%s'.", src_fieldname ); return CE_Failure; } else { char *table_name = CPLStrdup( src_fieldname ); table_name[strlen(src_fieldname)-2] = '/0'; for( itable = 0; itable < field_list->table_count; itable++ ) { if( strcasecmp(table_name, field_list->table_defs[itable].table_alias ) == 0 ) break; } if( itable == field_list->table_count ) { CPLError( CE_Failure, CPLE_AppDefined, "Table %s not recognised from %s definition.", table_name, src_fieldname ); CPLFree( table_name ); return CE_Failure; } CPLFree( table_name ); /* count the number of fields in this table. */ new_fields = 0; for( i = 0; i < field_list->count; i++ ) { if( field_list->table_ids[i] == itable ) new_fields++; } } if (new_fields > 0) {/* -------------------------------------------------------------------- *//* Reallocate the column list larger. *//* -------------------------------------------------------------------- */ CPLFree( column_defs[isrc].field_name ); delete column_defs[isrc].expr; column_defs = (swq_col_def *) CPLRealloc( column_defs, sizeof(swq_col_def) * (result_columns + new_fields - 1 ) );/* -------------------------------------------------------------------- *//* Push the old definitions that came after the one to be *//* replaced further up in the array. *//* -------------------------------------------------------------------- */ if (new_fields != 1) { for( i = result_columns-1; i > isrc; i-- ) { memcpy( column_defs + i + new_fields - 1, column_defs + i, sizeof( swq_col_def ) ); } } result_columns += (new_fields - 1 );/* -------------------------------------------------------------------- *//* Zero out all the stuff in the target column definitions. *///.........这里部分代码省略.........
开发者ID:0004c,项目名称:node-gdal,代码行数:101,
示例24: CPLError/********************************************************************** * TABIDFile::Open() * * Open a .ID file, and initialize the structures to be ready to read * objects from it. * * If the filename that is passed in contains a .MAP extension then * the extension will be changed to .ID before trying to open the file. * * Returns 0 on success, -1 on error. **********************************************************************/int TABIDFile::Open(const char *pszFname, TABAccess eAccess){ int nLen; if (m_fp) { CPLError(CE_Failure, CPLE_FileIO, "Open() failed: object already contains an open file"); return -1; } /*----------------------------------------------------------------- * Validate access mode and make sure we use binary access. * Note that in Write mode we need TABReadWrite since we do random * updates in the index as data blocks are split *----------------------------------------------------------------*/ const char* pszAccess = NULL; if (eAccess == TABRead) { m_eAccessMode = TABRead; pszAccess = "rb"; } else if (eAccess == TABWrite) { m_eAccessMode = TABReadWrite; pszAccess = "wb+"; } else if (eAccess == TABReadWrite) { m_eAccessMode = TABReadWrite; pszAccess = "rb+"; } else { CPLError(CE_Failure, CPLE_FileIO, "Open() failed: access mode /"%d/" not supported", eAccess); return -1; } /*----------------------------------------------------------------- * Change .MAP extension to .ID if necessary *----------------------------------------------------------------*/ m_pszFname = CPLStrdup(pszFname); nLen = strlen(m_pszFname); if (nLen > 4 && strcmp(m_pszFname+nLen-4, ".MAP")==0) strcpy(m_pszFname+nLen-4, ".ID"); else if (nLen > 4 && strcmp(m_pszFname+nLen-4, ".map")==0) strcpy(m_pszFname+nLen-4, ".id"); /*----------------------------------------------------------------- * Change .MAP extension to .ID if necessary *----------------------------------------------------------------*/#ifndef _WIN32 TABAdjustFilenameExtension(m_pszFname);#endif /*----------------------------------------------------------------- * Open file *----------------------------------------------------------------*/ m_fp = VSIFOpenL(m_pszFname, pszAccess); if (m_fp == NULL) { CPLError(CE_Failure, CPLE_FileIO, "Open() failed for %s", m_pszFname); CPLFree(m_pszFname); m_pszFname = NULL; return -1; } if (m_eAccessMode == TABRead || m_eAccessMode == TABReadWrite) { /*------------------------------------------------------------- * READ access: * Establish the number of object IDs from the size of the file *------------------------------------------------------------*/ VSIStatBufL sStatBuf; if ( VSIStatL(m_pszFname, &sStatBuf) == -1 ) { CPLError(CE_Failure, CPLE_FileIO, "stat() failed for %s/n", m_pszFname); Close(); return -1; } m_nMaxId = (int)(sStatBuf.st_size/4); m_nBlockSize = MIN(1024, m_nMaxId*4);//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例25: DB2_V72_FIX_BYTE_ORDEROGRErr OGRPolygon::importFromWkb( unsigned char * pabyData, int nSize ){ OGRwkbByteOrder eByteOrder; int nDataOffset, b3D; if( nSize < 9 && nSize != -1 ) return OGRERR_NOT_ENOUGH_DATA;/* -------------------------------------------------------------------- *//* Get the byte order byte. *//* -------------------------------------------------------------------- */ eByteOrder = DB2_V72_FIX_BYTE_ORDER((OGRwkbByteOrder) *pabyData); if (!( eByteOrder == wkbXDR || eByteOrder == wkbNDR )) return OGRERR_CORRUPT_DATA;/* -------------------------------------------------------------------- *//* Get the geometry feature type. For now we assume that *//* geometry type is between 0 and 255 so we only have to fetch *//* one byte. *//* -------------------------------------------------------------------- */#ifdef DEBUG OGRwkbGeometryType eGeometryType; if( eByteOrder == wkbNDR ) eGeometryType = (OGRwkbGeometryType) pabyData[1]; else eGeometryType = (OGRwkbGeometryType) pabyData[4]; if( eGeometryType != wkbPolygon ) return OGRERR_CORRUPT_DATA;#endif if( eByteOrder == wkbNDR ) b3D = pabyData[4] & 0x80 || pabyData[2] & 0x80; else b3D = pabyData[1] & 0x80 || pabyData[3] & 0x80; if( b3D ) nCoordDimension = 3; else nCoordDimension = 2;/* -------------------------------------------------------------------- *//* Do we already have some rings? *//* -------------------------------------------------------------------- */ if( nRingCount != 0 ) { for( int iRing = 0; iRing < nRingCount; iRing++ ) delete papoRings[iRing]; OGRFree( papoRings ); papoRings = NULL; } /* -------------------------------------------------------------------- *//* Get the ring count. *//* -------------------------------------------------------------------- */ memcpy( &nRingCount, pabyData + 5, 4 ); if( OGR_SWAP( eByteOrder ) ) nRingCount = CPL_SWAP32(nRingCount); if (nRingCount < 0 || nRingCount > INT_MAX / 4) { nRingCount = 0; return OGRERR_CORRUPT_DATA; } /* Each ring has a minimum of 4 bytes (point count) */ if (nSize != -1 && nSize - 9 < nRingCount * 4) { CPLError( CE_Failure, CPLE_AppDefined, "Length of input WKB is too small" ); nRingCount = 0; return OGRERR_NOT_ENOUGH_DATA; } papoRings = (OGRLinearRing **) VSIMalloc2(sizeof(void*), nRingCount); if (nRingCount != 0 && papoRings == NULL) { nRingCount = 0; return OGRERR_NOT_ENOUGH_MEMORY; } nDataOffset = 9; if( nSize != -1 ) nSize -= nDataOffset;/* -------------------------------------------------------------------- *//* Get the rings. *//* -------------------------------------------------------------------- */ for( int iRing = 0; iRing < nRingCount; iRing++ ) { OGRErr eErr; papoRings[iRing] = new OGRLinearRing(); eErr = papoRings[iRing]->_importFromWkb( eByteOrder, b3D, pabyData + nDataOffset,//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
注:本文中的CPLError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLErrorReset函数代码示例 C++ CPLDestroyXMLNode函数代码示例 |