这篇教程C++ CPLStrdup函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CPLStrdup函数的典型用法代码示例。如果您正苦于以下问题:C++ CPLStrdup函数的具体用法?C++ CPLStrdup怎么用?C++ CPLStrdup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CPLStrdup函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: VSIFOpenint OGRGMLDataSource::Open( const char * pszNewName, int bTestOpen ){ FILE *fp; char szHeader[1000];/* -------------------------------------------------------------------- *//* Open the source file. *//* -------------------------------------------------------------------- */ fp = VSIFOpen( pszNewName, "r" ); if( fp == NULL ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open GML file `%s'.", pszNewName ); return FALSE; }/* -------------------------------------------------------------------- *//* If we aren't sure it is GML, load a header chunk and check *//* for signs it is GML *//* -------------------------------------------------------------------- */ if( bTestOpen ) { size_t nRead = VSIFRead( szHeader, 1, sizeof(szHeader), fp ); if (nRead <= 0) { VSIFClose( fp ); return FALSE; } szHeader[MIN(nRead, sizeof(szHeader))-1] = '/0';/* -------------------------------------------------------------------- *//* Check for a UTF-8 BOM and skip if found *//* *//* TODO: BOM is variable-lenght parameter and depends on encoding. *//* Add BOM detection for other encodings. *//* -------------------------------------------------------------------- */ // Used to skip to actual beginning of XML data char* szPtr = szHeader; if( ( (unsigned char)szHeader[0] == 0xEF ) && ( (unsigned char)szHeader[1] == 0xBB ) && ( (unsigned char)szHeader[2] == 0xBF) ) { szPtr += 3; }/* -------------------------------------------------------------------- *//* Here, we expect the opening chevrons of GML tree root element *//* -------------------------------------------------------------------- */ if( szPtr[0] != '<' || strstr(szPtr,"opengis.net/gml") == NULL ) { VSIFClose( fp ); return FALSE; } } /* -------------------------------------------------------------------- *//* We assume now that it is GML. Close and instantiate a *//* GMLReader on it. *//* -------------------------------------------------------------------- */ VSIFClose( fp ); poReader = CreateGMLReader(); if( poReader == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "File %s appears to be GML but the GML reader can't/n" "be instantiated, likely because Xerces or Expat support wasn't/n" "configured in.", pszNewName ); return FALSE; } poReader->SetSourceFile( pszNewName ); pszName = CPLStrdup( pszNewName );/* -------------------------------------------------------------------- *//* Can we find a GML Feature Schema (.gfs) for the input file? *//* -------------------------------------------------------------------- */ const char *pszGFSFilename; VSIStatBuf sGFSStatBuf, sGMLStatBuf; int bHaveSchema = FALSE; pszGFSFilename = CPLResetExtension( pszNewName, "gfs" ); if( CPLStat( pszGFSFilename, &sGFSStatBuf ) == 0 ) { CPLStat( pszNewName, &sGMLStatBuf ); if( sGMLStatBuf.st_mtime > sGFSStatBuf.st_mtime ) { CPLDebug( "GML", "Found %s but ignoring because it appears/n" "be older than the associated GML file.", //.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例2: HDF5ReadDoubleAttr/** * Captures Geolocation information from a COSMO-SKYMED * file. * The geoid will always be WGS84 * The projection type may be UTM or UPS, depending on the * latitude from the center of the image. * @param iProductType type of CSK subproduct, see HDF5CSKProduct */void HDF5ImageDataset::CaptureCSKGeolocation(int iProductType){ // Set the ellipsoid to WGS84. oSRS.SetWellKnownGeogCS( "WGS84" ); if(iProductType == PROD_CSK_L1C||iProductType == PROD_CSK_L1D) { double *dfProjFalseEastNorth = NULL; double *dfProjScaleFactor = NULL; double *dfCenterCoord = NULL; // Check if all the metadata attributes are present. if(HDF5ReadDoubleAttr("Map Projection False East-North", &dfProjFalseEastNorth) == CE_Failure|| HDF5ReadDoubleAttr("Map Projection Scale Factor", &dfProjScaleFactor) == CE_Failure|| HDF5ReadDoubleAttr("Map Projection Centre", &dfCenterCoord) == CE_Failure|| GetMetadataItem("Projection_ID") == NULL) { pszProjection = CPLStrdup(""); pszGCPProjection = CPLStrdup(""); CPLError( CE_Failure, CPLE_OpenFailed, "The CSK hdf5 file geolocation information is " "malformed/n" ); } else { // Fetch projection Type. CPLString osProjectionID = GetMetadataItem("Projection_ID"); //If the projection is UTM if(EQUAL(osProjectionID,"UTM")) { // @TODO: use SetUTM oSRS.SetProjCS(SRS_PT_TRANSVERSE_MERCATOR); oSRS.SetTM(dfCenterCoord[0], dfCenterCoord[1], dfProjScaleFactor[0], dfProjFalseEastNorth[0], dfProjFalseEastNorth[1]); } else { //TODO Test! I didn't had any UPS projected files to test! //If the projection is UPS if(EQUAL(osProjectionID,"UPS")) { oSRS.SetProjCS(SRS_PT_POLAR_STEREOGRAPHIC); oSRS.SetPS(dfCenterCoord[0], dfCenterCoord[1], dfProjScaleFactor[0], dfProjFalseEastNorth[0], dfProjFalseEastNorth[1]); } } //Export Projection to Wkt. //In case of error then clean the projection if (oSRS.exportToWkt(&pszProjection) != OGRERR_NONE) pszProjection = CPLStrdup(""); CPLFree(dfCenterCoord); CPLFree(dfProjScaleFactor); CPLFree(dfProjFalseEastNorth); } } else { //Export GCPProjection to Wkt. //In case of error then clean the projection if(oSRS.exportToWkt(&pszGCPProjection) != OGRERR_NONE) pszGCPProjection = CPLStrdup(""); }}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:80,
示例3: CPLAssert//.........这里部分代码省略......... CPLError( CE_Failure, CPLE_AppDefined, "mysql_init() failed." ); }/* -------------------------------------------------------------------- *//* Set desired options on the connection: charset and timeout. *//* -------------------------------------------------------------------- */ if( hConn ) { const char *pszTimeoutLength = CPLGetConfigOption( "MYSQL_TIMEOUT", "0" ); unsigned int timeout = atoi(pszTimeoutLength); mysql_options(hConn, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&timeout); mysql_options(hConn, MYSQL_SET_CHARSET_NAME, "utf8" ); } /* -------------------------------------------------------------------- *//* Perform connection. *//* -------------------------------------------------------------------- */ if( hConn && mysql_real_connect( hConn, oHost.length() ? oHost.c_str() : NULL, oUser.length() ? oUser.c_str() : NULL, oPassword.length() ? oPassword.c_str() : NULL, oDB.length() ? oDB.c_str() : NULL, nPort, NULL, CLIENT_INTERACTIVE ) == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "MySQL connect failed for: %s/n%s", pszNewName + 6, mysql_error( hConn ) ); mysql_close( hConn ); hConn = NULL; } if( hConn == NULL ) { CSLDestroy( papszTableNames ); return FALSE; } pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate;/* -------------------------------------------------------------------- *//* Get a list of available tables. *//* -------------------------------------------------------------------- */ if( papszTableNames == NULL ) { MYSQL_RES *hResultSet; MYSQL_ROW papszRow; if( mysql_query( hConn, "SHOW TABLES" ) ) { ReportError( "SHOW TABLES Failed" ); return FALSE; } hResultSet = mysql_store_result( hConn ); if( hResultSet == NULL ) { ReportError( "mysql_store_result() failed on SHOW TABLES result."); return FALSE; } while( (papszRow = mysql_fetch_row( hResultSet )) != NULL ) { if( papszRow[0] == NULL ) continue; if( EQUAL(papszRow[0],"spatial_ref_sys") || EQUAL(papszRow[0],"geometry_columns") ) continue; papszTableNames = CSLAddString(papszTableNames, papszRow[0] ); } mysql_free_result( hResultSet ); }/* -------------------------------------------------------------------- *//* Get the schema of the available tables. *//* -------------------------------------------------------------------- */ int iRecord; for( iRecord = 0; papszTableNames != NULL && papszTableNames[iRecord] != NULL; iRecord++ ) { // FIXME: This should be fixed to deal with tables // for which we can't open because the name is bad/ OpenTable( papszTableNames[iRecord], bUpdate, FALSE ); } CSLDestroy( papszTableNames ); return nLayers > 0 || bUpdate;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例4: InterruptLongResultOGRLayer *OGRMySQLDataSource::CreateLayer( const char * pszLayerNameIn, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ MYSQL_RES *hResult=NULL; char szCommand[1024]; const char *pszGeometryType; const char *pszGeomColumnName; const char *pszExpectedFIDName; char *pszLayerName; int nDimension = 3; // MySQL only supports 2d currently/* -------------------------------------------------------------------- *//* Make sure there isn't an active transaction already. *//* -------------------------------------------------------------------- */ InterruptLongResult(); if( CSLFetchBoolean(papszOptions,"LAUNDER",TRUE) ) pszLayerName = LaunderName( pszLayerNameIn ); else pszLayerName = CPLStrdup( pszLayerNameIn ); if( wkbFlatten(eType) == eType ) nDimension = 2; CPLDebug("MYSQL","Creating layer %s.", pszLayerName);/* -------------------------------------------------------------------- *//* Do we already have this layer? If so, should we blow it *//* away? *//* -------------------------------------------------------------------- */ int iLayer; for( iLayer = 0; iLayer < nLayers; iLayer++ ) { if( EQUAL(pszLayerName,papoLayers[iLayer]->GetLayerDefn()->GetName()) ) { if( CSLFetchNameValue( papszOptions, "OVERWRITE" ) != NULL && !EQUAL(CSLFetchNameValue(papszOptions,"OVERWRITE"),"NO") ) { DeleteLayer( iLayer ); } else { CPLError( CE_Failure, CPLE_AppDefined, "Layer %s already exists, CreateLayer failed./n" "Use the layer creation option OVERWRITE=YES to " "replace it.", pszLayerName ); CPLFree( pszLayerName ); return NULL; } } } pszGeomColumnName = CSLFetchNameValue( papszOptions, "GEOMETRY_NAME" ); if (!pszGeomColumnName) pszGeomColumnName="SHAPE"; pszExpectedFIDName = CSLFetchNameValue( papszOptions, "MYSQL_FID" ); if (!pszExpectedFIDName) pszExpectedFIDName="OGR_FID"; CPLDebug("MYSQL","Geometry Column Name %s.", pszGeomColumnName); CPLDebug("MYSQL","FID Column Name %s.", pszExpectedFIDName); if( wkbFlatten(eType) == wkbNone ) { sprintf( szCommand, "CREATE TABLE `%s` ( " " %s INT UNIQUE NOT NULL AUTO_INCREMENT )", pszLayerName, pszExpectedFIDName ); } else { sprintf( szCommand, "CREATE TABLE `%s` ( " " %s INT UNIQUE NOT NULL AUTO_INCREMENT, " " %s GEOMETRY NOT NULL )", pszLayerName, pszExpectedFIDName, pszGeomColumnName ); } if( CSLFetchNameValue( papszOptions, "ENGINE" ) != NULL ) { strcat( szCommand, " ENGINE = " ); strcat( szCommand, CSLFetchNameValue( papszOptions, "ENGINE" ) ); } if( !mysql_query(GetConn(), szCommand ) ) { if( mysql_field_count( GetConn() ) == 0 ) CPLDebug("MYSQL","Created table %s.", pszLayerName);//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例5: OGRFeatureDefnCPLErr OGRIDBLayer::BuildFeatureDefn( const char *pszLayerName, ITCursor *poCurr ){ poFeatureDefn = new OGRFeatureDefn( pszLayerName ); SetDescription( poFeatureDefn->GetName() ); const ITTypeInfo * poInfo = poCurr->RowType(); int nRawColumns = poInfo->ColumnCount(); poFeatureDefn->Reference(); for( int iCol = 0; iCol < nRawColumns; iCol++ ) { const char * pszColName = poInfo->ColumnName(iCol); const ITTypeInfo * poTI = poInfo->ColumnType(iCol); const char * pszTypName = poTI->Name(); OGRFieldDefn oField( pszColName, OFTString ); oField.SetWidth( MAX(0,poTI->Bound()) ); if ( pszGeomColumn != NULL && EQUAL(pszColName,pszGeomColumn) ) continue; if ( EQUALN("st_", pszTypName, 3) && pszGeomColumn == NULL ) { // We found spatial column! pszGeomColumn = CPLStrdup(pszColName); if ( EQUAL("st_point", pszTypName) ) poFeatureDefn->SetGeomType( wkbPoint ); else if ( EQUAL("st_linestring", pszTypName) ) poFeatureDefn->SetGeomType( wkbLineString ); else if ( EQUAL("st_polygon", pszTypName) ) poFeatureDefn->SetGeomType( wkbPolygon ); else if ( EQUAL("st_multipoint", pszTypName) ) poFeatureDefn->SetGeomType( wkbMultiPoint ); else if ( EQUAL("st_multilinestring", pszTypName) ) poFeatureDefn->SetGeomType( wkbMultiLineString ); else if ( EQUAL("st_multipolygon", pszTypName) ) poFeatureDefn->SetGeomType( wkbMultiPolygon ); continue; } // Check other field types if ( EQUAL( pszTypName, "blob" ) || EQUAL( pszTypName, "byte" ) || EQUAL( pszTypName, "opaque" ) || EQUAL( pszTypName, "text" ) || EQUALN( pszTypName, "list", 4 ) || EQUALN( pszTypName, "collection", 10 ) || EQUALN( pszTypName, "row", 3 ) || EQUALN( pszTypName, "set", 3 ) ) { CPLDebug( "OGR_IDB", "'%s' column type not supported yet. Column '%s'", pszTypName, pszColName ); continue; } if ( EQUALN( pszTypName, "st_", 3 ) ) { oField.SetType( OFTBinary ); } else if ( EQUAL( pszTypName, "date" ) ) { oField.SetType( OFTDate ); } else if ( EQUAL( pszTypName, "datetime" ) ) { oField.SetType( OFTDateTime ); } else if ( EQUAL( pszTypName, "decimal" ) || EQUAL( pszTypName, "money" ) || EQUAL( pszTypName, "float" ) || EQUAL( pszTypName, "smallfloat" ) ) { oField.SetType( OFTReal ); oField.SetPrecision( MAX( 0, poTI->Scale() ) ); // -1 for numeric } else if ( EQUAL( pszTypName, "integer" ) || EQUAL( pszTypName, "serial" ) ) { oField.SetType( OFTInteger ); // 10 as hardcoded max int32 value length + 1 sig bit oField.SetWidth( 11 ); } else if ( EQUAL( pszTypName, "smallint" ) ) { oField.SetType( OFTInteger ); // 5 as hardcoded max int16 value length + 1 sig bit oField.SetWidth( 6 ); } else { // leave as string: // *char, character, character varing, *varchar // interval. int8, serial8 }//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例6: CPLGetConfigOptionint S57ClassRegistrar::LoadInfo( const char * pszDirectory, const char * pszProfile, int bReportErr ){ FILE *fp; char szTargetFile[1024]; if( pszDirectory == NULL ) pszDirectory = CPLGetConfigOption("S57_CSV",NULL);/* ==================================================================== *//* Read the s57objectclasses file. *//* ==================================================================== */ if( pszProfile == NULL ) pszProfile = CPLGetConfigOption( "S57_PROFILE", "" ); if( EQUAL(pszProfile, "Additional_Military_Layers") ) { sprintf( szTargetFile, "s57objectclasses_%s.csv", "aml" ); } else if ( EQUAL(pszProfile, "Inland_Waterways") ) { sprintf( szTargetFile, "s57objectclasses_%s.csv", "iw" ); } else if( strlen(pszProfile) > 0 ) { sprintf( szTargetFile, "s57objectclasses_%s.csv", pszProfile ); } else { strcpy( szTargetFile, "s57objectclasses.csv" ); } if( !FindFile( szTargetFile, pszDirectory, bReportErr, &fp ) ) return FALSE;/* -------------------------------------------------------------------- *//* Skip the line defining the column titles. *//* -------------------------------------------------------------------- */ const char * pszLine = ReadLine( fp ); if( !EQUAL(pszLine, "/"Code/",/"ObjectClass/",/"Acronym/",/"Attribute_A/"," "/"Attribute_B/",/"Attribute_C/",/"Class/",/"Primitives/"" ) ) { CPLError( CE_Failure, CPLE_AppDefined, "s57objectclasses columns don't match expected format!/n" ); return FALSE; }/* -------------------------------------------------------------------- *//* Read and form string list. *//* -------------------------------------------------------------------- */ CSLDestroy( papszClassesInfo ); papszClassesInfo = (char **) CPLCalloc(sizeof(char *),MAX_CLASSES); nClasses = 0; while( nClasses < MAX_CLASSES && (pszLine = ReadLine(fp)) != NULL ) { papszClassesInfo[nClasses] = CPLStrdup(pszLine); if( papszClassesInfo[nClasses] == NULL ) break; nClasses++; } if( nClasses == MAX_CLASSES ) CPLError( CE_Warning, CPLE_AppDefined, "MAX_CLASSES exceeded in S57ClassRegistrar::LoadInfo()./n" );/* -------------------------------------------------------------------- *//* Cleanup, and establish state. *//* -------------------------------------------------------------------- */ if( fp != NULL ) VSIFClose( fp ); iCurrentClass = -1; if( nClasses == 0 ) return FALSE;/* ==================================================================== *//* Read the attributes list. *//* ==================================================================== */ if( EQUAL(pszProfile, "Additional_Military_Layers") ) { sprintf( szTargetFile, "s57attributes_%s.csv", "aml" ); } else if ( EQUAL(pszProfile, "Inland_Waterways") ) { sprintf( szTargetFile, "s57attributes_%s.csv", "iw" ); } else if( strlen(pszProfile) > 0 ) { sprintf( szTargetFile, "s57attributes_%s.csv", pszProfile ); }//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例7: CPLFreevoid DTEDDataset::SetFileName(const char* pszFilenameIn){ CPLFree(this->pszFilename); this->pszFilename = CPLStrdup(pszFilenameIn);}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:6,
示例8: CPLAssert//.........这里部分代码省略......... { const char *pszTimeoutLength = CPLGetConfigOption( "MYSQL_TIMEOUT", "0" ); unsigned int timeout = atoi(pszTimeoutLength); mysql_options(hConn, MYSQL_OPT_CONNECT_TIMEOUT, (char*)&timeout); mysql_options(hConn, MYSQL_SET_CHARSET_NAME, "utf8" ); } /* -------------------------------------------------------------------- */ /* Perform connection. */ /* -------------------------------------------------------------------- */ if( hConn && mysql_real_connect( hConn, oHost.length() ? oHost.c_str() : NULL, oUser.length() ? oUser.c_str() : NULL, oPassword.length() ? oPassword.c_str() : NULL, oDB.length() ? oDB.c_str() : NULL, nPort, NULL, CLIENT_INTERACTIVE ) == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "MySQL connect failed for: %s/n%s", pszNewName + 6, mysql_error( hConn ) ); mysql_close( hConn ); hConn = NULL; } if( hConn == NULL ) { CSLDestroy( papszTableNames ); return FALSE; } else { // Enable automatic reconnection // Must be called after mysql_real_connect() on MySQL < 5.0.19 // and at any point on more recent versions. my_bool reconnect = 1; mysql_options(hConn, MYSQL_OPT_RECONNECT, &reconnect); } pszName = CPLStrdup( pszNewName ); bDSUpdate = bUpdate; /* -------------------------------------------------------------------- */ /* Get a list of available tables. */ /* -------------------------------------------------------------------- */ if( papszTableNames == NULL ) { MYSQL_RES *hResultSet; MYSQL_ROW papszRow; if( mysql_query( hConn, "SHOW TABLES" ) ) { ReportError( "SHOW TABLES Failed" ); return FALSE; } hResultSet = mysql_store_result( hConn ); if( hResultSet == NULL ) { ReportError( "mysql_store_result() failed on SHOW TABLES result."); return FALSE; } while( (papszRow = mysql_fetch_row( hResultSet )) != NULL ) { if( papszRow[0] == NULL ) continue; if( EQUAL(papszRow[0],"spatial_ref_sys") || EQUAL(papszRow[0],"geometry_columns") ) continue; papszTableNames = CSLAddString(papszTableNames, papszRow[0] ); } mysql_free_result( hResultSet ); } /* -------------------------------------------------------------------- */ /* Get the schema of the available tables. */ /* -------------------------------------------------------------------- */ int iRecord; for( iRecord = 0; papszTableNames != NULL && papszTableNames[iRecord] != NULL; iRecord++ ) { // FIXME: This should be fixed to deal with tables // for which we can't open because the name is bad/ OpenTable( papszTableNames[iRecord], bUpdate ); } CSLDestroy( papszTableNames ); return nLayers > 0 || bUpdate;}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:101,
示例9: VSIFOpenL//.........这里部分代码省略......... "Reference_Meridian", 0.0 ); } else { //All other projections: Mercator, Transverse Mercator, Lambert Conformal, etc. //Geographic, so set an ellipse if (bIsGeographic) { oSRS.SetGeogCS( geog_name, datum_name, sphere_name, semi_major, iflattening, "Reference_Meridian", 0.0 ); } else { //Geocentric, so force a sphere. I hope... oSRS.SetGeogCS( geog_name, datum_name, sphere_name, semi_major, 0.0, "Reference_Meridian", 0.0 ); } } // translate back into a projection string. char *pszResult = NULL; oSRS.exportToWkt( &pszResult ); poDS->osProjection = pszResult; CPLFree( pszResult ); }/* END ISIS3 Label Read *//*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /* -------------------------------------------------------------------- *//* Is the CUB detached - if so, reset name to binary file? *//* -------------------------------------------------------------------- */#ifdef notdef // Frank - is this correct? //The extension already added on so don't add another. But is this needed? char *pszPath = CPLStrdup( CPLGetPath( poOpenInfo->pszFilename ) ); char *pszName = CPLStrdup( CPLGetBasename( poOpenInfo->pszFilename ) ); if (bIsDetached) pszCUBFilename = CPLFormCIFilename( pszPath, detachedCub, "" );#endif/* -------------------------------------------------------------------- *//* 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 || nBands < 1 ) { delete poDS; return NULL; }/* -------------------------------------------------------------------- *//* Capture some information from the file that is of interest. *//* -------------------------------------------------------------------- */ poDS->nRasterXSize = nCols; poDS->nRasterYSize = nRows;/* -------------------------------------------------------------------- *//* Open target binary file. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_ReadOnly ) poDS->fpImage = VSIFOpenL( osQubeFile, "r" ); else poDS->fpImage = VSIFOpenL( osQubeFile, "r+" ); if( poDS->fpImage == NULL ) {
开发者ID:drownedout,项目名称:datamap,代码行数:67,
示例10: CPLGetConfigOptionOGRDGNLayer::OGRDGNLayer( const char * pszName, DGNHandle hDGN, int bUpdate ) { this->hDGN = hDGN; this->bUpdate = bUpdate;/* -------------------------------------------------------------------- *//* Work out what link format we are using. *//* -------------------------------------------------------------------- */ OGRFieldType eLinkFieldType; pszLinkFormat = (char *) CPLGetConfigOption( "DGN_LINK_FORMAT", "FIRST" ); if( EQUAL(pszLinkFormat,"FIRST") ) eLinkFieldType = OFTInteger; else if( EQUAL(pszLinkFormat,"LIST") ) eLinkFieldType = OFTIntegerList; else if( EQUAL(pszLinkFormat,"STRING") ) eLinkFieldType = OFTString; else { CPLError( CE_Warning, CPLE_AppDefined, "DGN_LINK_FORMAT=%s, but only FIRST, LIST or STRING supported.", pszLinkFormat ); pszLinkFormat = (char *) "FIRST"; eLinkFieldType = OFTInteger; } pszLinkFormat = CPLStrdup(pszLinkFormat);/* -------------------------------------------------------------------- *//* Create the feature definition. *//* -------------------------------------------------------------------- */ poFeatureDefn = new OGRFeatureDefn( pszName ); poFeatureDefn->Reference(); OGRFieldDefn oField( "", OFTInteger );/* -------------------------------------------------------------------- *//* Element type *//* -------------------------------------------------------------------- */ oField.SetName( "Type" ); oField.SetType( OFTInteger ); oField.SetWidth( 2 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* Level number. *//* -------------------------------------------------------------------- */ oField.SetName( "Level" ); oField.SetType( OFTInteger ); oField.SetWidth( 2 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* graphic group *//* -------------------------------------------------------------------- */ oField.SetName( "GraphicGroup" ); oField.SetType( OFTInteger ); oField.SetWidth( 4 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* ColorIndex *//* -------------------------------------------------------------------- */ oField.SetName( "ColorIndex" ); oField.SetType( OFTInteger ); oField.SetWidth( 3 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* Weight *//* -------------------------------------------------------------------- */ oField.SetName( "Weight" ); oField.SetType( OFTInteger ); oField.SetWidth( 2 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* Style *//* -------------------------------------------------------------------- */ oField.SetName( "Style" ); oField.SetType( OFTInteger ); oField.SetWidth( 1 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );/* -------------------------------------------------------------------- *//* EntityNum *//* -------------------------------------------------------------------- */ oField.SetName( "EntityNum" ); oField.SetType( eLinkFieldType ); oField.SetWidth( 0 ); oField.SetPrecision( 0 ); poFeatureDefn->AddFieldDefn( &oField );//.........这里部分代码省略.........
开发者ID:Mofangbao,项目名称:node-gdal,代码行数:101,
示例11: CPLStrdupint OGRARCGENDataSource::Open( const char * pszFilename, int bUpdateIn){ if (bUpdateIn) { return FALSE; } pszName = CPLStrdup( pszFilename );// -------------------------------------------------------------------- // Does this appear to be a Arc/Info generate file?// -------------------------------------------------------------------- VSILFILE* fp = VSIFOpenL(pszFilename, "rb"); if (fp == NULL) return FALSE; /* Check that the first line is compatible with a generate file */ /* and in particular contain >= 32 && <= 127 bytes */ char szFirstLine[256+1]; int nRet = VSIFReadL(szFirstLine, 1, 256, fp); szFirstLine[nRet] = '/0'; int i; int bFoundEOL = FALSE; for(i=0;szFirstLine[i] != '/0';i++) { if (szFirstLine[i] == '/n' || szFirstLine[i] == '/r') { bFoundEOL = TRUE; szFirstLine[i] = '/0'; break; } if (szFirstLine[i] < 32) { VSIFCloseL(fp); return FALSE; } } if (!bFoundEOL) { VSIFCloseL(fp); return FALSE; } char** papszTokens = CSLTokenizeString2( szFirstLine, " ,", 0 ); int nTokens = CSLCount(papszTokens); if (nTokens != 1 && nTokens != 3 && nTokens != 4) { VSIFCloseL(fp); CSLDestroy(papszTokens); return FALSE; } for(int i=0;i<nTokens;i++) { if( CPLGetValueType(papszTokens[i]) == CPL_VALUE_STRING ) { VSIFCloseL(fp); CSLDestroy(papszTokens); return FALSE; } } CSLDestroy(papszTokens); /* Go to end of file, and count the number of END keywords */ /* If there's 1, it's a point layer */ /* If there's 2, it's a linestring or polygon layer */ VSIFSeekL( fp, 0, SEEK_END ); vsi_l_offset nSize = VSIFTellL(fp); if (nSize < 10) { VSIFCloseL(fp); return FALSE; } char szBuffer[10+1]; VSIFSeekL( fp, nSize - 10, SEEK_SET ); VSIFReadL( szBuffer, 1, 10, fp ); szBuffer[10] = '/0'; VSIFSeekL( fp, 0, SEEK_SET ); OGRwkbGeometryType eType; const char* szPtr = szBuffer; const char* szEnd = strstr(szPtr, "END"); if (szEnd == NULL) szEnd = strstr(szPtr, "end"); if (szEnd == NULL) { VSIFCloseL(fp); return FALSE; } szPtr = szEnd + 3; szEnd = strstr(szPtr, "END"); if (szEnd == NULL) szEnd = strstr(szPtr, "end"); if (szEnd == NULL) { const char* pszLine = CPLReadLine2L(fp,256,NULL); if (pszLine == NULL) {//.........这里部分代码省略.........
开发者ID:imincik,项目名称:pkg-gdal,代码行数:101,
示例12: RPFTOCReadFromBuffer//.........这里部分代码省略......... if (!bOK || pathLength > 256) { CPLError( CE_Failure, CPLE_NotSupported, "Path length is big : %d. Probably corrupted TOC file.", static_cast<int>( pathLength ) ); RPFTOCFree(toc); return NULL; } frameEntry->directory = reinterpret_cast<char *>( CPLMalloc(pathLength+1) ); bOK &= VSIFReadL( frameEntry->directory, 1, pathLength, fp) == pathLength; if( !bOK ) { CPLError(CE_Failure, CPLE_FileIO, "I/O error"); RPFTOCFree(toc); return NULL; } frameEntry->directory[pathLength] = 0; if (pathLength > 0 && frameEntry->directory[pathLength-1] == '/') frameEntry->directory[pathLength-1] = 0; if (frameEntry->directory[0] == '.' && frameEntry->directory[1] == '/') { memmove(frameEntry->directory, frameEntry->directory+2, strlen(frameEntry->directory+2)+1); // Some A.TOC have subdirectory names like ".//X/" ... (#5979) // Check if it was not intended to be "./X/" instead. VSIStatBufL sStatBuf; if( frameEntry->directory[0] == '/' && VSIStatL(CPLFormFilename(CPLGetDirname(pszFilename), frameEntry->directory+1, NULL), &sStatBuf) == 0 && VSI_ISDIR(sStatBuf.st_mode) ) { memmove(frameEntry->directory, frameEntry->directory+1, strlen(frameEntry->directory+1)+1); } } { char* baseDir = CPLStrdup(CPLGetDirname(pszFilename)); VSIStatBufL sStatBuf; char* subdir; if (CPLIsFilenameRelative(frameEntry->directory) == FALSE) subdir = CPLStrdup(frameEntry->directory); else if (frameEntry->directory[0] == '.' && frameEntry->directory[1] == 0) subdir = CPLStrdup(baseDir); else subdir = CPLStrdup(CPLFormFilename(baseDir, frameEntry->directory, NULL));#if !defined(_WIN32) && !defined(_WIN32_CE) if( VSIStatL( subdir, &sStatBuf ) != 0 && strlen(subdir) > strlen(baseDir) && subdir[strlen(baseDir)] != 0) { char* c = subdir + strlen(baseDir)+1; while(*c) { if (*c >= 'A' && *c <= 'Z') *c += 'a' - 'A'; c++; } }#endif frameEntry->fullFilePath = CPLStrdup(CPLFormFilename( subdir, frameEntry->filename, NULL)); if( VSIStatL( frameEntry->fullFilePath, &sStatBuf ) != 0 ) {#if !defined(_WIN32) && !defined(_WIN32_CE) char* c = frameEntry->fullFilePath + strlen(subdir)+1; while(*c) { if (*c >= 'A' && *c <= 'Z') *c += 'a' - 'A'; c++; } if( VSIStatL( frameEntry->fullFilePath, &sStatBuf ) != 0 )#endif { frameEntry->fileExists = 0; CPLError( CE_Warning, CPLE_AppDefined, "File %s does not exist.", frameEntry->fullFilePath ); }#if !defined(_WIN32) && !defined(_WIN32_CE) else { frameEntry->fileExists = 1; }#endif } else { frameEntry->fileExists = 1; } CPLFree(subdir); CPLFree(baseDir); } CPLDebug("RPFTOC", "Entry %d : %s,%s (%d, %d)", boundaryId, frameEntry->directory, frameEntry->filename, frameRow, frameCol); frameEntry->exists = 1; } return toc;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例13: strlenstatic GDALDataset *OGRSQLiteDriverOpen( GDALOpenInfo* poOpenInfo ){ if( OGRSQLiteDriverIdentify(poOpenInfo) == FALSE ) return NULL;/* -------------------------------------------------------------------- *//* Check VirtualShape:xxx.shp syntax *//* -------------------------------------------------------------------- */ int nLen = (int) strlen(poOpenInfo->pszFilename); if (EQUALN(poOpenInfo->pszFilename, "VirtualShape:", strlen( "VirtualShape:" )) && nLen > 4 && EQUAL(poOpenInfo->pszFilename + nLen - 4, ".SHP")) { OGRSQLiteDataSource *poDS; poDS = new OGRSQLiteDataSource(); char** papszOptions = CSLAddString(NULL, "SPATIALITE=YES"); int nRet = poDS->Create( ":memory:", papszOptions ); poDS->SetDescription(poOpenInfo->pszFilename); CSLDestroy(papszOptions); if (!nRet) { delete poDS; return NULL; } char* pszSQLiteFilename = CPLStrdup(poOpenInfo->pszFilename + strlen( "VirtualShape:" )); GDALDataset* poSQLiteDS = (GDALDataset*) GDALOpenEx(pszSQLiteFilename, GDAL_OF_VECTOR, NULL, NULL, NULL); if (poSQLiteDS == NULL) { CPLFree(pszSQLiteFilename); delete poDS; return NULL; } delete poSQLiteDS; char* pszLastDot = strrchr(pszSQLiteFilename, '.'); if (pszLastDot) *pszLastDot = '/0'; const char* pszTableName = CPLGetBasename(pszSQLiteFilename); char* pszSQL = CPLStrdup(CPLSPrintf("CREATE VIRTUAL TABLE %s USING VirtualShape(%s, CP1252, -1)", pszTableName, pszSQLiteFilename)); poDS->ExecuteSQL(pszSQL, NULL, NULL); CPLFree(pszSQL); CPLFree(pszSQLiteFilename); poDS->SetUpdate(FALSE); return poDS; }/* -------------------------------------------------------------------- *//* We think this is really an SQLite database, go ahead and try *//* and open it. *//* -------------------------------------------------------------------- */ OGRSQLiteDataSource *poDS; poDS = new OGRSQLiteDataSource(); if( !poDS->Open( poOpenInfo->pszFilename, poOpenInfo->eAccess == GA_Update, poOpenInfo->papszOpenOptions ) ) { delete poDS; return NULL; } else return poDS;}
开发者ID:drownedout,项目名称:datamap,代码行数:70,
示例14: CPLAssertint OGRGMLDataSource::Create( const char *pszFilename, char **papszOptions ){ if( fpOutput != NULL || poReader != NULL ) { CPLAssert( FALSE ); return FALSE; }/* -------------------------------------------------------------------- *//* Create the output file. *//* -------------------------------------------------------------------- */ pszName = CPLStrdup( pszFilename ); if( EQUAL(pszFilename,"stdout") ) fpOutput = stdout; else fpOutput = VSIFOpen( pszFilename, "wt+" ); if( fpOutput == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to create GML file %s.", pszFilename ); return FALSE; }/* -------------------------------------------------------------------- *//* Write out "standard" header. *//* -------------------------------------------------------------------- */ VSIFPrintf( fpOutput, "%s", "<?xml version=/"1.0/" encoding=/"utf-8/" ?>/n" ); nSchemaInsertLocation = VSIFTell( fpOutput ); VSIFPrintf( fpOutput, "%s", "<ogr:FeatureCollection/n" );/* -------------------------------------------------------------------- *//* Write out schema info if provided in creation options. *//* -------------------------------------------------------------------- */ const char *pszSchemaURI = CSLFetchNameValue(papszOptions,"XSISCHEMAURI"); const char *pszSchemaOpt = CSLFetchNameValue( papszOptions, "XSISCHEMA" ); if( pszSchemaURI != NULL ) { VSIFPrintf( fpOutput, " xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/"/n" " xsi:schemaLocation=/"%s/"/n", CSLFetchNameValue( papszOptions, "XSISCHEMAURI" ) ); } else if( pszSchemaOpt == NULL || EQUAL(pszSchemaOpt,"EXTERNAL") ) { char *pszBasename = CPLStrdup(CPLGetBasename( pszName )); VSIFPrintf( fpOutput, " xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/"/n" " xsi:schemaLocation=/"http://ogr.maptools.org/ %s/"/n", CPLResetExtension( pszBasename, "xsd" ) ); CPLFree( pszBasename ); } VSIFPrintf( fpOutput, "%s", " xmlns:ogr=/"http://ogr.maptools.org//"/n" ); VSIFPrintf( fpOutput, "%s", " xmlns:gml=/"http://www.opengis.net/gml/">/n" );/* -------------------------------------------------------------------- *//* Should we initialize an area to place the boundedBy element? *//* We will need to seek back to fill it in. *//* -------------------------------------------------------------------- */ if( CSLFetchBoolean( papszOptions, "BOUNDEDBY", TRUE ) ) { nBoundedByLocation = VSIFTell( fpOutput ); if( nBoundedByLocation != -1 ) VSIFPrintf( fpOutput, "%280s/n", "" ); } else nBoundedByLocation = -1; return TRUE;}
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:83,
示例15: CPLDebugvoid GDALDefaultOverviews::OverviewScan(){ if( bCheckedForOverviews || poDS == nullptr ) return; bCheckedForOverviews = true; static thread_local int nAntiRecursionCounter = 0; // arbitrary number. 32 should be enough to handle a .ovr.ovr.ovr... if( nAntiRecursionCounter == 64 ) return; ++nAntiRecursionCounter; CPLDebug( "GDAL", "GDALDefaultOverviews::OverviewScan()" );/* -------------------------------------------------------------------- *//* Open overview dataset if it exists. *//* -------------------------------------------------------------------- */ if( pszInitName == nullptr ) pszInitName = CPLStrdup(poDS->GetDescription()); if( !EQUAL(pszInitName,":::VIRTUAL:::") && GDALCanFileAcceptSidecarFile(pszInitName) ) { if( bInitNameIsOVR ) osOvrFilename = pszInitName; else osOvrFilename.Printf( "%s.ovr", pszInitName ); std::vector<char> achOvrFilename; achOvrFilename.resize(osOvrFilename.size() + 1); memcpy(&(achOvrFilename[0]), osOvrFilename.c_str(), osOvrFilename.size() + 1); bool bExists = CPL_TO_BOOL( CPLCheckForFile( &achOvrFilename[0], papszInitSiblingFiles ) ); osOvrFilename = &achOvrFilename[0];#if !defined(WIN32) if( !bInitNameIsOVR && !bExists && !papszInitSiblingFiles ) { osOvrFilename.Printf( "%s.OVR", pszInitName ); memcpy(&(achOvrFilename[0]), osOvrFilename.c_str(), osOvrFilename.size() + 1); bExists = CPL_TO_BOOL( CPLCheckForFile( &achOvrFilename[0], papszInitSiblingFiles ) ); osOvrFilename = &achOvrFilename[0]; if( !bExists ) osOvrFilename.Printf( "%s.ovr", pszInitName ); }#endif if( bExists ) { poODS = GDALDataset::Open( osOvrFilename, GDAL_OF_RASTER | (poDS->GetAccess() == GA_Update ? GDAL_OF_UPDATE : 0), nullptr, nullptr, papszInitSiblingFiles ); } }/* -------------------------------------------------------------------- *//* We didn't find that, so try and find a corresponding aux *//* file. Check that we are the dependent file of the aux *//* file. *//* *//* We only use the .aux file for overviews if they already have *//* overviews existing, or if USE_RRD is set true. *//* -------------------------------------------------------------------- */ if( !poODS && !EQUAL(pszInitName,":::VIRTUAL:::") && GDALCanFileAcceptSidecarFile(pszInitName) ) { bool bTryFindAssociatedAuxFile = true; if( papszInitSiblingFiles ) { CPLString osAuxFilename = CPLResetExtension( pszInitName, "aux"); int iSibling = CSLFindString( papszInitSiblingFiles, CPLGetFilename(osAuxFilename) ); if( iSibling < 0 ) { osAuxFilename = pszInitName; osAuxFilename += ".aux"; iSibling = CSLFindString( papszInitSiblingFiles, CPLGetFilename(osAuxFilename) ); if( iSibling < 0 ) bTryFindAssociatedAuxFile = false; } } if( bTryFindAssociatedAuxFile ) { poODS = GDALFindAssociatedAuxFile( pszInitName, poDS->GetAccess(), poDS ); } if( poODS ) {//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,
示例16: CPLAssertint OGRVRTDataSource::Initialize( CPLXMLNode *psTree, const char *pszNewName, int bUpdate ){ CPLAssert( nLayers == 0 ); this->psTree = psTree;/* -------------------------------------------------------------------- *//* Set name, and capture the directory path so we can use it *//* for relative datasources. *//* -------------------------------------------------------------------- */ CPLString osVRTDirectory = CPLGetPath( pszNewName ); pszName = CPLStrdup( pszNewName );/* -------------------------------------------------------------------- *//* Look for the OGRVRTDataSource node, it might be after an *//* <xml> node. *//* -------------------------------------------------------------------- */ CPLXMLNode *psVRTDSXML = CPLGetXMLNode( psTree, "=OGRVRTDataSource" ); if( psVRTDSXML == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Did not find the <OGRVRTDataSource> node in the root of the document,/n" "this is not really an OGR VRT." ); return FALSE; }/* -------------------------------------------------------------------- *//* Determine if we must proxy layers. *//* -------------------------------------------------------------------- */ int nOGRVRTLayerCount = CountOGRVRTLayers(psVRTDSXML); int nMaxSimultaneouslyOpened = atoi(CPLGetConfigOption("OGR_VRT_MAX_OPENED", "100")); if( nMaxSimultaneouslyOpened < 1 ) nMaxSimultaneouslyOpened = 1; if( nOGRVRTLayerCount > nMaxSimultaneouslyOpened ) poLayerPool = new OGRLayerPool(nMaxSimultaneouslyOpened);/* -------------------------------------------------------------------- *//* Apply any dataset level metadata. *//* -------------------------------------------------------------------- */ oMDMD.XMLInit( psVRTDSXML, TRUE );/* -------------------------------------------------------------------- *//* Look for layers. *//* -------------------------------------------------------------------- */ CPLXMLNode *psLTree; for( psLTree=psVRTDSXML->psChild; psLTree != NULL; psLTree=psLTree->psNext ) { if( psLTree->eType != CXT_Element ) continue;/* -------------------------------------------------------------------- *//* Create the layer object. *//* -------------------------------------------------------------------- */ OGRLayer *poLayer = InstanciateLayer(psLTree, osVRTDirectory, bUpdate); if( poLayer == NULL ) continue;/* -------------------------------------------------------------------- *//* Add layer to data source layer list. *//* -------------------------------------------------------------------- */ nLayers ++; papoLayers = (OGRLayer **) CPLRealloc( papoLayers, sizeof(OGRLayer *) * nLayers ); papoLayers[nLayers-1] = poLayer; paeLayerType = (OGRLayerType*) CPLRealloc( paeLayerType, sizeof(int) * nLayers ); if( poLayerPool != NULL && EQUAL(psLTree->pszValue,"OGRVRTLayer")) { paeLayerType[nLayers - 1] = OGR_VRT_PROXIED_LAYER; } else if( EQUAL(psLTree->pszValue,"OGRVRTLayer") ) { paeLayerType[nLayers - 1] = OGR_VRT_LAYER; } else { paeLayerType[nLayers - 1] = OGR_VRT_OTHER_LAYER; } } return TRUE;}
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:88,
示例17: CPLStrdupint OGRIdrisiDataSource::Open( const char * pszFilename ){ pszName = CPLStrdup( pszFilename ); VSILFILE* fpVCT = VSIFOpenL(pszFilename, "rb"); if (fpVCT == NULL) return FALSE; char* pszWTKString = NULL;// --------------------------------------------------------------------// Look for .vdc file// -------------------------------------------------------------------- const char* pszVDCFilename = CPLResetExtension(pszFilename, "vdc"); VSILFILE* fpVDC = VSIFOpenL(pszVDCFilename, "rb"); if (fpVDC == NULL) { pszVDCFilename = CPLResetExtension(pszFilename, "VDC"); fpVDC = VSIFOpenL(pszVDCFilename, "rb"); } char** papszVDC = NULL; if (fpVDC != NULL) { VSIFCloseL(fpVDC); fpVDC = NULL; CPLPushErrorHandler(CPLQuietErrorHandler); papszVDC = CSLLoad2(pszVDCFilename, 1024, 256, NULL); CPLPopErrorHandler(); CPLErrorReset(); } OGRwkbGeometryType eType = wkbUnknown; if (papszVDC != NULL) { CSLSetNameValueSeparator( papszVDC, ":" ); const char *pszVersion = CSLFetchNameValue( papszVDC, "file format " ); if( pszVersion == NULL || !EQUAL( pszVersion, "IDRISI Vector A.1" ) ) { CSLDestroy( papszVDC ); VSIFCloseL(fpVCT); return FALSE; } const char *pszRefSystem = CSLFetchNameValue( papszVDC, "ref. system " ); const char *pszRefUnits = CSLFetchNameValue( papszVDC, "ref. units " ); if (pszRefSystem != NULL && pszRefUnits != NULL) IdrisiGeoReference2Wkt( pszFilename, pszRefSystem, pszRefUnits, &pszWTKString); } GByte chType; if (VSIFReadL(&chType, 1, 1, fpVCT) != 1) { VSIFCloseL(fpVCT); CSLDestroy( papszVDC ); return FALSE; } if (chType == 1) eType = wkbPoint; else if (chType == 2) eType = wkbLineString; else if (chType == 3) eType = wkbPolygon; else { CPLError( CE_Failure, CPLE_AppDefined, "Unsupport geometry type : %d", static_cast<int>(chType) ); VSIFCloseL(fpVCT); CSLDestroy( papszVDC ); return FALSE; } const char *pszMinX = CSLFetchNameValue( papszVDC, "min. X " ); const char *pszMaxX = CSLFetchNameValue( papszVDC, "max. X " ); const char *pszMinY = CSLFetchNameValue( papszVDC, "min. Y " ); const char *pszMaxY = CSLFetchNameValue( papszVDC, "max. Y " ); OGRIdrisiLayer* poLayer = new OGRIdrisiLayer(pszFilename, CPLGetBasename(pszFilename), fpVCT, eType, pszWTKString); papoLayers = static_cast<OGRLayer**>( CPLMalloc(sizeof(OGRLayer*)) ); papoLayers[nLayers ++] = poLayer; if( pszMinX != NULL && pszMaxX != NULL && pszMinY != NULL && pszMaxY != NULL) { poLayer->SetExtent( CPLAtof(pszMinX), CPLAtof(pszMinY), CPLAtof(pszMaxX), CPLAtof(pszMaxY) ); }//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例18: CSLTokenizeString2int OGRILI1DataSource::Open( const char * pszNewName, int bTestOpen ){ FILE *fp; char szHeader[1000]; std::string osBasename, osModelFilename; if (strlen(pszNewName) == 0) { return FALSE; } char **filenames = CSLTokenizeString2( pszNewName, ",", 0 ); osBasename = filenames[0]; if( CSLCount(filenames) > 1 ) osModelFilename = filenames[1]; CSLDestroy( filenames );/* -------------------------------------------------------------------- *//* Open the source file. *//* -------------------------------------------------------------------- */ fp = VSIFOpen( osBasename.c_str(), "r" ); if( fp == NULL ) { if( !bTestOpen ) CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open ILI1 file `%s'.", pszNewName ); return FALSE; }/* -------------------------------------------------------------------- *//* If we aren't sure it is ILI1, load a header chunk and check *//* for signs it is ILI1 *//* -------------------------------------------------------------------- */ if( bTestOpen ) { int nLen = (int)VSIFRead( szHeader, 1, sizeof(szHeader), fp ); if (nLen == sizeof(szHeader)) szHeader[sizeof(szHeader)-1] = '/0'; else szHeader[nLen] = '/0'; if( strstr(szHeader,"SCNT") == NULL ) { VSIFClose( fp ); return FALSE; } }/* -------------------------------------------------------------------- *//* We assume now that it is ILI1. Close and instantiate a *//* ILI1Reader on it. *//* -------------------------------------------------------------------- */ VSIFClose( fp ); poReader = CreateILI1Reader(); if( poReader == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "File %s appears to be ILI1 but the ILI1 reader can't/n" "be instantiated, likely because Xerces support wasn't/n" "configured in.", pszNewName ); return FALSE; } poReader->OpenFile( osBasename.c_str() ); pszName = CPLStrdup( osBasename.c_str() ); if (osModelFilename.length() > 0 ) poReader->ReadModel( poImdReader, osModelFilename.c_str(), this ); if( getenv( "ARC_DEGREES" ) != NULL ) { //No better way to pass arguments to the reader (it could even be an -lco arg) poReader->SetArcDegrees( atof( getenv("ARC_DEGREES") ) ); } //Parse model and read data - without surface joing and polygonizing poReader->ReadFeatures(); return TRUE;}
开发者ID:samalone,项目名称:gdal-ios,代码行数:88,
示例19: psDTEDDTEDDataset::DTEDDataset() : psDTED(NULL){ pszFilename = CPLStrdup("unknown"); pszProjection = CPLStrdup(""); bVerifyChecksum = CPLTestBool(CPLGetConfigOption("DTED_VERIFY_CHECKSUM", "NO"));}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:6,
示例20: swq_expr_node//.........这里部分代码省略......... poRet->int_value = sub_node_values[0]->int_value % sub_node_values[1]->int_value; break; default: CPLAssert( FALSE ); delete poRet; poRet = NULL; break; } }/* -------------------------------------------------------------------- *//* String operations. *//* -------------------------------------------------------------------- */ else { poRet = new swq_expr_node(0); poRet->field_type = node->field_type; if( node->nOperation != SWQ_ISNULL ) { for( int i = 0; i < node->nSubExprCount; i++ ) { if( sub_node_values[i]->is_null ) { if( poRet->field_type == SWQ_BOOLEAN ) { poRet->int_value = FALSE; return poRet; } else if( poRet->field_type == SWQ_STRING ) { poRet->string_value = CPLStrdup(""); poRet->is_null = 1; return poRet; } } } } switch( (swq_op) node->nOperation ) { case SWQ_EQ: { /* When comparing timestamps, the +00 at the end might be discarded */ /* if the other member has no explicit timezone */ if( (sub_node_values[0]->field_type == SWQ_TIMESTAMP || sub_node_values[0]->field_type == SWQ_STRING) && (sub_node_values[1]->field_type == SWQ_TIMESTAMP || sub_node_values[1]->field_type == SWQ_STRING) && strlen(sub_node_values[0]->string_value) > 3 && strlen(sub_node_values[1]->string_value) > 3 && (strcmp(sub_node_values[0]->string_value + strlen(sub_node_values[0]->string_value)-3, "+00") == 0 && sub_node_values[1]->string_value[strlen(sub_node_values[1]->string_value)-3] == ':') ) { poRet->int_value = EQUALN(sub_node_values[0]->string_value, sub_node_values[1]->string_value, strlen(sub_node_values[1]->string_value)); } else if( (sub_node_values[0]->field_type == SWQ_TIMESTAMP || sub_node_values[0]->field_type == SWQ_STRING) && (sub_node_values[1]->field_type == SWQ_TIMESTAMP || sub_node_values[1]->field_type == SWQ_STRING) && strlen(sub_node_values[0]->string_value) > 3 &&
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:67,
示例21: DTEDOpenEx//.........这里部分代码省略......... poDS->SetMetadataItem( "DTED_MaintenanceDate", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_MATCHMERGE_DATE ); poDS->SetMetadataItem( "DTED_MatchMergeDate", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_MAINT_DESCRIPTION ); poDS->SetMetadataItem( "DTED_MaintenanceDescription", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_PRODUCER ); poDS->SetMetadataItem( "DTED_Producer", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_VERTDATUM ); poDS->SetMetadataItem( "DTED_VerticalDatum", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_HORIZDATUM ); poDS->SetMetadataItem( "DTED_HorizontalDatum", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_DIGITIZING_SYS ); poDS->SetMetadataItem( "DTED_DigitizingSystem", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_COMPILATION_DATE ); poDS->SetMetadataItem( "DTED_CompilationDate", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_HORIZACCURACY ); poDS->SetMetadataItem( "DTED_HorizontalAccuracy", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_REL_HORIZACCURACY ); poDS->SetMetadataItem( "DTED_RelHorizontalAccuracy", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_REL_VERTACCURACY ); poDS->SetMetadataItem( "DTED_RelVerticalAccuracy", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_ORIGINLAT ); poDS->SetMetadataItem( "DTED_OriginLatitude", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_ORIGINLONG ); poDS->SetMetadataItem( "DTED_OriginLongitude", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_NIMA_DESIGNATOR ); poDS->SetMetadataItem( "DTED_NimaDesignator", pszValue ); CPLFree( pszValue ); pszValue = DTEDGetMetadata( psDTED, DTEDMD_PARTIALCELL_DSI ); poDS->SetMetadataItem( "DTED_PartialCellIndicator", pszValue ); CPLFree( pszValue ); poDS->SetMetadataItem( GDALMD_AREA_OR_POINT, GDALMD_AOP_POINT );/* -------------------------------------------------------------------- *//* Initialize any PAM information. *//* -------------------------------------------------------------------- */ poDS->SetDescription( poOpenInfo->pszFilename ); poDS->TryLoadXML( poOpenInfo->GetSiblingFiles() ); // if no SR in xml, try aux const char* pszPrj = poDS->GDALPamDataset::GetProjectionRef(); if( !pszPrj || strlen(pszPrj) == 0 ) { int bTryAux = TRUE; if( poOpenInfo->GetSiblingFiles() != NULL && CSLFindString(poOpenInfo->GetSiblingFiles(), CPLResetExtension(CPLGetFilename(poOpenInfo->pszFilename), "aux")) < 0 && CSLFindString(poOpenInfo->GetSiblingFiles(), CPLSPrintf("%s.aux", CPLGetFilename(poOpenInfo->pszFilename))) < 0 ) bTryAux = FALSE; if( bTryAux ) { GDALDataset* poAuxDS = GDALFindAssociatedAuxFile( poOpenInfo->pszFilename, GA_ReadOnly, poDS ); if( poAuxDS ) { pszPrj = poAuxDS->GetProjectionRef(); if( pszPrj && strlen(pszPrj) > 0 ) { CPLFree( poDS->pszProjection ); poDS->pszProjection = CPLStrdup(pszPrj); } GDALClose( poAuxDS ); } } }/* -------------------------------------------------------------------- *//* Support overviews. *//* -------------------------------------------------------------------- */ poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename, poOpenInfo->GetSiblingFiles() ); return( poDS );}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例22: whilechar *CPLRecodeFromWCharIconv( const wchar_t *pwszSource, const char *pszSrcEncoding, const char *pszDstEncoding ){/* -------------------------------------------------------------------- *//* What is the source length. *//* -------------------------------------------------------------------- */ size_t nSrcLen = 0; while ( pwszSource[nSrcLen] != 0 ) nSrcLen++;/* -------------------------------------------------------------------- *//* iconv() does not support wchar_t so we need to repack the *//* characters according to the width of a character in the *//* source encoding. For instance if wchar_t is 4 bytes but our *//* source is UTF16 then we need to pack down into 2 byte *//* characters before passing to iconv(). *//* -------------------------------------------------------------------- */ int nTargetCharWidth = CPLEncodingCharSize( pszSrcEncoding ); if( nTargetCharWidth < 1 ) { CPLError( CE_Warning, CPLE_AppDefined, "Recode from %s with CPLRecodeFromWChar() failed because" " the width of characters in the encoding are not known.", pszSrcEncoding ); return CPLStrdup(""); } GByte *pszIconvSrcBuf = (GByte*) CPLCalloc((nSrcLen+1),nTargetCharWidth); for( unsigned int iSrc = 0; iSrc <= nSrcLen; iSrc++ ) { if( nTargetCharWidth == 1 ) pszIconvSrcBuf[iSrc] = (GByte) pwszSource[iSrc]; else if( nTargetCharWidth == 2 ) ((short *)pszIconvSrcBuf)[iSrc] = (short) pwszSource[iSrc]; else if( nTargetCharWidth == 4 ) ((GInt32 *)pszIconvSrcBuf)[iSrc] = pwszSource[iSrc]; }/* -------------------------------------------------------------------- *//* Create the iconv() translation object. *//* -------------------------------------------------------------------- */ iconv_t sConv; sConv = iconv_open( pszDstEncoding, pszSrcEncoding ); if ( sConv == (iconv_t)-1 ) { CPLFree( pszIconvSrcBuf ); CPLError( CE_Warning, CPLE_AppDefined, "Recode from %s to %s failed with the error: /"%s/".", pszSrcEncoding, pszDstEncoding, strerror(errno) ); return CPLStrdup( "" ); }/* -------------------------------------------------------------------- *//* XXX: There is a portability issue: iconv() function could be *//* declared differently on different platforms. The second *//* argument could be declared as char** (as POSIX defines) or *//* as a const char**. Handle it with the ICONV_CPP_CONST macro here. *//* -------------------------------------------------------------------- */ ICONV_CPP_CONST char *pszSrcBuf = (ICONV_CPP_CONST char *) pszIconvSrcBuf; /* iconv expects a number of bytes, not characters */ nSrcLen *= sizeof(wchar_t);/* -------------------------------------------------------------------- *//* Allocate destination buffer. *//* -------------------------------------------------------------------- */ size_t nDstCurLen = MAX(CPL_RECODE_DSTBUF_SIZE, nSrcLen + 1); size_t nDstLen = nDstCurLen; char *pszDestination = (char *)CPLCalloc( nDstCurLen, sizeof(char) ); char *pszDstBuf = pszDestination; while ( nSrcLen > 0 ) { size_t nConverted = iconv( sConv, &pszSrcBuf, &nSrcLen, &pszDstBuf, &nDstLen ); if ( nConverted == (size_t)-1 ) { if ( errno == EILSEQ ) { // Skip the invalid sequence in the input string. nSrcLen--; pszSrcBuf += sizeof(wchar_t); if (!bHaveWarned2) { bHaveWarned2 = true; CPLError(CE_Warning, CPLE_AppDefined, "One or several characters couldn't be converted correctly from %s to %s./n" "This warning will not be emitted anymore", pszSrcEncoding, pszDstEncoding); } continue;//.........这里部分代码省略.........
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:101,
示例23: VRTCreateCopystatic GDALDataset *VRTCreateCopy( const char * pszFilename, GDALDataset *poSrcDS, int bStrict, char ** papszOptions, CPL_UNUSED GDALProgressFunc pfnProgress, CPL_UNUSED void * pProgressData ){ VRTDataset *poVRTDS = NULL; (void) bStrict; (void) papszOptions; CPLAssert( NULL != poSrcDS );/* -------------------------------------------------------------------- *//* If the source dataset is a virtual dataset then just write *//* it to disk as a special case to avoid extra layers of *//* indirection. *//* -------------------------------------------------------------------- */ if( poSrcDS->GetDriver() != NULL && EQUAL(poSrcDS->GetDriver()->GetDescription(),"VRT") ) { /* -------------------------------------------------------------------- */ /* Convert tree to a single block of XML text. */ /* -------------------------------------------------------------------- */ char *pszVRTPath = CPLStrdup(CPLGetPath(pszFilename)); ((VRTDataset *) poSrcDS)->UnsetPreservedRelativeFilenames(); CPLXMLNode *psDSTree = ((VRTDataset *) poSrcDS)->SerializeToXML( pszVRTPath ); char *pszXML = CPLSerializeXMLTree( psDSTree ); CPLDestroyXMLNode( psDSTree ); CPLFree( pszVRTPath ); /* -------------------------------------------------------------------- */ /* Write to disk. */ /* -------------------------------------------------------------------- */ GDALDataset* pCopyDS = NULL; if( 0 != strlen( pszFilename ) ) { VSILFILE *fpVRT = NULL; fpVRT = VSIFOpenL( pszFilename, "wb" ); if (fpVRT == NULL) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot create %s", pszFilename); CPLFree( pszXML ); return NULL; } VSIFWriteL( pszXML, 1, strlen(pszXML), fpVRT ); VSIFCloseL( fpVRT ); pCopyDS = (GDALDataset *) GDALOpen( pszFilename, GA_Update ); } else { /* No destination file is given, so pass serialized XML directly. */ pCopyDS = (GDALDataset *) GDALOpen( pszXML, GA_Update ); } CPLFree( pszXML ); return pCopyDS; }/* -------------------------------------------------------------------- *//* Create the virtual dataset. *//* -------------------------------------------------------------------- */ poVRTDS = (VRTDataset *) VRTDataset::Create( pszFilename, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), 0, GDT_Byte, NULL ); if (poVRTDS == NULL) return NULL;/* -------------------------------------------------------------------- *//* Do we have a geotransform? *//* -------------------------------------------------------------------- */ double adfGeoTransform[6]; if( poSrcDS->GetGeoTransform( adfGeoTransform ) == CE_None ) { poVRTDS->SetGeoTransform( adfGeoTransform ); }/* -------------------------------------------------------------------- *//* Copy projection *//* -------------------------------------------------------------------- */ poVRTDS->SetProjection( poSrcDS->GetProjectionRef() );/* -------------------------------------------------------------------- *//* Emit dataset level metadata. *///.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例24: iconv_openchar *CPLRecodeIconv( const char *pszSource, const char *pszSrcEncoding, const char *pszDstEncoding ){ iconv_t sConv; sConv = iconv_open( pszDstEncoding, pszSrcEncoding ); if ( sConv == (iconv_t)-1 ) { CPLError( CE_Warning, CPLE_AppDefined, "Recode from %s to %s failed with the error: /"%s/".", pszSrcEncoding, pszDstEncoding, strerror(errno) ); return CPLStrdup(pszSource); }/* -------------------------------------------------------------------- *//* XXX: There is a portability issue: iconv() function could be *//* declared differently on different platforms. The second *//* argument could be declared as char** (as POSIX defines) or *//* as a const char**. Handle it with the ICONV_CPP_CONST macro here. *//* -------------------------------------------------------------------- */ ICONV_CPP_CONST char *pszSrcBuf = (ICONV_CPP_CONST char *)pszSource; size_t nSrcLen = strlen( pszSource ); size_t nDstCurLen = MAX(CPL_RECODE_DSTBUF_SIZE, nSrcLen + 1); size_t nDstLen = nDstCurLen; char *pszDestination = (char *)CPLCalloc( nDstCurLen, sizeof(char) ); char *pszDstBuf = pszDestination; while ( nSrcLen > 0 ) { size_t nConverted = iconv( sConv, &pszSrcBuf, &nSrcLen, &pszDstBuf, &nDstLen ); if ( nConverted == (size_t)-1 ) { if ( errno == EILSEQ ) { // Skip the invalid sequence in the input string. if (!bHaveWarned1) { bHaveWarned1 = true; CPLError(CE_Warning, CPLE_AppDefined, "One or several characters couldn't be converted correctly from %s to %s./n" "This warning will not be emitted anymore", pszSrcEncoding, pszDstEncoding); } nSrcLen--, pszSrcBuf++; continue; } else if ( errno == E2BIG ) { // We are running out of the output buffer. // Dynamically increase the buffer size. size_t nTmp = nDstCurLen; nDstCurLen *= 2; pszDestination = (char *)CPLRealloc( pszDestination, nDstCurLen ); pszDstBuf = pszDestination + nTmp - nDstLen; nDstLen += nDstCurLen - nTmp; continue; } else break; } } pszDestination[nDstCurLen - nDstLen] = '/0'; iconv_close( sConv ); return pszDestination;}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:77,
示例25: CPLStrdupOGRFeatureDefn *OGRMySQLTableLayer::ReadTableDefinition( const char *pszTable ){ MYSQL_RES *hResult; CPLString osCommand;/* -------------------------------------------------------------------- *//* Fire off commands to get back the schema of the table. *//* -------------------------------------------------------------------- */ osCommand.Printf("DESCRIBE `%s`", pszTable ); pszGeomColumnTable = CPLStrdup(pszTable); if( mysql_query( poDS->GetConn(), osCommand ) ) { poDS->ReportError( "DESCRIBE Failed" ); return NULL; } hResult = mysql_store_result( poDS->GetConn() ); if( hResult == NULL ) { poDS->ReportError( "mysql_store_result() failed on DESCRIBE result." ); return NULL; }/* -------------------------------------------------------------------- *//* Parse the returned table information. *//* -------------------------------------------------------------------- */ OGRFeatureDefn *poDefn = new OGRFeatureDefn( pszTable ); char **papszRow; OGRwkbGeometryType eForcedGeomType = wkbUnknown; int bGeomColumnNotNullable = FALSE; poDefn->Reference(); while( (papszRow = mysql_fetch_row( hResult )) != NULL ) { const char *pszType; OGRFieldDefn oField( papszRow[0], OFTString); int nLenType; pszType = papszRow[1]; if( pszType == NULL ) continue; nLenType = (int)strlen(pszType); if( EQUAL(pszType,"varbinary") || (nLenType>=4 && EQUAL(pszType+nLenType-4,"blob"))) { oField.SetType( OFTBinary ); } else if( EQUAL(pszType,"varchar") || (nLenType>=4 && EQUAL(pszType+nLenType-4,"enum")) || (nLenType>=3 && EQUAL(pszType+nLenType-3,"set")) ) { oField.SetType( OFTString ); } else if( STARTS_WITH_CI(pszType, "char") ) { oField.SetType( OFTString ); char ** papszTokens; papszTokens = CSLTokenizeString2(pszType,"(),",0); if (CSLCount(papszTokens) >= 2) { /* width is the second */ oField.SetWidth(atoi(papszTokens[1])); } CSLDestroy( papszTokens ); oField.SetType( OFTString ); } if(nLenType>=4 && EQUAL(pszType+nLenType-4,"text")) { oField.SetType( OFTString ); } else if( STARTS_WITH_CI(pszType,"varchar") ) { /* pszType is usually in the form "varchar(15)" so we'll split it up and get the width and precision */ oField.SetType( OFTString ); char ** papszTokens; papszTokens = CSLTokenizeString2(pszType,"(),",0); if (CSLCount(papszTokens) >= 2) { /* width is the second */ oField.SetWidth(atoi(papszTokens[1])); } CSLDestroy( papszTokens ); oField.SetType( OFTString ); }//.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例26: GDAL_IMD_AA2Rstatic int GDAL_IMD_AA2R( char ***ppapszIMD ){ char **papszIMD = *ppapszIMD;/* -------------------------------------------------------------------- *//* Verify that we have a new format file. *//* -------------------------------------------------------------------- */ const char *pszValue = CSLFetchNameValue( papszIMD, "version" ); if( pszValue == NULL ) return FALSE; if( EQUAL(pszValue,"/"R/"") ) return TRUE; if( !EQUAL(pszValue,"/"AA/"") ) { CPLDebug( "IMD", "The file is not the expected 'version = /"AA/"' format./nProceeding, but file may be corrupted." ); }/* -------------------------------------------------------------------- *//* Fix the version line. *//* -------------------------------------------------------------------- */ papszIMD = CSLSetNameValue( papszIMD, "version", "/"R/"" );/* -------------------------------------------------------------------- *//* remove a bunch of fields. *//* -------------------------------------------------------------------- */ int iKey; static const char *apszToRemove[] = { "productCatalogId", "childCatalogId", "productType", "numberOfLooks", "effectiveBandwidth", "mode", "scanDirection", "cloudCover", "productGSD", NULL }; for( iKey = 0; apszToRemove[iKey] != NULL; iKey++ ) { int iTarget = CSLFindName( papszIMD, apszToRemove[iKey] ); if( iTarget != -1 ) papszIMD = CSLRemoveStrings( papszIMD, iTarget, 1, NULL ); }/* -------------------------------------------------------------------- *//* Replace various min/mean/max with just the mean. *//* -------------------------------------------------------------------- */ static const char *keylist[] = { "CollectedRowGSD", "CollectedColGSD", "SunAz", "SunEl", "SatAz", "SatEl", "InTrackViewAngle", "CrossTrackViewAngle", "OffNadirViewAngle", NULL }; for( iKey = 0; keylist[iKey] != NULL; iKey++ ) { CPLString osTarget; int iTarget; osTarget.Printf( "IMAGE_1.min%s", keylist[iKey] ); iTarget = CSLFindName( papszIMD, osTarget ); if( iTarget != -1 ) papszIMD = CSLRemoveStrings( papszIMD, iTarget, 1, NULL ); osTarget.Printf( "IMAGE_1.max%s", keylist[iKey] ); iTarget = CSLFindName( papszIMD, osTarget ); if( iTarget != -1 ) papszIMD = CSLRemoveStrings( papszIMD, iTarget, 1, NULL ); osTarget.Printf( "IMAGE_1.mean%s", keylist[iKey] ); iTarget = CSLFindName( papszIMD, osTarget ); if( iTarget != -1 ) { CPLString osValue = CSLFetchNameValue( papszIMD, osTarget ); CPLString osLine; osTarget.Printf( "IMAGE_1.%c%s", tolower(keylist[iKey][0]), keylist[iKey]+1 ); osLine = osTarget + "=" + osValue; CPLFree( papszIMD[iTarget] ); papszIMD[iTarget] = CPLStrdup(osLine); } } *ppapszIMD = papszIMD; return TRUE;//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例27: CPLCalloc/** * Retrieves and stores the GCPs from a COSMO-SKYMED dataset * It only retrieves the GCPs for L0, L1A and L1B products * for L1C and L1D products, geotransform is provided. * The GCPs provided will be the Image's corners. * @param iProductType type of CSK product @see HDF5CSKProductEnum */void HDF5ImageDataset::CaptureCSKGCPs(int iProductType){ //Only retrieve GCPs for L0,L1A and L1B products if(iProductType == PROD_CSK_L0||iProductType == PROD_CSK_L1A|| iProductType == PROD_CSK_L1B) { nGCPCount = 4; pasGCPList = static_cast<GDAL_GCP *>( CPLCalloc(sizeof(GDAL_GCP),4) ); CPLString osCornerName[4]; double pdCornerPixel[4] = {0.0, 0.0, 0.0, 0.0}; double pdCornerLine[4] = {0.0, 0.0, 0.0, 0.0}; const char * const pszSubdatasetName = GetSubdatasetName(); //Load the subdataset name first for( int i=0; i < 4; i++ ) osCornerName[i] = pszSubdatasetName; //Load the attribute name, and raster coordinates for //all the corners osCornerName[0] += "/Top Left Geodetic Coordinates"; pdCornerPixel[0] = 0; pdCornerLine[0] = 0; osCornerName[1] += "/Top Right Geodetic Coordinates"; pdCornerPixel[1] = GetRasterXSize(); pdCornerLine[1] = 0; osCornerName[2] += "/Bottom Left Geodetic Coordinates"; pdCornerPixel[2] = 0; pdCornerLine[2] = GetRasterYSize(); osCornerName[3] += "/Bottom Right Geodetic Coordinates"; pdCornerPixel[3] = GetRasterXSize(); pdCornerLine[3] = GetRasterYSize(); //For all the image's corners for( int i=0;i<4;i++) { GDALInitGCPs( 1, pasGCPList + i ); CPLFree( pasGCPList[i].pszId ); pasGCPList[i].pszId = NULL; double *pdCornerCoordinates = NULL; // Retrieve the attributes. if(HDF5ReadDoubleAttr(osCornerName[i].c_str(), &pdCornerCoordinates) == CE_Failure) { CPLError( CE_Failure, CPLE_OpenFailed, "Error retrieving CSK GCPs/n" ); // Free on failure, e.g. in case of QLK subdataset. for( i = 0; i < 4; i++ ) { if( pasGCPList[i].pszId ) CPLFree( pasGCPList[i].pszId ); if( pasGCPList[i].pszInfo ) CPLFree( pasGCPList[i].pszInfo ); } CPLFree( pasGCPList ); pasGCPList = NULL; nGCPCount = 0; break; } //Fill the GCPs name pasGCPList[i].pszId = CPLStrdup( osCornerName[i].c_str() ); //Fill the coordinates pasGCPList[i].dfGCPX = pdCornerCoordinates[1]; pasGCPList[i].dfGCPY = pdCornerCoordinates[0]; pasGCPList[i].dfGCPZ = pdCornerCoordinates[2]; pasGCPList[i].dfGCPPixel = pdCornerPixel[i]; pasGCPList[i].dfGCPLine = pdCornerLine[i]; //Free the returned coordinates CPLFree(pdCornerCoordinates); } }}
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:88,
示例28: VSIFOpenL//.........这里部分代码省略......... "DOQ Data Type (%d) is not a supported configuration.", nBandTypes ); CSLDestroy( papszMetadata ); CPL_IGNORE_RET_VAL(VSIFCloseL(fp)); return NULL; }/* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CSLDestroy( papszMetadata ); CPLError( CE_Failure, CPLE_NotSupported, "The DOQ2 driver does not support update access to existing" " datasets." ); CPL_IGNORE_RET_VAL(VSIFCloseL(fp)); return NULL; }/* -------------------------------------------------------------------- *//* Create a corresponding GDALDataset. *//* -------------------------------------------------------------------- */ DOQ2Dataset *poDS = new DOQ2Dataset(); poDS->nRasterXSize = nWidth; poDS->nRasterYSize = nHeight; poDS->SetMetadata( papszMetadata ); CSLDestroy( papszMetadata ); papszMetadata = NULL; poDS->fpImage = fp;/* -------------------------------------------------------------------- *//* Compute layout of data. *//* -------------------------------------------------------------------- */ if( nBandCount < 2 ) nBandCount = nBytesPerPixel; else nBytesPerPixel *= nBandCount; const int nBytesPerLine = nBytesPerPixel * nWidth;/* -------------------------------------------------------------------- *//* Create band information objects. *//* -------------------------------------------------------------------- */ CPLErrorReset(); for( int i = 0; i < nBandCount; i++ ) { poDS->SetBand( i+1, new RawRasterBand( poDS, i+1, poDS->fpImage, nSkipBytes + i, nBytesPerPixel, nBytesPerLine, GDT_Byte, TRUE, TRUE ) ); if( CPLGetLastErrorType() != CE_None ) { delete poDS; CPLFree( pszQuadname ); CPLFree( pszQuadquad ); CPLFree( pszState ); return NULL; } } if (nProjType == 1) { poDS->pszProjection = CPLStrdup( CPLSPrintf( UTM_FORMAT, pszDatumShort ? pszDatumShort : "", nZone, pszDatumLong ? pszDatumLong : "", nZone >= 1 && nZone <= 60 ? nZone * 6 - 183 : 0, pszUnits ? pszUnits : "" ) ); } else { poDS->pszProjection = CPLStrdup(""); } poDS->dfULX = dfULXMap; poDS->dfULY = dfULYMap; poDS->dfXPixelSize = dfXDim; poDS->dfYPixelSize = dfYDim; CPLFree( pszQuadname ); CPLFree( pszQuadquad ); CPLFree( pszState );/* -------------------------------------------------------------------- *//* Initialize any PAM information. *//* -------------------------------------------------------------------- */ poDS->SetDescription( poOpenInfo->pszFilename ); poDS->TryLoadXML();/* -------------------------------------------------------------------- *//* Check for overviews. *//* -------------------------------------------------------------------- */ poDS->oOvManager.Initialize( poDS, poOpenInfo->pszFilename ); return poDS;}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:101,
示例29: mysql_store_resultOGRSpatialReference *OGRMySQLDataSource::FetchSRS( int nId ){ char szCommand[128]; char **papszRow; MYSQL_RES *hResult; if( nId < 0 ) return NULL;/* -------------------------------------------------------------------- *//* First, we look through our SRID cache, is it there? *//* -------------------------------------------------------------------- */ int i; for( i = 0; i < nKnownSRID; i++ ) { if( panSRID[i] == nId ) return papoSRS[i]; } OGRSpatialReference *poSRS = NULL; // make sure to attempt to free any old results hResult = mysql_store_result( GetConn() ); if( hResult != NULL ) mysql_free_result( hResult ); hResult = NULL; sprintf( szCommand, "SELECT srtext FROM spatial_ref_sys WHERE srid = %d", nId ); if( !mysql_query( GetConn(), szCommand ) ) hResult = mysql_store_result( GetConn() ); char *pszWKT = NULL; papszRow = NULL; if( hResult != NULL ) papszRow = mysql_fetch_row( hResult ); if( papszRow != NULL && papszRow[0] != NULL ) { pszWKT = CPLStrdup(papszRow[0]); } if( hResult != NULL ) mysql_free_result( hResult ); hResult = NULL; poSRS = new OGRSpatialReference(); char* pszWKTOri = pszWKT; if( pszWKT == NULL || poSRS->importFromWkt( &pszWKT ) != OGRERR_NONE ) { delete poSRS; CPLFree(pszWKTOri); poSRS = NULL; } CPLFree(pszWKTOri);/* -------------------------------------------------------------------- *//* Add to the cache. *//* -------------------------------------------------------------------- */ panSRID = (int *) CPLRealloc(panSRID,sizeof(int) * (nKnownSRID+1) ); papoSRS = (OGRSpatialReference **) CPLRealloc(papoSRS, sizeof(void*) * (nKnownSRID + 1) ); panSRID[nKnownSRID] = nId; papoSRS[nKnownSRID] = poSRS; nKnownSRID ++; return poSRS;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:74,
示例30: CSLFetchNameValue//.........这里部分代码省略......... } const int nDimension = 2 + ((GeometryTypeFlags & OGRGeometry::OGR_G_3D) ? 1 : 0) + ((GeometryTypeFlags & OGRGeometry::OGR_G_MEASURED) ? 1 : 0); /* Should we turn layers with None geometry type as Unknown/GEOMETRY */ /* so they are still recorded in geometry_columns table ? (#4012) */ int bNoneAsUnknown = CPLTestBool(CSLFetchNameValueDef( papszOptions, "NONE_AS_UNKNOWN", "NO")); if (bNoneAsUnknown && eType == wkbNone) eType = wkbUnknown; else if (eType == wkbNone) bHavePostGIS = FALSE; int bExtractSchemaFromLayerName = CPLTestBool(CSLFetchNameValueDef( papszOptions, "EXTRACT_SCHEMA_FROM_LAYER_NAME", "YES")); /* Postgres Schema handling: Extract schema name from input layer name or passed with -lco SCHEMA. Set layer name to "schema.table" or to "table" if schema == current_schema() Usage without schema name is backwards compatible */ const char* pszDotPos = strstr(pszLayerName,"."); if ( pszDotPos != NULL && bExtractSchemaFromLayerName ) { int length = static_cast<int>(pszDotPos - pszLayerName); pszSchemaName = (char*)CPLMalloc(length+1); strncpy(pszSchemaName, pszLayerName, length); pszSchemaName[length] = '/0'; if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) pszTableName = OGRPGCommonLaunderName( pszDotPos + 1, "PGDump" ); //skip "." else pszTableName = CPLStrdup( pszDotPos + 1 ); //skip "." } else { pszSchemaName = NULL; if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) pszTableName = OGRPGCommonLaunderName( pszLayerName, "PGDump" ); //skip "." else pszTableName = CPLStrdup( pszLayerName ); //skip "." } LogCommit();/* -------------------------------------------------------------------- *//* Set the default schema for the layers. *//* -------------------------------------------------------------------- */ if( CSLFetchNameValue( papszOptions, "SCHEMA" ) != NULL ) { CPLFree(pszSchemaName); pszSchemaName = CPLStrdup(CSLFetchNameValue( papszOptions, "SCHEMA" )); if (bCreateSchema) { osCommand.Printf("CREATE SCHEMA /"%s/"", pszSchemaName); Log(osCommand); } } if ( pszSchemaName == NULL) { pszSchemaName = CPLStrdup("public"); }/* -------------------------------------------------------------------- */
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:67,
注:本文中的CPLStrdup函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CPLString函数代码示例 C++ CPLSetConfigOption函数代码示例 |