当前位置: 首页>>代码示例>>C++>>正文


C++ OGRPoint::Intersects方法代码示例

本文整理汇总了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;
}
开发者ID:PulliamLab-UFL,项目名称:dengue,代码行数:38,代码来源:clip_raster_by_region.cpp


注:本文中的OGRPoint::Intersects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。