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


C++ RasterElement::isGeoreferenced方法代码示例

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


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

示例1: accept

void ChippingWindow::accept()
{
   // Check if the original data set has been georeferenced
   if (mpView != NULL)
   {
      RasterElement* pRaster = getRasterElement();
      VERIFYNRV(pRaster != NULL);

      // Display a warning if the data set has not been georeferenced
      if (pRaster->isGeoreferenced() == false)
      {
         QString strMessage = "The parent data set is not georeferenced so the created chip will not "
            "contain a GCP List.\nIf you want to preserve geographic info, press Cancel, cancel the "
            "chipping dialog,\ngeoreference the parent data set, and then create a new chip.";
         int iReturn = QMessageBox::warning(this, windowTitle(), strMessage, "Continue", "Cancel");
         if (iReturn == 1)
         {
            return;
         }
      }
   }

   // Create the chip
   if (mpFileRadio->isChecked() == true)
   {
      createFile();
   }
   else if (mpWindowRadio->isChecked() == true)
   {
      createView();
   }

   // Close the dialog
   QDialog::accept();
}
开发者ID:wzssyqa,项目名称:opticks-cmake,代码行数:35,代码来源:ChippingWindow.cpp

示例2: updateGeoreferenceAttachment

void MeasurementObjectImp::updateGeoreferenceAttachment()
{
   if (mpGeoreference.get() != NULL)
   {
      return;
   }

   RasterElement* pGeoreference = NULL;

   // Must find Georeference through the view, since the GraphicElement is a root element.
   GraphicLayer* pLayer = getLayer();
   if (pLayer != NULL)
   {
      SpatialDataView* pView = dynamic_cast<SpatialDataView*>(pLayer->getView());
      if (pView != NULL)
      {
         LayerList* pLayerList = pView->getLayerList();
         VERIFYNRV(pLayerList != NULL);
         pGeoreference = pLayerList->getPrimaryRasterElement();
      }
   }

   if (pGeoreference != NULL && pGeoreference->isGeoreferenced())
   {
      mpGeoreference.reset(pGeoreference);
      enableGeo();
      generateGeoStrings();
   }
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:29,代码来源:MeasurementObjectImp.cpp

示例3: addView

bool Kml::addView(const SpatialDataView* pView)
{
   if (pView == NULL)
   {
      return false;
   }
   // ensure we are georeferenced
   RasterElement* pElement = static_cast<RasterElement*>(pView->getLayerList()->getPrimaryRasterElement());
   VERIFY(pElement);
   if (!pElement->isGeoreferenced())
   {
      if (mpProgress != NULL)
      {
         mpProgress->updateProgress("The " + pView->getDisplayName(true) +
            " view does not have georeference information and will not be exported.", 0, ERRORS);
      }
      return false;
   }
   Layer* pPrimaryLayer = pView->getLayerList()->getLayer(RASTER, pElement);
   mXml.pushAddPoint(mXml.addElement("Folder"));
   string name = pView->getDisplayName();
   if (name.empty())
   {
      name = pView->getName();
   }
   mXml.addText(name, mXml.addElement("name"));
   mXml.addText(pView->getDisplayText(), mXml.addElement("description"));

   bool success = false;
   vector<Layer*> layers;
   pView->getLayerList()->getLayers(layers);
   int totalLayers = static_cast<int>(pView->getLayerList()->getNumLayers());
   for (vector<Layer*>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
   {
      if (!pView->isLayerDisplayed(*layer))
      {
         continue;
      }
      if (addLayer(*layer, pPrimaryLayer, pView, totalLayers))
      {
         success = true;
      }
   }
   mXml.popAddPoint(); // Folder

   return success;
}
开发者ID:Tom-VdE,项目名称:opticks,代码行数:47,代码来源:Kml.cpp

示例4: getGeoreferencedRaster

RasterElement* ResultsExporter::getGeoreferencedRaster() const
{
    if (mpResults == NULL)
    {
        return NULL;
    }

    // First check if this RasterElement is georeferenced
    if (mpResults->isGeoreferenced())
    {
        return mpResults;
    }
    // Next, assume this is a "Results matrix" and check the parent
    RasterElement* pParent = dynamic_cast<RasterElement*>(mpResults->getParent());
    if (pParent != NULL && pParent->isGeoreferenced())
    {
        return pParent;
    }
    // Finally, give up...there's no geodata
    return NULL;
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例5: orient

void EastArrowObjectImp::orient()
{
   if (isOriented() == true)
   {
      return;
   }

   GraphicLayer* pLayer = NULL;
   pLayer = getLayer();
   if (pLayer == NULL)
   {
      return;
   }

   View* pView = NULL;
   pView = pLayer->getView();
   if (pView == NULL)
   {
      return;
   }

   SpatialDataView* pSpatialDataView = NULL;
   if (pView->isKindOf("SpatialDataView") == true)
   {
      pSpatialDataView = static_cast<SpatialDataView*> (pView);
   }
   else if (pView->isKindOf("ProductView") == true)
   {
      ProductView* pProductView = static_cast<ProductView*> (pView);

      GraphicLayer* pLayoutLayer = NULL;
      pLayoutLayer = pProductView->getLayoutLayer();
      if (pLayoutLayer == pLayer)
      {
         list<GraphicObject*> viewObjects;
         pLayoutLayer->getObjects(VIEW_OBJECT, viewObjects);

         list<GraphicObject*>::iterator iter = viewObjects.begin();
         while (iter != viewObjects.end())
         {
            GraphicObject* pObject = *iter;
            if (pObject != NULL)
            {
               View* pObjectView = pObject->getObjectView();
               if (pObjectView != NULL)
               {
                  if (pObjectView->isKindOf("SpatialDataView") == true)
                  {
                     pSpatialDataView = static_cast<SpatialDataView*> (pObjectView);
                  }
               }
            }

            ++iter;
         }
      }
   }

   if (pSpatialDataView == NULL)
   {
      return;
   }

   LayerList* pLayerList = pSpatialDataView->getLayerList();
   VERIFYNRV(pLayerList != NULL);
   RasterElement* pRaster = pLayerList->getPrimaryRasterElement();
   VERIFYNRV(pRaster != NULL);
   if (!pRaster->isGeoreferenced())
   {
      return;
   }

   // Calculate the angle of the object relative to the pixel coordinates
   updateHandles();

   LocationType pixelStart = mHandles[7];

   ProductView* pProductView = dynamic_cast<ProductView*> (pView);
   if (pProductView != NULL)
   {
      // Convert to the screen coordinate system
      double dScreenX = 0;
      double dScreenY = 0;
      pLayer->translateDataToWorld(pixelStart.mX, pixelStart.mY, pixelStart.mX, pixelStart.mY);
      pProductView->translateWorldToScreen(pixelStart.mX, pixelStart.mY, dScreenX, dScreenY);
      
      // Convert to the spatial data view coordinate system
      pSpatialDataView->translateScreenToWorld(dScreenX,
         dScreenY, pixelStart.mX, pixelStart.mY);
      pLayer->translateWorldToData(pixelStart.mX, pixelStart.mY, pixelStart.mX, pixelStart.mY);
   }

   double dAngle;
   if (GeoAlgorithms::getAngleToNorth(pRaster, dAngle, pixelStart) == false)
   {
      return;
   }

   // Update the angle if the object is in the layout layer
   if (pProductView != NULL)
//.........这里部分代码省略.........
开发者ID:wzssyqa,项目名称:opticks-cmake,代码行数:101,代码来源:EastArrowObjectImp.cpp

示例6: createView


//.........这里部分代码省略.........
                  }

                  if (newBand.isValid() == false)
                  {
                     bandCopied = false;
                     newBand = pDescriptor->getBands().front();
                  }

                  // No need to explicitly set the RasterElement here since the new view only has one RasterElement.
                  pLayer->setDisplayedBand(*iter, newBand);

                  // Use the default stretch properties if the displayed band was removed from the view or
                  // if the non-primary raster element was displayed. Otherwise, copy the stretch properties.
                  if (bandCopied && pRaster == pOrigLayer->getDisplayedRasterElement(*iter))
                  {
                     // Set the stretch units first so that stretch values are interpreted correctly.
                     pLayer->setStretchUnits(*iter, pOrigLayer->getStretchUnits(*iter));

                     double lower;
                     double upper;
                     pOrigLayer->getStretchValues(*iter, lower, upper);
                     pLayer->setStretchValues(*iter, lower, upper);
                  }
               }

               pLayer->setCurrentStretchAsOriginalStretch();
               pView->refresh();
            }
         }
      }
   }

   // Create a GCP layer
   if (pRaster->isGeoreferenced() == true)
   {
      const vector<DimensionDescriptor>& rows = mpChippingWidget->getChipRows();
      const vector<DimensionDescriptor>& columns = mpChippingWidget->getChipColumns();
      if ((rows.empty() == false) && (columns.empty() == false))
      {
         // Get the geocoordinates at the chip corners
         VERIFYNRV(rows.front().isActiveNumberValid() == true);
         VERIFYNRV(rows.back().isActiveNumberValid() == true);
         VERIFYNRV(columns.front().isActiveNumberValid() == true);
         VERIFYNRV(columns.back().isActiveNumberValid() == true);

         unsigned int startRow = rows.front().getActiveNumber();
         unsigned int endRow = rows.back().getActiveNumber();
         unsigned int startCol = columns.front().getActiveNumber();
         unsigned int endCol = columns.back().getActiveNumber();

         GcpPoint ulPoint;
         ulPoint.mPixel = LocationType(startCol, startRow);
         ulPoint.mCoordinate = pRaster->convertPixelToGeocoord(ulPoint.mPixel);

         GcpPoint urPoint;
         urPoint.mPixel = LocationType(endCol, startRow);
         urPoint.mCoordinate = pRaster->convertPixelToGeocoord(urPoint.mPixel);

         GcpPoint llPoint;
         llPoint.mPixel = LocationType(startCol, endRow);
         llPoint.mCoordinate = pRaster->convertPixelToGeocoord(llPoint.mPixel);

         GcpPoint lrPoint;
         lrPoint.mPixel = LocationType(endCol, endRow);
         lrPoint.mCoordinate = pRaster->convertPixelToGeocoord(lrPoint.mPixel);
开发者ID:wzssyqa,项目名称:opticks-cmake,代码行数:66,代码来源:ChippingWindow.cpp

示例7: operator

void GeocoordLinkFunctor::operator()(ViewImp *pDestView) const
{
   // lazily prepare the functor with the source information
   if (!const_cast<GeocoordLinkFunctor*>(this)->initialize())
   {
      return;
   }

   SpatialDataViewImp* pDstViewSpatial = dynamic_cast<SpatialDataViewImp*>(pDestView);
   if (pDstViewSpatial == NULL)
   {
      return;
   }

   LayerList* pDstLayerList = pDstViewSpatial->getLayerList();
   if (pDstLayerList == NULL)
   {
      return;
   }

   RasterElement* pDstGeo = pDstLayerList->getPrimaryRasterElement();
   if (pDstGeo == NULL || !pDstGeo->isGeoreferenced())
   {
      return;
   }

   Layer* pDstLayer = pDstLayerList->getLayer(RASTER, pDstGeo);
   if (pDstLayer == NULL)
   {
      return;
   }

   pDstViewSpatial->setPanLimit(NO_LIMIT);
   pDstViewSpatial->setMinimumZoom(0);
   pDstViewSpatial->setMaximumZoom(0);

   LocationType dstDataCenter = pDstGeo->convertGeocoordToPixel(mCenterGeocoord);
   LocationType dstWorldCenter;
   pDstLayer->translateDataToWorld(dstDataCenter.mX, dstDataCenter.mY, 
      dstWorldCenter.mX, dstWorldCenter.mY);
   LocationType dstScreenCenter(pDstViewSpatial->width() / 2.0, pDstViewSpatial->height() / 2.0);

   // Determined zoom and rotation are relative to the view's current state.
   // Reset the zoom and rotation to prevent cascading rounding errors
   pDstViewSpatial->resetOrientation();
   if (pDstViewSpatial->getDataOrigin() == UPPER_LEFT)
   {
      pDstViewSpatial->flipVertical();
   }
   pDstViewSpatial->panTo(dstWorldCenter);
   pDstViewSpatial->zoomTo(100);

   double localTightness = mTightness / findResolution(pDstGeo, pDstLayer, mCenterGeocoord);

   vector<LocationType> dstScreen(NUM_POINTS);
   dstScreen[0] = dstScreenCenter + LocationType(0, localTightness);
   dstScreen[1] = dstScreenCenter + LocationType(0, -localTightness);
   dstScreen[2] = dstScreenCenter + LocationType(localTightness, 0);
   dstScreen[3] = dstScreenCenter + LocationType(-localTightness, 0);

   // (Desired screen offset) / (world offset) yields zoom (magnitude) and rotation (phase).
   vector<complex<double> > transformVec(NUM_POINTS);
   for (unsigned int i = 0; i < NUM_POINTS; ++i)
   {
      // dst: screen -> world -> data -> geo
      LocationType dstWorld;
      pDstViewSpatial->translateScreenToWorld(dstScreen[i].mX, dstScreen[i].mY, dstWorld.mX, dstWorld.mY);
      LocationType dstData;
      pDstLayer->translateWorldToData(dstWorld.mX, dstWorld.mY, dstData.mX, dstData.mY);
      LocationType dstGeo = pDstGeo->convertPixelToGeocoord(dstData);

      // src: geo -> data -> screen
      LocationType srcData = mpSrcGeo->convertGeocoordToPixel(dstGeo);
      LocationType srcScreen;
      mpSrcLayer->translateDataToScreen(srcData.mX, srcData.mY, srcScreen.mX, srcScreen.mY);
      complex<double> srcScreenOffset = complex<double>(srcScreen.mX, srcScreen.mY) - mSrcScreenCenter;
      LocationType dstDataOffset = dstWorld - dstWorldCenter;
      transformVec[i] = srcScreenOffset / complex<double>(dstDataOffset.mX, dstDataOffset.mY);
   }

   // find average zoom and rotation for each axis
   complex<double> vertical = (transformVec[0] + transformVec[1]) / complex<double>(2);
   complex<double> horizontal = (transformVec[2] + transformVec[3]) / complex<double>(2);

   // find the aspects from the relative zoom, and correct the
   // vector to get a better rotation and zoom
   double aspect = abs(horizontal) / abs(vertical);
   if (aspect > 1)
   {
      horizontal /= aspect;
   }
   else
   {
      vertical *= aspect;
   }

   complex<double> total = (horizontal + vertical) / complex<double>(2);
   complex<double> totalFlipped = (horizontal - vertical) / complex<double>(2);
   if (abs(totalFlipped) > abs(total))
   {
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例8: addGeoKeys

bool TiffDetails::addGeoKeys(TIFF* pOut, int width, int height, const SessionItem *pItem)
{
   if ((pOut == NULL) || (width == 0) || (height == 0))
   {
      return false;
   }

   const View* pInputView = dynamic_cast<const View*>(pItem);
   if (pInputView == NULL)
   {
      return false;
   }

   RasterElement* pGeoreferencedRaster = NULL; // First raster element we find with georeferencing information
   const ProductView* pView = dynamic_cast<const ProductView*>(pInputView);
   if (pView != NULL)
   {
      AnnotationLayer* pAnno = pView->getLayoutLayer();
      if (pAnno == NULL)
      {
         return false;
      }

      /* NOTE: If we find more than one SpatialDataView with a georeferenced RasterElement, we will only provide
      geo-data for the FIRST one - because two views could theoretically screw up the
      geo-data if one is in Australia and the other in Canada.
      */

      // get all the view objects
      std::list<GraphicObject*> objs;
      pAnno->getObjects(VIEW_OBJECT, objs);

      // for every object, find the data set with a geocoord matrix
      for (std::list<GraphicObject*>::iterator it = objs.begin(); it != objs.end(); ++it)
      {
         GraphicObject* pObj = *it;
         if (pObj != NULL)
         {
            SpatialDataView* pSpView = dynamic_cast<SpatialDataView*>(pObj->getObjectView());
            if (pSpView != NULL)
            {
               LayerList* pLayerList = pSpView->getLayerList();
               if (pLayerList != NULL)
               {
                  RasterElement* pRaster = pLayerList->getPrimaryRasterElement();
                  if (pRaster != NULL && pRaster->isGeoreferenced())
                  {
                     pGeoreferencedRaster = pRaster;
                     break;
                  }
               }
            }
         }
      }
   }

   const SpatialDataView* pSpView = dynamic_cast<const SpatialDataView*>(pInputView);
   if (pSpView != NULL)
   {
      LayerList* pLayerList = pSpView->getLayerList();
      if (pLayerList != NULL)
      {
         RasterElement* pRaster = pLayerList->getPrimaryRasterElement();
         if (pRaster != NULL && pRaster->isGeoreferenced())
         {
            pGeoreferencedRaster = pRaster;
         }
      }
   }

   if (pGeoreferencedRaster == NULL)
   {
      return false;
   }

   GTIF* pGtif = GTIFNew(pOut);
   if (pGtif == NULL)
   {
      return false;
   }

   LocationType lowerLeft;
   LocationType upperLeft;
   LocationType upperRight;
   LocationType lowerRight;
   pInputView->getVisibleCorners(lowerLeft, upperLeft, upperRight, lowerRight);

   LocationType latLong;
   //get the lat/long's (0,0)
   latLong = pGeoreferencedRaster->convertPixelToGeocoord(upperLeft);
   double ll1y = latLong.mY;               //delta long
   double ll1x = latLong.mX;               //delta lat

   latLong = pGeoreferencedRaster->convertPixelToGeocoord(upperRight);
   double ll2y = latLong.mY;               //long
   double ll2x = latLong.mX;               //lat

   latLong = pGeoreferencedRaster->convertPixelToGeocoord(lowerLeft);
   double ll3y = latLong.mY;               //long
   double ll3x = latLong.mX;               //lat
//.........这里部分代码省略.........
开发者ID:Tom-VdE,项目名称:opticks,代码行数:101,代码来源:TiffDetails.cpp

示例9: getExportOptionsWidget

QWidget* ResultsExporter::getExportOptionsWidget(const PlugInArgList *pInArgList)
{
   const DataDescriptor* pDescriptor = NULL;
   if (pInArgList != NULL)
   {
      RasterElement* pElement = pInArgList->getPlugInArgValue<RasterElement>(Exporter::ExportItemArg());
      if (pElement != NULL)
      {
         pDescriptor = pElement->getDataDescriptor();
      }
   }
   if (mpOptionsWidget == NULL)
   {
      Service<DesktopServices> pDesktop;
      VERIFY(pDesktop.get() != NULL);

      mpOptionsWidget = new ResultsOptionsWidget(pDesktop->getMainWidget());
   }

   if (mpOptionsWidget != NULL)
   {
      const string& name = pDescriptor->getName();
      const string& type = pDescriptor->getType();
      DataElement* pParent = pDescriptor->getParent();

      RasterElement* pResults = dynamic_cast<RasterElement*>(mpModel->getElement(name, type, pParent));
      if (pResults != NULL)
      {
         GeocoordType geocoordType;
         PassArea passArea = MIDDLE;
         double dFirstThreshold = 0.0;
         double dSecondThreshold = 0.0;

         SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(mpDesktop->getCurrentWorkspaceWindow());
         if (pWindow != NULL)
         {
            SpatialDataView* pView = pWindow->getSpatialDataView();
            if (pView != NULL)
            {
               LayerList* pLayerList = pView->getLayerList();
               if (pLayerList != NULL)
               {
                  ThresholdLayer* pThresholdLayer =
                     static_cast<ThresholdLayer*>(pLayerList->getLayer(THRESHOLD, pResults));
                  if (pThresholdLayer != NULL)
                  {
                     passArea = pThresholdLayer->getPassArea();
                     dFirstThreshold = pThresholdLayer->getFirstThreshold();
                     dSecondThreshold = pThresholdLayer->getSecondThreshold();
                  }
                  else
                  {
                     Statistics* pStatistics = pResults->getStatistics();
                     if (pStatistics != NULL)
                     {
                        dFirstThreshold = pStatistics->getMin();
                        dSecondThreshold = pStatistics->getMax();
                     }
                  }
               }

               LatLonLayer* pLatLonLayer = static_cast<LatLonLayer*>(pView->getTopMostLayer(LAT_LONG));
               if (pLatLonLayer != NULL)
               {
                  geocoordType = pLatLonLayer->getGeocoordType();
               }
            }

            if (geocoordType.isValid() == false)
            {
               bool hasGeoData = pResults->isGeoreferenced();
               if (hasGeoData == false)
               {
                  RasterElement* pParent = dynamic_cast<RasterElement*>(mpResults->getParent());
                  if (pParent != NULL)
                  {
                     hasGeoData = pParent->isGeoreferenced();
                  }
               }

               if (hasGeoData == true)
               {
                  geocoordType = Georeference::getSettingGeocoordType();
               }
            }
         }

         mpOptionsWidget->setGeocoordType(geocoordType);
         mpOptionsWidget->setPassArea(passArea);
         mpOptionsWidget->setFirstThreshold(dFirstThreshold);
         mpOptionsWidget->setSecondThreshold(dSecondThreshold);
      }
   }

   return mpOptionsWidget;
}
开发者ID:Siddharthk,项目名称:opticks,代码行数:96,代码来源:ResultsExporter.cpp

示例10: execute


//.........这里部分代码省略.........


      // Create a GCP layer

/*
      SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(Service<DesktopServices>()->createWindow(pResultCube.get()->getName(), SPATIAL_DATA_WINDOW));

   SpatialDataView* pView = pWindow->getSpatialDataView();
   */


      Service<DesktopServices> pDesktop;

      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow(pResultCube->getName(),
         SPATIAL_DATA_WINDOW));

      SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
      if (pView == NULL)
      {
         std::string msg = "Unable to create view.";
         pStep->finalize(Message::Failure, msg);
         if (pProgress != NULL) 
         {
            pProgress->updateProgress(msg, 0, ERRORS);
         }
         return false;
      }

      pView->setPrimaryRasterElement(pResultCube.get());
      pView->createLayer(RASTER, pResultCube.get());


	  // Create the GCP list
	     if (pCube->isGeoreferenced() == true)
		 {


   
      const vector<DimensionDescriptor>& rows = pDescriptor->getRows();
      const vector<DimensionDescriptor>& columns = pDescriptor->getColumns();
      if ((rows.empty() == false) && (columns.empty() == false))
      {
         // Get the geocoordinates at the chip corners
		  /*
         VERIFYNRV(rows.front().isActiveNumberValid() == true);
         VERIFYNRV(rows.back().isActiveNumberValid() == true);
         VERIFYNRV(columns.front().isActiveNumberValid() == true);
         VERIFYNRV(columns.back().isActiveNumberValid() == true);
		 */

         unsigned int startRow = rows.front().getActiveNumber();
         unsigned int endRow = rows.back().getActiveNumber();
         unsigned int startCol = columns.front().getActiveNumber();
         unsigned int endCol = columns.back().getActiveNumber();

         GcpPoint ulPoint;
         ulPoint.mPixel = LocationType(startCol, startRow);
         ulPoint.mCoordinate = pCube->convertPixelToGeocoord(ulPoint.mPixel);

         GcpPoint urPoint;
         urPoint.mPixel = LocationType(endCol, startRow);
         urPoint.mCoordinate = pCube->convertPixelToGeocoord(urPoint.mPixel);

         GcpPoint llPoint;
         llPoint.mPixel = LocationType(startCol, endRow);
         llPoint.mCoordinate = pCube->convertPixelToGeocoord(llPoint.mPixel);
开发者ID:pMav5,项目名称:Ship-Detection-Applet-for-Opticks,代码行数:67,代码来源:kdistribution.cpp

示例11: execute

bool ShapeFileImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   // prevent session auto save while importing shape file
   SessionSaveLock lock;

   StepResource pStep("Run Importer", "app", "F5264701-1D60-474b-AB62-C674A6AC1477");
   mpStep = pStep.get();
   pStep->addProperty("name", getName());

   mpProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
   Progress* pProgress = mpProgress;

   // interactive

   SpatialDataView* pView = pInArgList->getPlugInArgValue<SpatialDataView>(Executable::ViewArg());
   RasterElement* pRaster = NULL;

   FAIL_IF(pView == NULL, "Could not find view to insert into.", return false);

   AnnotationElement* pAnno = pInArgList->getPlugInArgValue<AnnotationElement>(Importer::ImportElementArg());
   FAIL_IF(pAnno == NULL, "Could not find created element.", return false);

   AnnotationLayer* pAnnotationLayer = NULL;
   const LayerList* pLayerList = pView->getLayerList();
   FAIL_IF(pLayerList == NULL, "Could not find layer list.", return false);

   pRaster = pLayerList->getPrimaryRasterElement();

   FAIL_IF(pRaster == NULL, "No data cube could be found.", return false);
   FAIL_IF(!pRaster->isGeoreferenced(), "No georeference could be found.", return false)

   const DataDescriptor* pDescriptor = pAnno->getDataDescriptor();
   FAIL_IF(pDescriptor == NULL, "The descriptor is invalid.", return false);

   createFeatureClassIfNeeded(pDescriptor);
   if (mpFeatureClass.get() == NULL)
   {
      // Progress and Step has been taken care of
      return false;
   }

   if (mpOptionsWidget != NULL)
   {
      mpOptionsWidget->applyChanges();
   }

   const ArcProxyLib::ConnectionParameters& connect = mpFeatureClass->getConnectionParameters();
   pStep->addProperty("connectionParameters", connect.toString());

   vector<ArcProxyLib::ConnectionType> availableConnections = getAvailableConnectionTypes();
   FAIL_IF(find(availableConnections.begin(), availableConnections.end(), 
      connect.getConnectionType()) == availableConnections.end(), 
      "The selected connection type is not available.", return false)

   Service<ModelServices> pModel;
   FAIL_IF(!pModel->setElementParent(pAnno, pRaster) || !pModel->setElementName(pAnno, connect.getFeatureClass()),
      "This shape file has already been imported", return false)

   FAIL_IF(pAnno->setGeocentric(true) == false, "Could not set the element to geocentric.", return false)

   UndoGroup group(pView, "Set Object Properties");

   string layerName = mpFeatureClass->getLayerName();

   pAnnotationLayer = static_cast<AnnotationLayer*>(pLayerList->getLayer(ANNOTATION, pAnno, layerName));
   if (pAnnotationLayer == NULL)
   {
      pAnnotationLayer = static_cast<AnnotationLayer*>(pView->createLayer(ANNOTATION, pAnno, layerName));
   }
   if (pAnnotationLayer != NULL && mpFeatureClass->hasLabels())
   {
      pAnnotationLayer->setShowLabels(true);
   }

   pAnnotationLayer->setLayerLocked(true);

   ModelResource<Any> pAny("Geographic feature", pAnno, "FeatureClass");

   mpFeatureClass->setParentElement(pAnno);

   if (!mpFeatureClass->open(mMessageText) || !mpFeatureClass->update(mpProgress, mMessageText))
   {
      if (mpProgress)
      {
         mpProgress->updateProgress("Error: " + mMessageText, 0, ERRORS);
      }

      pStep->finalize(Message::Failure, mMessageText);
      return false;
   }

   pAny->setData(mpFeatureClass.release());
   pAny.release();
   mpProgress->updateProgress("Complete", 100, NORMAL);
   pStep->finalize(Message::Success);

   return true;
}
开发者ID:,项目名称:,代码行数:98,代码来源:

示例12: mergeData


//.........这里部分代码省略.........
		//	pRequest->setWritable(true);
			DataAccessor pSrcAcc = pData->getDataAccessor(pRequest.release());	
			switchOnEncoding(pDesc->getDataType(), mergeElement, NULL, rowCount, 
				colCount, pSrcAcc, pDesAcc, i, band, pProgress, mergeList->count());
	//		QMessageBox::about(this, "Test", "Here5");
		}
		else {
			QMessageBox::critical(this, "Error", "pData is NULL");
			return false;
		}

	//	mergeElementList.push_back(filenameMap[tmpItemText.toStdString()]);
	}

	Service<DesktopServices> pDesktop;
	SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(pDesktop->createWindow("DataMergeResult",
	   SPATIAL_DATA_WINDOW));

    SpatialDataView* pView = (pWindow == NULL) ? NULL : pWindow->getSpatialDataView();
    if (pView == NULL)
    {
		pStep->finalize(Message::Failure, "SpatialDataView error!");
	    return false;
    }

	pView->setPrimaryRasterElement(pDesRaster);
    pView->createLayer(RASTER, pDesRaster);
	

	if (pDesc != NULL)
    {
		const RasterFileDescriptor* pFileDescriptor = dynamic_cast<const RasterFileDescriptor*>(pDesc->getFileDescriptor());
        if (pFileDescriptor != NULL)
        {
			Service<ModelServices> pModel;
            if (pModel.get() != NULL)
            {
				list<GcpPoint> gcps;             
                gcps = pFileDescriptor->getGcps();           
                if (gcps.empty() == true)
                {
					if (pInitData->isGeoreferenced())
                    {
						GcpPoint gcp;

                        // Lower left
                        gcp.mPixel.mX = 0.0;
                        gcp.mPixel.mY = 0.0;
                        gcp.mCoordinate = pInitData->convertPixelToGeocoord(gcp.mPixel);
                        gcps.push_back(gcp);

                        // Lower right
                        gcp.mPixel.mX = colCount - 1;
                        gcp.mPixel.mY = 0.0;
                        gcp.mCoordinate = pInitData->convertPixelToGeocoord(gcp.mPixel);
                        gcps.push_back(gcp);

                        // Upper left
                        gcp.mPixel.mX = 0.0;
                        gcp.mPixel.mY = rowCount - 1;
                        gcp.mCoordinate = pInitData->convertPixelToGeocoord(gcp.mPixel);
                        gcps.push_back(gcp);

                        // Upper right
                        gcp.mPixel.mX = colCount - 1;
                        gcp.mPixel.mY = rowCount - 1;
                        gcp.mCoordinate = pInitData->convertPixelToGeocoord(gcp.mPixel);
                        gcps.push_back(gcp);

                        // Center
                        gcp.mPixel.mX = colCount / 2.0;
                        gcp.mPixel.mY = rowCount / 2.0;
                        gcp.mCoordinate = pInitData->convertPixelToGeocoord(gcp.mPixel);
                        gcps.push_back(gcp);
                     }
                  }

                  if (gcps.empty() == false)
                  {
                     DataDescriptor* pGcpDescriptor = pModel->createDataDescriptor("Corner Coordinates",
                        "GcpList", pDesRaster);
                     if (pGcpDescriptor != NULL)
                     {
                        GcpList* pGcpList = static_cast<GcpList*>(pModel->createElement(pGcpDescriptor));
                        if (pGcpList != NULL)
                        {
                           // Add the GCPs to the GCP list
                           pGcpList->addPoints(gcps);

                           // Create the GCP list layer
                           pView->createLayer(GCP_LAYER, pGcpList);
                        }
                     }
                  }
               }
		}
	}

	return true;
}
开发者ID:yuguess,项目名称:GSoC,代码行数:101,代码来源:DataMergeGui.cpp


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