资源简介
主要利用图像控制点校正卫星遥感图像,主要为开源技术的体现
代码片段和文件信息
// CRectifier.cpp: implementation of the CRectifier class.
//
//////////////////////////////////////////////////////////////////////
#include “stdafx.h“
#include “CRectifier.h“
#include “.\include\cpl_conv.h“
#include “.\include\cpl_string.h“
#include “.\include\ogrsf_frmts.h“
#include “.\include\gdalwarper.h“
#pragma comment(lib“lib\\gdal_i.lib“)
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CRectifier::CRectifier()
{
}
CRectifier::CRectifier(CString filename)
{
SetScrFileName(filename);
}
CRectifier::~CRectifier()
{
}
VOID CRectifier::AddGCPS(double* gcpsint nCount)
{
m_Count = nCount;
m_Gcps = new GDAL_GCP[m_Count];
for (int i=0;i {
char pszId[5];
sprintf(pszId“GCP-%d“i);
m_Gcps[i].pszId = pszId;
m_Gcps[i].pszInfo=““;
m_Gcps[i].dfGCPPixel = gcps[4*i];
m_Gcps[i].dfGCPLine = gcps[4*i+1];
m_Gcps[i].dfGCPX = gcps[4*i+2];
m_Gcps[i].dfGCPY = gcps[4*i+3];
m_Gcps[i].dfGCPZ = 0;
}
}
VOID CRectifier:: SetScrFileName(CString filename)
{
m_ScrFileName = filename;
int index = m_ScrFileName.ReverseFind(‘.‘) + 1;
m_DestFileName = m_ScrFileName.Left(index) + “_Dest“;
m_DestFileName += m_ScrFileName.Right(m_ScrFileName.GetLength() - index );
}
CString CRectifier::GetDestFileName()
{
return m_DestFileName;
}
BOOL CRectifier::Transform()
{
GDALDatasetH hSrcDS hDstDS;
GDALDriverH hDriver;
GDALDataType eDT;
try
{
GDALAllRegister();
// Open the source file.
hSrcDS = GDALOpen( m_ScrFileName GA_ReadOnly );
CPLAssert( hSrcDS != NULL );
GDALSetGCPs(hSrcDSm_Countm_GcpsNULL);
// Create output with same datatype as first input band.
eDT = GDALGetRasterDataType(GDALGetRasterBand(hSrcDS1));
// Get output driver (GeoTIFF format)
hDriver = GDALGetDriverByName( “GTiff“ );
CPLAssert( hDriver != NULL );
// Get Source coordinate system.
const char *pszSrcWKT = NULL;
//
// pszSrcWKT = GDALGetProjectionRef( hSrcDS );
// CPLAssert( pszSrcWKT != NULL && strlen(pszSrcWKT) > 0 );
//
// // Setup output coordinate system that is input by user.
//
char *pszDstWKT = NULL;
//
// oTargetSRS.exportToWkt( &pszDstWKT );
// CPLAssert( pszDstWKT != NULL && strlen(pszDstWKT) > 0 );
// Create a transformer that maps from source pixel/line coordinates
// to destination georeferenced coordinates (not destination
// pixel line). We do that by omitting the destination dataset
// handle (setting it to NULL).
void *hTransformArg;
hTransformArg =
GDALCreateGenImgProjTransformer( hSrcDS pszSrcWKT NULL pszDstWKT
FALSE 0 1 );
CPLAssert( hTransformArg != NULL );
// Get appro
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5756 2009-09-14 22:46 CRectifier.cpp
文件 1017 2009-09-15 09:49 CRectifier.h
文件 4820 2007-08-30 23:15 RasterRectifierDlg.cpp
----------- --------- ---------- ----- ----
11593 3
- 上一篇:高精度动态称重算法与实现
- 下一篇:桌面助手,不会后悔的
评论
共有 条评论