예제 #1
0
bool DeriveLayer::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   VERIFY(pInArgList != NULL);
   StepResource pStep("Execute Wizard Item", "app", "56D70072-0716-4506-B70D-9E6BD10C96A3");
   pStep->addProperty("Item", getName());
   mpStep = pStep.get();

   if (!extractInputArgs(pInArgList))
   {
      reportError("Unable to extract input arguments.", "4DB42DD5-2198-4d1e-BBB5-9745D4242C9D");
      return false;
   }

   // Get the view
   SpatialDataView* pView = dynamic_cast<SpatialDataView*>(mpInputLayer->getView());
   if (pView == NULL)
   {
      reportError("Only layers in a spatial data view can be converted.", "{039ac767-e6d5-441b-9b27-bf59cbb9ee9d}");
      return false;
   }

   Layer* pNewLayer = NULL;
   if (mNewLayerName.empty())
   {
      pNewLayer = pView->convertLayer(mpInputLayer, mNewLayerType);
   }
   else
   {
      pNewLayer = pView->deriveLayer(mpInputLayer, mNewLayerType);
      if (pNewLayer != NULL)
      {
         if (!pView->getLayerList()->renameLayer(pNewLayer, mNewLayerName))
         {
            pView->deleteLayer(pNewLayer);
            reportError("Unable to derive a layer with the given name, because another layer "
               "with the same name already exists.", "{1e81e201-624f-4e96-83b5-8ceae01d7c1d}");
            return false;
         }
      }
   }
   if (pNewLayer == NULL)
   {
      reportError("Unable to convert the layer.", "{f09810c2-f2a2-4887-a0f0-6848d74ffd28}");
      return false;
   }

   // Set the output value
   if (pOutArgList != NULL)
   {
      if (!pOutArgList->setPlugInArgValue("Layer", pNewLayer) ||
          !pOutArgList->setPlugInArgValue("Element", pNewLayer->getDataElement()))
      {
         reportError("Could not set the output value!", "3E2591B0-F41B-4de1-9D76-45245F9EF343");
         return false;
      }
   }

   reportComplete();
   return true;
}
예제 #2
0
 Layer* convertLayer(Layer* pLayer, const char* pType)
 {
    if (pLayer == NULL)
    {
       setLastError(SIMPLE_BAD_PARAMS);
       return NULL;
    }
    SpatialDataView* pView = dynamic_cast<SpatialDataView*>(pLayer->getView());
    if (pView == NULL)
    {
       setLastError(SIMPLE_WRONG_VIEW_TYPE);
       return NULL;
    }
    pLayer = pView->convertLayer(pLayer, StringUtilities::fromXmlString<LayerType>(std::string(pType)));
    if (pLayer == NULL)
    {
       setLastError(SIMPLE_WRONG_TYPE);
       return NULL;
    }
    setLastError(SIMPLE_NO_ERROR);
    return pLayer;
 }