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(); }
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(); } }
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; }
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; }
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) { // Rotation dAngle -= pSpatialDataView->getRotation(); // Pitch double dPitch = pSpatialDataView->getPitch(); if (dPitch > 0.0) { dAngle *= -1.0; } } // Rotate the object setRotation(dAngle); // Update the orientation flag DirectionalArrowObjectImp::orient(); }
void ChippingWindow::createView() { if (mpChippingWidget == NULL) { return; } RasterElement* pRaster = getRasterElement(); if (pRaster == NULL) { return; } // Create the new raster element from the primary element of the source. // Note that this does not chip displayed elements if they differ from the primary element. // This causes a special case below where the stretch values are being applied to the chipped layer. RasterElement* pRasterChip = pRaster->createChip(pRaster->getParent(), "_chip", mpChippingWidget->getChipRows(), mpChippingWidget->getChipColumns(), mpChippingWidget->getChipBands()); if (pRasterChip == NULL) { QMessageBox::critical(this, windowTitle(), "Unable to create a new cube!"); return; } const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(pRasterChip->getDataDescriptor()); VERIFYNRV(pDescriptor != NULL); // Create a view for the new chip SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>( Service<DesktopServices>()->createWindow(pRasterChip->getName(), SPATIAL_DATA_WINDOW)); if (pWindow == NULL) { return; } SpatialDataView* pView = pWindow->getSpatialDataView(); if (pView == NULL) { Service<DesktopServices>()->deleteWindow(pWindow); return; } UndoLock lock(pView); if (pView->setPrimaryRasterElement(pRasterChip) == false) { Service<DesktopServices>()->deleteWindow(pWindow); return; } // RasterLayerImp is needed for the call to setCurrentStretchAsOriginalStretch(). RasterLayerImp* pLayer = dynamic_cast<RasterLayerImp*>(pView->createLayer(RASTER, pRasterChip)); if (pLayer == NULL) { Service<DesktopServices>()->deleteWindow(pWindow); return; } string origName = pRaster->getName(); SpatialDataWindow* pOrigWindow = dynamic_cast<SpatialDataWindow*>( Service<DesktopServices>()->getWindow(origName, SPATIAL_DATA_WINDOW)); if (pOrigWindow != NULL) { SpatialDataView* pOrigView = pOrigWindow->getSpatialDataView(); if (pOrigView != NULL) { LayerList* pLayerList = pOrigView->getLayerList(); if (pLayerList != NULL) { RasterLayer* pOrigLayer = static_cast<RasterLayer*>(pLayerList->getLayer(RASTER, pRaster)); if (pOrigLayer != NULL) { // Set the stretch type first so that stretch values are interpreted correctly. pLayer->setStretchType(GRAYSCALE_MODE, pOrigLayer->getStretchType(GRAYSCALE_MODE)); pLayer->setStretchType(RGB_MODE, pOrigLayer->getStretchType(RGB_MODE)); pLayer->setDisplayMode(pOrigLayer->getDisplayMode()); // Set the properties of the cube layer in the new view. // For each channel, display the first band if the previously displayed band was chipped. vector<RasterChannelType> channels = StringUtilities::getAllEnumValues<RasterChannelType>(); for (vector<RasterChannelType>::const_iterator iter = channels.begin(); iter != channels.end(); ++iter) { bool bandCopied = true; DimensionDescriptor newBand; DimensionDescriptor oldBand = pOrigLayer->getDisplayedBand(*iter); if (oldBand.isOriginalNumberValid() == true) { newBand = pDescriptor->getOriginalBand(oldBand.getOriginalNumber()); } 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); GcpPoint centerPoint; centerPoint.mPixel = LocationType((startCol + endCol) / 2, (startRow + endRow) / 2); centerPoint.mCoordinate = pRaster->convertPixelToGeocoord(centerPoint.mPixel); // Reset the coordinates to be in active numbers relative to the chip const vector<DimensionDescriptor>& chipRows = pDescriptor->getRows(); const vector<DimensionDescriptor>& chipColumns = pDescriptor->getColumns(); VERIFYNRV(chipRows.front().isActiveNumberValid() == true); VERIFYNRV(chipRows.back().isActiveNumberValid() == true); VERIFYNRV(chipColumns.front().isActiveNumberValid() == true); VERIFYNRV(chipColumns.back().isActiveNumberValid() == true); unsigned int chipStartRow = chipRows.front().getActiveNumber(); unsigned int chipEndRow = chipRows.back().getActiveNumber(); unsigned int chipStartCol = chipColumns.front().getActiveNumber(); unsigned int chipEndCol = chipColumns.back().getActiveNumber(); ulPoint.mPixel = LocationType(chipStartCol, chipStartRow); urPoint.mPixel = LocationType(chipEndCol, chipStartRow); llPoint.mPixel = LocationType(chipStartCol, chipEndRow); lrPoint.mPixel = LocationType(chipEndCol, chipEndRow); centerPoint.mPixel = LocationType((chipStartCol + chipEndCol) / 2, (chipStartRow + chipEndRow) / 2); // Create the GCP list Service<ModelServices> pModel; GcpList* pGcpList = static_cast<GcpList*>(pModel->createElement("Corner Coordinates", TypeConverter::toString<GcpList>(), pRasterChip)); if (pGcpList != NULL) { list<GcpPoint> gcps; gcps.push_back(ulPoint); gcps.push_back(urPoint); gcps.push_back(llPoint); gcps.push_back(lrPoint); gcps.push_back(centerPoint); pGcpList->addPoints(gcps); // Create the layer if (pView->createLayer(GCP_LAYER, pGcpList) == NULL) { QMessageBox::warning(this, windowTitle(), "Could not create a GCP layer."); } } else { QMessageBox::warning(this, windowTitle(), "Could not create a GCP list."); } } } }
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)) { total = conj(totalFlipped); pDstViewSpatial->flipVertical(); } double zoom = 100 * abs(total); double rot = 360 - (arg(total) * 180/PI); pDstViewSpatial->rotateTo(fmod(rot, 360)); pDstViewSpatial->zoomTo(zoom); pDstViewSpatial->setPixelAspect(aspect); }
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 //compute transformation Matrix values //added slight modification, must divide by magnitude double a = (ll2y - ll1y) / width; double b = (ll3y - ll1y) / height; double d = (ll1y); double e = (ll2x - ll1x) / width; double f = (ll3x - ll1x) / height; double h = (ll1x); double tMatrix[16] = { a, b, 0.0, d, e, f, 0.0, h, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }; TIFFSetField(pOut, GTIFF_TRANSMATRIX, 16, tMatrix); GTIFKeySet(pGtif, GTRasterTypeGeoKey, TYPE_SHORT, 1, RasterPixelIsArea); GTIFKeySet(pGtif, GTModelTypeGeoKey, TYPE_SHORT, 1, ModelGeographic); GTIFKeySet(pGtif, GeographicTypeGeoKey, TYPE_SHORT, 1, GCS_WGS_84); // Here we violate the GTIF abstraction to retarget on another file. // We should just have a function for copying tags from one GTIF object // to another. pGtif->gt_tif = pOut; pGtif->gt_flags |= FLAG_FILE_MODIFIED; // Install keys and tags GTIFWriteKeys(pGtif); GTIFFree(pGtif); return true; }
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; }
bool KDISTRIBUTION::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { StepResource pStep("KDISTRIBUTION", "app10", "F298D57C-D816-42F0-AE27-43DAA02C0544"); if (pInArgList == NULL || pOutArgList == NULL) { return false; } Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); RasterElement* pCube = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg()); if (pCube == NULL) { std::string msg = "A raster cube must be specified."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pCube->getDataDescriptor()); VERIFY(pDesc != NULL); FactoryResource<DataRequest> pRequest; FactoryResource<DataRequest> pRequest2; pRequest->setInterleaveFormat(BSQ); pRequest2->setInterleaveFormat(BSQ); DataAccessor pAcc = pCube->getDataAccessor(pRequest.release()); DataAccessor pAcc2 = pCube->getDataAccessor(pRequest2.release()); ModelResource<RasterElement> pResultCube(RasterUtilities::createRasterElement(pCube->getName() + "Result", pDesc->getRowCount(), pDesc->getColumnCount(), pDesc->getDataType())); if (pResultCube.get() == NULL) { std::string msg = "A raster cube could not be created."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } FactoryResource<DataRequest> pResultRequest; pResultRequest->setWritable(true); DataAccessor pDestAcc = pResultCube->getDataAccessor(pResultRequest.release()); const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(pCube->getDataDescriptor()); int tester_count = 0; int eastCol = 0; int northRow = 0; int westCol = 0; int southRow = 0; double zstatistic = 0; double total = 0.0; double total_sum = 0.0; double mean = 0.0; double std = 0.0; double a=0; int rowSize=pDesc->getRowCount(); int colSize=pDesc->getColumnCount(); int prevCol = 0; int prevRow = 0; int nextCol = 0; int nextRow = 0; double long PFA = 0.0; int DEPTH1 = 10; int DEPTH2 = 10; int DEPTH3 = 1; int DEPTH4 = 1; int count=0; int zero=0; double long threshold = 100000.0; double look_table1[24][6]; for(int i=0; i<24; i++) { for(int j=0; j<3; j++) { look_table1[i][j]=0.0; } } QStringList Names("0.0000001"); QString value = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(), "Input a PFA value", "Input a PFA value (0.0000001 or 0.00000001)", Names); std::string strAoi = value.toStdString(); std::istringstream stm; stm.str(strAoi); //stm >> PFA; PFA=::atof(strAoi.c_str()); if (PFA==0.0000001) { look_table1[0][0]=1.0; look_table1[0][1]=5.0; look_table1[0][2]=32.3372530103729330; look_table1[1][0]=1.0; look_table1[1][1]=10.0; look_table1[1][2]=25.0723580041031010; look_table1[2][0]=1.0; look_table1[2][1]=15.0; look_table1[2][2]=22.3991160013551250; look_table1[3][0]=1.0; look_table1[3][1]=20.0; look_table1[3][2]=20.9821949998985920; look_table1[4][1]=1.0; look_table1[4][2]=40.0; look_table1[5][3]=18.7055519975583020; look_table1[5][1]=1.0; look_table1[5][2]=90.0; look_table1[5][3]=18.7055519975583020; look_table1[6][0]=2.0; look_table1[6][1]=5.0; look_table1[6][2]=20.2619339991581950; look_table1[7][0]=2.0; look_table1[7][1]=10.0; look_table1[7][2]=15.4860609951617470; look_table1[8][0]=2.0; look_table1[8][1]=15.0; look_table1[8][2]=13.7276789964777210; look_table1[9][0]=2.0; look_table1[9][1]=20.0; look_table1[9][2]=12.7942589971762930; look_table1[10][0]=2.0; look_table1[10][1]=40.0; look_table1[10][2]=11.2895769983023970; look_table1[11][0]=2.0; look_table1[11][1]=90.0; look_table1[11][2]=10.3695259989909640; look_table1[12][0]=3.0; look_table1[12][1]=5.0; look_table1[12][2]=15.9102209948443050; look_table1[13][0]=3.0; look_table1[13][1]=10.0; look_table1[13][2]=12.0443629977375150; look_table1[14][0]=3.0; look_table1[14][1]=15.0; look_table1[14][2]=10.6203179988032710; look_table1[15][0]=3.0; look_table1[15][1]=20.0; look_table1[15][2]=9.8635499993696367; look_table1[16][0]=3.0; look_table1[16][1]=40.0; look_table1[16][2]=8.6407550002847771; look_table1[17][0]=3.0; look_table1[17][1]=90.0; look_table1[17][2]=7.8893780007488568; look_table1[18][0]=4.0; look_table1[18][1]=5.0; look_table1[18][2]=13.6166519965608130; look_table1[19][0]=4.0; look_table1[19][1]=10.0; look_table1[19][2]=10.2336029990926890; look_table1[20][0]=4.0; look_table1[20][1]=15.0; look_table1[20][2]=10.6203179988032710; look_table1[21][0]=4.0; look_table1[21][1]=20.0; look_table1[21][2]=8.9868610000257512; look_table1[22][0]=4.0; look_table1[22][1]=40.0; look_table1[22][2]=7.2502150006595159; look_table1[23][0]=4.0; look_table1[23][1]=90.0; look_table1[23][2]=6.5879140005669408; } if (PFA==0.00000001) { look_table1[0][0]=1.0; look_table1[0][1]=5.0; look_table1[0][2]=20.0000019988889410; look_table1[1][0]=1.0; look_table1[1][1]=10.0; look_table1[1][2]=20.0000019988889410; look_table1[2][0]=1.0; look_table1[2][1]=15.0; look_table1[2][2]=20.0000019988889410; look_table1[3][0]=1.0; look_table1[3][1]=20.0; look_table1[3][2]=20.0000019988889410; look_table1[4][1]=1.0; look_table1[4][2]=40.0; look_table1[5][3]=20.0000019988889410; look_table1[5][1]=1.0; look_table1[5][2]=90.0; look_table1[5][3]=20.0000019988889410; look_table1[6][0]=2.0; look_table1[6][1]=5.0; look_table1[6][2]=18.3243529971664460; look_table1[7][0]=2.0; look_table1[7][1]=10.0; look_table1[7][2]=18.3243529971664460; look_table1[8][0]=2.0; look_table1[8][1]=15.0; look_table1[8][2]=16.0869139948664570; look_table1[9][0]=2.0; look_table1[9][1]=20.0; look_table1[9][2]=14.8998299956004820; look_table1[10][0]=2.0; look_table1[10][1]=40.0; look_table1[10][2]=12.9846719970337880; look_table1[11][0]=2.0; look_table1[11][1]=90.0; look_table1[11][2]=11.8094659979133120; look_table1[12][0]=3.0; look_table1[12][1]=5.0; look_table1[12][2]=18.9816659978421360; look_table1[13][0]=3.0; look_table1[13][1]=10.0; look_table1[13][2]=14.1167729961865230; look_table1[14][0]=3.0; look_table1[14][1]=15.0; look_table1[14][2]=12.3304539975234050; look_table1[15][0]=3.0; look_table1[15][1]=20.0; look_table1[15][2]=11.3819769982332450; look_table1[16][0]=3.0; look_table1[16][1]=40.0; look_table1[16][2]=9.8488249993806569; look_table1[17][0]=3.0; look_table1[17][1]=90.0; look_table1[17][2]=8.9039850000877756; look_table1[18][0]=4.0; look_table1[18][1]=5.0; look_table1[18][2]=16.1272319949079020; look_table1[19][0]=4.0; look_table1[19][1]=10.0; look_table1[19][2]=11.9117899978367330; look_table1[20][0]=4.0; look_table1[20][1]=15.0; look_table1[20][2]=10.3636999989953240; look_table1[21][0]=4.0; look_table1[21][1]=20.0; look_table1[21][2]=9.5411879996108926; look_table1[22][0]=4.0; look_table1[22][1]=40.0; look_table1[22][2]=8.2095870006074634; look_table1[23][0]=4.0; look_table1[23][1]=90.0; look_table1[23][2]=7.3860650006785047; } QStringList Names1("10"); QString value1 = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(), "Input the size of the window width", "Input the size of the window width in terms of the number of pixels (eg. 10)", Names1); std::string strAoi1 = value1.toStdString(); std::istringstream stm1; stm1.str(strAoi1); //stm1 >> DEPTH1; DEPTH1=::atof(strAoi1.c_str()); QStringList Names2("10"); QString value2 = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(), "Input the size of the window height", "Input the size of the window height in terms of the number of pixels (eg. 10)", Names2); std::string strAoi2 = value2.toStdString(); std::istringstream stm2; stm2.str(strAoi2); //stm2 >> DEPTH2; DEPTH2=::atof(strAoi2.c_str()); QStringList Names3("1"); QString value3 = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(), "Input the size of the gaurd width", "Input the size of the guard width in terms of the number of pixels (eg. 1)", Names3); std::string strAoi3 = value3.toStdString(); std::istringstream stm3; stm3.str(strAoi3); //stm3 >> DEPTH3; DEPTH3=::atof(strAoi3.c_str()); QStringList Names4("1"); QString value4 = QInputDialog::getItem(Service<DesktopServices>()->getMainWidget(), "Input the size of the guard height", "Input the size of the guard height in terms of the number of pixels (eg. 1)", Names4); std::string strAoi4 = value4.toStdString(); std::istringstream stm4; stm4.str(strAoi4); stm4 >> DEPTH4; DEPTH4=::atof(strAoi4.c_str()); for (int row = 0; row < rowSize; ++row) { if (isAborted()) { std::string msg = getName() + " has been aborted."; pStep->finalize(Message::Abort, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ABORT); } return false; } if (!pAcc.isValid()) { std::string msg = "Unable to access the cube data."; pStep->finalize(Message::Failure, msg); if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } if (pProgress != NULL) { pProgress->updateProgress("Calculating statistics", row * 100 / pDesc->getRowCount(), NORMAL); } for (int col = 0; col < colSize; ++col) { //p[col]=pAcc2->getColumnAsInteger(); westCol=max(col-DEPTH1,zero); northRow=max(row-DEPTH2,zero); eastCol=min(colSize-1,col+DEPTH1); southRow=min(rowSize-1,row+DEPTH2); prevCol=max(col-DEPTH3,zero); prevRow=max(row-DEPTH4,zero); nextCol=min(col+DEPTH3,colSize-1); nextRow=min(row+DEPTH4,rowSize-1); pAcc2->toPixel(northRow,westCol); for(int row1=northRow; row1 < southRow+1; ++row1) { for (int col1=westCol; col1 < eastCol+1; ++col1) { if((row1>=prevRow && row1<=nextRow) && (col1>=prevCol && col1<=nextCol)) { continue; } else { updateStatistics3(pAcc2->getColumnAsDouble(), total, total_sum, count); } pAcc2->nextColumn(); } pAcc2->nextRow(); } mean = total / count; std = sqrt(total_sum / count - mean * mean); int ELVI = (mean/std)*(mean/std); int v = (ELVI+1)/((ELVI*mean/(std*std))-1); pAcc2->toPixel(row,col); pDestAcc->toPixel(row,col); zstatistic = (pAcc2->getColumnAsDouble()-mean)/std; if(v<=7 && v>=0) { v=5; } if(v<=12 && v>7) { v=10; } if(v<=17 && v>12) { v=15; } if(v<=30 && v>17) { v=20; } if(v<=65 && v>30) { v=40; } if(v<=90 && v>65) { v=90; } for(int i=0; i<24; i++) { if((look_table1[i][0]=ELVI) && (look_table1[i][1]==v)) { threshold=look_table1[i][2]; } } if(zstatistic>threshold) { switchOnEncoding(pDesc->getDataType(), conversion1, pDestAcc->getColumn(), 1000.0); } else { switchOnEncoding(pDesc->getDataType(), conversion1, pDestAcc->getColumn(), 0.0); } total = 0.0; total_sum=0.0; threshold=100000.0; mean = 0.0; std = 0.0; count=0; pAcc->nextColumn(); } pAcc->nextRow(); } // 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); GcpPoint lrPoint; lrPoint.mPixel = LocationType(endCol, endRow); lrPoint.mCoordinate = pCube->convertPixelToGeocoord(lrPoint.mPixel); GcpPoint centerPoint; centerPoint.mPixel = LocationType((startCol + endCol) / 2, (startRow + endRow) / 2); centerPoint.mCoordinate = pCube->convertPixelToGeocoord(centerPoint.mPixel); /* // Reset the coordinates to be in active numbers relative to the chip const vector<DimensionDescriptor>& chipRows = pDescriptor->getRows(); const vector<DimensionDescriptor>& chipColumns = pDescriptor->getColumns(); VERIFYNRV(chipRows.front().isActiveNumberValid() == true); VERIFYNRV(chipRows.back().isActiveNumberValid() == true); VERIFYNRV(chipColumns.front().isActiveNumberValid() == true); VERIFYNRV(chipColumns.back().isActiveNumberValid() == true); unsigned int chipStartRow = chipRows.front().getActiveNumber(); unsigned int chipEndRow = chipRows.back().getActiveNumber(); unsigned int chipStartCol = chipColumns.front().getActiveNumber(); unsigned int chipEndCol = chipColumns.back().getActiveNumber(); ulPoint.mPixel = LocationType(chipStartCol, chipStartRow); urPoint.mPixel = LocationType(chipEndCol, chipStartRow); llPoint.mPixel = LocationType(chipStartCol, chipEndRow); lrPoint.mPixel = LocationType(chipEndCol, chipEndRow); centerPoint.mPixel = LocationType((chipStartCol + chipEndCol) / 2, (chipStartRow + chipEndRow) / 2); */ Service<ModelServices> pModel; GcpList* pGcpList = static_cast<GcpList*>(pModel->createElement("Corner Coordinates", TypeConverter::toString<GcpList>(), pResultCube.get())); if (pGcpList != NULL) { list<GcpPoint> gcps; gcps.push_back(ulPoint); gcps.push_back(urPoint); gcps.push_back(llPoint); gcps.push_back(lrPoint); gcps.push_back(centerPoint); pGcpList->addPoints(gcps); pView->createLayer(GCP_LAYER, pGcpList); } } } if (pProgress != NULL) { pProgress->updateProgress("CFAR is compete.", 100, NORMAL); } pOutArgList->setPlugInArgValue("Result", pResultCube.release()); pStep->finalize(); return true; }
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; }
bool DataMergeGui::mergeData() { // Service<ModelServices> pModel; StepResource pStep("Data Merge Begin", "app", "5E4BCD48-E662-408b-93AF-F9127CE56C66"); if (mergeList->count() == 0) { QMessageBox::critical(NULL, "Spectral Data Merge", "No RasterElement to merge", "OK"); pStep->finalize(Message::Failure, "No RasterElement to merge"); return false; } // pProgress = new Progress(this, "Progress Reporter"); // std::vector<DataElement*> cubes = pModel->getElements("RasterElement"); /* if (mergeElementList.size() == 0) { QMessageBox::critical(NULL, "Spectral Data Merge", "No RasterElement input found!", "OK"); pStep->finalize(Message::Failure, "No RasterElement input found!"); return false; } */ //QListWidgetItem *tmpItem = mergeList->item(i0); //QString tmpItemText = tmpItem->text(); RasterElement* pInitData = extractRasterElement(mergeList->item(0)->text()); // vector<RasterElement*>::iterator initIter = mergeElementList.begin(); // RasterElement* pInitData = model_cast<RasterElement*>(*initIter); if (pInitData == NULL) { pStep->finalize(Message::Failure, "Cube Data error!"); QMessageBox::critical(this, "Error", "pInitData Error"); return false; } RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pInitData->getDataDescriptor()); EncodingType type = pDesc->getDataType(); int rowCount = pDesc->getRowCount(); int colCount = pDesc->getColumnCount(); int bandCount = mergeList->count(); RasterElement* pDesRaster = RasterUtilities::createRasterElement("DataMergeCube", rowCount, colCount, bandCount, type, BIP, true, NULL); if (pDesRaster == NULL) { QMessageBox::critical(NULL, "Spectral Data Merge", "Create RasterElement failed, Please close the previous merge result!", "OK"); pStep->finalize(Message::Failure, "No RasterElement input found!"); return false; } FactoryResource<DataRequest> pRequest; pRequest->setInterleaveFormat(BIP); DataAccessor pDesAcc = pDesRaster->getDataAccessor(pRequest.release()); if (!pDesAcc.isValid()) { QMessageBox::critical(NULL, "Spectral Data Merge", "pDesRaster Data Accessor Error!", "OK"); pStep->finalize(Message::Failure, "pDesRaster Data Accessor Error!"); return false; } if (pProgress == NULL) { QMessageBox::critical(NULL, "Spectral Data Merge", "pProgress Initialize Error!", "OK"); pStep->finalize(Message::Failure, "pProgress Error!"); return false; } // progressDialog = new QProgressDialog(); // progressDialog->setRange(0, rowCount); //int index = 0; for (int i = 0; i < mergeList->count(); i++) { QListWidgetItem *tmpItem = mergeList->item(i); QString tmpItemText = tmpItem->text(); RasterElement* pData = extractRasterElement(tmpItemText); int band = extractMergeBand(tmpItemText); if (pData != NULL) { RasterDataDescriptor* pDesc = static_cast<RasterDataDescriptor*>(pData->getDataDescriptor()); if (rowCount != pDesc->getRowCount()) { QMessageBox::critical(NULL, "Spectral Data Merge", "Merge Data Format Error!", "OK"); pStep->finalize(Message::Failure, "Merge Data Row Format Error!"); return false; } if (colCount != pDesc->getColumnCount()) { QMessageBox::critical(NULL, "Spectral Data Merge", "Merge Data Format Error!", "OK"); pStep->finalize(Message::Failure, "Merge Data Column Format Error!"); return false; } // QMessageBox::about(this, "Test", "Here2"); FactoryResource<DataRequest> pRequest; pRequest->setInterleaveFormat(BIP); // 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; }