本文整理汇总了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;
}
示例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;
}