Exemplo n.º 1
0
ossimDpt ossimRpcProjection::getMetersPerPixel() const
{
   ossimDpt result;
   
//    ossimDpt left  = ossimDpt(theSampOffset-1,
//                              theLineOffset);
//    ossimDpt right = ossimDpt(theSampOffset+1,
//                              theLineOffset);
   ossimDpt top  = ossimDpt(theSampOffset,
                            theLineOffset-1);
   ossimDpt bottom = ossimDpt(theSampOffset,
                              theLineOffset+1);
//    ossimGpt leftG;
//    ossimGpt rightG;
   ossimGpt topG;
   ossimGpt bottomG;
   
//    lineSampleToWorld(left, leftG);
//    lineSampleToWorld(right, rightG);
   lineSampleToWorld(top, topG);
   lineSampleToWorld(bottom, bottomG);
   
//    result.x = (ossimEcefPoint(leftG) - ossimEcefPoint(rightG)).magnitude()/2.0;
   result.y = (ossimEcefPoint(topG) - ossimEcefPoint(bottomG)).magnitude()/2.0;
   result.x = result.y;

   return result;
}
Exemplo n.º 2
0
ossimDrect ossimFgdcXmlDoc::getBoundingBox()
{
   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";
      vector<ossimRefPtr<ossimXmlNode> > xml_nodes;
      m_xmlDocument->findNodes(xpath, xml_nodes);
      if (xml_nodes.size() > 0)
      {
         ul_lon = xml_nodes[0]->getText().toDouble();
         ll_lon = ul_lon;
      }
      
      xpath = "/metadata/idinfo/spdom/lboundng/rightbc";
      xml_nodes.clear();
      m_xmlDocument->findNodes(xpath, xml_nodes);
      if (xml_nodes.size() > 0)
      {
         ur_lon = xml_nodes[0]->getText().toDouble();
         lr_lon = ur_lon;
      }
      
      xpath = "/metadata/idinfo/spdom/lboundng/bottombc";
      xml_nodes.clear();
      m_xmlDocument->findNodes(xpath, xml_nodes);
      if (xml_nodes.size() > 0)
      {
         ll_lat = xml_nodes[0]->getText().toDouble();
         lr_lat = ll_lat;
      }
      
      xpath = "/metadata/idinfo/spdom/lboundng/topbc";
      xml_nodes.clear();
      m_xmlDocument->findNodes(xpath, xml_nodes);
      if (xml_nodes.size() > 0)
      {
         ul_lat = xml_nodes[0]->getText().toDouble();
         ur_lat = ul_lat;
      }
      
      ossimDrect rect(ossimDpt(ul_lon, ul_lat),
                      ossimDpt(ur_lon, ur_lat),
                      ossimDpt(lr_lon, lr_lat),
                      ossimDpt(ll_lon, ll_lat), OSSIM_RIGHT_HANDED); 
      
      return rect;
   }
   
   return ossimDrect();
}
void ossimAnnotationMultiPolyObject::applyScale(double x,
        double y)
{
    for(ossim_uint32 i =0; i<theMultiPolygon.size(); ++i)
    {
        theMultiPolygon[i] *= ossimDpt(x, y);
    }

    theBoundingRect *= ossimDpt(x,y);
}
Exemplo n.º 4
0
void ossimQuadTreeWarp::setToIdentity()
{
   for(ossim_uint32 i = 0; i < theVertexList.size(); ++i)
   {
      theVertexList[i]->theDelta = ossimDpt(0,0);
   }
}
Exemplo n.º 5
0
ossimApplanixUtmModel::ossimApplanixUtmModel()
   :theOmega(0.0),
    thePhi(0.0),
    theKappa(0.0),
    theBoreSightTx(0.0),
    theBoreSightTy(0.0),
    theBoreSightTz(0.0)
{
   theCompositeMatrix          = ossimMatrix4x4::createIdentity();
   theCompositeMatrixInverse   = ossimMatrix4x4::createIdentity();
   theFocalLength              = 55.0;
   thePixelSize = ossimDpt(.009, .009);
   theEcefPlatformPosition = ossimGpt(0.0,0.0, 1000.0);
   theGSD.x = 0.1524;
   theGSD.y = 0.1524;
   theMeanGSD = 0.1524;
   theLensDistortion = new ossimMeanRadialLensDistortion;
   initAdjustableParameters();

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimApplanixUtmModel::ossimApplanixUtmModel DEBUG:" << endl;
#ifdef OSSIM_ID_ENABLED
      ossimNotify(ossimNotifyLevel_DEBUG)<< "OSSIM_ID:  " << OSSIM_ID << endl;
#endif
   }
}
Exemplo n.º 6
0
bool ossimAlphaSensorHSI::initialize( const ossimAlphaSensorSupportData& supData )
{
   bool result = true; // Currently no error checking.

   ossimDpt imageSize = supData.getImageSize();
   setImageSize(imageSize);
   setImageRect(ossimDrect(0,0,imageSize.x-1, imageSize.y-1));
   setRefImgPt(ossimDpt(imageSize.x*.5, imageSize.y*.5));
   
   setFov(supData.getFov());
   setRollBias(supData.getRollBias());
   setPitchBias(supData.getPitchBias());
   setHeadingBias(supData.getHeadingBias());
   setSlitRot(supData.getSlitRot());
   
   setRollPoly(supData.getRollPoly());
   setPitchPoly(supData.getPitchPoly());
   setHeadingPoly(supData.getHeadingPoly());
   setLonPoly(supData.getLonPoly());
   setLatPoly(supData.getLatPoly());
   setAltPoly(supData.getAltPoly());
   setScanPoly(supData.getScanPoly());

   updateModel();

   return result;
}
Exemplo n.º 7
0
   void ImageViewManipulator::wheelEvent (QWheelEvent * event, 
                                          bool& consumeEvent )
   {
      consumeEvent = false;

      switch(event->modifiers())
      {
         case Qt::ShiftModifier:
         {
            double factor = 1.0 + fabs(event->delta()/500.0);
		    
            if(event->delta() > 0)
            {
               zoomIn(factor);
            }
            else 
            {
               zoomOut(factor);
            }
            consumeEvent = true;
            break;
         }
         default:
         {
            consumeEvent = false;
            break;
         }
      }
      QPointF p = m_scrollView->mapToScene(event->pos());
      m_scrollView->emitTracking(ossimDpt(p.x(), p.y()));
   }
Exemplo n.º 8
0
bool ossimPolygon::loadState(const ossimKeywordlist& kwl,
                             const char* prefix)
{
   ossimString order = kwl.find(prefix, VERTEX_ORDER_KW);
   const char* number_vertices = kwl.find(prefix, NUMBER_VERTICES_KW);
   ossimString x,y;
   if(order=="unknown")
   {
      theOrderingType = OSSIM_VERTEX_ORDER_UNKNOWN;
   }
   else if(order =="clockwise")
   {
      theOrderingType = OSSIM_CLOCKWISE_ORDER;
   }
   else if(order =="counter_clockwise")
   {
      theOrderingType = OSSIM_COUNTERCLOCKWISE_ORDER;
   }

   theVertexList.clear();
   int vertexCount = ossimString(number_vertices).toLong();
   int i = 0;
   for(i = 0; i < vertexCount; ++i)
   {
      ossimString v = kwl.find(prefix, (ossimString("v")+ossimString::toString(i)).c_str());
      v = v.trim();

      istringstream vStream(v);
      vStream >> x >> y;
      theVertexList.push_back(ossimDpt(x.toDouble(),y.toDouble()));
   }

   return true;
}
ossimSpectraboticsRedEdgeModel::ossimSpectraboticsRedEdgeModel()
{
   m_compositeMatrix          = ossimMatrix4x4::createIdentity();
   m_compositeMatrixInverse   = ossimMatrix4x4::createIdentity();
   m_roll                     = 0.0;
   m_pitch                    = 0.0;
   m_heading                  = 0.0;
   m_focalLength              = 5.5;
   m_pixelSize = ossimDpt(0.003, 0.003);
   m_ecefPlatformPosition = ossimGpt(0.0,0.0, 1000.0);
   m_adjEcefPlatformPosition = ossimGpt(0.0,0.0, 1000.0);
   theGSD.x   = 0.076;
   theGSD.y   = 0.076;
   theMeanGSD = 0.076;
   m_fov = 48.8; // degrees
   m_lensDistortion = new ossimTangentialRadialLensDistortion();
   initAdjustableParameters();

   if (traceDebug())
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "ossimSpectraboticsRedEdgeModel::ossimSpectrabotics DEBUG:" << endl;
#ifdef OSSIM_ID_ENABLED
      ossimNotify(ossimNotifyLevel_DEBUG)<< "OSSIM_ID:  " << OSSIM_ID << endl;
#endif
   }
}
Exemplo n.º 10
0
 void ImageViewManipulator::setImageScrollView(ImageScrollView* scrollView)
 {
    m_fullResolutionScale = ossimDpt(1.0,1.0);
    m_scrollView = scrollView;
    if(m_scrollView)
    {
       m_scrollView->setMouseTracking(true);
    }
 }
Exemplo n.º 11
0
void oms::ImageModel::centerToGround(ossimGpt& gpt)const
{
   if(thePrivateData->theImageHandler.valid())
   {
      imageToGround(ossimDpt(thePrivateData->theBoundingRect.width()/2.0,
                             thePrivateData->theBoundingRect.height()/2.0),
                    gpt);
   }
}
Exemplo n.º 12
0
//*************************************************************************************************
//! Collects common code among all parsers
//*************************************************************************************************
void ossimQuickbirdRpcModel::finishConstruction()
{
   theImageSize.line = theImageClipRect.height();
   theImageSize.samp = theImageClipRect.width();
   theRefImgPt.line = theImageClipRect.midPoint().y;
   theRefImgPt.samp = theImageClipRect.midPoint().x;
   theRefGndPt.lat = theLatOffset;
   theRefGndPt.lon = theLonOffset;
   theRefGndPt.hgt = theHgtOffset;

   //---
   // NOTE:  We must call "updateModel()" to set parameter used by base
   // ossimRpcModel prior to calling lineSampleHeightToWorld or all
   // the world points will be same.
   //---
   updateModel();

   ossimGpt v0, v1, v2, v3;
   lineSampleHeightToWorld(theImageClipRect.ul(), theHgtOffset, v0);
   lineSampleHeightToWorld(theImageClipRect.ur(), theHgtOffset, v1);
   lineSampleHeightToWorld(theImageClipRect.lr(), theHgtOffset, v2);
   lineSampleHeightToWorld(theImageClipRect.ll(), theHgtOffset, v3);

   theBoundGndPolygon = ossimPolygon (ossimDpt(v0), ossimDpt(v1), ossimDpt(v2), ossimDpt(v3));

   // Set the ground reference point using the model.
   lineSampleHeightToWorld(theRefImgPt, theHgtOffset, theRefGndPt);

   if( theGSD.hasNans() )
   {
      try
      {
         // This will set theGSD and theMeanGSD. Method throws ossimException.
         computeGsd();
      }
      catch (const ossimException& e)
      {
         ossimNotify(ossimNotifyLevel_WARN)
            << "ossimQuickbirdRpcModel::finishConstruction -- caught exception:\n"
            << e.what() << std::endl;
      }
   }
}
Exemplo n.º 13
0
 void ImageViewManipulator::mouseMoveEvent ( QMouseEvent * event, 
                                             bool& consumeEvent )
 {
    QPointF pt = m_scrollView->mapToScene(event->pos());
    if(m_leftButtonPressed)
    {
       m_scrollView->emitTracking(ossimDpt(pt.x(), pt.y()));
    }
    consumeEvent = false;
 }
Exemplo n.º 14
0
   void ImageViewManipulator::initializeToCurrentView()
   {
      if(m_scrollView)
      {
         //ossimDpt center  = m_scrollView->getInputBounds().midPoint();
         //m_centerPoint = center;

         m_fullResolutionScale = ossimDpt(1.0,1.0);

         ossimTypeNameVisitor visitor("ossimImageRenderer", true);
         m_scrollView->connectableObject()->accept(visitor);


         ossimConnectableObject* connectable = dynamic_cast<ossimConnectableObject*>(visitor.getObject());
         ossimViewInterface* geomSource = connectable?dynamic_cast<ossimViewInterface*>(connectable):0;
         ossimImageSource* is = connectable?dynamic_cast<ossimImageSource*>(connectable->getInput()):0;

         if(geomSource)
         {
            if(geomSource->getView())
            {
               m_obj = (ossimObject*)(geomSource->getView()->dup());
            }
         }
         if(!is)
         {
            visitor.reset();
            visitor.setTypeName("ossimImageHandler");
            m_scrollView->connectableObject()->accept(visitor);
            is = dynamic_cast<ossimImageSource*>(visitor.getObject());
         }
         bool affineFlag = isAffine();
         if(is)
         {
            ossim_uint32 nLevels = is->getNumberOfDecimationLevels();
            nLevels = nLevels?nLevels:1;
            ossim_float64 nLevelsPower2 = 1<<(nLevels-1);
            ossim_float64 zoomInFactor  = 1<<7;
            ossimRefPtr<ossimImageGeometry> geom = is->getImageGeometry();
            if(!affineFlag&&geom.valid()&&geom->getProjection())
            {
               m_fullResolutionScale = geom->getMetersPerPixel();
               m_fullResolutionScale.x = m_fullResolutionScale.y;
               m_scaleRange.m_min = m_fullResolutionScale.y*(1.0/zoomInFactor);
               m_scaleRange.m_max = m_fullResolutionScale.y*nLevelsPower2;
            }
            else
            {
               m_scaleRange.m_min =1.0/nLevelsPower2;
               m_scaleRange.m_max = zoomInFactor;
            }
         }
         setCommonCenter();
      }
   }
Exemplo n.º 15
0
ossimDrect shapefileClip::LineSampleToWorld(ossimIrect rect, ossimRefPtr<ossimImageGeometry> ImageGeom)
{
	ossimGpt gp1;
	ossimGpt gp2;
	ossimGpt gp3;
	ossimGpt gp4;

	ImageGeom->localToWorld(rect.ul(), gp1);
	ImageGeom->localToWorld(rect.ur(), gp2);
	ImageGeom->localToWorld(rect.lr(), gp3);
	ImageGeom->localToWorld(rect.ll(), gp4);
   
	ossimDrect boundsRect(ossimDpt(gp1.lond(), gp1.latd()),
		ossimDpt(gp2.lond(), gp2.latd()),
		ossimDpt(gp3.lond(), gp3.latd()),	
		ossimDpt(gp4.lond(), gp4.latd()),
		OSSIM_RIGHT_HANDED);

	return boundsRect;
}
Exemplo n.º 16
0
ossimGui::ImageScrollWidget::ImageScrollWidget(QWidget* parent)
:QScrollArea(parent),
m_listener(new ConnectionListener(this)),
m_jobQueue(new DisplayTimerJobQueue())
{
   m_trackPoint.makeNan();
   m_oldTrackPoint.makeNan();
   m_trackingFlag = true;
   m_mouseInsideFlag = false;
   
   m_layers = new Layers();
   //m_connector->addListener(m_listener);
   m_widget = new ImageWidget(this, viewport());
   //m_widget->setAttribute(Qt::WA_StaticContents);
   m_widget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
   // setWidget(m_widget);
   setWidgetResizable(false);
   m_widget->show();
   m_trackingFlag = true;
   m_scrollOrigin = ossimDpt(0.0,0.0);
   m_tileSize = ossimIpt(64,64);
   //m_widget->setTileCache(new StaticTileImageCache(m_tileSize));
   m_timerId = -1;
   viewport()->setCursor(Qt::CrossCursor);
   m_imageWidgetJob = new ImageWidgetJob();//this);
   m_imageWidgetJob->setCallback(new Callback(this));
   
 //  m_multiLayerAlgorithm = HORIZONTAL_SWIPE_ALGORITHM;
 //  m_multiLayerAlgorithm = VERTICAL_SWIPE_ALGORITHM;
 //  m_multiLayerAlgorithm = BOX_SWIPE_ALGORITHM;
   m_multiLayerAlgorithm = CIRCLE_SWIPE_ALGORITHM;


   // Initialize drawing control
   m_drawPts = false;
   // m_regOverlay = new RegistrationOverlay();

   ///????????????
   // m_scene = new QGraphicsScene(0,0,500,400,this);
   // m_view = new QGraphicsView(this);
   // m_view->setScene(m_scene);
   // m_view->setStyleSheet("background: transparent");

   // QGraphicsRectItem* rect = m_scene->addRect(50,40,100,200);
   // rect->setFlags(QGraphicsItem::ItemIsMovable);
   // rect->setBrush(QBrush(Qt::blue));
   // rect->setOpacity(0.3);

   // QGraphicsItem* item = m_scene->addText("QGraphicsTextItem");
   // item->setFlags(QGraphicsItem::ItemIsMovable);

   // m_view->show();

}
Exemplo n.º 17
0
   void ImageViewManipulator::mouseReleaseEvent (QMouseEvent* event, 
                                                 bool& consumeEvent )
   {

      QPointF pt = m_scrollView->mapToScene(event->pos());
		
      if(m_scrollView	&& m_leftButtonPressed)
      {
         if(event->modifiers()&Qt::ShiftModifier)
         {
            m_centerPoint = sceneToLocal(ossimDpt(pt.x(), pt.y()));
            m_scrollView->centerOn(pt);
         }
         m_leftButtonPressed = false;
         m_scrollView->emitTracking(ossimDpt(pt.x(), pt.y()));

      } 

      consumeEvent = false;
   }
Exemplo n.º 18
0
ossimBuckeyeSensor::ossimBuckeyeSensor()
{
	if (traceDebug())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(): entering..." << std::endl;

	theCompositeMatrix			= ossimMatrix4x4::createIdentity();
	theCompositeMatrixInverse	= ossimMatrix4x4::createIdentity();
	theRoll						= 0.0;
	thePitch					= 0.0;
	theHeading					= 0.0;
	theFocalLength				= 195.1000;
	thePixelSize				= ossimDpt(.006, .006);
	thePrincipalPoint			= ossimDpt(0, 0);
	theEcefPlatformPosition		= ossimGpt(0.0,0.0, 1000.0);
	theAdjEcefPlatformPosition	= ossimGpt(0.0,0.0, 1000.0);
	theLensDistortion			= new ossimSmacCallibrationSystem();

	theGSD.makeNan();
	initAdjustableParameters();

	if (traceDebug())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(): returning..." << std::endl;
}
Exemplo n.º 19
0
ossimDpt ossimQuadTreeWarp::getOrigin()const
{
   if(!isEmpty())
   {
      if(!theTree->theBoundingRect.hasNans())
      {
         return theTree->theBoundingRect.midPoint();
      }
      
   }
   
   return ossimDpt(0,0);
}
Exemplo n.º 20
0
 void ImageViewManipulator::setObject(ossimObject* obj)
 {
    m_obj = obj;	
    ossimImageViewTransform* ivt = getObjectAs<ossimImageViewTransform>();
    if(ivt)
    {
       m_fullResolutionScale = ivt->getInputMetersPerPixel();
    }
    if(m_fullResolutionScale.hasNans())
    {
       m_fullResolutionScale = ossimDpt(1.0,1.0);
    }
 }
Exemplo n.º 21
0
   void ImageViewManipulator::mousePressEvent (QMouseEvent* event,
                                               bool& consumeEvent)
   {
      m_leftButtonPressed = false;
      if(event->buttons() & Qt::LeftButton)
      {
         m_leftButtonPressed = true;
      }
      consumeEvent = false;
      if(m_leftButtonPressed)
      {
         QPointF p = m_scrollView->mapToScene(event->pos());
         m_scrollView->emitTracking(ossimDpt(p.x(), p.y()));
      }
		
   }
void ossimAnnotationMultiLineObject::applyScale(double x,
                                                double y)
{
   for(ossim_uint32 i=0; i < thePolyLineList.size(); ++i)
   {
      vector<ossimDpt>& vList = thePolyLineList[i].getVertexList();
      
      for(ossim_uint32 i2 = 0; i2 < vList.size(); ++i2)
      {
         vList[i].x *= x;
         vList[i].y *= y;
         vList[i].x *= x;
         vList[i].y *= y;
      }
   }
   theBoundingRect *= ossimDpt(x, y);
}
void ossimGeographicAnnotationGrid::computeBoundingRect()
{
   static const char* MODULE = "ossimGeographicAnnotationGrid::computeBoundingRect";
   
   if(theViewProjection.valid())
   {
      vector<ossimDpt> points(4);

      theViewProjection->worldToLineSample(theGroundRect.ul(), points[0]);
      theViewProjection->worldToLineSample(theGroundRect.ll(), points[1]);
      theViewProjection->worldToLineSample(theGroundRect.lr(), points[2]);
      theViewProjection->worldToLineSample(theGroundRect.ur(), points[3]);

      // now solve the bounding rect in view space.
      theBoundingRect = ossimDrect(points);

      // for now we will add a border for the labelling
      // of lat lon readouts.  We need a better border
      // computation that checks exactly what we need
      // based on font sizes.
      //
      ossimDpt ul = theBoundingRect.ul();
      ossimDpt lr = theBoundingRect.lr();

      
      ossimRefPtr<ossimAnnotationGdBitmapFont> font = new ossimAnnotationGdBitmapFont();;
      font->setCenterText(ossimDpt(0,0),"[email protected]'ss.ssssC");
      ossimDrect boundingRect;
      font->getBoundingRect(boundingRect);
      font = 0;
      
      theBoundingRect = ossimDrect(ul.x - boundingRect.width(),
                                   ul.y - boundingRect.height(),
                                   lr.x + boundingRect.width(),
                                   lr.y + boundingRect.height());

      if(traceDebug())
      {
         CLOG << " bounding rect: " << theBoundingRect << endl;
      }
   }
}
ossimDpt ossimVanDerGrintenProjection::forward(const ossimGpt &latLon)const
{
   double easting  = 0.0;
   double northing = 0.0;
   ossimGpt gpt = latLon;
   
   if (theDatum)
   {
      if (theDatum->code() != latLon.datum()->code())
      {
         gpt.changeDatum(theDatum); // Shift to our datum.
      }
   }

   Convert_Geodetic_To_Van_der_Grinten(gpt.latr(),
                                       gpt.lonr(),
                                       &easting,
                                       &northing);
   return ossimDpt(easting, northing);
}
Exemplo n.º 25
0
ossimGpt ossimGeoPolygon::computeCentroid()const
{
   if(!size())
   {
      return ossimGpt();
   }
   ossimDpt average(0.0,0.0);
   double height=0.0;
   for(ossim_uint32 i = 0; i < size(); ++i)
   {
      average += ossimDpt(theVertexList[i]);
      height  += theVertexList[i].height();
   }

   
   average.x /= size();
   average.y /= size();
   height    /= size();

   return ossimGpt(average.y, average.x, height, theVertexList[0].datum());
}
ossimDpt ossimTransCylEquAreaProjection::forward(const ossimGpt &latLon)const
{
   double easting  = 0.0;
   double northing = 0.0;
   ossimGpt gpt = latLon;
   
   if (theDatum)
   {
      if (theDatum->code() != latLon.datum()->code())
      {
         gpt.changeDatum(theDatum); // Shift to our datum.
      }
   }

   Convert_Geodetic_To_Trans_Cyl_Eq_Area(gpt.latr(),
                                         gpt.lonr(),
                                         &easting,
                                         &northing);
   
   return ossimDpt(easting, northing);
}
Exemplo n.º 27
0
void ossimGui::ImageScrollWidget::paintWidget(QPainter& painter)
{
   if((m_layers->numberOfLayers() > 1)&&(m_multiLayerAlgorithm!=NO_ALGORITHM))
   {
      paintMultiLayer(painter);
   }
   else 
   {
      ossimRefPtr<Layer> topLayer    = m_layers->layer((ossim_uint32)0);
      if(topLayer.valid())
      {
         ossimRefPtr<StaticTileImageCache> topTileCache = topLayer->tileCache();
         if(topTileCache.valid())
         {
            ossimIrect rect          = topTileCache->getRect();
            QRectF rectF = m_scrollToLocal.mapRect(QRectF(rect.ul().x, rect.ul().y, rect.width(), rect.height()));
            
            ossimIpt topOriginOffset = ossimDpt(rectF.x(), rectF.y());
            painter.drawImage(topOriginOffset.x, topOriginOffset.y, topTileCache->getCache());
         }
      }
   }
   if(!m_trackPoint.hasNans()&&m_trackingFlag&&!m_mouseInsideFlag)
   {
      drawCursor(painter);
   }


   // Temporary marker control
   // if (m_drawPts == true)
   // {
   //    m_regOverlay->drawMeas(painter, m_viewToLocal);
   // }
   // m_regOverlay->drawProj(painter, m_viewToLocal);

}
Exemplo n.º 28
0
void oms::Mosaic::setupOrthoThumbnail(const std::string& filename,
                                      const std::string& entryId,
                                      const std::string& srsCode,
                                      ossim_uint32 resolution,
                                      const std::string& histogramAutoStretchModeType)
{
    thePrivateData->clear();
    std::string id = addInputFile(filename, entryId);
    if(id.empty())
    {
        return;
    }
    if(srsCode.empty())
    {
        ossimRefPtr<ossimImageGeometry> geom = thePrivateData->theImageChainList[0]->theHandler->getImageGeometry();
        if(geom.valid())
        {
            if(!dynamic_cast<ossimMapProjection*>(geom->getProjection()))
            {
                ossimIrect rect = thePrivateData->theImageChainList[0]->theHandler->getBoundingRect();
                if(!rect.hasNans())
                {
                    ossimGpt midPoint;
                    geom->localToWorld(rect.midPoint(), midPoint);
                    ossimMapProjection* mapProj = new ossimEquDistCylProjection();
                    mapProj->setMetersPerPixel(geom->getMetersPerPixel());
                    mapProj->setOrigin(midPoint);
                    thePrivateData->theViewGeometry = new ossimImageGeometry(0, mapProj);
                }
            }
            else
            {
                thePrivateData->theViewGeometry = (ossimImageGeometry*)geom->dup();
            }
        }
    }
    else
    {
        ossimRefPtr<ossimProjection> proj = ossimProjectionFactoryRegistry::instance()->createProjection(srsCode);
        thePrivateData->theViewGeometry = new ossimImageGeometry(0, proj.get());
    }
    if(!thePrivateData->theViewGeometry.valid())
    {
        return;
    }
    thePrivateData->theImageChainList[0]->theBandSelector = new ossimBandSelector;
    thePrivateData->theImageChainList[0]->theBandSelector->connectMyInputTo(0, thePrivateData->theImageChainList[0]->theHandler.get());

    thePrivateData->theImageChainList[0]->theHistogramRemapper = new ossimHistogramRemapper;
    thePrivateData->theImageChainList[0]->theHistogramRemapper->connectMyInputTo(0, thePrivateData->theImageChainList[0]->theBandSelector.get());

    if(!histogramAutoStretchModeType.empty())
    {
        if(thePrivateData->theImageChainList[0]->theHistogramRemapper->openHistogram(thePrivateData->theImageChainList[0]->theHandler->createDefaultHistogramFilename()))
        {
            thePrivateData->theImageChainList[0]->theHistogramRemapper->setStretchModeAsString(histogramAutoStretchModeType);
        }
    }
    thePrivateData->theImageChainList[0]->theReprojection = new ossimImageRenderer;
    thePrivateData->theImageChainList[0]->theReprojection->setView(thePrivateData->theViewGeometry.get());
    thePrivateData->theImageChainList[0]->theReprojection->connectMyInputTo(0, thePrivateData->theImageChainList[0]->theHistogramRemapper.get());

    ossimIrect bounds = thePrivateData->theImageChainList[0]->theReprojection->getBoundingRect();

    ossim_uint32 maxRes = ossim::max(bounds.width(), bounds.height());
    if(maxRes > resolution)
    {
        double scale = 0.0;

        if(resolution > 1)
        {
            scale = (double)maxRes/(double)(resolution-1);
        }
        else
        {
            scale = (double)maxRes/(double)(resolution);
        }
        ossimMapProjection* mapProj = dynamic_cast<ossimMapProjection*>(thePrivateData->theViewGeometry->getProjection());
        if(mapProj)
        {
            mapProj->applyScale(ossimDpt(scale,scale), true);
            thePrivateData->theImageChainList[0]->theReprojection->setView(thePrivateData->theViewGeometry.get());
        }
        else
        {
            return;
        }
    }
    thePrivateData->theMosaic->connectMyInputTo(thePrivateData->theImageChainList[0]->theReprojection.get());
    bounds = thePrivateData->theMosaic->getBoundingRect();
}
Exemplo n.º 29
0
void ossimNitfProjectionFactory::parseUtmString(const ossimString& utmLocation,
                                                ossim_uint32& zone,
                                                std::vector<ossimDpt>& utmPoints)const
{
   ossim_uint32 idx = 0;
   ossimString z;
   ossimString east;
   ossimString north;

   
   z    = ossimString(utmLocation.begin() + idx,
                   utmLocation.begin() + idx + 2);
   idx += 2;
   east = ossimString(utmLocation.begin() + idx,
                      utmLocation.begin() + idx + 6);
   idx += 6;
   north = ossimString(utmLocation.begin() + idx,
                       utmLocation.begin() + idx + 7);
   idx += 7;

   utmPoints.push_back(ossimDpt(east.toDouble(),
                                north.toDouble()));
   
   z    = ossimString(utmLocation.begin() + idx,
                   utmLocation.begin() + idx + 2);
   idx += 2;
   east = ossimString(utmLocation.begin() + idx,
                      utmLocation.begin() + idx + 6);
   idx += 6;
   north = ossimString(utmLocation.begin() + idx,
                       utmLocation.begin() + idx + 7);
   idx += 7;
   utmPoints.push_back(ossimDpt(east.toDouble(),
                                north.toDouble()));

   z    = ossimString(utmLocation.begin() + idx,
                   utmLocation.begin() + idx + 2);
   idx += 2;
   east = ossimString(utmLocation.begin() + idx,
                      utmLocation.begin() + idx + 6);
   idx += 6;
   north = ossimString(utmLocation.begin() + idx,
                       utmLocation.begin() + idx + 7);
   idx += 7;
   utmPoints.push_back(ossimDpt(east.toDouble(),
                                north.toDouble()));

   z    = ossimString(utmLocation.begin() + idx,
                   utmLocation.begin() + idx + 2);
   idx += 2;
   east = ossimString(utmLocation.begin() + idx,
                      utmLocation.begin() + idx + 6);
   idx += 6;
   north = ossimString(utmLocation.begin() + idx,
                       utmLocation.begin() + idx + 7);
   idx += 7;
   utmPoints.push_back(ossimDpt(east.toDouble(),
                                north.toDouble()));

   zone = z.toUInt32();
}
Exemplo n.º 30
0
//*******************************************************************
// Public method:
//*******************************************************************
ossimRefPtr<ossimImageGeometry> ossimAdrgTileSource::getImageGeometry()
{
   if ( !theGeometry )
   {
      // Check for external geom:
      theGeometry = getExternalImageGeometry();
      
      if ( !theGeometry )
      {
         // origin of latitude
         ossim_float64 originLatitude = (m_AdrgHeader->maxLatitude() +
                                         m_AdrgHeader->minLatitude()) / 2.0;
         
         // central meridian.
         ossim_float64 centralMeridian = (m_AdrgHeader->maxLongitude() +
                                          m_AdrgHeader->minLongitude()) / 2.0;
         
         //---
         // Compute the pixel size in latitude and longitude direction.  This will
         // be full image extents divided by full image lines and samples.
         //---
         
         // Samples in full image (used to compute degPerPixelX).
         ossim_float64 samples = m_AdrgHeader->samples();
         
         // Lines in full image (used to compute degPerPixelX).
         ossim_float64 lines = m_AdrgHeader->lines();
         
         // Degrees in latitude direction of the full image.
         ossim_float64 degrees_in_lat_dir = m_AdrgHeader->maxLatitude() -
            m_AdrgHeader->minLatitude();
         
         // Degrees in longitude direction of the full image.
         ossim_float64 degrees_in_lon_dir = m_AdrgHeader->maxLongitude() -
            m_AdrgHeader->minLongitude();
         
         ossim_float64 degPerPixelY = degrees_in_lat_dir / lines;
         ossim_float64 degPerPixelX = degrees_in_lon_dir / samples;
         
         //---
         // The tie is determined with the following assumptions that need to be
         // verified:
         // 1) Rows and columns start at 1.
         // 2) The min / max latitudes longitudes go to the edge of the pixel.
         // 3) Latitude decreases by degPerPixelY with each line.
         // 4) Longitude increases by degPerPixelX with each sample.
         //---
         ossim_float64 ul_lat = (m_AdrgHeader->maxLatitude() - 
                                 ( (m_AdrgHeader->startRow() - 1) *
                                   degPerPixelY ) - ( degPerPixelY * 0.5 ) );
         ossim_float64 ul_lon = (m_AdrgHeader->minLongitude() +
                                 ( (m_AdrgHeader->startCol() -1) *
                                   degPerPixelX ) +  ( degPerPixelX * 0.5 ) );
         
         // projection type
         ossimKeywordlist kwl;
         const char* prefix = 0;
         kwl.add(prefix,
                 ossimKeywordNames::TYPE_KW,
                 "ossimEquDistCylProjection",
                 true);
         
         // datum.
         kwl.add(prefix,
                 ossimKeywordNames::DATUM_KW,
                 "WGE",
                 true);
         
         // origin latitude
         kwl.add(prefix,
                 ossimKeywordNames::ORIGIN_LATITUDE_KW,
                 originLatitude,
                 true);

         // central meridin
         kwl.add(prefix,
                 ossimKeywordNames::CENTRAL_MERIDIAN_KW,
                 centralMeridian,
                 true);

         // Save the tie point.
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_XY_KW,
                 ossimDpt(ul_lon, ul_lat).toString().c_str(),
                 true);
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_UNITS_KW,
                 ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES),
                 true);

         // Save the scale.
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_LAT_KW,
                 ul_lat,
                 true);
   
         kwl.add(prefix,
                 ossimKeywordNames::TIE_POINT_LON_KW,
                 ul_lon,
                 true);

         // Save the scale.
         kwl.add(prefix,
                 ossimKeywordNames::PIXEL_SCALE_XY_KW,
                 ossimDpt(degPerPixelX, degPerPixelY).toString().c_str(),
                 true);
         kwl.add(prefix,
                 ossimKeywordNames::PIXEL_SCALE_UNITS_KW,
                 ossimUnitTypeLut::instance()->getEntryString(OSSIM_DEGREES),
                 true);  

         // lines
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_LINES_KW,
                 getNumberOfLines());

         // samples
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_SAMPLES_KW,
                 getNumberOfSamples());

         // res sets
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_REDUCED_RES_SETS_KW,
                 getNumberOfDecimationLevels());

         // bands
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_INPUT_BANDS_KW,
                 getNumberOfInputBands());

         // bands
         kwl.add(prefix,
                 ossimKeywordNames::NUMBER_OUTPUT_BANDS_KW,
                 getNumberOfOutputBands());
   
         if (traceDebug())
         {
            ossimNotify(ossimNotifyLevel_DEBUG)
               << "\nminLon:             " << m_AdrgHeader->minLon()
               << "\nminLond:            " << m_AdrgHeader->minLongitude() 
               << "\nminLat:             " << m_AdrgHeader->minLat()
               << "\nminLatd:            " << m_AdrgHeader->minLatitude()
               << "\nmaxLon:             " << m_AdrgHeader->maxLon()
               << "\nmaxLond:            " << m_AdrgHeader->maxLongitude()
               << "\nmaxLat:             " << m_AdrgHeader->maxLat()
               << "\nmaxLatd:            " << m_AdrgHeader->maxLatitude()
               << "\nstartRow:           " << m_AdrgHeader->startRow()
               << "\nstartCol:           " << m_AdrgHeader->startCol()
               << "\nstopRow:            " << m_AdrgHeader->stopRow()
               << "\nstopCol:            " << m_AdrgHeader->stopCol()
               << "\nfull image lines:   " << lines
               << "\nfull image samples: " << samples
               << "\nkwl:\n"               << kwl
               << std::endl;
         }

         ossimProjection* new_proj = ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
         theGeometry = new ossimImageGeometry;
         theGeometry->setProjection(new_proj);  // assumes management of projection instance
         
      } // matches (after getExternalImageGeometry()):  if ( !theGeometry ) 
      
      // Set image things the geometry object should know about.
      initImageParameters( theGeometry.get() );
      
   } // matches: if ( !theGeometry )

   return theGeometry;
}