本文整理汇总了C++中OGRPoint::Intersects方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRPoint::Intersects方法的具体用法?C++ OGRPoint::Intersects怎么用?C++ OGRPoint::Intersects使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OGRPoint
的用法示例。
在下文中一共展示了OGRPoint::Intersects方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: report_raster_data_within_polygon
void report_raster_data_within_polygon(Raster* raster, OGRPolygon* poPolygon, int feature_num, string feature_name) {
if (raster->rasterBBox->Intersects( poPolygon ) ) {
OGRPolygon *poIntersection = (OGRPolygon*) raster->rasterBBox->Intersection( poPolygon );
OGREnvelope* envl = new OGREnvelope;
poIntersection->getEnvelope(envl);
//printf ("Bounding rect (minX, maxX; minY, maxY): %.3f, %.3f; %.3f, %.3f\n", envl->MinX, envl->MaxX, envl->MinY, envl->MaxY);
const double pw = raster->pixel_width;
const double ph = raster->pixel_height;
int pixelOffset_X = round((envl->MinX - raster->upper_left_x) / pw);
int pixelOffset_Y = round((raster->upper_left_y - envl->MaxY) / ph);
int nCellsX = round((envl->MaxX - raster->upper_left_x) / pw) - pixelOffset_X;
int nCellsY = round((raster->upper_left_y - envl->MinY) / ph) - pixelOffset_Y;
OGRPoint* pixelPoint = new OGRPoint(0,0);
float* pPixelValue = (float *) CPLMalloc(sizeof(float));
cerr << "Feature size: " << nCellsX << "x" << nCellsY << endl;
for ( int row = 0; row < nCellsY; ++row ) {
for ( int col = 0; col < nCellsX; ++col ) {
double xcenter = (col + pixelOffset_X + 0.5)*pw + raster->upper_left_x;
double ycenter = raster->upper_left_y - (row + pixelOffset_Y + 0.5)*ph;
pixelPoint->setX(xcenter);
pixelPoint->setY(ycenter);
if ( pixelPoint->Intersects(poPolygon)) {
raster->band->RasterIO( GF_Read, pixelOffset_X + col, pixelOffset_Y + row, 1,1, pPixelValue, 1,1, GDT_Float32, 0, 0 );
cout << setprecision(10) << xcenter << "," << setprecision(10) << ycenter << "," << *pPixelValue << "," << feature_num << "," << feature_name << endl;
}
}
}
delete envl;
CPLFree(pPixelValue);
} else {
cerr << "Feature does not intersect raster" << endl;
}
return;
}