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


C++ OGRLayer::SetSpatialFilterRect方法代码示例

本文整理汇总了C++中OGRLayer::SetSpatialFilterRect方法的典型用法代码示例。如果您正苦于以下问题:C++ OGRLayer::SetSpatialFilterRect方法的具体用法?C++ OGRLayer::SetSpatialFilterRect怎么用?C++ OGRLayer::SetSpatialFilterRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OGRLayer的用法示例。


在下文中一共展示了OGRLayer::SetSpatialFilterRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindNearestPoint

GNMGFID GNMGenericNetwork::FindNearestPoint(const OGRPoint* poPoint,
                                    const std::vector<OGRLayer*>& paPointLayers,
                                    double dfTolerance)
{
    VALIDATE_POINTER1(poPoint, "GNMGenericNetwork::FindNearestPoint", -1);
    double dfMinX = poPoint->getX() - dfTolerance;
    double dfMinY = poPoint->getY() - dfTolerance;
    double dfMaxX = poPoint->getX() + dfTolerance;
    double dfMaxY = poPoint->getY() + dfTolerance;

    OGRFeature *poFeature;

    for(size_t i = 0; i < paPointLayers.size(); ++i)
    {
        OGRLayer *poLayer = paPointLayers[i];

        poLayer->SetSpatialFilterRect(dfMinX, dfMinY,
                                      dfMaxX, dfMaxY);
        poLayer->ResetReading();
        while((poFeature = poLayer->GetNextFeature()) != NULL)
        {
            GNMGFID nRetFID = poFeature->GetFieldAsGNMGFID(GNM_SYSFIELD_GFID);
            OGRFeature::DestroyFeature(poFeature);
            return nRetFID;
        }
    }

    return -1;
}
开发者ID:Mavrx-inc,项目名称:gdal,代码行数:29,代码来源:gnmgenericnetwork.cpp

示例2: render

bool VectorLayer::render(HDC hDC, double scale, double dWorldOriginX, double dWorldOriginY) {

	Timer * timer = new Timer();
	timer->start();
	OGRLayer  *poLayer;

	poLayer = dataSource->GetLayer(0);

	poLayer->SetSpatialFilterRect(dWorldOriginX, dWorldOriginY - height / scale, dWorldOriginX + width / scale, dWorldOriginY);

	OGRFeature *poFeature;

    poLayer->ResetReading();

	HGDIOBJ oldObject = SelectObject(hDC, GetStockObject(BLACK_BRUSH));

    while( (poFeature = poLayer->GetNextFeature()) != NULL )
    {
		OGRGeometry *poGeometry;

        poGeometry = poFeature->GetGeometryRef();
		if( poGeometry != NULL) {

			//OGRwkbGeometryType type = wkbFlatten(poGeometry->getGeometryType());
			OGRwkbGeometryType type = poGeometry->getGeometryType();
			
			if (type == wkbPoint )
			{
				OGRPoint *poPoint = static_cast<OGRPoint *>(poGeometry);
			}
			else if (type == wkbLineString)
			{
				OGRLineString *poLineString = static_cast<OGRLineString *>(poGeometry);

				int numPoints = poLineString->getNumPoints();
				POINT * points = (POINT *)CPLMalloc(sizeof(POINT) * numPoints);

				if (points == NULL) return false;

				for (int i = 0; i < numPoints; ++i) {
					points[i].x = (LONG)((poLineString->getX(i) - dWorldOriginX) * scale + 0.5);
					points[i].y = (LONG)((dWorldOriginY - poLineString->getY(i)) * scale + 0.5);
				}

				Polyline(hDC, points, numPoints);

				free(points);
			}

			OGRFeature::DestroyFeature( poFeature );
		}
    }

	// Select old object back into dc (one can not delete an object if it is in the dc)
	SelectObject(hDC, oldObject);
	
	timer->stop();
	double timeTaken = timer->diffTime();
	MessageBox(0,doubleToString(timeTaken).c_str(),L"Time to render",MB_OK);

	return true;
}
开发者ID:ntj,项目名称:GravurGIS,代码行数:62,代码来源:VectorLayer.cpp


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