这篇教程C++ CSLFetchNameValue函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CSLFetchNameValue函数的典型用法代码示例。如果您正苦于以下问题:C++ CSLFetchNameValue函数的具体用法?C++ CSLFetchNameValue怎么用?C++ CSLFetchNameValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CSLFetchNameValue函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: msContourLayerReadRasterstatic int msContourLayerReadRaster(layerObj *layer, rectObj rect){ mapObj *map = layer->map; char **bands; char pointer[64], memDSPointer[128]; int band = 1; double adfGeoTransform[6], adfInvGeoTransform[6]; double llx, lly, urx, ury; rectObj copyRect, mapRect; int dst_xsize, dst_ysize; int virtual_grid_step_x, virtual_grid_step_y; int src_xoff, src_yoff, src_xsize, src_ysize; double map_cellsize_x, map_cellsize_y, dst_cellsize_x, dst_cellsize_y; GDALRasterBandH hBand = NULL; CPLErr eErr; contourLayerInfo *clinfo = (contourLayerInfo *) layer->layerinfo; if (layer->debug) msDebug("Entering msContourLayerReadRaster()./n"); if (clinfo == NULL || clinfo->hOrigDS == NULL) { msSetError(MS_MISCERR, "Assertion failed: Contour layer not opened!!!", "msContourLayerReadRaster()"); return MS_FAILURE; } bands = CSLTokenizeStringComplex( CSLFetchNameValue(layer->processing,"BANDS"), " ,", FALSE, FALSE ); if (CSLCount(bands) > 0) { band = atoi(bands[0]); if (band < 1 || band > GDALGetRasterCount(clinfo->hOrigDS)) { msSetError( MS_IMGERR, "BANDS PROCESSING directive includes illegal band '%d', should be from 1 to %d.", "msContourLayerReadRaster()", band, GDALGetRasterCount(clinfo->hOrigDS)); CSLDestroy(bands); return MS_FAILURE; } } CSLDestroy(bands); hBand = GDALGetRasterBand(clinfo->hOrigDS, band); if (hBand == NULL) { msSetError(MS_IMGERR, "Band %d does not exist on dataset.", "msContourLayerReadRaster()", band); return MS_FAILURE; } if (layer->projection.numargs > 0 && EQUAL(layer->projection.args[0], "auto")) { const char *wkt; wkt = GDALGetProjectionRef(clinfo->hOrigDS); if (wkt != NULL && strlen(wkt) > 0) { if (msOGCWKT2ProjectionObj(wkt, &(layer->projection), layer->debug) != MS_SUCCESS) { char msg[MESSAGELENGTH*2]; errorObj *ms_error = msGetErrorObj(); snprintf( msg, sizeof(msg), "%s/n" "PROJECTION AUTO cannot be used for this " "GDAL raster (`%s').", ms_error->message, layer->data); msg[MESSAGELENGTH-1] = '/0'; msSetError(MS_OGRERR, "%s","msDrawRasterLayer()", msg); return MS_FAILURE; } } } /* * Compute the georeferenced window of overlap, and read the source data * downsampled to match output resolution, or at full resolution if * output resolution is lower than the source resolution. * * A large portion of this overlap calculation code was borrowed from * msDrawRasterLayerGDAL(). * Would be possible to move some of this to a reusable function? * * Note: This code works only if no reprojection is involved. It would * need rework to support cases where output projection differs from source * data file projection. */ src_xsize = GDALGetRasterXSize(clinfo->hOrigDS); src_ysize = GDALGetRasterYSize(clinfo->hOrigDS); /* set the Dataset extent */ msGetGDALGeoTransform(clinfo->hOrigDS, map, layer, adfGeoTransform); clinfo->extent.minx = adfGeoTransform[0]; clinfo->extent.maxy = adfGeoTransform[3]; clinfo->extent.maxx = adfGeoTransform[0] + src_xsize * adfGeoTransform[1]; clinfo->extent.miny = adfGeoTransform[3] + src_ysize * adfGeoTransform[5]; if (layer->transform) {//.........这里部分代码省略.........
开发者ID:BentleySystems,项目名称:mapserver,代码行数:101,
示例2: GDALLoadRPCFilechar **CPL_STDCALL GDALLoadRPCFile( const char *pszFilename, char **papszSiblingFiles ){/* -------------------------------------------------------------------- *//* Try to identify the RPC file in upper or lower case. *//* -------------------------------------------------------------------- */ CPLString osTarget; /* Is this already a _RPC.TXT file ? */ if (strlen(pszFilename) > 8 && EQUAL(pszFilename + strlen(pszFilename) - 8, "_RPC.TXT")) osTarget = pszFilename; else { CPLString osSrcPath = pszFilename; CPLString soPt("."); size_t found = osSrcPath.rfind(soPt); if (found == CPLString::npos) return NULL; osSrcPath.replace (found, osSrcPath.size() - found, "_rpc.txt"); CPLString osTarget = osSrcPath; if( papszSiblingFiles == NULL ) { VSIStatBufL sStatBuf; if( VSIStatL( osTarget, &sStatBuf ) != 0 ) { osSrcPath = pszFilename; osSrcPath.replace (found, osSrcPath.size() - found, "_RPC.TXT"); osTarget = osSrcPath; if( VSIStatL( osTarget, &sStatBuf ) != 0 ) { osSrcPath = pszFilename; osSrcPath.replace (found, osSrcPath.size() - found, "_rpc.TXT"); osTarget = osSrcPath; if( VSIStatL( osTarget, &sStatBuf ) != 0 ) { return NULL; } } } } else { int iSibling = CSLFindString( papszSiblingFiles, CPLGetFilename(osTarget) ); if( iSibling < 0 ) return NULL; osTarget.resize(osTarget.size() - strlen(papszSiblingFiles[iSibling])); osTarget += papszSiblingFiles[iSibling]; } }/* -------------------------------------------------------------------- *//* Read file and parse. *//* -------------------------------------------------------------------- */ char **papszLines = CSLLoad2( osTarget, 100, 100, NULL ); if(!papszLines) return NULL; char **papszMD = NULL; /* From LINE_OFF to HEIGHT_SCALE */ for(size_t i = 0; i < 19; i += 2 ) { const char *pszRPBVal = CSLFetchNameValue(papszLines, apszRPBMap[i] ); if( pszRPBVal == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "%s file found, but missing %s field (and possibly others).", osTarget.c_str(), apszRPBMap[i]); CSLDestroy( papszMD ); CSLDestroy( papszLines ); return NULL; } else { papszMD = CSLSetNameValue( papszMD, apszRPBMap[i], pszRPBVal ); } } /* For LINE_NUM_COEFF, LINE_DEN_COEFF, SAMP_NUM_COEFF, SAMP_DEN_COEFF */ /* parameters that have 20 values each */ for(size_t i = 20; apszRPBMap[i] != NULL; i += 2 ) { CPLString soVal; for(int j = 1; j <= 20; j++) { CPLString soRPBMapItem; soRPBMapItem.Printf("%s_%d", apszRPBMap[i], j); const char *pszRPBVal = CSLFetchNameValue(papszLines, soRPBMapItem.c_str() ); if( pszRPBVal == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "%s file found, but missing %s field (and possibly others).", osTarget.c_str(), soRPBMapItem.c_str() );//.........这里部分代码省略.........
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:101,
示例3: 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,
示例4: CPLErrorGDALDataset *WEBPDataset::CreateCopy( const char * pszFilename, GDALDataset *poSrcDS, int bStrict, char ** papszOptions, GDALProgressFunc pfnProgress, void * pProgressData ){/* -------------------------------------------------------------------- *//* WEBP library initialization *//* -------------------------------------------------------------------- */ WebPPicture sPicture; if (!WebPPictureInit(&sPicture)) { CPLError(CE_Failure, CPLE_AppDefined, "WebPPictureInit() failed"); return nullptr; }/* -------------------------------------------------------------------- *//* Some some rudimentary checks *//* -------------------------------------------------------------------- */ const int nXSize = poSrcDS->GetRasterXSize(); const int nYSize = poSrcDS->GetRasterYSize(); if( nXSize > 16383 || nYSize > 16383 ) { CPLError( CE_Failure, CPLE_NotSupported, "WEBP maximum image dimensions are 16383 x 16383."); return nullptr; } const int nBands = poSrcDS->GetRasterCount(); if( nBands != 3#if WEBP_ENCODER_ABI_VERSION >= 0x0100 && nBands != 4#endif ) { CPLError( CE_Failure, CPLE_NotSupported, "WEBP driver doesn't support %d bands. Must be 3 (RGB) "#if WEBP_ENCODER_ABI_VERSION >= 0x0100 "or 4 (RGBA) "#endif "bands.", nBands ); return nullptr; } const GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); if( eDT != GDT_Byte ) { CPLError( (bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported, "WEBP driver doesn't support data type %s. " "Only eight bit byte bands supported.", GDALGetDataTypeName( poSrcDS->GetRasterBand(1)->GetRasterDataType()) ); if (bStrict) return nullptr; }/* -------------------------------------------------------------------- *//* What options has the user selected? *//* -------------------------------------------------------------------- */ float fQuality = 75.0f; const char* pszQUALITY = CSLFetchNameValue(papszOptions, "QUALITY"); if( pszQUALITY != nullptr ) { fQuality = static_cast<float>( CPLAtof(pszQUALITY) ); if( fQuality < 0.0f || fQuality > 100.0f ) { CPLError( CE_Failure, CPLE_IllegalArg, "%s=%s is not a legal value.", "QUALITY", pszQUALITY); return nullptr; } } WebPPreset nPreset = WEBP_PRESET_DEFAULT; const char* pszPRESET = CSLFetchNameValueDef( papszOptions, "PRESET", "DEFAULT" ); if (EQUAL(pszPRESET, "DEFAULT")) nPreset = WEBP_PRESET_DEFAULT; else if (EQUAL(pszPRESET, "PICTURE")) nPreset = WEBP_PRESET_PICTURE; else if (EQUAL(pszPRESET, "PHOTO")) nPreset = WEBP_PRESET_PHOTO; else if (EQUAL(pszPRESET, "PICTURE")) nPreset = WEBP_PRESET_PICTURE; else if (EQUAL(pszPRESET, "DRAWING")) nPreset = WEBP_PRESET_DRAWING; else if (EQUAL(pszPRESET, "ICON")) nPreset = WEBP_PRESET_ICON; else if (EQUAL(pszPRESET, "TEXT")) nPreset = WEBP_PRESET_TEXT; else { CPLError( CE_Failure, CPLE_IllegalArg,//.........这里部分代码省略.........
开发者ID:OSGeo,项目名称:gdal,代码行数:101,
示例5: InterruptLongResultOGRLayer *OGRMySQLDataSource::ICreateLayer( const char * pszLayerNameIn, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ MYSQL_RES *hResult=NULL; CPLString osCommand; 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, "FID" ); if (!pszExpectedFIDName) pszExpectedFIDName = CSLFetchNameValue( papszOptions, "MYSQL_FID" ); if (!pszExpectedFIDName) pszExpectedFIDName="OGR_FID"; int bFID64 = CSLFetchBoolean(papszOptions, "FID64", FALSE); const char* pszFIDType = bFID64 ? "BIGINT": "INT"; CPLDebug("MYSQL","Geometry Column Name %s.", pszGeomColumnName); CPLDebug("MYSQL","FID Column Name %s.", pszExpectedFIDName); if( wkbFlatten(eType) == wkbNone ) { osCommand.Printf( "CREATE TABLE `%s` ( " " %s %s UNIQUE NOT NULL AUTO_INCREMENT )", pszLayerName, pszExpectedFIDName, pszFIDType ); } else { osCommand.Printf( "CREATE TABLE `%s` ( " " %s %s UNIQUE NOT NULL AUTO_INCREMENT, " " %s GEOMETRY NOT NULL )", pszLayerName, pszExpectedFIDName, pszFIDType, pszGeomColumnName ); } if( CSLFetchNameValue( papszOptions, "ENGINE" ) != NULL ) { osCommand += " ENGINE = "; osCommand += CSLFetchNameValue( papszOptions, "ENGINE" ); }//.........这里部分代码省略.........
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:101,
示例6: CPLErrorOGRLayer *OGRShapeDataSource::CreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ SHPHandle hSHP; DBFHandle hDBF; int nShapeType;/* -------------------------------------------------------------------- *//* Verify we are in update mode. *//* -------------------------------------------------------------------- */ if( !bDSUpdate ) { CPLError( CE_Failure, CPLE_NoWriteAccess, "Data source %s opened read-only./n" "New layer %s cannot be created./n", pszName, pszLayerName ); return NULL; }/* -------------------------------------------------------------------- *//* Figure out what type of layer we need. *//* -------------------------------------------------------------------- */ if( eType == wkbUnknown || eType == wkbLineString ) nShapeType = SHPT_ARC; else if( eType == wkbPoint ) nShapeType = SHPT_POINT; else if( eType == wkbPolygon ) nShapeType = SHPT_POLYGON; else if( eType == wkbMultiPoint ) nShapeType = SHPT_MULTIPOINT; else if( eType == wkbPoint25D ) nShapeType = SHPT_POINTZ; else if( eType == wkbLineString25D ) nShapeType = SHPT_ARCZ; else if( eType == wkbMultiLineString ) nShapeType = SHPT_ARC; else if( eType == wkbMultiLineString25D ) nShapeType = SHPT_ARCZ; else if( eType == wkbPolygon25D ) nShapeType = SHPT_POLYGONZ; else if( eType == wkbMultiPolygon ) nShapeType = SHPT_POLYGON; else if( eType == wkbMultiPolygon25D ) nShapeType = SHPT_POLYGONZ; else if( eType == wkbMultiPoint25D ) nShapeType = SHPT_MULTIPOINTZ; else if( eType == wkbNone ) nShapeType = SHPT_NULL; else nShapeType = -1;/* -------------------------------------------------------------------- *//* Has the application overridden this with a special creation *//* option? *//* -------------------------------------------------------------------- */ const char *pszOverride = CSLFetchNameValue( papszOptions, "SHPT" ); if( pszOverride == NULL ) /* ignore */; else if( EQUAL(pszOverride,"POINT") ) { nShapeType = SHPT_POINT; eType = wkbPoint; } else if( EQUAL(pszOverride,"ARC") ) { nShapeType = SHPT_ARC; eType = wkbLineString; } else if( EQUAL(pszOverride,"POLYGON") ) { nShapeType = SHPT_POLYGON; eType = wkbPolygon; } else if( EQUAL(pszOverride,"MULTIPOINT") ) { nShapeType = SHPT_MULTIPOINT; eType = wkbMultiPoint; } else if( EQUAL(pszOverride,"POINTZ") ) { nShapeType = SHPT_POINTZ; eType = wkbPoint25D; } else if( EQUAL(pszOverride,"ARCZ") ) { nShapeType = SHPT_ARCZ; eType = wkbLineString25D; } else if( EQUAL(pszOverride,"POLYGONZ") ) { nShapeType = SHPT_POLYGONZ; eType = wkbPolygon25D; } else if( EQUAL(pszOverride,"MULTIPOINTZ") )//.........这里部分代码省略.........
开发者ID:Chaduke,项目名称:bah.mod,代码行数:101,
示例7: 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,
示例8: msUVRASTERLayerWhichShapesint msUVRASTERLayerWhichShapes(layerObj *layer, rectObj rect, int isQuery){ uvRasterLayerInfo *uvlinfo = (uvRasterLayerInfo *) layer->layerinfo; imageObj *image_tmp; mapObj map_tmp; unsigned int spacing; int width, height, u_src_off, v_src_off, i, x, y; char **alteredProcessing = NULL; char **savedProcessing = NULL; if (layer->debug) msDebug("Entering msUVRASTERLayerWhichShapes()./n"); if( uvlinfo == NULL ) return MS_FAILURE; /* QUERY NOT SUPPORTED YET */ if (isQuery == MS_TRUE) { msSetError( MS_MISCERR, "Query is not supported for UV layer.", "msUVRASTERLayerWhichShapes()" ); return MS_FAILURE; } if( CSLFetchNameValue( layer->processing, "BANDS" ) == NULL ) { msSetError( MS_MISCERR, "BANDS processing option is required for UV layer. You have to specified 2 bands.", "msUVRASTERLayerWhichShapes()" ); return MS_FAILURE; } /* -------------------------------------------------------------------- */ /* Determine desired spacing. Default to 30 if not otherwise set */ /* -------------------------------------------------------------------- */ spacing = 30; if( CSLFetchNameValue( layer->processing, "UV_SPACING" ) != NULL ) { spacing = atoi(CSLFetchNameValue( layer->processing, "UV_SPACING" )); } width = (int)ceil(layer->map->width/spacing); height = (int)ceil(layer->map->height/spacing); map_tmp.cellsize = layer->map->cellsize*spacing; if (layer->debug) msDebug("msUVRASTERLayerWhichShapes(): width: %d, height: %d, cellsize: %g/n", width, height, map_tmp.cellsize); /* Initialize our dummy map */ MS_INIT_COLOR(map_tmp.imagecolor, 255,255,255,255); map_tmp.resolution = layer->map->resolution; map_tmp.defresolution = layer->map->defresolution; map_tmp.outputformat = (outputFormatObj *) msSmallCalloc(1,sizeof(outputFormatObj)); uvlinfo->band_count = map_tmp.outputformat->bands = 2; map_tmp.outputformat->name = NULL; map_tmp.outputformat->driver = NULL; map_tmp.outputformat->refcount = 0; map_tmp.outputformat->vtable = NULL; map_tmp.outputformat->device = NULL; map_tmp.outputformat->renderer = MS_RENDER_WITH_RAWDATA; map_tmp.outputformat->imagemode = MS_IMAGEMODE_FLOAT32; map_tmp.mappath = layer->map->mappath; map_tmp.shapepath = layer->map->shapepath; map_tmp.extent.minx = layer->map->extent.minx-(0.5*layer->map->cellsize)+(0.5*map_tmp.cellsize); map_tmp.extent.miny = layer->map->extent.miny-(0.5*layer->map->cellsize)+(0.5*map_tmp.cellsize); map_tmp.extent.maxx = map_tmp.extent.minx+((width-1)*map_tmp.cellsize); map_tmp.extent.maxy = map_tmp.extent.miny+((height-1)*map_tmp.cellsize); map_tmp.gt.rotation_angle = 0.0; msInitProjection(&map_tmp.projection); msCopyProjection(&map_tmp.projection, &layer->map->projection); if (layer->debug == 5) msDebug("msUVRASTERLayerWhichShapes(): extent: %g %d %g %g/n", map_tmp.extent.minx, map_tmp.extent.miny, map_tmp.extent.maxx, map_tmp.extent.maxy); /* important to use that function, to compute map geotransform, used by the resampling*/ msMapSetSize(&map_tmp, width, height); if (layer->debug == 5) msDebug("msUVRASTERLayerWhichShapes(): geotransform: %g %g %g %g %g %g/n", map_tmp.gt.geotransform[0], map_tmp.gt.geotransform[1], map_tmp.gt.geotransform[2], map_tmp.gt.geotransform[3], map_tmp.gt.geotransform[4], map_tmp.gt.geotransform[5]); uvlinfo->extent = map_tmp.extent; image_tmp = msImageCreate(width, height, map_tmp.outputformat, NULL, NULL, map_tmp.resolution, map_tmp.defresolution, &(map_tmp.imagecolor)); /* Default set to AVERAGE resampling */ if( CSLFetchNameValue( layer->processing, "RESAMPLE" ) == NULL ) { alteredProcessing = CSLDuplicate( layer->processing ); alteredProcessing = CSLSetNameValue( alteredProcessing, "RESAMPLE", "AVERAGE"); savedProcessing = layer->processing; layer->processing = alteredProcessing;//.........这里部分代码省略.........
开发者ID:shaohuifan,项目名称:mapserver,代码行数:101,
示例9: VSIFOpenLGDALDataset *NDFDataset::Open( GDALOpenInfo * poOpenInfo ){/* -------------------------------------------------------------------- *//* The user must select the header file (ie. .H1). *//* -------------------------------------------------------------------- */ if( poOpenInfo->nHeaderBytes < 50 ) return NULL; if( !EQUALN((const char *)poOpenInfo->pabyHeader,"NDF_REVISION=2",14) && !EQUALN((const char *)poOpenInfo->pabyHeader,"NDF_REVISION=0",14) ) return NULL;/* -------------------------------------------------------------------- *//* Read and process the header into a local name/value *//* stringlist. We just take off the trailing semicolon. The *//* keyword is already seperated from the value by an equal *//* sign. *//* -------------------------------------------------------------------- */ VSILFILE* fp = VSIFOpenL(poOpenInfo->pszFilename, "rb"); if (fp == NULL) return NULL; const char *pszLine; const int nHeaderMax = 1000; int nHeaderLines = 0; char **papszHeader = (char **) CPLMalloc(sizeof(char *) * (nHeaderMax+1)); while( nHeaderLines < nHeaderMax && (pszLine = CPLReadLineL( fp )) != NULL && !EQUAL(pszLine,"END_OF_HDR;") ) { char *pszFixed; if( strstr(pszLine,"=") == NULL ) break; pszFixed = CPLStrdup( pszLine ); if( pszFixed[strlen(pszFixed)-1] == ';' ) pszFixed[strlen(pszFixed)-1] = '/0'; papszHeader[nHeaderLines++] = pszFixed; papszHeader[nHeaderLines] = NULL; } VSIFCloseL(fp); fp = NULL; if( CSLFetchNameValue( papszHeader, "PIXELS_PER_LINE" ) == NULL || CSLFetchNameValue( papszHeader, "LINES_PER_DATA_FILE" ) == NULL || CSLFetchNameValue( papszHeader, "BITS_PER_PIXEL" ) == NULL || CSLFetchNameValue( papszHeader, "PIXEL_FORMAT" ) == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "Dataset appears to be NDF but is missing a required field."); CSLDestroy( papszHeader ); return NULL; } if( !EQUAL(CSLFetchNameValue( papszHeader, "PIXEL_FORMAT"), "BYTE" ) || !EQUAL(CSLFetchNameValue( papszHeader, "BITS_PER_PIXEL"),"8") ) { CPLError( CE_Failure, CPLE_AppDefined, "Currently NDF driver supports only 8bit BYTE format." ); CSLDestroy( papszHeader ); return NULL; } /* -------------------------------------------------------------------- *//* Confirm the requested access is supported. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { CSLDestroy( papszHeader ); CPLError( CE_Failure, CPLE_NotSupported, "The NDF driver does not support update access to existing" " datasets./n" ); return NULL; } /* -------------------------------------------------------------------- *//* Create a corresponding GDALDataset. *//* -------------------------------------------------------------------- */ NDFDataset *poDS; poDS = new NDFDataset(); poDS->papszHeader = papszHeader; poDS->nRasterXSize = atoi(poDS->Get("PIXELS_PER_LINE","")); poDS->nRasterYSize = atoi(poDS->Get("LINES_PER_DATA_FILE",""));/* -------------------------------------------------------------------- *//* Create a raw raster band for each file. *//* -------------------------------------------------------------------- */ int iBand; const char* pszBand = CSLFetchNameValue(papszHeader, "NUMBER_OF_BANDS_IN_VOLUME"); if (pszBand == NULL) {//.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例10: CPLCalloc//.........这里部分代码省略......... afPL[0] = pasGCPList[iGCP].dfGCPPixel; afPL[1] = pasGCPList[iGCP].dfGCPLine; afXY[0] = pasGCPList[iGCP].dfGCPX; afXY[1] = pasGCPList[iGCP].dfGCPY; std::map< std::pair<double, double>, int >::iterator oIter; oIter = oMapPixelLineToIdx.find( std::pair<double,double>(afPL[0], afPL[1]) ); if( oIter != oMapPixelLineToIdx.end() ) { if( afXY[0] == pasGCPList[oIter->second].dfGCPX && afXY[1] == pasGCPList[oIter->second].dfGCPY ) { continue; } else { CPLError(CE_Warning, CPLE_AppDefined, "GCP %d and %d have same (pixel,line)=(%f,%f) but different (X,Y): (%f,%f) vs (%f,%f)", iGCP + 1, oIter->second, afPL[0], afPL[1], afXY[0], afXY[1], pasGCPList[oIter->second].dfGCPX, pasGCPList[oIter->second].dfGCPY); } } else { oMapPixelLineToIdx[ std::pair<double,double>(afPL[0], afPL[1]) ] = iGCP; } oIter = oMapXYToIdx.find( std::pair<double,double>(afXY[0], afXY[1]) ); if( oIter != oMapXYToIdx.end() ) { CPLError(CE_Warning, CPLE_AppDefined, "GCP %d and %d have same (x,y)=(%f,%f) but different (pixel,line): (%f,%f) vs (%f,%f)", iGCP + 1, oIter->second, afXY[0], afXY[1], afPL[0], afPL[1], pasGCPList[oIter->second].dfGCPPixel, pasGCPList[oIter->second].dfGCPLine); } else { oMapXYToIdx[ std::pair<double,double>(afXY[0], afXY[1]) ] = iGCP; } bool bOK = true; if( bReversed ) { bOK &= psInfo->poReverse->add_point( afPL[0], afPL[1], afXY ); bOK &= psInfo->poForward->add_point( afXY[0], afXY[1], afPL ); } else { bOK &= psInfo->poForward->add_point( afPL[0], afPL[1], afXY ); bOK &= psInfo->poReverse->add_point( afXY[0], afXY[1], afPL ); } if( !bOK ) { GDALDestroyTPSTransformer(psInfo); return NULL; } } psInfo->nRefCount = 1; int nThreads = 1; if( nGCPCount > 100 ) { const char* pszWarpThreads = CSLFetchNameValue(papszOptions, "NUM_THREADS"); if (pszWarpThreads == NULL) pszWarpThreads = CPLGetConfigOption("GDAL_NUM_THREADS", "1"); if (EQUAL(pszWarpThreads, "ALL_CPUS")) nThreads = CPLGetNumCPUs(); else nThreads = atoi(pszWarpThreads); } if( nThreads > 1 ) { /* Compute direct and reverse transforms in parallel */ CPLJoinableThread* hThread = CPLCreateJoinableThread(GDALTPSComputeForwardInThread, psInfo); psInfo->bReverseSolved = psInfo->poReverse->solve() != 0; if( hThread != NULL ) CPLJoinThread(hThread); else psInfo->bForwardSolved = psInfo->poForward->solve() != 0; } else { psInfo->bForwardSolved = psInfo->poForward->solve() != 0; psInfo->bReverseSolved = psInfo->poReverse->solve() != 0; } if( !psInfo->bForwardSolved || !psInfo->bReverseSolved ) { GDALDestroyTPSTransformer(psInfo); return NULL; } return psInfo;}
开发者ID:StephenHolzman,项目名称:UVAmisc,代码行数:101,
示例11: CPLErrorGDALDataset *ISIS2Dataset::Create(const char* pszFilename, int nXSize, int nYSize, int nBands, GDALDataType eType, char** papszParmList) { /* Verify settings. In Isis 2 core pixel values can be represented in * three different ways : 1, 2 4, or 8 Bytes */ if( eType != GDT_Byte && eType != GDT_Int16 && eType != GDT_Float32 && eType != GDT_UInt16 && eType != GDT_Float64 ){ CPLError(CE_Failure, CPLE_AppDefined, "The ISIS2 driver does not supporting creating files of type %s.", GDALGetDataTypeName( eType ) ); return nullptr; } /* (SAMPLE, LINE, BAND) - Band Sequential (BSQ) - default choice (SAMPLE, BAND, LINE) - Band Interleaved by Line (BIL) (BAND, SAMPLE, LINE) - Band Interleaved by Pixel (BIP) */ const char *pszInterleaving = "(SAMPLE,LINE,BAND)"; const char *pszInterleavingParam = CSLFetchNameValue( papszParmList, "INTERLEAVE" ); if ( pszInterleavingParam ) { if ( STARTS_WITH_CI(pszInterleavingParam, "bip") ) pszInterleaving = "(BAND,SAMPLE,LINE)"; else if ( STARTS_WITH_CI(pszInterleavingParam, "bil") ) pszInterleaving = "(SAMPLE,BAND,LINE)"; else pszInterleaving = "(SAMPLE,LINE,BAND)"; } /* default labeling method is attached */ bool bAttachedLabelingMethod = true; /* check if labeling method is set : check the all three first chars */ const char *pszLabelingMethod = CSLFetchNameValue( papszParmList, "LABELING_METHOD" ); if ( pszLabelingMethod ){ if ( STARTS_WITH_CI( pszLabelingMethod, "det" /* "detached" */ ) ){ bAttachedLabelingMethod = false; } if ( STARTS_WITH_CI( pszLabelingMethod, "att" /* attached" */ ) ){ bAttachedLabelingMethod = true; } } /* set the label and data files */ CPLString osLabelFile, osRasterFile, osOutFile; if( bAttachedLabelingMethod ) { osLabelFile = ""; osRasterFile = pszFilename; osOutFile = osRasterFile; } else { CPLString sExtension = "cub"; const char* pszExtension = CSLFetchNameValue( papszParmList, "IMAGE_EXTENSION" ); if( pszExtension ){ sExtension = pszExtension; } if( EQUAL(CPLGetExtension( pszFilename ), sExtension) ) { CPLError( CE_Failure, CPLE_AppDefined, "IMAGE_EXTENSION (%s) cannot match LABEL file extension.", sExtension.c_str() ); return nullptr; } osLabelFile = pszFilename; osRasterFile = CPLResetExtension( osLabelFile, sExtension ); osOutFile = osLabelFile; } const char *pszObject = CSLFetchNameValue( papszParmList, "OBJECT" ); CPLString sObject = "QUBE"; // default choice if (pszObject) { if ( EQUAL( pszObject, "IMAGE") ){ sObject = "IMAGE"; } if ( EQUAL( pszObject, "SPECTRAL_QUBE")){ sObject = "SPECTRAL_QUBE"; } } GUIntBig iRecords = ISIS2Dataset::RecordSizeCalculation(nXSize, nYSize, nBands, eType); GUIntBig iLabelRecords(2); CPLDebug("ISIS2","irecord = %i",static_cast<int>(iRecords)); if( bAttachedLabelingMethod ) { ISIS2Dataset::WriteLabel(osRasterFile, "", sObject, nXSize, nYSize, nBands, eType, iRecords, pszInterleaving, iLabelRecords, true); } else { ISIS2Dataset::WriteLabel(osLabelFile, osRasterFile, sObject, nXSize, nYSize, nBands, eType, iRecords, pszInterleaving, iLabelRecords); } if( !ISIS2Dataset::WriteRaster(osRasterFile, bAttachedLabelingMethod, iRecords, iLabelRecords, eType, pszInterleaving) ) return nullptr; return reinterpret_cast<GDALDataset *>( GDALOpen( osOutFile, GA_Update ) );//.........这里部分代码省略.........
开发者ID:ksshannon,项目名称:gdal,代码行数:101,
示例12: VSIMallocCPLErr VRTWarpedDataset::ProcessBlock( int iBlockX, int iBlockY ){ if( poWarper == NULL ) return CE_Failure; const GDALWarpOptions *psWO = poWarper->GetOptions();/* -------------------------------------------------------------------- *//* Allocate block of memory large enough to hold all the bands *//* for this block. *//* -------------------------------------------------------------------- */ int iBand; GByte *pabyDstBuffer; int nDstBufferSize; int nWordSize = (GDALGetDataTypeSize(psWO->eWorkingDataType) / 8); // FIXME? : risk of overflow in multiplication if nBlockXSize or nBlockYSize are very large nDstBufferSize = nBlockXSize * nBlockYSize * psWO->nBandCount * nWordSize; pabyDstBuffer = (GByte *) VSIMalloc(nDstBufferSize); if( pabyDstBuffer == NULL ) { CPLError( CE_Failure, CPLE_OutOfMemory, "Out of memory allocating %d byte buffer in VRTWarpedDataset::ProcessBlock()", nDstBufferSize ); return CE_Failure; } memset( pabyDstBuffer, 0, nDstBufferSize );/* -------------------------------------------------------------------- *//* Process INIT_DEST option to initialize the buffer prior to *//* warping into it. *//* NOTE:The following code is 99% similar in gdalwarpoperation.cpp and *//* vrtwarped.cpp. Be careful to keep it in sync ! *//* -------------------------------------------------------------------- */ const char *pszInitDest = CSLFetchNameValue( psWO->papszWarpOptions, "INIT_DEST" ); if( pszInitDest != NULL && !EQUAL(pszInitDest, "") ) { char **papszInitValues = CSLTokenizeStringComplex( pszInitDest, ",", FALSE, FALSE ); int nInitCount = CSLCount(papszInitValues); for( iBand = 0; iBand < psWO->nBandCount; iBand++ ) { double adfInitRealImag[2]; GByte *pBandData; int nBandSize = nBlockXSize * nBlockYSize * nWordSize; const char *pszBandInit = papszInitValues[MIN(iBand,nInitCount-1)]; if( EQUAL(pszBandInit,"NO_DATA") && psWO->padfDstNoDataReal != NULL ) { adfInitRealImag[0] = psWO->padfDstNoDataReal[iBand]; adfInitRealImag[1] = psWO->padfDstNoDataImag[iBand]; } else { CPLStringToComplex( pszBandInit, adfInitRealImag + 0, adfInitRealImag + 1); } pBandData = ((GByte *) pabyDstBuffer) + iBand * nBandSize; if( psWO->eWorkingDataType == GDT_Byte ) memset( pBandData, MAX(0,MIN(255,(int)adfInitRealImag[0])), nBandSize); else if( adfInitRealImag[0] == 0.0 && adfInitRealImag[1] == 0 ) { memset( pBandData, 0, nBandSize ); } else if( adfInitRealImag[1] == 0.0 ) { GDALCopyWords( &adfInitRealImag, GDT_Float64, 0, pBandData,psWO->eWorkingDataType,nWordSize, nBlockXSize * nBlockYSize ); } else { GDALCopyWords( &adfInitRealImag, GDT_CFloat64, 0, pBandData,psWO->eWorkingDataType,nWordSize, nBlockXSize * nBlockYSize ); } } CSLDestroy( papszInitValues ); }/* -------------------------------------------------------------------- *//* Warp into this buffer. *//* -------------------------------------------------------------------- */ CPLErr eErr; eErr = poWarper->WarpRegionToBuffer( //.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例13: CPLErrorOGRLayer *OGRCSVDataSource::ICreateLayer( const char *pszLayerName, OGRSpatialReference *poSpatialRef, OGRwkbGeometryType eGType, char ** papszOptions ){/* -------------------------------------------------------------------- *//* Verify we are in update mode. *//* -------------------------------------------------------------------- */ if (!bUpdate) { CPLError( CE_Failure, CPLE_NoWriteAccess, "Data source %s opened read-only./n" "New layer %s cannot be created./n", pszName, pszLayerName ); return NULL; }/* -------------------------------------------------------------------- *//* Verify that the datasource is a directory. *//* -------------------------------------------------------------------- */ VSIStatBufL sStatBuf; if( strncmp(pszName, "/vsizip/", 8) == 0) { /* Do nothing */ } else if( !EQUAL(pszName, "/vsistdout/") && (VSIStatL( pszName, &sStatBuf ) != 0 || !VSI_ISDIR( sStatBuf.st_mode )) ) { CPLError( CE_Failure, CPLE_AppDefined, "Attempt to create csv layer (file) against a non-directory datasource." ); return NULL; }/* -------------------------------------------------------------------- *//* What filename would we use? *//* -------------------------------------------------------------------- */ CPLString osFilename; if( osDefaultCSVName != "" ) { osFilename = CPLFormFilename( pszName, osDefaultCSVName, NULL ); osDefaultCSVName = ""; } else { osFilename = CPLFormFilename( pszName, pszLayerName, "csv" ); }/* -------------------------------------------------------------------- *//* Does this directory/file already exist? *//* -------------------------------------------------------------------- */ if( VSIStatL( osFilename, &sStatBuf ) == 0 ) { CPLError( CE_Failure, CPLE_AppDefined, "Attempt to create layer %s, but %s already exists.", pszLayerName, osFilename.c_str() ); return NULL; }/* -------------------------------------------------------------------- *//* Create the empty file. *//* -------------------------------------------------------------------- */ const char *pszDelimiter = CSLFetchNameValue( papszOptions, "SEPARATOR"); char chDelimiter = ','; if (pszDelimiter != NULL) { if (EQUAL(pszDelimiter, "COMMA")) chDelimiter = ','; else if (EQUAL(pszDelimiter, "SEMICOLON")) chDelimiter = ';'; else if (EQUAL(pszDelimiter, "TAB")) chDelimiter = '/t'; else { CPLError( CE_Warning, CPLE_AppDefined, "SEPARATOR=%s not understood, use one of COMMA, SEMICOLON or TAB.", pszDelimiter ); } }/* -------------------------------------------------------------------- *//* Create a layer. *//* -------------------------------------------------------------------- */ nLayers++; papoLayers = (OGRCSVLayer **) CPLRealloc(papoLayers, sizeof(void*) * nLayers); papoLayers[nLayers-1] = new OGRCSVLayer( pszLayerName, NULL, osFilename, TRUE, TRUE, chDelimiter, NULL, NULL );/* -------------------------------------------------------------------- *//* Was a partiuclar CRLF order requested? *//* -------------------------------------------------------------------- */ const char *pszCRLFFormat = CSLFetchNameValue( papszOptions, "LINEFORMAT");//.........这里部分代码省略.........
开发者ID:samalone,项目名称:gdal-ios,代码行数:101,
示例14: msContourLayerGenerateContourstatic int msContourLayerGenerateContour(layerObj *layer){ OGRSFDriverH hDriver; OGRFieldDefnH hFld; OGRLayerH hLayer; const char *elevItem; char *option; double interval = 1.0, levels[1000]; int levelCount = 0; GDALRasterBandH hBand = NULL; CPLErr eErr; contourLayerInfo *clinfo = (contourLayerInfo *) layer->layerinfo; OGRRegisterAll(); if (clinfo == NULL) { msSetError(MS_MISCERR, "Assertion failed: Contour layer not opened!!!", "msContourLayerCreateOGRDataSource()"); return MS_FAILURE; } if (!clinfo->hDS) { /* no overlap */ return MS_SUCCESS; } hBand = GDALGetRasterBand(clinfo->hDS, 1); if (hBand == NULL) { msSetError(MS_IMGERR, "Band %d does not exist on dataset.", "msContourLayerGenerateContour()", 1); return MS_FAILURE; } /* Create the OGR DataSource */ hDriver = OGRGetDriverByName("Memory"); if (hDriver == NULL) { msSetError(MS_OGRERR, "Unable to get OGR driver 'Memory'.", "msContourLayerCreateOGRDataSource()"); return MS_FAILURE; } clinfo->hOGRDS = OGR_Dr_CreateDataSource(hDriver, "", NULL); if (clinfo->hOGRDS == NULL) { msSetError(MS_OGRERR, "Unable to create OGR DataSource.", "msContourLayerCreateOGRDataSource()"); return MS_FAILURE; } hLayer = OGR_DS_CreateLayer(clinfo->hOGRDS, clinfo->ogrLayer.name, NULL, wkbLineString, NULL ); hFld = OGR_Fld_Create("ID", OFTInteger); OGR_Fld_SetWidth(hFld, 8); OGR_L_CreateField(hLayer, hFld, FALSE); OGR_Fld_Destroy(hFld); /* Check if we have a coutour item specified */ elevItem = CSLFetchNameValue(layer->processing,"CONTOUR_ITEM"); if (elevItem && strlen(elevItem) > 0) { hFld = OGR_Fld_Create(elevItem, OFTReal); OGR_Fld_SetWidth(hFld, 12); OGR_Fld_SetPrecision(hFld, 3); OGR_L_CreateField(hLayer, hFld, FALSE); OGR_Fld_Destroy(hFld); } else { elevItem = NULL; } option = msContourGetOption(layer, "CONTOUR_INTERVAL"); if (option) { interval = atof(option); free(option); } option = msContourGetOption(layer, "CONTOUR_LEVELS"); if (option) { int i,c; char **levelsTmp; levelsTmp = CSLTokenizeStringComplex(option, ",", FALSE, FALSE); c = CSLCount(levelsTmp); for (i=0;i<c && i<(int)(sizeof(levels)/sizeof(double)) ;++i) levels[levelCount++] = atof(levelsTmp[i]); CSLDestroy(levelsTmp); free(option); } eErr = GDALContourGenerate( hBand, interval, 0.0, levelCount, levels, FALSE, 0.0, hLayer, OGR_FD_GetFieldIndex(OGR_L_GetLayerDefn( hLayer), "ID" ), (elevItem == NULL) ? -1 : OGR_FD_GetFieldIndex(OGR_L_GetLayerDefn( hLayer), elevItem ),//.........这里部分代码省略.........
开发者ID:BentleySystems,项目名称:mapserver,代码行数:101,
示例15: NITFDESExtractShapefileint NITFDESExtractShapefile(NITFDES* psDES, const char* pszRadixFileName){ NITFSegmentInfo* psSegInfo; const char* apszExt[3]; int anOffset[4]; int iShpFile; char* pszFilename; if ( CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE_USE") == NULL ) return FALSE; psSegInfo = psDES->psFile->pasSegmentInfo + psDES->iSegment; apszExt[0] = CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE1_NAME"); anOffset[0] = atoi(CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE1_START")); apszExt[1] = CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE2_NAME"); anOffset[1] = atoi(CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE2_START")); apszExt[2] = CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE3_NAME"); anOffset[2] = atoi(CSLFetchNameValue(psDES->papszMetadata, "NITF_SHAPE3_START")); anOffset[3] = (int) psSegInfo->nSegmentSize; for(iShpFile = 0; iShpFile < 3; iShpFile ++) { if (!EQUAL(apszExt[iShpFile], "SHP") && !EQUAL(apszExt[iShpFile], "SHX") && !EQUAL(apszExt[iShpFile], "DBF")) return FALSE; if (anOffset[iShpFile] < 0 || anOffset[iShpFile] >= anOffset[iShpFile+1]) return FALSE; } pszFilename = (char*) VSIMalloc(strlen(pszRadixFileName) + 4 + 1); if (pszFilename == NULL) return FALSE; for(iShpFile = 0; iShpFile < 3; iShpFile ++) { VSILFILE* fp; GByte* pabyBuffer; int nSize = anOffset[iShpFile+1] - anOffset[iShpFile]; pabyBuffer = (GByte*) VSIMalloc(nSize); if (pabyBuffer == NULL) { VSIFree(pszFilename); return FALSE; } VSIFSeekL(psDES->psFile->fp, psSegInfo->nSegmentStart + anOffset[iShpFile], SEEK_SET); if (VSIFReadL(pabyBuffer, 1, nSize, psDES->psFile->fp) != nSize) { VSIFree(pabyBuffer); VSIFree(pszFilename); return FALSE; } sprintf(pszFilename, "%s.%s", pszRadixFileName, apszExt[iShpFile]); fp = VSIFOpenL(pszFilename, "wb"); if (fp == NULL) { VSIFree(pabyBuffer); VSIFree(pszFilename); return FALSE; } VSIFWriteL(pabyBuffer, 1, nSize, fp); VSIFCloseL(fp); VSIFree(pabyBuffer); } VSIFree(pszFilename); return TRUE;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:76,
示例16: CPLErrorOGRErr PDFWritableVectorDataset::SyncToDisk(){ if (nLayers == 0 || !bModified) return OGRERR_NONE; bModified = FALSE; OGREnvelope sGlobalExtent; int bHasExtent = FALSE; for(int i=0;i<nLayers;i++) { OGREnvelope sExtent; if (papoLayers[i]->GetExtent(&sExtent) == OGRERR_NONE) { bHasExtent = TRUE; sGlobalExtent.Merge(sExtent); } } if (!bHasExtent || sGlobalExtent.MinX == sGlobalExtent.MaxX || sGlobalExtent.MinY == sGlobalExtent.MaxY) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot compute spatial extent of features"); return OGRERR_FAILURE; } PDFCompressMethod eStreamCompressMethod = COMPRESS_DEFLATE; const char* pszStreamCompressMethod = CSLFetchNameValue(papszOptions, "STREAM_COMPRESS"); if (pszStreamCompressMethod) { if( EQUAL(pszStreamCompressMethod, "NONE") ) eStreamCompressMethod = COMPRESS_NONE; else if( EQUAL(pszStreamCompressMethod, "DEFLATE") ) eStreamCompressMethod = COMPRESS_DEFLATE; else { CPLError( CE_Warning, CPLE_NotSupported, "Unsupported value for STREAM_COMPRESS."); } } const char* pszGEO_ENCODING = CSLFetchNameValueDef(papszOptions, "GEO_ENCODING", "ISO32000"); double dfDPI = CPLAtof(CSLFetchNameValueDef(papszOptions, "DPI", "72")); if (dfDPI < 72.0) dfDPI = 72.0; const char* pszNEATLINE = CSLFetchNameValue(papszOptions, "NEATLINE"); int nMargin = atoi(CSLFetchNameValueDef(papszOptions, "MARGIN", "0")); PDFMargins sMargins; sMargins.nLeft = nMargin; sMargins.nRight = nMargin; sMargins.nTop = nMargin; sMargins.nBottom = nMargin; const char* pszLeftMargin = CSLFetchNameValue(papszOptions, "LEFT_MARGIN"); if (pszLeftMargin) sMargins.nLeft = atoi(pszLeftMargin); const char* pszRightMargin = CSLFetchNameValue(papszOptions, "RIGHT_MARGIN"); if (pszRightMargin) sMargins.nRight = atoi(pszRightMargin); const char* pszTopMargin = CSLFetchNameValue(papszOptions, "TOP_MARGIN"); if (pszTopMargin) sMargins.nTop = atoi(pszTopMargin); const char* pszBottomMargin = CSLFetchNameValue(papszOptions, "BOTTOM_MARGIN"); if (pszBottomMargin) sMargins.nBottom = atoi(pszBottomMargin); const char* pszExtraImages = CSLFetchNameValue(papszOptions, "EXTRA_IMAGES"); const char* pszExtraStream = CSLFetchNameValue(papszOptions, "EXTRA_STREAM"); const char* pszExtraLayerName = CSLFetchNameValue(papszOptions, "EXTRA_LAYER_NAME"); const char* pszOGRDisplayField = CSLFetchNameValue(papszOptions, "OGR_DISPLAY_FIELD"); const char* pszOGRDisplayLayerNames = CSLFetchNameValue(papszOptions, "OGR_DISPLAY_LAYER_NAMES"); int bWriteOGRAttributes = CSLFetchBoolean(papszOptions, "OGR_WRITE_ATTRIBUTES", TRUE); const char* pszOGRLinkField = CSLFetchNameValue(papszOptions, "OGR_LINK_FIELD"); const char* pszOffLayers = CSLFetchNameValue(papszOptions, "OFF_LAYERS"); const char* pszExclusiveLayers = CSLFetchNameValue(papszOptions, "EXCLUSIVE_LAYERS"); const char* pszJavascript = CSLFetchNameValue(papszOptions, "JAVASCRIPT"); const char* pszJavascriptFile = CSLFetchNameValue(papszOptions, "JAVASCRIPT_FILE");/* -------------------------------------------------------------------- *//* Create file. *//* -------------------------------------------------------------------- */ VSILFILE* fp = VSIFOpenL(GetDescription(), "wb"); if( fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to create PDF file %s./n", GetDescription() ); return OGRERR_FAILURE; } GDALPDFWriter oWriter(fp);//.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例17: CPLError//.........这里部分代码省略......... nPixelOffset = 8; } poSrcDS->GetGeoTransform( adfTransform ); pszWKT = (char *)poSrcDS->GetProjectionRef(); nErr = oSRS.importFromWkt(&pszWKT); if (nErr != OGRERR_NONE) { CPLError( CE_Failure, CPLE_NotSupported, "Cannot import spatial reference WKT from source dataset."); return NULL; } if (oSRS.GetAuthorityCode("PROJCS") != NULL) { nSrs = atoi(oSRS.GetAuthorityCode("PROJCS")); } else if (oSRS.GetAuthorityCode("GEOGCS") != NULL) { nSrs = atoi(oSRS.GetAuthorityCode("GEOGCS")); } else { // could not determine projected or geographic code // default to EPSG:3857 if no code could be found nSrs = 3857; } /********************************************************************/ /* Create JSON companion file. */ /********************************************************************/ osJSONFilename = GetJsonFilename(pszFilename); poJSONObject = json_object_new_object(); pszTokens = poSrcDS->GetMetadata(); pszLayer = CSLFetchNameValue(pszTokens, "LAYER"); if ( pszLayer == NULL) { // Set the layer json_object_object_add(poJSONObject, "layer", json_object_new_string( CPLGetBasename(osJSONFilename) )); } else { // Set the layer json_object_object_add(poJSONObject, "layer", json_object_new_string( pszLayer )); } // Set the type json_object_object_add(poJSONObject, "type", json_object_new_string("arg")); // Set the datatype json_object_object_add(poJSONObject, "datatype", json_object_new_string(pszDataType)); // Set the number of rows json_object_object_add(poJSONObject, "rows", json_object_new_int(nYSize)); // Set the number of columns json_object_object_add(poJSONObject, "cols", json_object_new_int(nXSize)); // Set the xmin json_object_object_add(poJSONObject, "xmin", json_object_new_double(adfTransform[0])); // Set the ymax json_object_object_add(poJSONObject, "ymax", json_object_new_double(adfTransform[3])); // Set the cellwidth json_object_object_add(poJSONObject, "cellwidth", json_object_new_double(adfTransform[1])); // Set the cellheight json_object_object_add(poJSONObject, "cellheight", json_object_new_double(-adfTransform[5])); // Set the xmax json_object_object_add(poJSONObject, "xmax", json_object_new_double(adfTransform[0] + nXSize * adfTransform[1]));
开发者ID:rashadkm,项目名称:lib_gdal,代码行数:67,
示例18: GDALLoadIMDFile/** * LoadMetadata() */void GDALMDReaderLandsat::LoadMetadata(){ if(m_bIsMetadataLoad) return; if (!m_osIMDSourceFilename.empty()) { m_papszIMDMD = GDALLoadIMDFile( m_osIMDSourceFilename ); } m_papszDEFAULTMD = CSLAddNameValue(m_papszDEFAULTMD, MD_NAME_MDTYPE, "ODL"); m_bIsMetadataLoad = true; // date/time // DATE_ACQUIRED = 2013-04-07 // SCENE_CENTER_TIME = 15:47:03.0882620Z // L1_METADATA_FILE.PRODUCT_METADATA.SPACECRAFT_ID const char* pszSatId = CSLFetchNameValue(m_papszIMDMD, "L1_METADATA_FILE.PRODUCT_METADATA.SPACECRAFT_ID"); if(NULL != pszSatId) { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_SATELLITE, CPLStripQuotes(pszSatId)); } // L1_METADATA_FILE.IMAGE_ATTRIBUTES.CLOUD_COVER const char* pszCloudCover = CSLFetchNameValue(m_papszIMDMD, "L1_METADATA_FILE.IMAGE_ATTRIBUTES.CLOUD_COVER"); if(NULL != pszCloudCover) { double fCC = CPLAtofM(pszCloudCover); if(fCC < 0) { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_CLOUDCOVER, MD_CLOUDCOVER_NA); } else { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_CLOUDCOVER, CPLSPrintf("%d", int(fCC))); } } // L1_METADATA_FILE.PRODUCT_METADATA.ACQUISITION_DATE // L1_METADATA_FILE.PRODUCT_METADATA.SCENE_CENTER_SCAN_TIME // L1_METADATA_FILE.PRODUCT_METADATA.DATE_ACQUIRED // L1_METADATA_FILE.PRODUCT_METADATA.SCENE_CENTER_TIME const char* pszDate = CSLFetchNameValue(m_papszIMDMD, "L1_METADATA_FILE.PRODUCT_METADATA.ACQUISITION_DATE"); if(NULL == pszDate) { pszDate = CSLFetchNameValue(m_papszIMDMD, "L1_METADATA_FILE.PRODUCT_METADATA.DATE_ACQUIRED"); } if(NULL != pszDate) { const char* pszTime = CSLFetchNameValue(m_papszIMDMD, "L1_METADATA_FILE.PRODUCT_METADATA.SCENE_CENTER_SCAN_TIME"); if(NULL == pszTime) { pszTime = CSLFetchNameValue(m_papszIMDMD, "L1_METADATA_FILE.PRODUCT_METADATA.SCENE_CENTER_TIME"); } if(NULL == pszTime) pszTime = "00:00:00.000000Z"; char buffer[80]; time_t timeMid = GetAcquisitionTimeFromString(CPLSPrintf( "%sT%s", pszDate, pszTime)); strftime (buffer, 80, MD_DATETIMEFORMAT, localtime(&timeMid)); m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_ACQDATETIME, buffer); }}
开发者ID:bbradbury,项目名称:lib_gdal,代码行数:83,
示例19: CSLFetchNameValueOGRLayer *OGRPGDumpDataSource::ICreateLayer( const char * pszLayerName, OGRSpatialReference *poSRS, OGRwkbGeometryType eType, char ** papszOptions ){ CPLString osCommand; const char *pszGeomType = NULL; char *pszTableName = NULL; char *pszSchemaName = NULL; int bHavePostGIS = TRUE; int GeometryTypeFlags = 0; const char* pszFIDColumnNameIn = CSLFetchNameValue(papszOptions, "FID"); CPLString osFIDColumnName, osFIDColumnNameEscaped; if (pszFIDColumnNameIn == NULL) osFIDColumnName = "ogc_fid"; else { if( CSLFetchBoolean(papszOptions,"LAUNDER", TRUE) ) { char* pszLaunderedFid = OGRPGCommonLaunderName(pszFIDColumnNameIn, "PGDump"); osFIDColumnName = pszLaunderedFid; CPLFree(pszLaunderedFid); } else { osFIDColumnName = pszFIDColumnNameIn; } } osFIDColumnNameEscaped = OGRPGDumpEscapeColumnName(osFIDColumnName); if (STARTS_WITH(pszLayerName, "pg")) { CPLError(CE_Warning, CPLE_AppDefined, "The layer name should not begin by 'pg' as it is a reserved prefix"); } //bHavePostGIS = CSLFetchBoolean(papszOptions,"POSTGIS", TRUE); int bCreateTable = CSLFetchBoolean(papszOptions,"CREATE_TABLE", TRUE); int bCreateSchema = CSLFetchBoolean(papszOptions,"CREATE_SCHEMA", TRUE); const char* pszDropTable = CSLFetchNameValueDef(papszOptions,"DROP_TABLE", "IF_EXISTS"); if( OGR_GT_HasZ((OGRwkbGeometryType)eType) ) GeometryTypeFlags |= OGRGeometry::OGR_G_3D; if( OGR_GT_HasM((OGRwkbGeometryType)eType) ) GeometryTypeFlags |= OGRGeometry::OGR_G_MEASURED; int ForcedGeometryTypeFlags = -1; const char* pszDim = CSLFetchNameValue( papszOptions, "DIM"); if( pszDim != NULL ) { if( EQUAL(pszDim, "XY") || EQUAL(pszDim, "2") ) { GeometryTypeFlags = 0; ForcedGeometryTypeFlags = GeometryTypeFlags; } else if( EQUAL(pszDim, "XYZ") || EQUAL(pszDim, "3") ) { GeometryTypeFlags = OGRGeometry::OGR_G_3D; ForcedGeometryTypeFlags = GeometryTypeFlags; } else if( EQUAL(pszDim, "XYM") ) { GeometryTypeFlags = OGRGeometry::OGR_G_MEASURED; ForcedGeometryTypeFlags = GeometryTypeFlags; } else if( EQUAL(pszDim, "XYZM") || EQUAL(pszDim, "4") ) { GeometryTypeFlags = OGRGeometry::OGR_G_3D | OGRGeometry::OGR_G_MEASURED; ForcedGeometryTypeFlags = GeometryTypeFlags; } else { CPLError(CE_Failure, CPLE_AppDefined, "Invalid value for DIM"); } } 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 *///.........这里部分代码省略.........
开发者ID:Wedjaa,项目名称:node-gdal,代码行数:101,
示例20: CPLAssertint OGRGPXDataSource::Create( const char *pszFilename, char **papszOptions ){ if( fpOutput != NULL) { CPLAssert( FALSE ); return FALSE; } if (strcmp(pszFilename, "/dev/stdout") == 0) pszFilename = "/vsistdout/";/* -------------------------------------------------------------------- *//* Do not override exiting file. *//* -------------------------------------------------------------------- */ VSIStatBufL sStatBuf; if( VSIStatL( pszFilename, &sStatBuf ) == 0 ) { CPLError(CE_Failure, CPLE_NotSupported, "You have to delete %s before being able to create it with the GPX driver", pszFilename); return FALSE; } /* -------------------------------------------------------------------- *//* Create the output file. *//* -------------------------------------------------------------------- */ pszName = CPLStrdup( pszFilename ); if( strcmp(pszName, "/vsistdout/") == 0 ) { bIsBackSeekable = FALSE; fpOutput = VSIFOpenL( pszFilename, "w" ); } else fpOutput = VSIFOpenL( pszFilename, "w+" ); if( fpOutput == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to create GPX file %s.", pszFilename ); return FALSE; }/* -------------------------------------------------------------------- *//* End of line character. *//* -------------------------------------------------------------------- */ const char *pszCRLFFormat = CSLFetchNameValue( papszOptions, "LINEFORMAT"); int bUseCRLF; if( pszCRLFFormat == NULL ) {#ifdef WIN32 bUseCRLF = TRUE;#else bUseCRLF = FALSE;#endif } else if( EQUAL(pszCRLFFormat,"CRLF") ) bUseCRLF = TRUE; else if( EQUAL(pszCRLFFormat,"LF") ) bUseCRLF = FALSE; else { CPLError( CE_Warning, CPLE_AppDefined, "LINEFORMAT=%s not understood, use one of CRLF or LF.", pszCRLFFormat );#ifdef WIN32 bUseCRLF = TRUE;#else bUseCRLF = FALSE;#endif } pszEOL = (bUseCRLF) ? "/r/n" : "/n";/* -------------------------------------------------------------------- *//* Look at use extensions options. *//* -------------------------------------------------------------------- */ const char* pszUseExtensions = CSLFetchNameValue( papszOptions, "GPX_USE_EXTENSIONS"); const char* pszExtensionsNSURL = NULL; if (pszUseExtensions && CSLTestBoolean(pszUseExtensions)) { bUseExtensions = TRUE; const char* pszExtensionsNSOption = CSLFetchNameValue( papszOptions, "GPX_EXTENSIONS_NS"); const char* pszExtensionsNSURLOption = CSLFetchNameValue( papszOptions, "GPX_EXTENSIONS_NS_URL"); if (pszExtensionsNSOption && pszExtensionsNSURLOption) { pszExtensionsNS = CPLStrdup(pszExtensionsNSOption); pszExtensionsNSURL = pszExtensionsNSURLOption; } else { pszExtensionsNS = CPLStrdup("ogr"); pszExtensionsNSURL = "http://osgeo.org/gdal"; } } //.........这里部分代码省略.........
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:101,
示例21: CSLFetchNameValuevoid OGRGMLDataSource::InsertHeader(){ FILE *fpSchema; int nSchemaStart = 0; if( fpOutput == NULL || fpOutput == stdout ) return;/* -------------------------------------------------------------------- *//* Do we want to write the schema within the GML instance doc *//* or to a separate file? For now we only support external. *//* -------------------------------------------------------------------- */ const char *pszSchemaURI = CSLFetchNameValue(papszCreateOptions, "XSISCHEMAURI"); const char *pszSchemaOpt = CSLFetchNameValue( papszCreateOptions, "XSISCHEMA" ); if( pszSchemaURI != NULL ) return; if( pszSchemaOpt == NULL || EQUAL(pszSchemaOpt,"EXTERNAL") ) { const char *pszXSDFilename = CPLResetExtension( pszName, "xsd" ); fpSchema = VSIFOpen( pszXSDFilename, "wt" ); if( fpSchema == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Failed to open file %.500s for schema output.", pszXSDFilename ); return; } fprintf( fpSchema, "<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n" ); } else if( EQUAL(pszSchemaOpt,"INTERNAL") ) { nSchemaStart = VSIFTell( fpOutput ); fpSchema = fpOutput; } else return;/* ==================================================================== *//* Write the schema section at the end of the file. Once *//* complete, we will read it back in, and then move the whole *//* file "down" enough to insert the schema at the beginning. *//* ==================================================================== *//* -------------------------------------------------------------------- *//* Emit the start of the schema section. *//* -------------------------------------------------------------------- */ const char *pszTargetNameSpace = "http://ogr.maptools.org/"; const char *pszPrefix = "ogr"; VSIFPrintf( fpSchema, "<xs:schema targetNamespace=/"%s/" xmlns:%s=/"%s/" xmlns:xs=/"http://www.w3.org/2001/XMLSchema/" xmlns:gml=/"http://www.opengis.net/gml/" elementFormDefault=/"qualified/" version=/"1.0/">/n", pszTargetNameSpace, pszPrefix, pszTargetNameSpace ); VSIFPrintf( fpSchema, "<xs:import namespace=/"http://www.opengis.net/gml/" schemaLocation=/"http://schemas.opengeospatial.net/gml/2.1.2/feature.xsd/"/>" );/* -------------------------------------------------------------------- *//* Define the FeatureCollection *//* -------------------------------------------------------------------- */ VSIFPrintf( fpSchema, "<xs:element name=/"FeatureCollection/" type=/"%s:FeatureCollectionType/" substitutionGroup=/"gml:_FeatureCollection/"/>/n", pszPrefix ); VSIFPrintf( fpSchema, "<xs:complexType name=/"FeatureCollectionType/">/n" " <xs:complexContent>/n" " <xs:extension base=/"gml:AbstractFeatureCollectionType/">/n" " <xs:attribute name=/"lockId/" type=/"xs:string/" use=/"optional/"/>/n" " <xs:attribute name=/"scope/" type=/"xs:string/" use=/"optional/"/>/n" " </xs:extension>/n" " </xs:complexContent>/n" "</xs:complexType>/n" );/* ==================================================================== *//* Define the schema for each layer. *//* ==================================================================== */ int iLayer; for( iLayer = 0; iLayer < GetLayerCount(); iLayer++ ) { OGRFeatureDefn *poFDefn = GetLayer(iLayer)->GetLayerDefn(); /* -------------------------------------------------------------------- *//* Emit initial stuff for a feature type. *//* -------------------------------------------------------------------- */ VSIFPrintf( fpSchema, "<xs:element name=/"%s/" type=/"%s:%s_Type/" substitutionGroup=/"gml:_Feature/"/>/n", poFDefn->GetName(), pszPrefix, poFDefn->GetName() ); VSIFPrintf( fpSchema, "<xs:complexType name=/"%s_Type/">/n"//.........这里部分代码省略.........
开发者ID:469447793,项目名称:World-Wind-Java,代码行数:101,
示例22: CSLTestBoolean/** * /brief Fetch a document from an url and return in a string. * * @param pszURL valid URL recognized by underlying download library (libcurl) * @param papszOptions option list as a NULL-terminated array of strings. May be NULL. * The following options are handled : * <ul> * <li>TIMEOUT=val, where val is in seconds</li> * <li>HEADERS=val, where val is an extra header to use when getting a web page. * For example "Accept: application/x-ogcwkt" * <li>HTTPAUTH=[BASIC/NTLM/GSSNEGOTIATE/ANY] to specify an authentication scheme to use. * <li>USERPWD=userid:password to specify a user and password for authentication * <li>POSTFIELDS=val, where val is a nul-terminated string to be passed to the server * with a POST request. * <li>PROXY=val, to make requests go through a proxy server, where val is of the * form proxy.server.com:port_number * <li>PROXYUSERPWD=val, where val is of the form username:password * <li>PROXYAUTH=[BASIC/NTLM/DIGEST/ANY] to specify an proxy authentication scheme to use. * <li>NETRC=[YES/NO] to enable or disable use of $HOME/.netrc, default YES. * <li>CUSTOMREQUEST=val, where val is GET, PUT, POST, DELETE, etc.. (GDAL >= 1.9.0) * <li>COOKIE=val, where val is formatted as COOKIE1=VALUE1; COOKIE2=VALUE2; ... * <li>MAX_RETRY=val, where val is the maximum number of retry attempts if a 503 or * 504 HTTP error occurs. Default is 0. (GDAL >= 2.0) * <li>RETRY_DELAY=val, where val is the number of seconds between retry attempts. * Default is 30. (GDAL >= 2.0) * </ul> * * Alternatively, if not defined in the papszOptions arguments, the PROXY, * PROXYUSERPWD, PROXYAUTH, NETRC, MAX_RETRY and RETRY_DELAY values are searched in the configuration * options named GDAL_HTTP_PROXY, GDAL_HTTP_PROXYUSERPWD, GDAL_PROXY_AUTH, * GDAL_HTTP_NETRC, GDAL_HTTP_MAX_RETRY and GDAL_HTTP_RETRY_DELAY. * * @return a CPLHTTPResult* structure that must be freed by * CPLHTTPDestroyResult(), or NULL if libcurl support is disabled */CPLHTTPResult *CPLHTTPFetch( const char *pszURL, char **papszOptions ){ if( strncmp(pszURL, "/vsimem/", strlen("/vsimem/")) == 0 && /* Disabled by default for potential security issues */ CSLTestBoolean(CPLGetConfigOption("CPL_CURL_ENABLE_VSIMEM", "FALSE")) ) { CPLString osURL(pszURL); const char* pszPost = CSLFetchNameValue( papszOptions, "POSTFIELDS" ); if( pszPost != NULL ) /* Hack: we append post content to filename */ { osURL += "&POSTFIELDS="; osURL += pszPost; } vsi_l_offset nLength = 0; CPLHTTPResult* psResult = (CPLHTTPResult* )CPLCalloc(1, sizeof(CPLHTTPResult)); GByte* pabyData = VSIGetMemFileBuffer( osURL, &nLength, FALSE ); if( pabyData == NULL ) { CPLDebug("HTTP", "Cannot find %s", osURL.c_str()); psResult->nStatus = 1; psResult->pszErrBuf = CPLStrdup(CPLSPrintf("HTTP error code : %d", 404)); CPLError( CE_Failure, CPLE_AppDefined, "%s", psResult->pszErrBuf ); } else if( nLength != 0 ) { psResult->nDataLen = (size_t)nLength; psResult->pabyData = (GByte*) CPLMalloc((size_t)nLength + 1); memcpy(psResult->pabyData, pabyData, (size_t)nLength); psResult->pabyData[(size_t)nLength] = 0; } if( psResult->pabyData != NULL && strncmp((const char*)psResult->pabyData, "Content-Type: ", strlen("Content-Type: ")) == 0 ) { const char* pszContentType = (const char*)psResult->pabyData + strlen("Content-type: "); const char* pszEOL = strchr(pszContentType, '/r'); if( pszEOL ) pszEOL = strchr(pszContentType, '/n'); if( pszEOL ) { int nLength = pszEOL - pszContentType; psResult->pszContentType = (char*)CPLMalloc(nLength + 1); memcpy(psResult->pszContentType, pszContentType, nLength); psResult->pszContentType[nLength] = 0; } } return psResult; }#ifndef HAVE_CURL (void) papszOptions; (void) pszURL; CPLError( CE_Failure, CPLE_NotSupported, "GDAL/OGR not compiled with libcurl support, remote requests not supported." ); return NULL;#else/* -------------------------------------------------------------------- *//* Are we using a persistent named session? If so, search for *//* or create it. *//* *///.........这里部分代码省略.........
开发者ID:drownedout,项目名称:datamap,代码行数:101,
示例23: CPLAssertint OGRMySQLDataSource::Open( const char * pszNewName, char** papszOpenOptionsIn, int bUpdate ){ CPLAssert( nLayers == 0 ); /* -------------------------------------------------------------------- */ /* Use options process to get .my.cnf file contents. */ /* -------------------------------------------------------------------- */ int nPort = 0; char **papszTableNames=NULL; std::string oHost, oPassword, oUser, oDB; CPLString osNewName(pszNewName); const char* apszOpenOptions[] = { "dbname", "port", "user", "password", "host", "tables" }; for(int i=0; i <(int)(sizeof(apszOpenOptions)/sizeof(char*)); i++) { const char* pszVal = CSLFetchNameValue(papszOpenOptionsIn, apszOpenOptions[i]); if( pszVal ) { if( osNewName[osNewName.size()-1] != ':' ) osNewName += ","; if( i > 0 ) { osNewName += apszOpenOptions[i]; osNewName += "="; } if( EQUAL(apszOpenOptions[i], "tables") ) { for( ; *pszVal; ++pszVal ) { if( *pszVal == ',' ) osNewName += ";"; else osNewName += *pszVal; } } else osNewName += pszVal; } } /* -------------------------------------------------------------------- */ /* Parse out connection information. */ /* -------------------------------------------------------------------- */ char **papszItems = CSLTokenizeString2( osNewName+6, ",", CSLT_HONOURSTRINGS ); if( CSLCount(papszItems) < 1 ) { CSLDestroy( papszItems ); CPLError( CE_Failure, CPLE_AppDefined, "MYSQL: request missing databasename." ); return FALSE; } oDB = papszItems[0]; for( int i = 1; papszItems[i] != NULL; i++ ) { if( STARTS_WITH_CI(papszItems[i], "user=") ) oUser = papszItems[i] + 5; else if( STARTS_WITH_CI(papszItems[i], "password=") ) oPassword = papszItems[i] + 9; else if( STARTS_WITH_CI(papszItems[i], "host=") ) oHost = papszItems[i] + 5; else if( STARTS_WITH_CI(papszItems[i], "port=") ) nPort = atoi(papszItems[i] + 5); else if( STARTS_WITH_CI(papszItems[i], "tables=") ) { CSLDestroy(papszTableNames); papszTableNames = CSLTokenizeStringComplex( papszItems[i] + 7, ";", FALSE, FALSE ); } else CPLError( CE_Warning, CPLE_AppDefined, "'%s' in MYSQL datasource definition not recognised and ignored.", papszItems[i] ); } CSLDestroy( papszItems ); /* -------------------------------------------------------------------- */ /* Try to establish connection. */ /* -------------------------------------------------------------------- */ hConn = mysql_init( NULL ); if( hConn == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "mysql_init() failed." ); } /* -------------------------------------------------------------------- */ /* Set desired options on the connection: charset and timeout. */ /* -------------------------------------------------------------------- */ if( hConn ) { const char *pszTimeoutLength =//.........这里部分代码省略.........
开发者ID:nextgis-borsch,项目名称:lib_gdal,代码行数:101,
示例24: getRscFilenameGDALDataset *ROIPACDataset::Open( GDALOpenInfo *poOpenInfo ){/* -------------------------------------------------------------------- *//* Confirm that the header is compatible with a ROIPAC dataset. *//* -------------------------------------------------------------------- */ if ( !Identify(poOpenInfo) ) { return NULL; }/* -------------------------------------------------------------------- *//* Open the .rsc file *//* -------------------------------------------------------------------- */ CPLString osRscFilename = getRscFilename( poOpenInfo ); if ( osRscFilename.empty() ) { return NULL; } VSILFILE *fpRsc; if ( poOpenInfo->eAccess == GA_Update ) { fpRsc = VSIFOpenL( osRscFilename, "r+" ); } else { fpRsc = VSIFOpenL( osRscFilename, "r" ); } if ( fpRsc == NULL ) { return NULL; }/* -------------------------------------------------------------------- *//* Load the .rsc information. *//* -------------------------------------------------------------------- */ char **papszRsc = NULL; while ( true ) { const char *pszLine; char **papszTokens; pszLine = CPLReadLineL( fpRsc ); if (pszLine == NULL) { break; } papszTokens = CSLTokenizeString2( pszLine, " /t", CSLT_STRIPLEADSPACES | CSLT_STRIPENDSPACES | CSLT_PRESERVEQUOTES | CSLT_PRESERVEESCAPES ); if ( papszTokens == NULL || papszTokens[0] == NULL || papszTokens[1] == NULL ) { CSLDestroy ( papszTokens ); break; } papszRsc = CSLSetNameValue( papszRsc, papszTokens[0], papszTokens[1] ); CSLDestroy ( papszTokens ); }/* -------------------------------------------------------------------- *//* Fetch required fields. *//* -------------------------------------------------------------------- */ int nWidth = 0, nFileLength = 0; if ( CSLFetchNameValue( papszRsc, "WIDTH" ) == NULL || CSLFetchNameValue( papszRsc, "FILE_LENGTH" ) == NULL ) { CSLDestroy( papszRsc ); VSIFCloseL( fpRsc ); return NULL; } nWidth = atoi( CSLFetchNameValue( papszRsc, "WIDTH" ) ); nFileLength = atoi( CSLFetchNameValue( papszRsc, "FILE_LENGTH" ) );/* -------------------------------------------------------------------- *//* Create a corresponding GDALDataset. *//* -------------------------------------------------------------------- */ ROIPACDataset *poDS; poDS = new ROIPACDataset(); poDS->nRasterXSize = nWidth; poDS->nRasterYSize = nFileLength; poDS->eAccess = poOpenInfo->eAccess; poDS->fpRsc = fpRsc; poDS->pszRscFilename = CPLStrdup( osRscFilename.c_str() );/* -------------------------------------------------------------------- *//* Reopen file in update mode if necessary. *//* -------------------------------------------------------------------- */ if( poOpenInfo->eAccess == GA_Update ) { poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb+" ); } else { poDS->fpImage = VSIFOpenL( poOpenInfo->pszFilename, "rb" ); }//.........这里部分代码省略.........
开发者ID:AbdelghaniDr,项目名称:mirror,代码行数:101,
示例25: strstrint VICARKeywordHandler::Ingest( VSILFILE *fp, GByte *pabyHeader ){/* -------------------------------------------------------------------- *//* Read in buffer till we find END all on it's own line. *//* -------------------------------------------------------------------- */ if( VSIFSeekL( fp, 0, SEEK_SET ) != 0 ) return FALSE; // Find LBLSIZE Entry char* pszLBLSIZE = strstr((char*)pabyHeader,"LBLSIZE"); int nOffset = 0; if (pszLBLSIZE) nOffset = pszLBLSIZE - (const char *)pabyHeader; char *pch1 = strstr((char*)pabyHeader+nOffset, "="); if( pch1 == NULL ) return FALSE; ++pch1; char *pch2 = strstr((char*)pabyHeader+nOffset, " "); if( pch2 == NULL ) return FALSE; char keyval[100]; strncpy( keyval, pch1, MAX( pch2-pch1, 99 ) ); keyval[MAX(pch2-pch1, 99)] = '/0'; LabelSize = atoi( keyval ); if( LabelSize > 10 * 1024 * 124 ) return FALSE; char* pszChunk = (char*) VSIMalloc( LabelSize + 1 ); if( pszChunk == NULL ) return FALSE; int nBytesRead = VSIFReadL( pszChunk, 1, LabelSize, fp ); pszChunk[LabelSize] = 0; osHeaderText += pszChunk ; VSIFree( pszChunk ); pszHeaderNext = osHeaderText.c_str();/* -------------------------------------------------------------------- *//* Process name/value pairs, keeping track of a "path stack". *//* -------------------------------------------------------------------- */ if( !ReadGroup("") ) return FALSE;/* -------------------------------------------------------------------- *//* Now check for the Vicar End-of-Dataset Label... *//* -------------------------------------------------------------------- */ const char *pszResult = CSLFetchNameValue( papszKeywordList, "EOL" ); if( pszResult == NULL ) return FALSE; if( !EQUAL(pszResult,"1") ) return TRUE;/* -------------------------------------------------------------------- *//* There is a EOL! e.G. h4231_0000.nd4.06 *//* -------------------------------------------------------------------- */ long int nPixelOffset=0; if (EQUAL( CSLFetchNameValue(papszKeywordList,"FORMAT" ), "BYTE" )) { nPixelOffset = 1; } else if (EQUAL( CSLFetchNameValue(papszKeywordList,"FORMAT" ), "HALF" )) { nPixelOffset = 2; } else if (EQUAL( CSLFetchNameValue(papszKeywordList,"FORMAT" ), "FULL" )) { nPixelOffset = 4; } else if (EQUAL( CSLFetchNameValue(papszKeywordList,"FORMAT" ), "REAL" )) { nPixelOffset = 4; } const long int nCols = atoi( CSLFetchNameValue( papszKeywordList, "NS" ) ); const long int nRows = atoi( CSLFetchNameValue( papszKeywordList, "NL" ) ); const int nBands = atoi( CSLFetchNameValue( papszKeywordList, "NB" ) ); const int nBB = atoi( CSLFetchNameValue( papszKeywordList, "NBB" ) ); long int nLineOffset = nPixelOffset * nCols + nBB ; long int nBandOffset = nLineOffset * nRows; long int starteol = LabelSize + nBandOffset * nBands; if( VSIFSeekL( fp, starteol, SEEK_SET ) != 0 ) { printf("Error seeking to EOL!/n"); return FALSE; } char szChunk[100]; nBytesRead = VSIFReadL( szChunk, 1, 30, fp ); szChunk[nBytesRead] = '/0'; pszLBLSIZE = strstr( szChunk, "LBLSIZE" ); nOffset = 0; if (pszLBLSIZE) nOffset = pszLBLSIZE - (const char *)szChunk; pch1 = strstr( (char*)szChunk + nOffset,"=" ) + 1; pch2 = strstr( (char*)szChunk + nOffset, " " ); strncpy( keyval, pch1, pch2-pch1 );//.........这里部分代码省略.........
开发者ID:garnertb,项目名称:gdal,代码行数:101,
示例26: NITFDESGetTREint NITFDESGetTRE( NITFDES* psDES, int nOffset, char szTREName[7], char** ppabyTREData, int* pnFoundTRESize){ char szTREHeader[12]; char szTRETempName[7]; NITFSegmentInfo* psSegInfo; VSILFILE* fp; int nTRESize; memset(szTREName, '/0', 7); if (ppabyTREData) *ppabyTREData = NULL; if (pnFoundTRESize) *pnFoundTRESize = 0; if (nOffset < 0) return FALSE; if (psDES == NULL) return FALSE; if (CSLFetchNameValue(psDES->papszMetadata, "NITF_DESOFLW") == NULL) return FALSE; psSegInfo = psDES->psFile->pasSegmentInfo + psDES->iSegment; fp = psDES->psFile->fp; if (nOffset >= psSegInfo->nSegmentSize) return FALSE; VSIFSeekL(fp, psSegInfo->nSegmentStart + nOffset, SEEK_SET); if (VSIFReadL(szTREHeader, 1, 11, fp) != 11) { /* Some files have a nSegmentSize larger than what is is in reality */ /* So exit silently if we're at end of file */ VSIFSeekL(fp, 0, SEEK_END); if (VSIFTellL(fp) == psSegInfo->nSegmentStart + nOffset) return FALSE; CPLError(CE_Failure, CPLE_FileIO, "Cannot get 11 bytes at offset " CPL_FRMT_GUIB ".", psSegInfo->nSegmentStart + nOffset ); return FALSE; } szTREHeader[11] = '/0'; memcpy(szTRETempName, szTREHeader, 6); szTRETempName[6] = '/0'; nTRESize = atoi(szTREHeader + 6); if (nTRESize < 0) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid size (%d) for TRE %s", nTRESize, szTRETempName); return FALSE; } if (nOffset + 11 + nTRESize > psSegInfo->nSegmentSize) { CPLError(CE_Failure, CPLE_AppDefined, "Cannot read %s TRE. Not enough bytes : remaining %d, expected %d", szTRETempName, (int)(psSegInfo->nSegmentSize - (nOffset + 11)), nTRESize); return FALSE; } if (ppabyTREData) { /* Allocate one extra byte for the NULL terminating character */ *ppabyTREData = (char*) VSIMalloc(nTRESize + 1); if (*ppabyTREData == NULL) { CPLError(CE_Failure, CPLE_OutOfMemory, "Cannot allocate %d bytes for TRE %s", nTRESize, szTRETempName); return FALSE; } (*ppabyTREData)[nTRESize] = '/0'; if ((int)VSIFReadL(*ppabyTREData, 1, nTRESize, fp) != nTRESize) { CPLError(CE_Failure, CPLE_FileIO, "Cannot get %d bytes at offset " CPL_FRMT_GUIB ".", nTRESize, VSIFTellL(fp) ); VSIFree(*ppabyTREData); *ppabyTREData = NULL; return FALSE; } } strcpy(szTREName, szTRETempName); if (pnFoundTRESize) *pnFoundTRESize = nTRESize; return TRUE;}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:100,
示例27: GDALWriteRPBFileCPLErr CPL_STDCALL GDALWriteRPBFile( const char *pszFilename, char **papszMD ){ CPLString osRPBFilename = CPLResetExtension( pszFilename, "RPB" ); /* -------------------------------------------------------------------- *//* Read file and parse. *//* -------------------------------------------------------------------- */ VSILFILE *fp = VSIFOpenL( osRPBFilename, "w" ); if( fp == NULL ) { CPLError( CE_Failure, CPLE_OpenFailed, "Unable to create %s for writing./n%s", osRPBFilename.c_str(), CPLGetLastErrorMsg() ); return CE_Failure; } /* -------------------------------------------------------------------- *//* Write the prefix information. *//* -------------------------------------------------------------------- */ VSIFPrintfL( fp, "%s", "satId = /"QB02/";/n" ); VSIFPrintfL( fp, "%s", "bandId = /"P/";/n" ); VSIFPrintfL( fp, "%s", "SpecId = /"RPC00B/";/n" ); VSIFPrintfL( fp, "%s", "BEGIN_GROUP = IMAGE/n" ); VSIFPrintfL( fp, "%s", "/terrBias = 0.0;/n" ); VSIFPrintfL( fp, "%s", "/terrRand = 0.0;/n" );/* -------------------------------------------------------------------- *//* Write RPC values from our RPC metadata. *//* -------------------------------------------------------------------- */ int i; for( i = 0; apszRPBMap[i] != NULL; i += 2 ) { const char *pszRPBVal = CSLFetchNameValue( papszMD, apszRPBMap[i] ); const char *pszRPBTag; if( pszRPBVal == NULL ) { CPLError( CE_Failure, CPLE_AppDefined, "%s field missing in metadata, %s file not written.", apszRPBMap[i], osRPBFilename.c_str() ); VSIFCloseL( fp ); VSIUnlink( osRPBFilename ); return CE_Failure; } pszRPBTag = apszRPBMap[i+1]; if( EQUALN(pszRPBTag,"IMAGE.",6) ) pszRPBTag += 6; if( strstr(apszRPBMap[i], "COEF" ) == NULL ) { VSIFPrintfL( fp, "/t%s = %s;/n", pszRPBTag, pszRPBVal ); } else { // Reformat in brackets with commas over multiple lines. VSIFPrintfL( fp, "/t%s = (/n", pszRPBTag ); char **papszItems = CSLTokenizeStringComplex( pszRPBVal, " ,", FALSE, FALSE ); if( CSLCount(papszItems) != 20 ) { CPLError( CE_Failure, CPLE_AppDefined, "%s field is corrupt (not 20 values), %s file not written./n%s = %s", apszRPBMap[i], osRPBFilename.c_str(), apszRPBMap[i], pszRPBVal ); VSIFCloseL( fp ); VSIUnlink( osRPBFilename ); return CE_Failure; } int j; for( j = 0; j < 20; j++ ) { if( j < 19 ) VSIFPrintfL( fp, "/t/t/t%s,/n", papszItems[j] ); else VSIFPrintfL( fp, "/t/t/t%s);/n", papszItems[j] ); } CSLDestroy( papszItems ); } }/* -------------------------------------------------------------------- *//* Write end part *//* -------------------------------------------------------------------- */ VSIFPrintfL( fp, "%s", "END_GROUP = IMAGE/n" ); VSIFPrintfL( fp, "END;/n" ); VSIFCloseL( fp ); return CE_None;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:99,
示例28: return//.........这里部分代码省略......... NITFGetField( szDESID, pachHeader, 2, 25); /* For NITF < 02.10, we cannot rely on DESID=TRE_OVERFLOW to detect */ /* if DESOFLW and DESITEM are present. So if the next 4 bytes are non */ /* numeric, we'll assume that DESOFLW is there */ bHasDESOFLW = EQUALN(szDESID, "TRE_OVERFLOW", strlen("TRE_OVERFLOW")) || (!((pachHeader[nOffset+0] >= '0' && pachHeader[nOffset+0] <= '9') && (pachHeader[nOffset+1] >= '0' && pachHeader[nOffset+1] <= '9') && (pachHeader[nOffset+2] >= '0' && pachHeader[nOffset+2] <= '9') && (pachHeader[nOffset+3] >= '0' && pachHeader[nOffset+3] <= '9'))); if (bHasDESOFLW) { if ((int)psSegInfo->nSegmentHeaderSize < nOffset + 6 + 3 ) { CPLError(CE_Failure, CPLE_AppDefined, "DES header too small"); NITFDESDeaccess(psDES); return NULL; } GetMD( 6, DESOFLW ); GetMD( 3, DESITEM ); } if ((int)psSegInfo->nSegmentHeaderSize < nOffset + 4 ) { CPLError(CE_Failure, CPLE_AppDefined, "DES header too small"); NITFDESDeaccess(psDES); return NULL; } GetMD( 4, DESSHL ); nDESSHL = atoi(CSLFetchNameValue( psDES->papszMetadata, "NITF_DESSHL" ) ); if (nDESSHL < 0) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid value for DESSHL"); NITFDESDeaccess(psDES); return NULL; } if ( (int)psSegInfo->nSegmentHeaderSize < nOffset + nDESSHL) { CPLError(CE_Failure, CPLE_AppDefined, "DES header too small"); NITFDESDeaccess(psDES); return NULL; } if (EQUALN(szDESID, "CSSHPA DES", strlen("CSSHPA DES"))) { if ( nDESSHL != 62 && nDESSHL != 80) { CPLError(CE_Failure, CPLE_AppDefined, "Invalid DESSHL for CSSHPA DES"); NITFDESDeaccess(psDES); return NULL; } GetMD( 25, SHAPE_USE ); GetMD( 10, SHAPE_CLASS ); if (nDESSHL == 80) GetMD( 18, CC_SOURCE ); GetMD( 3, SHAPE1_NAME ); GetMD( 6, SHAPE1_START );
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:67,
示例29: GDALLoadIMDFilechar ** CPL_STDCALL GDALLoadIMDFile( const char *pszFilename, char **papszSiblingFiles ){/* -------------------------------------------------------------------- *//* Try to identify the IMD file in upper or lower case. *//* -------------------------------------------------------------------- */ CPLString osTarget = CPLResetExtension( pszFilename, "IMD" ); /* Is this already a IMD file ? */ if (EQUAL(CPLGetExtension(pszFilename), "IMD")) osTarget = pszFilename; else if( papszSiblingFiles == NULL ) { VSIStatBufL sStatBuf; if( VSIStatL( osTarget, &sStatBuf ) != 0 ) { osTarget = CPLResetExtension( pszFilename, "imd" ); if( VSIStatL( osTarget, &sStatBuf ) != 0 ) return NULL; } } else { int iSibling = CSLFindString( papszSiblingFiles, CPLGetFilename(osTarget) ); if( iSibling < 0 ) return NULL; osTarget.resize(osTarget.size() - strlen(papszSiblingFiles[iSibling])); osTarget += papszSiblingFiles[iSibling]; }/* -------------------------------------------------------------------- *//* Read file and parse. *//* -------------------------------------------------------------------- */ CPLKeywordParser oParser; VSILFILE *fp = VSIFOpenL( osTarget, "r" ); if( fp == NULL ) return NULL; if( !oParser.Ingest( fp ) ) { VSIFCloseL( fp ); return NULL; } VSIFCloseL( fp );/* -------------------------------------------------------------------- *//* Consider version changing. *//* -------------------------------------------------------------------- */ char **papszIMD = CSLDuplicate( oParser.GetAllKeywords() ); const char *pszVersion = CSLFetchNameValue( papszIMD, "version" ); if( pszVersion == NULL ) { /* ? */; } else if( EQUAL(pszVersion,"/"AA/"") ) { GDAL_IMD_AA2R( &papszIMD ); } return papszIMD;}
开发者ID:actian-geospatial,项目名称:ogr-ingres,代码行数:70,
示例30: ReadTxtToList/** * LoadMetadata() */void GDALMDReaderKompsat::LoadMetadata(){ if(m_bIsMetadataLoad) return; if(!m_osIMDSourceFilename.empty()) { m_papszIMDMD = ReadTxtToList( ); } if(!m_osRPBSourceFilename.empty()) { m_papszRPCMD = GDALLoadRPCFile( m_osRPBSourceFilename ); } m_papszDEFAULTMD = CSLAddNameValue(m_papszDEFAULTMD, MD_NAME_MDTYPE, "KARI"); m_bIsMetadataLoad = true; const char* pszSatId1 = CSLFetchNameValue(m_papszIMDMD, "AUX_SATELLITE_NAME"); const char* pszSatId2 = CSLFetchNameValue(m_papszIMDMD, "AUX_SATELLITE_SENSOR"); if(nullptr != pszSatId1 && nullptr != pszSatId2) { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_SATELLITE, CPLSPrintf( "%s %s", CPLStripQuotes(pszSatId1).c_str(), CPLStripQuotes(pszSatId2).c_str())); } else if(nullptr != pszSatId1 && nullptr == pszSatId2) { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_SATELLITE, CPLStripQuotes(pszSatId1)); } else if(nullptr == pszSatId1 && nullptr != pszSatId2) { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_SATELLITE, CPLStripQuotes(pszSatId2)); } const char* pszCloudCover = CSLFetchNameValue(m_papszIMDMD, "AUX_CLOUD_STATUS"); if(nullptr != pszCloudCover) { int nCC = atoi(pszCloudCover); if(nCC > 100 || nCC < 0) { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_CLOUDCOVER, MD_CLOUDCOVER_NA); } else { m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_CLOUDCOVER, CPLSPrintf("%d", nCC)); } } const char* pszDate = CSLFetchNameValue(m_papszIMDMD, "AUX_STRIP_ACQ_DATE_UT"); if(nullptr != pszDate) { const char* pszTime = CSLFetchNameValue(m_papszIMDMD, "AUX_STRIP_ACQ_START_UT"); if(nullptr == pszTime) pszTime = "000000.000000"; char buffer[80]; time_t timeMid = GetAcquisitionTimeFromString(CPLSPrintf( "%sT%s", pszDate, pszTime)); strftime (buffer, 80, MD_DATETIMEFORMAT, localtime(&timeMid)); m_papszIMAGERYMD = CSLAddNameValue(m_papszIMAGERYMD, MD_NAME_ACQDATETIME, buffer); }}
开发者ID:OSGeo,项目名称:gdal,代码行数:77,
注:本文中的CSLFetchNameValue函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CSLFetchNameValueDef函数代码示例 C++ CSLFetchBoolean函数代码示例 |