本文整理汇总了C++中LayerList::getPrimaryRasterElement方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerList::getPrimaryRasterElement方法的具体用法?C++ LayerList::getPrimaryRasterElement怎么用?C++ LayerList::getPrimaryRasterElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerList
的用法示例。
在下文中一共展示了LayerList::getPrimaryRasterElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
bool GetPrimaryRasterLayer::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
StepResource pStep("Execute Wizard Item", "app", "5D20DF72-1C71-4a5d-9B1A-398A91154EBD");
pStep->addProperty("Item", getName());
mpStep = pStep.get();
if (pInArgList == NULL || pOutArgList == NULL)
{
reportError("Invalid Plug-In Arg List specified.", "8161F92F-124F-4118-8E24-532187A442AA");
return false;
}
if (extractInputArgs(pInArgList) == false)
{
return false;
}
LayerList* pLayerList = mpSpatialDataView->getLayerList();
VERIFY(pLayerList != NULL);
RasterElement* pElement = pLayerList->getPrimaryRasterElement();
RasterLayer* pLayer = dynamic_cast<RasterLayer*>(pLayerList->getLayer(RASTER, pElement));
if (pOutArgList->setPlugInArgValue(Executable::LayerArg(), pLayer) == false)
{
reportError("Unable to set output argument.", "B4DE1827-3B96-4a96-89BB-62431B6E81CF");
return false;
}
reportComplete();
return true;
}
示例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();
}
}
示例3: execute
bool PrintView::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
StepResource pStep("Execute Wizard Item", "app", "4EA89098-57C8-4b93-B04F-3197C59B0D58");
pStep->addProperty("Item", getName());
mpStep = pStep.get();
if (!extractInputArgs(pInArgList))
{
reportError("Unable to extract input arguments.", "9FC540AC-4BCF-4041-9E8E-484A494AF6AD");
return false;
}
// Get the window
SpatialDataWindow* pWindow = NULL;
vector<Window*> windows;
Service<DesktopServices> pDesktop;
if (pDesktop.get() != NULL)
{
pDesktop->getWindows(SPATIAL_DATA_WINDOW, windows);
}
for (vector<Window*>::iterator iter = windows.begin(); iter != windows.end(); ++iter)
{
SpatialDataWindow* pCurrentWindow = static_cast<SpatialDataWindow*>(*iter);
if (pCurrentWindow != NULL)
{
SpatialDataView* pView = pCurrentWindow->getSpatialDataView();
if (pView != NULL)
{
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
RasterElement* pRasterElement = pLayerList->getPrimaryRasterElement();
if (pRasterElement != NULL && pRasterElement == mpRasterElement)
{
pWindow = pCurrentWindow;
break;
}
}
}
}
}
if (pWindow == NULL)
{
reportError("Could not get the window for the data set!", "28355746-8AE3-44a4-9253-58684E1964C1");
return false;
}
// Print the view
pWindow->print(mbPrintDialog);
reportComplete();
return true;
}
示例4: updateSelectionBox
void OverviewWindow::updateSelectionBox()
{
if ((mpView == NULL) || (mpSelectionWidget == NULL))
{
return;
}
// Get the pixel coordinates at the view corners
LocationType lowerLeft;
LocationType upperLeft;
LocationType upperRight;
LocationType lowerRight;
mpView->getVisibleCorners(lowerLeft, upperLeft, upperRight, lowerRight);
// Disconnect the signal to update the view since the values are obtained from the view
disconnect(mpSelectionWidget, SIGNAL(selectionChanged(const std::vector<LocationType>&)), this,
SLOT(updateView(const std::vector<LocationType>&)));
LayerList* pLayerList = mpView->getLayerList();
VERIFYNRV(pLayerList != NULL);
Layer* pLayer = pLayerList->getLayer(RASTER, pLayerList->getPrimaryRasterElement());
VERIFYNRV(pLayer != NULL);
// Set the selection area
vector<LocationType> selectionArea;
LocationType dataCoord;
pLayer->translateWorldToData(lowerLeft.mX, lowerLeft.mY, dataCoord.mX, dataCoord.mY);
selectionArea.push_back(dataCoord);
pLayer->translateWorldToData(lowerRight.mX, lowerRight.mY, dataCoord.mX, dataCoord.mY);
selectionArea.push_back(dataCoord);
pLayer->translateWorldToData(upperRight.mX, upperRight.mY, dataCoord.mX, dataCoord.mY);
selectionArea.push_back(dataCoord);
pLayer->translateWorldToData(upperLeft.mX, upperLeft.mY, dataCoord.mX, dataCoord.mY);
selectionArea.push_back(dataCoord);
// update snail trail if zoom factor greater than or equal zoom threshold
if ((mpTrail != NULL) && (static_cast<int>(mpView->getZoomPercentage() + 0.5) >= mZoomThreshold))
{
// Translate each point into a screen location
if (mpOverview != NULL)
{
mpOverview->translateWorldToScreen(lowerLeft.mX, lowerLeft.mY, lowerLeft.mX, lowerLeft.mY);
mpOverview->translateWorldToScreen(lowerRight.mX, lowerRight.mY, lowerRight.mX, lowerRight.mY);
mpOverview->translateWorldToScreen(upperLeft.mX, upperLeft.mY, upperLeft.mX, upperLeft.mY);
mpOverview->translateWorldToScreen(upperRight.mX, upperRight.mY, upperRight.mX, upperRight.mY);
mpTrail->addToStencil(lowerLeft, lowerRight, upperLeft, upperRight);
}
}
mpSelectionWidget->setSelection(selectionArea);
// Reconnect the signal to update the view
connect(mpSelectionWidget, SIGNAL(selectionChanged(const std::vector<LocationType>&)), this,
SLOT(updateView(const std::vector<LocationType>&)));
}
示例5: getRasterElement
RasterElement* ChippingWindow::getRasterElement() const
{
LayerList* pLayerList = mpView->getLayerList();
if (pLayerList == NULL)
{
return NULL;
}
return pLayerList->getPrimaryRasterElement();
}
示例6: Image
Image(SpatialDataView* iPView) : pView(iPView) {
LayerList* pLayerList = pView->getLayerList(); VERIFYNRV(pLayerList != NULL);
pRaster = dynamic_cast<RasterElement*>(pLayerList->getPrimaryRasterElement()); VERIFYNRV(pRaster != NULL);
pDataDescriptor = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor()); VERIFYNR(pDataDescriptor != NULL);
/* Service<DesktopServices> pDesktop;
VERIFYNRV(pDesktop.get() != NULL);
SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(pDesktop->getWindow(pRaster->getName(), SPATIAL_DATA_WINDOW));
VERIFYNRV(pWindow != NULL);
VERIFYNRV(pDesktop->setCurrentWorkspaceWindow(pWindow));*/
}
示例7: createOverview
SpatialDataViewImp* OverviewWindow::createOverview()
{
SpatialDataViewImp* pOverview = NULL;
if (mpView != NULL)
{
pOverview = dynamic_cast<SpatialDataViewImp*>(mpView->copy());
VERIFYRV(pOverview != NULL, NULL);
pOverview->installEventFilter(this);
LayerList* pLayerList = NULL;
pLayerList = pOverview->getLayerList();
if (pLayerList != NULL)
{
// get primary raster layer from data view
LayerList* pSDVlist = mpView->getLayerList();
VERIFYRV(pSDVlist != NULL, NULL);
DataElement* pPrimElem = pSDVlist->getPrimaryRasterElement();
VERIFYRV(pPrimElem != NULL, NULL);
Layer* pPrimLayer = pSDVlist->getLayer(RASTER, pPrimElem);
VERIFYRV(pPrimLayer != NULL, NULL);
string primName(pPrimLayer->getName());
vector<Layer*> layers;
pLayerList->getLayers(layers);
for (unsigned int i = 0; i < layers.size(); i++)
{
Layer* pLayer = NULL;
pLayer = layers.at(i);
string layerName(pLayer->getName());
if (pLayer->getLayerType()==RASTER && layerName==primName)
{
pPrimLayer->linkLayer(pLayer);
// reset the scale to what is in the model
DataElement* pElement = pLayer->getDataElement();
VERIFYRV(pElement != NULL, NULL);
const RasterDataDescriptor* pDescriptor =
dynamic_cast<const RasterDataDescriptor*>(pElement->getDataDescriptor());
VERIFYRV(pDescriptor != NULL, NULL);
pLayer->setYScaleFactor(pDescriptor->getYPixelSize());
pLayer->setXScaleFactor(pDescriptor->getXPixelSize());
}
else
{
pOverview->deleteLayer(pLayer);
}
}
pOverview->resetOrientation();
}
}
return pOverview;
}
示例8: initialize
bool GeocoordLinkFunctor::initialize()
{
if (mInitialized)
{
return true;
}
if (mpSrcView != NULL)
{
LayerList* pSrcLayerList = mpSrcView->getLayerList();
if (pSrcLayerList == NULL)
{
return false;
}
mpSrcGeo = pSrcLayerList->getPrimaryRasterElement();
if (mpSrcGeo == NULL || !mpSrcGeo->isGeoreferenced())
{
return false;
}
mpSrcLayer = pSrcLayerList->getLayer(RASTER, mpSrcGeo);
if (mpSrcLayer == NULL)
{
return false;
}
LocationType srcWorldCenter(mpSrcView->getVisibleCenter());
LocationType srcScreenCenter;
mpSrcView->translateWorldToScreen(srcWorldCenter.mX, srcWorldCenter.mY,
srcScreenCenter.mX, srcScreenCenter.mY);
mSrcScreenCenter = complex<double>(srcScreenCenter.mX, srcScreenCenter.mY);
LocationType srcDataCenter;
mpSrcLayer->translateWorldToData(srcWorldCenter.mX, srcWorldCenter.mY,
srcDataCenter.mX, srcDataCenter.mY);
mCenterGeocoord = mpSrcGeo->convertPixelToGeocoord(srcDataCenter);
mTightness = findResolution(mpSrcGeo, mpSrcLayer, mCenterGeocoord) * LINK_TIGHTNESS;
mInitialized = true;
return true;
}
return false;
}
示例9: updateView
void OverviewWindow::updateView(const vector<LocationType>& selectionArea)
{
if ((mpView == NULL) || (selectionArea.size() != 4))
{
return;
}
LayerList* pLayerList = mpView->getLayerList();
VERIFYNRV(pLayerList != NULL);
Layer* pLayer = pLayerList->getLayer(RASTER, pLayerList->getPrimaryRasterElement());
VERIFYNRV(pLayer != NULL);
LocationType worldLl;
LocationType worldUr;
pLayer->translateDataToWorld(selectionArea[0].mX, selectionArea[0].mY, worldLl.mX, worldLl.mY);
pLayer->translateDataToWorld(selectionArea[2].mX, selectionArea[2].mY, worldUr.mX, worldUr.mY);
// Update the view
mpView->zoomToBox(worldLl, worldUr);
mpView->repaint();
}
示例10: execute
//.........这里部分代码省略.........
//no view provided, so find current view
SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(mpDesktop->getCurrentWorkspaceWindow());
if (pWindow != NULL)
{
pView = pWindow->getSpatialDataView();
}
}
if (pView == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Could not access the view to create the layer.", 100, ERRORS);
}
pStep->finalize(Message::Failure, "Could not access the view to create the layer.");
return false;
}
bool error = false;
LayerType layerType = StringUtilities::fromXmlString<LayerType>(type, &error);
if (error == true)
{
if (pProgress != NULL)
{
pProgress->updateProgress("The layer type is invalid.", 100, ERRORS);
}
pStep->finalize(Message::Failure, "The layer type is invalid.");
return false;
}
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
RasterElement* pNewParentElement = pLayerList->getPrimaryRasterElement();
if (pNewParentElement != NULL)
{
Service<ModelServices> pModel;
if (pModel->setElementParent(pElement, pNewParentElement) == false)
{
pProgress->updateProgress("The layer already exists.", 100, ERRORS);
pStep->finalize(Message::Failure, "The layer already exists.");
return false;
}
}
}
UndoGroup group(pView, "Import " + StringUtilities::toDisplayString(layerType) + " Layer");
pLayer = pView->createLayer(layerType, pElement);
if (pLayer == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Unable to create the layer", 100, ERRORS);
}
pStep->finalize(Message::Failure, "Unable to create the layer");
return false;
}
if (pProgress != NULL)
{
pProgress->updateProgress("Build the layer", 60, NORMAL);
}
// deserialize the layer
try
{
if (pLayer->fromXml(pRootElement, formatVersion) == false)
{
pProgress->updateProgress("Problem with layer file.", 100, ERRORS);
pStep->finalize(Message::Failure, "Problem with layer file.");
return false;
}
}
catch (XmlReader::DomParseException&)
{
return false;
}
pStep->finalize(Message::Success);
if (pProgress != NULL)
{
pProgress->updateProgress("Finished loading the layer", 100, NORMAL);
}
// Add the layer to the view
pView->addLayer(pLayer);
pView->setActiveLayer(pLayer);
pView->setMouseMode("LayerMode");
if (pOutArgList != NULL)
{
// set the output arguments
pOutArgList->setPlugInArgValue("Layer", pLayer);
}
return true;
}
示例11: execute
bool CgmImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
Progress* pProgress = NULL;
DataElement* pElement = NULL;
StepResource pStep("Import cgm element", "app", "8D5522FE-4A89-44cb-9735-6920A3BFC903");
// get input arguments and log some useful info about them
{ // scope the MessageResource
MessageResource pMsg("Input arguments", "app", "A1735AC7-C182-45e6-826F-690DBA15D84A");
pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg());
pMsg->addBooleanProperty("Progress Present", (pProgress != NULL));
pElement = pInArgList->getPlugInArgValue<DataElement>(Importer::ImportElementArg());
if (pElement == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("No data element", 0, ERRORS);
}
pStep->finalize(Message::Failure, "No data element");
return false;
}
pMsg->addProperty("Element name", pElement->getName());
}
if (pProgress != NULL)
{
pProgress->updateProgress((string("Read and parse file ") + pElement->getFilename()), 20, NORMAL);
}
// Create a new annotation layer for a spatial data view or get the layout layer for a product view
if (pProgress != NULL)
{
pProgress->updateProgress("Create a new layer", 30, NORMAL);
}
View* pView = mpDesktop->getCurrentWorkspaceWindowView();
if (pView == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Could not access the current view.", 0, ERRORS);
}
pStep->finalize(Message::Failure, "Could not access the current view.");
return false;
}
UndoGroup undoGroup(pView, "Import CGM");
AnnotationLayer* pLayer = NULL;
SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pView);
if (pSpatialDataView != NULL)
{
// Set the parent element of the annotation element to the primary raster element
LayerList* pLayerList = pSpatialDataView->getLayerList();
if (pLayerList != NULL)
{
RasterElement* pNewParentElement = pLayerList->getPrimaryRasterElement();
if (pNewParentElement != NULL)
{
Service<ModelServices> pModel;
pModel->setElementParent(pElement, pNewParentElement);
}
}
pLayer = dynamic_cast<AnnotationLayer*>(pSpatialDataView->createLayer(ANNOTATION, pElement));
}
else
{
ProductView* pProductView = dynamic_cast<ProductView*>(mpDesktop->getCurrentWorkspaceWindowView());
if (pProductView != NULL)
{
pLayer = pProductView->getLayoutLayer();
}
}
if (pLayer == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Unable to get the annotation layer", 0, ERRORS);
}
pStep->finalize(Message::Failure, "Unable to get the annotation layer");
return false;
}
// add the CGM object
if (pProgress != NULL)
{
pProgress->updateProgress("Create the CGM object", 60, NORMAL);
}
CgmObject* pCgmObject = dynamic_cast<CgmObject*>(pLayer->addObject(CGM_OBJECT));
if (pCgmObject == NULL)
{
if (pProgress != NULL)
{
pProgress->updateProgress("Unable to create the CGM object", 0, ERRORS);
}
//.........这里部分代码省略.........
示例12: get_data_element_names
/**
* Get the names of all the data elements which are children of the primary raster element.
*
* @param[in] WINDOW @opt
* The name of the window. Defaults to the active window.
* @return An array of data element names or the string "failure" if an error occurred.
* @usage names = get_data_element_names()
* @endusage
*/
IDL_VPTR get_data_element_names(int argc, IDL_VPTR pArgv[], char* pArgk)
{
typedef struct
{
IDL_KW_RESULT_FIRST_FIELD;
int windowExists;
IDL_STRING windowName;
} KW_RESULT;
//IDL_KW_FAST_SCAN is the type of scan we are using, following it is the
//name of the keyword, followed by the type, the mask(which should be 1),
//flags, a boolean whether the value was populated and finally the value itself
static IDL_KW_PAR kw_pars[] = {
IDL_KW_FAST_SCAN,
{"WINDOW", IDL_TYP_STRING, 1, 0, reinterpret_cast<int*>(IDL_KW_OFFSETOF(windowExists)),
reinterpret_cast<char*>(IDL_KW_OFFSETOF(windowName))},
{NULL}
};
IdlFunctions::IdlKwResource<KW_RESULT> kw(argc, pArgv, pArgk, kw_pars, 0, 1);
std::string windowName;
std::string name;
bool bSuccess = false;
IDL_VPTR idlPtr;
unsigned int total = 0;
IDL_STRING* pStrarr = NULL;
if (kw->windowExists)
{
windowName = IDL_STRING_STR(&kw->windowName);
}
SpatialDataWindow* pWindow = NULL;
if (windowName.empty())
{
pWindow = dynamic_cast<SpatialDataWindow*>(Service<DesktopServices>()->getCurrentWorkspaceWindow());
}
else
{
pWindow = dynamic_cast<SpatialDataWindow*>(
Service<DesktopServices>()->getWindow(windowName, SPATIAL_DATA_WINDOW));
}
if (pWindow != NULL)
{
SpatialDataView* pView = pWindow->getSpatialDataView();
if (pView != NULL)
{
LayerList* pList = pView->getLayerList();
if (pList != NULL)
{
RasterElement* pElement = pList->getPrimaryRasterElement();
if (pElement != NULL)
{
std::vector<std::string> names = Service<ModelServices>()->getElementNames(pElement, "");
total = names.size();
if (total > 0)
{
pStrarr = reinterpret_cast<IDL_STRING*>(malloc(total * sizeof(IDL_STRING)));
for (unsigned int i=0; i < total; ++i)
{
IDL_StrStore(&(pStrarr[i]), const_cast<char*>(names[i].c_str()));
}
bSuccess = true;
}
}
}
}
}
else if (windowName == "all")
{
std::vector<std::string> names = Service<ModelServices>()->getElementNames("RasterElement");
total = names.size();
if (total > 0)
{
pStrarr = reinterpret_cast<IDL_STRING*>(malloc(total* sizeof(IDL_STRING)));
for (unsigned int i=0; i < total; ++i)
{
IDL_StrStore(&(pStrarr[i]), const_cast<char*>(names[i].c_str()));
}
bSuccess = true;
}
}
if (!bSuccess)
{
IDL_Message(IDL_M_GENERIC, IDL_MSG_RET, "No elements matched.");
return IDL_StrToSTRING("failure");
}
IDL_MEMINT dims[] = {total};
idlPtr = IDL_ImportArray(1, dims, IDL_TYP_STRING, reinterpret_cast<UCHAR*>(pStrarr),
reinterpret_cast<IDL_ARRAY_FREE_CB>(free), NULL);
return idlPtr;
//.........这里部分代码省略.........
示例13: execute
bool SetDataSetWavelengths::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
if (pInArgList == NULL)
{
return false;
}
StepResource pStep(string("Execute ") + getName(), "Spectral", "863CB0EE-5BC0-4A49-8FCB-FBC385F1AD2D");
// Extract the input args
Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(ProgressArg());
RasterElement* pDataset = pInArgList->getPlugInArgValue<RasterElement>(DataElementArg());
if ((pDataset == NULL) && (isBatch() == false))
{
SpatialDataView* pView = pInArgList->getPlugInArgValue<SpatialDataView>(ViewArg());
if (pView != NULL)
{
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
pDataset = pLayerList->getPrimaryRasterElement();
}
}
}
if (pDataset == NULL)
{
string message = "The data set input value is invalid.";
if (pProgress != NULL)
{
pProgress->updateProgress(message, 0, ERRORS);
}
pStep->finalize(Message::Failure, message);
return false;
}
DynamicObject* pWavelengthData = pInArgList->getPlugInArgValue<DynamicObject>(Wavelengths::WavelengthsArg());
if (pWavelengthData == NULL)
{
string message = "The " + Wavelengths::WavelengthsArg() + " input value is invalid.";
if (pProgress != NULL)
{
pProgress->updateProgress(message, 0, ERRORS);
}
pStep->finalize(Message::Failure, message);
return false;
}
// Apply the wavelength data to the data set
Wavelengths wavelengths(pWavelengthData);
if (wavelengths.applyToDataset(pDataset) == false)
{
string message = "The wavelengths could not be applied to the data set. The number of wavelength values "
"may not match the number of bands in the data set.";
if (pProgress != NULL)
{
pProgress->updateProgress(message, 0, ERRORS);
}
pStep->finalize(Message::Failure, message);
return false;
}
pStep->finalize(Message::Success);
return true;
}
示例14: 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
//.........这里部分代码省略.........
示例15: getLayer
Layer* getLayer(const char* pName, const char* pType)
{
Layer* pLayer = NULL;
const std::string name(pName == NULL ? std::string() : pName);
const std::string type(pType == NULL ? std::string() : pType);
SessionItem* pSessionItem = Service<SessionManager>()->getSessionItem(name);
if (pSessionItem != NULL)
{
pLayer = dynamic_cast<Layer*>(pSessionItem);
if (pLayer == NULL || (!type.empty() && !pLayer->isKindOf(type)))
{
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
}
else
{
std::vector<std::string> id = splitIdentifier(name);
SpatialDataView* pView = static_cast<SpatialDataView*>(getView(id.size() == 0 ? NULL : id.front().c_str(),
TypeConverter::toString<SpatialDataView>()));
LayerList* pLayerList = (pView == NULL) ? NULL : pView->getLayerList();
if (pLayerList == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
if (id.size() < 2)
{
if (!type.empty() && type == TypeConverter::toString<RasterLayer>())
{
pLayer = pLayerList->getLayer(RASTER, pLayerList->getPrimaryRasterElement());
}
else
{
pLayer = pView->getActiveLayer();
if (pLayer != NULL && !type.empty() && !pLayer->isKindOf(type))
{
pLayer = NULL;
}
if (pLayer == NULL)
{
if (type.empty())
{
pLayer = pView->getTopMostLayer();
}
else
{
pLayer = pView->getTopMostLayer(StringUtilities::fromDisplayString<LayerType>(type));
}
}
}
}
if (pLayer == NULL)
{
std::vector<Layer*> layers;
pLayerList->getLayers(layers);
for (std::vector<Layer*>::reverse_iterator layer = layers.rbegin();
layer != layers.rend();
++layer)
{
if ((type.empty() || (*layer)->isKindOf(type)) &&
(id.empty() || (*layer)->getName() == id.back() || (*layer)->getDisplayName() == id.back()))
{
pLayer = *layer;
break;
}
}
}
if (pLayer == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
}
setLastError(SIMPLE_NO_ERROR);
return pLayer;
}