本文整理汇总了C++中ossimDrect::getBounds方法的典型用法代码示例。如果您正苦于以下问题:C++ ossimDrect::getBounds方法的具体用法?C++ ossimDrect::getBounds怎么用?C++ ossimDrect::getBounds使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ossimDrect
的用法示例。
在下文中一共展示了ossimDrect::getBounds方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindVerticesInImage
bool shapefileClip::FindVerticesInImage(SHPHandle hSHP, ossimDrect imgRect, vector<int> &ShapeID)
{
if (!ShapeID.empty())
ShapeID.clear();
if (hSHP == NULL){
cerr << "Shapefile is not open." << endl
<< "Line: " << __LINE__ << " " << __FILE__ << endl;
}
// Get min and max values for image bounding rectangle.
double minx, miny, maxx, maxy;
imgRect.getBounds(minx, miny, maxx, maxy);
ossimDrect newImgRect;
newImgRect = ossimDrect(ossimDpt(minx, miny), ossimDpt(maxx, maxy));
// Determine if image is completely within any of the wvs polygons
bool allLandFlag = false;
bool imgCompWithinPoly = false;
bool onePointInPoly = false;
SHPObject *obj;
ossimDrect wvsPolyRect;
int withinBoundsVertCount = 0;
// Determine number of polygons in image
unsigned long int totalPolyCount = 0;
// loop through each shape in file
while( obj = SHPReadObject(hSHP, totalPolyCount)){
totalPolyCount++;
wvsPolyRect = ossimDrect(ossimDpt(obj->dfXMin, obj->dfYMin), ossimDpt(obj->dfXMax, obj->dfYMax));
imgCompWithinPoly = false;
if (newImgRect.completely_within(wvsPolyRect)){
imgCompWithinPoly = true;
allLandFlag = true;
}
if (wvsPolyRect.intersects(newImgRect) || wvsPolyRect.completely_within(newImgRect) || imgCompWithinPoly){
withinBoundsVertCount = 0;
if (obj->nParts > 0 && obj->nVertices > 1){
// loop through vertices of qualified shape
for (unsigned long int shapeVertex = 0; shapeVertex < (unsigned)obj->nVertices && withinBoundsVertCount==0; ++shapeVertex){
// If vertex is within bounding box, then save
if ((double)obj->padfX[shapeVertex] > minx &&
(double)obj->padfX[shapeVertex] < maxx &&
(double)obj->padfY[shapeVertex] > miny &&
(double)obj->padfY[shapeVertex] < maxy){
++withinBoundsVertCount;
}
}
if (withinBoundsVertCount){
ShapeID.push_back(obj->nShapeId);
}
else if (imgCompWithinPoly){ // If bounding box completely within polygon and no vertices found
ossimPolygon entirePoly;
for (int j = 0; j < obj->nVertices; ++j)
entirePoly.addPoint(ossimDpt(obj->padfX[j], obj->padfY[j]));
// Check if image upper left point is within the shapefile polygon
if (entirePoly.isPointWithin(ossimDpt(minx, miny))){
onePointInPoly = true;
}
}
}
}
// Image completely within flag
imgCompWithinPoly = false;
SHPDestroyObject(obj);
}
SHPDestroyObject(obj);
obj = NULL;
// If image boundary is completely within a polygon, but vertices were found within the image boundary, image contains all land
if (allLandFlag && onePointInPoly && ShapeID.empty()){
return true;
}
else{
return false;
}
}