void ossimQuadTreeWarp::create(const ossimDrect& boundingRect, const ossimDpt& ulShift, const ossimDpt& urShift, const ossimDpt& lrShift, const ossimDpt& llShift) { clear(); theTree = new ossimQuadTreeWarpNode(boundingRect); ossimQuadTreeWarpVertex* ul = new ossimQuadTreeWarpVertex(boundingRect.ul(), ulShift); ossimQuadTreeWarpVertex* ur = new ossimQuadTreeWarpVertex(boundingRect.ur(), urShift); ossimQuadTreeWarpVertex* lr = new ossimQuadTreeWarpVertex(boundingRect.lr(), lrShift); ossimQuadTreeWarpVertex* ll = new ossimQuadTreeWarpVertex(boundingRect.ll(), llShift); ul->addSharedNode(theTree); ur->addSharedNode(theTree); lr->addSharedNode(theTree); ll->addSharedNode(theTree); theVertexList.push_back(ul); theVertexList.push_back(ur); theVertexList.push_back(lr); theVertexList.push_back(ll); theTree->theUlVertex = ul; theTree->theUrVertex = ur; theTree->theLrVertex = lr; theTree->theLlVertex = ll; }
ossimPolygon::ossimPolygon(const ossimDrect& rect) : theVertexList(4), theCurrentVertex(0), theOrderingType(OSSIM_CLOCKWISE_ORDER) { theVertexList[0] = rect.ul(); theVertexList[1] = rect.ur(); theVertexList[2] = rect.lr(); theVertexList[3] = rect.ll(); }
void oms::SingleImageChain::setImageCut(const ossimDrect& rect) { std::vector<ossimDpt> pointList(4); pointList[0] = rect.ul(); pointList[1] = rect.ur(); pointList[2] = rect.lr(); pointList[3] = rect.ll(); setImageCut(pointList); }
bool ossimPolygon::clipToRect(vector<ossimPolygon>& result, const ossimDrect& rect)const { result.clear(); ossimPolyArea2d p1(*this); ossimPolyArea2d p2(rect.ul(), rect.ur(), rect.lr(), rect.ll()); p1&=p2; p1.getVisiblePolygons(result); return (result.size() > 0); }
void oms::SingleImageChain::setViewCut(const ossimDrect& rect, bool imageSpaceFlag) { if(!imageSpaceFlag) { const ossimProjection* proj = getViewProjection(); if(proj) { std::vector<ossimGpt> pointList(4); proj->lineSampleToWorld(rect.ul(), pointList[0]); proj->lineSampleToWorld(rect.ur(), pointList[1]); proj->lineSampleToWorld(rect.lr(), pointList[2]); proj->lineSampleToWorld(rect.ll(), pointList[3]); setViewCut(pointList); } } else { std::vector<ossimDpt> pointList(4); pointList[0] = rect.ul(); pointList[1] = rect.ur(); pointList[2] = rect.lr(); pointList[3] = rect.ll(); theViewCutter->setEnableFlag(false); theViewImageCutter->setEnableFlag(true); theViewImageCutter->setPolygon(pointList); theViewImageCutter->initialize(); ossimPropertyEvent evt(theViewImageCutter); theViewImageCutter->propagateEventToOutputs(evt); } }
ossimDrect ossimImageViewTransform::getImageToViewBounds(const ossimDrect& imageRect)const { ossimDpt p1; ossimDpt p2; ossimDpt p3; ossimDpt p4; imageToView(imageRect.ul(), p1); imageToView(imageRect.ur(), p2); imageToView(imageRect.lr(), p3); imageToView(imageRect.ll(), p4); return ossimDrect(p1, p2, p3, p4); }
//***************************************************************************** // METHOD: ossimDblGrid::initialize() // // Permits initialization after construction // //***************************************************************************** void ossimDblGrid::initialize(const ossimDrect& uv_rect, const ossimDpt& spacing, double null_value) { static const char MODULE[] = "ossimDblGrid::initialize()"; if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering...\n"; ossimIpt size ((int) (uv_rect.width()/spacing.x) + 1, (int) (uv_rect.height()/spacing.y) + 1); initialize(size, uv_rect.ul(), spacing, null_value); if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " returning...\n"; return; }
//************************************************************************************************** // Converts the local image space rect into bounding view-space rect //************************************************************************************************** ossimDrect ossimImageViewProjectionTransform::getImageToViewBounds(const ossimDrect& imageRect)const { // Let base class try: ossimDrect result = ossimImageViewTransform::getImageToViewBounds(imageRect); // If not successful, compute using input and output geometries: if (result.hasNans() && m_imageGeometry.valid() && m_viewGeometry.valid() && m_imageGeometry->hasProjection() && m_viewGeometry->hasProjection()) { ossimGeoPolygon viewClip; m_viewGeometry->getProjection()->getGroundClipPoints(viewClip); if(viewClip.size()) { std::vector<ossimGpt> imageGpts(4); m_imageGeometry->localToWorld(imageRect.ul(), imageGpts[0]); m_imageGeometry->localToWorld(imageRect.ur(), imageGpts[1]); m_imageGeometry->localToWorld(imageRect.lr(), imageGpts[2]); m_imageGeometry->localToWorld(imageRect.ll(), imageGpts[3]); const ossimDatum* viewDatum = m_viewGeometry->getProjection()->origin().datum(); imageGpts[0].changeDatum(viewDatum); imageGpts[1].changeDatum(viewDatum); imageGpts[2].changeDatum(viewDatum); imageGpts[3].changeDatum(viewDatum); ossimPolyArea2d viewPolyArea(viewClip.getVertexList()); ossimPolyArea2d imagePolyArea(imageGpts); viewPolyArea &= imagePolyArea; std::vector<ossimPolygon> visiblePolygons; viewPolyArea.getVisiblePolygons(visiblePolygons); if(visiblePolygons.size()) { std::vector<ossimDpt> vpts; ossim_uint32 idx = 0; for(idx=0; idx<visiblePolygons[0].getNumberOfVertices();++idx) { ossimDpt tempPt; ossimGpt gpt(visiblePolygons[0][idx].lat, visiblePolygons[0][idx].lon, 0.0, viewDatum); m_viewGeometry->worldToLocal(gpt, tempPt); vpts.push_back(tempPt); } result = ossimDrect(vpts); } } } return result; }
//******************************************************************* // Public Method: //******************************************************************* bool ossimDrect::intersects(const ossimDrect& rect) const { if(rect.hasNans() || hasNans()) { return false; } if (theOrientMode != rect.theOrientMode) return false; ossim_float64 ulx = ossim::max(rect.ul().x,ul().x); ossim_float64 lrx = ossim::min(rect.lr().x,lr().x); ossim_float64 uly, lry; bool rtn=false; if (theOrientMode == OSSIM_LEFT_HANDED) { uly = ossim::max(rect.ul().y,ul().y); lry = ossim::min(rect.lr().y,lr().y); rtn = ((ulx <= lrx) && (uly <= lry)); } else { uly = ossim::max(rect.ll().y,ll().y); lry = ossim::min(rect.ur().y,ur().y); rtn = ((ulx <= lrx) && (uly <= lry)); } return (rtn); }
/*!**************************************************************************** * CONSTRUCTOR: ossimDblGrid * *****************************************************************************/ ossimDblGrid::ossimDblGrid(const ossimDrect& rect, const ossimDpt& spacing, double null_value) : theGridData (0), theMinValue (OSSIM_DEFAULT_MIN_PIX_DOUBLE), theMaxValue (OSSIM_DEFAULT_MAX_PIX_DOUBLE), theExtrapIsEnabled (true), theDomainType (CONTINUOUS) { static const char MODULE[] = "ossimDblGrid Constructor"; if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entering...\n"; ossimIpt size ((int) (rect.width()/spacing.x) + 1, (int) (rect.height()/spacing.y) + 1); initialize(size, rect.ul(), spacing, null_value); if (traceExec()) ossimNotify(ossimNotifyLevel_WARN) << MODULE << " returning...\n"; }
bool ossimAnnotationMultiPolyObject::intersects(const ossimDrect& rect)const { // do the quick checks first // if(rect.hasNans()) return false; if(!rect.intersects(theBoundingRect)) return false; if(theMultiPolygon.size()<1) return false; for(ossim_uint32 i =0; i < theMultiPolygon.size(); ++i) { vector<ossimPolygon> result; if(theMultiPolygon[i].clipToRect(result, rect)) { return true; } } return false; }
//******************************************************************* // Public Method: ossimDrect::getCode //******************************************************************* long ossimDrect::getCode(const ossimDpt& aPoint, const ossimDrect& clipRect) { long result=NONE; // initialize to inside rect if( (aPoint.x > clipRect.lr().x) ) result |= RIGHT; else if( (aPoint.x < clipRect.ul().x) ) result |= LEFT; if (clipRect.theOrientMode == OSSIM_LEFT_HANDED) { if( (aPoint.y < clipRect.ul().y) ) result |= TOP; else if( (aPoint.y > clipRect.lr().y) ) result |= BOTTOM; } else { if( (aPoint.y > clipRect.ul().y) ) result |= TOP; else if( (aPoint.y < clipRect.lr().y) ) result |= BOTTOM; } return result; }
//******************************************************************* // Public Method: ossimDrect::completely_within //******************************************************************* bool ossimDrect::completely_within(const ossimDrect& rect) const { if(hasNans() || rect.hasNans()) { return false; } if (theOrientMode != rect.theOrientMode) return false; /* -------------- | 1 | | ---------- | | | | | | | | | | | 2 | | | | | | | | | | | ---------- | | | -------------- */ bool rtn = true; if (theUlCorner.x < rect.ul().x) rtn = false; else if (theLrCorner.x > rect.lr().x) rtn = false; else if (theOrientMode == OSSIM_LEFT_HANDED) { if (theUlCorner.y < rect.ul().y) rtn = false; else if (theLrCorner.y > rect.lr().y) rtn = false; } else { if (theUlCorner.y > rect.ul().y) rtn = false; else if (theLrCorner.y < rect.lr().y) rtn = false; } return rtn; }
bool ossimPolygon::isInsideEdge(const ossimDpt& pt, const ossimDrect& rect, int edge)const { switch(edge) { case RECT_LEFT_EDGE: { return (pt.x>rect.ul().x); break; } case RECT_TOP_EDGE: { if(rect.orientMode() == OSSIM_LEFT_HANDED) { return (pt.y > rect.ul().y); } else { return (pt.y < rect.ul().y); } break; } case RECT_RIGHT_EDGE: { return (pt.x<rect.lr().x); break; } case RECT_BOTTOM_EDGE: { if(rect.orientMode() == OSSIM_LEFT_HANDED) { return (pt.y < rect.lr().y); } else { return (pt.y > rect.lr().y); } break; } } return false; }
void ossimPolygon::intersectEdge(ossimDpt& result, const ossimLine& segment, const ossimDrect& rect, int edge) { ossimLine edgeLine; switch(edge) { case RECT_LEFT_EDGE: { edgeLine.theP1 = rect.ll(); edgeLine.theP2 = rect.ul(); break; } case RECT_TOP_EDGE: { edgeLine.theP1 = rect.ul(); edgeLine.theP2 = rect.ur(); break; } case RECT_RIGHT_EDGE: { edgeLine.theP1 = rect.ur(); edgeLine.theP2 = rect.lr(); break; } case RECT_BOTTOM_EDGE: { edgeLine.theP1 = rect.lr(); edgeLine.theP2 = rect.ll(); break; } } result = segment.intersectInfinite(edgeLine); }
void ossimShapeObject::getBoundingRect(ossimDrect& result, ossimCoordSysOrientMode orient)const { double minx, miny, maxx, maxy; if(theShape) { getBounds(minx, miny, maxx, maxy); if(orient == OSSIM_RIGHT_HANDED) { result = ossimDrect(minx, maxy, maxx, miny, orient); } else { result = ossimDrect(minx, miny, maxx, maxy, orient); } } else { result = ossimDrect(0,0,0,0,orient); result.makeNan(); } }
//******************************************************************* // Public Method: ossimDrect::clipToRect //******************************************************************* ossimDrect ossimDrect::clipToRect(const ossimDrect& rect)const { ossimDrect result; result.makeNan(); if(rect.hasNans() || hasNans()) { return result; } if (theOrientMode != rect.theOrientMode) return (*this); double x0 = ossim::max(rect.ul().x, ul().x); double x1 = ossim::min(rect.lr().x, lr().x); double y0, y1; if (theOrientMode == OSSIM_LEFT_HANDED) { y0 = ossim::max(rect.ll().y, ll().y); y1 = ossim::min(rect.ur().y, ur().y); if( (x1 < x0) || (y1 < y0) ) return result; else result = ossimDrect(x0, y0, x1, y1, theOrientMode); } else { y0 = ossim::max(rect.ll().y,ll().y); y1 = ossim::min(rect.ur().y,ur().y); if((x0 <= x1) && (y0 <= y1)) { result = ossimDrect(x0, y1, x1, y0, theOrientMode); } } return result; }
void ossimImageViewTransform::getScaleChangeViewToImage(ossimDpt& result, const ossimDrect& viewRect) { result.makeNan(); if(!viewRect.hasNans()) { ossimDpt iul; ossimDpt iur; ossimDpt ilr; ossimDpt ill; imageToView(viewRect.ul(), iul); imageToView(viewRect.ur(), iur); imageToView(viewRect.lr(), ilr); imageToView(viewRect.ll(), ill); if(!iul.hasNans()&& !iur.hasNans()&& !ilr.hasNans()&& !ill.hasNans()) { double deltaTop = (iul - iur).length(); double deltaBottom = (ill - ilr).length(); double deltaRight = (iur - ilr).length(); double w = viewRect.width(); double h = viewRect.height(); result.x = (deltaTop/w + deltaBottom/w)*.5; result.y = (deltaRight/h + deltaRight/h)*.5; } } }
void ossimImageViewTransform::getScaleChangeImageToView(ossimDpt& result, const ossimDrect& imageRect) { result.makeNan(); if(!imageRect.hasNans()) { ossimDpt vul; ossimDpt vur; ossimDpt vlr; ossimDpt vll; imageToView(imageRect.ul(), vul); imageToView(imageRect.ur(), vur); imageToView(imageRect.lr(), vlr); imageToView(imageRect.ll(), vll); if(!vul.hasNans()&& !vur.hasNans()&& !vlr.hasNans()&& !vll.hasNans()) { double deltaTop = (vul - vur).length(); double deltaBottom = (vll - vlr).length(); double deltaRight = (vur - vlr).length(); double w = imageRect.width(); double h = imageRect.height(); result.x = (deltaTop/w + deltaBottom/w)*.5; result.y = (deltaRight/h + deltaRight/h)*.5; } } }
void ossimFgdcXmlDoc::getBoundingBox(ossimDrect& rect) const { rect.makeNan(); if (isOpen()) { double ll_lat = 0.0; double ll_lon = 0.0; double lr_lat = 0.0; double lr_lon = 0.0; double ul_lat = 0.0; double ul_lon = 0.0; double ur_lat = 0.0; double ur_lon = 0.0; ossimString xpath = "/metadata/idinfo/spdom/lboundng/leftbc"; bool result = getPath(xpath, ul_lon); if (!result) { xpath = "/metadata/idinfo/spdom/bounding/westbc"; result = getPath(xpath, ul_lon); m_boundInDegree = true; } if (result) { ll_lon = ul_lon; } xpath = "/metadata/idinfo/spdom/lboundng/rightbc"; result = getPath(xpath, ur_lon); if (!result) { xpath = "/metadata/idinfo/spdom/bounding/eastbc"; result = getPath(xpath, ur_lon); m_boundInDegree = true; } if (result) { lr_lon = ur_lon; } xpath = "/metadata/idinfo/spdom/lboundng/bottombc"; result = getPath(xpath, ll_lat); if (!result) { xpath = "/metadata/idinfo/spdom/bounding/southbc"; result = getPath(xpath, ll_lat); m_boundInDegree = true; } if (result) { lr_lat = ll_lat; } xpath = "/metadata/idinfo/spdom/lboundng/topbc"; result = getPath(xpath, ul_lat); if (!result) { xpath = "/metadata/idinfo/spdom/bounding/northbc"; result = getPath(xpath, ul_lat); m_boundInDegree = true; } if (result) { ur_lat = ul_lat; } rect = ossimDrect(ossimDpt(ul_lon, ul_lat), ossimDpt(ur_lon, ur_lat), ossimDpt(lr_lon, lr_lat), ossimDpt(ll_lon, ll_lat), OSSIM_RIGHT_HANDED); } }
bool ossimAnnotationFontObject::intersects(const ossimDrect& rect)const { return rect.intersects(theBoundingRect); }
void ossimBuckeyeSensor::setImageRect(const ossimDrect& rect) { theImageClipRect = rect; theRefImgPt = rect.midPoint(); }
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; } }
void ossimSpectraboticsRedEdgeModel::setImageRect(const ossimDrect& rect) { theImageClipRect = rect; theRefImgPt = rect.midPoint(); }
void ossimApplanixUtmModel::setImageRect(const ossimDrect& rect) { theImageClipRect = rect; theRefImgPt = rect.midPoint(); }
void ossimQuadTreeWarp::getNewQuads(ossimQuadTreeWarpNode* parent, const ossimDrect& ul, const ossimDrect& ur, const ossimDrect& lr, const ossimDrect& ll, ossimQuadTreeWarpNode*& ulNode, ossimQuadTreeWarpNode*& urNode, ossimQuadTreeWarpNode*& lrNode, ossimQuadTreeWarpNode*& llNode) { ossimDpt midShift; getShift(midShift, parent, ul.lr()); ossimQuadTreeWarpVertex* midV = new ossimQuadTreeWarpVertex(ul.lr(), midShift); ulNode = new ossimQuadTreeWarpNode(ul, parent); urNode = new ossimQuadTreeWarpNode(ur, parent); lrNode = new ossimQuadTreeWarpNode(lr, parent); llNode = new ossimQuadTreeWarpNode(ll, parent); midV->addSharedNode(ulNode); midV->addSharedNode(urNode); midV->addSharedNode(lrNode); midV->addSharedNode(llNode); // get the shared vertices first. We will add ourself // to the pointer list. when we construct // the quad nodes. Note the mid point will be shared // by all quads and will be marked as adjustable // ossimQuadTreeWarpVertex* ulSharedV = getVertex(ul.ul()); ossimQuadTreeWarpVertex* urSharedV = getVertex(ur.ur()); ossimQuadTreeWarpVertex* lrSharedV = getVertex(lr.lr()); ossimQuadTreeWarpVertex* llSharedV = getVertex(ll.ll()); if(!ulSharedV|| !urSharedV|| !lrSharedV|| !llSharedV) { ossimNotify(ossimNotifyLevel_FATAL) << "FATAL: " << "ossimQuadTreeWarp::split, can't locating shared vertices. This Shouldn't happen!!!\n"; return; } // we know that the midpoint is new and is shared by all quads // so we have 2 more to check ossimQuadTreeWarpVertex* topSharedV = getVertex(ul.ur()); ossimQuadTreeWarpVertex* bottomSharedV = getVertex(lr.ll()); ossimQuadTreeWarpVertex* leftSharedV = getVertex(ul.ll()); ossimQuadTreeWarpVertex* rightSharedV = getVertex(ur.lr()); ossimDpt tempShift; if(!topSharedV) { getShift(tempShift, parent, ul.ur()); topSharedV = new ossimQuadTreeWarpVertex(ul.ur(), tempShift); theVertexList.push_back(topSharedV); } if(!bottomSharedV) { getShift(tempShift, parent, ll.lr()); bottomSharedV = new ossimQuadTreeWarpVertex(ll.lr(), tempShift); theVertexList.push_back(bottomSharedV); } if(!leftSharedV) { getShift(tempShift, parent, ul.ll()); leftSharedV = new ossimQuadTreeWarpVertex(ul.ll(), tempShift); theVertexList.push_back(leftSharedV); } if(!rightSharedV) { getShift(tempShift, parent, ur.lr()); rightSharedV = new ossimQuadTreeWarpVertex(ur.lr(), tempShift); theVertexList.push_back(rightSharedV); } theVertexList.push_back(midV); topSharedV->addSharedNode(ulNode); topSharedV->addSharedNode(urNode); bottomSharedV->addSharedNode(llNode); bottomSharedV->addSharedNode(lrNode); leftSharedV->addSharedNode(ulNode); leftSharedV->addSharedNode(llNode); rightSharedV->addSharedNode(urNode); rightSharedV->addSharedNode(lrNode); ulSharedV->addSharedNode(ulNode); urSharedV->addSharedNode(urNode); lrSharedV->addSharedNode(lrNode); llSharedV->addSharedNode(llNode); ulNode->theUlVertex = ulSharedV; ulNode->theUrVertex = topSharedV; ulNode->theLrVertex = midV; ulNode->theLlVertex = leftSharedV; urNode->theUlVertex = topSharedV; urNode->theUrVertex = urSharedV; urNode->theLrVertex = rightSharedV; urNode->theLlVertex = midV; lrNode->theUlVertex = midV; lrNode->theUrVertex = rightSharedV; lrNode->theLrVertex = lrSharedV; lrNode->theLlVertex = bottomSharedV; llNode->theUlVertex = leftSharedV; llNode->theUrVertex = midV; llNode->theLrVertex = bottomSharedV; llNode->theLlVertex = llSharedV; }