本文整理汇总了C++中OGRGeometry::transformTo方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRGeometry::transformTo方法的具体用法?C++ OGRGeometry::transformTo怎么用?C++ OGRGeometry::transformTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRGeometry
的用法示例。
在下文中一共展示了OGRGeometry::transformTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeGrid
void Dust::MakeGrid(WindNinjaInputs &input, AsciiGrid<double> &grid)
{
/*------------------------------------------*/
/* Open grid as a GDAL dataset */
/*------------------------------------------*/
int nXSize = grid.get_nCols();
int nYSize = grid.get_nRows();
GDALDriverH hDriver = GDALGetDriverByName( "MEM" );
GDALDatasetH hMemDS = GDALCreate(hDriver, "", nXSize, nYSize, 1, GDT_Float64, NULL);
double *padfScanline;
padfScanline = new double[nXSize];
double adfGeoTransform[6];
adfGeoTransform[0] = grid.get_xllCorner();
adfGeoTransform[1] = grid.get_cellSize();
adfGeoTransform[2] = 0;
adfGeoTransform[3] = grid.get_yllCorner()+(grid.get_nRows()*grid.get_cellSize());
adfGeoTransform[4] = 0;
adfGeoTransform[5] = -grid.get_cellSize();
char* pszDstWKT = (char*)grid.prjString.c_str();
GDALSetProjection(hMemDS, pszDstWKT);
GDALSetGeoTransform(hMemDS, adfGeoTransform);
GDALRasterBandH hBand = GDALGetRasterBand( hMemDS, 1 );
GDALSetRasterNoDataValue(hBand, -9999.0);
for(int i=nYSize-1; i>=0; i--)
{
for(int j=0; j<nXSize; j++)
{
padfScanline[j] = grid.get_cellValue(nYSize-1-i, j);
}
GDALRasterIO(hBand, GF_Write, 0, i, nXSize, 1, padfScanline, nXSize,
1, GDT_Float64, 0, 0);
}
/*------------------------------------------*/
/* Get the geometry info */
/*------------------------------------------*/
OGRDataSourceH hOGRDS = 0;
hOGRDS = OGROpen(input.dustFilename.c_str(), FALSE, 0);
if(hOGRDS == NULL)
{
throw std::runtime_error("Could not open the fire perimeter file '" +
input.dustFilename + "' for reading.");
}
OGRLayer *poLayer;
OGRFeature *poFeature;
OGRGeometry *poGeo;
poLayer = (OGRLayer*)OGR_DS_GetLayer(hOGRDS, 0);
poLayer->ResetReading();
poFeature = poLayer->GetNextFeature();
poGeo = poFeature->GetGeometryRef();
OGRGeometryH hPolygon = (OGRGeometryH) poGeo;
/* -------------------------------------------------------------------- */
/* Check for same CRS in fire perimeter and DEM files */
/* -------------------------------------------------------------------- */
char *pszSrcWKT;
OGRSpatialReference *poSrcSRS, oDstSRS;
poSrcSRS = poLayer->GetSpatialRef(); //shapefile CRS
poSrcSRS->exportToWkt( &pszSrcWKT );
//printf("CRS of DEM is:\n %s\n", pszDstWKT);
//printf("WKT CRS of .shp is:\n %s\n", pszSrcWKT);
oDstSRS.importFromWkt( &pszDstWKT );
char *pszDstProj4, *pszSrcProj4;
oDstSRS.exportToProj4( &pszDstProj4 );
poSrcSRS->exportToProj4( &pszSrcProj4 );
//printf("proj4 of .shp is:\n %s\n", pszSrcProj4);
//printf("proj4 of dem is:\n %s\n", pszDstProj4);
/* -------------------------------------------------------------------- */
/* If the CRSs are not equal, convert shapefile CRS to DEM CRS */
/* -------------------------------------------------------------------- */
GDALTransformerFunc pfnTransformer = NULL;
if( !EQUAL( pszSrcProj4, pszDstProj4 ) ){ //tranform shp CRS to DEM CRS
poGeo->transformTo(&oDstSRS);
}
/* -------------------------------------------------------------------- */
/* Rasterize the shapefile */
/* -------------------------------------------------------------------- */
int nTargetBand = 1;
double BurnValue = 1.0;
CPLErr eErr;
//.........这里部分代码省略.........