How to create a feature dataset


This sample will demonstrate the steps needed to create a new feature dataset in a geodatabase. The function does not require that the spatial reference be supplied, however it is recommended that the appropriate spatial reference is used when creating data.
 

How to use

  1. Paste the function in your project.
  2. Call the function from your code.
[VCPP]
//
//
// createDataset:  creates a dataset in a workspace
// ISpatialReference is optional but should generally be defined by the caller
//
HRESULT createDataset(BSTR name, IWorkspace *workspace, IFeatureDataset
  **ppOutFeatureDataset, ISpatialReference *pSpatialReference)
{
  if (!workspace || !name)
    return E_POINTER;

  if (ppOutFeatureDataset == NULL)
    return E_POINTER;

  HRESULT hr;

  // establish the spatial reference if the caller took advantage of optional parameter
  CComPtr < ISpatialReference > ipSRef = pSpatialReference;
  if (!ipSRef)
  {
    ipSRef.CoCreateInstance(CLSID_UnknownCoordinateSystem);
    ipSRef->SetDomain(0, 21474.83645, 0, 21474.83645);
    ipSRef->SetFalseOriginAndUnits(0, 0, 100000);
    ipSRef->SetMDomain(0, 21474.83645);
    ipSRef->SetZDomain(0, 21474.83645);
    ipSRef->SetZFalseOriginAndUnits(0, 100000);
  }

  CComPtr < IFeatureWorkspace > ipFeatWksp;
  if (FAILED(hr = workspace->QueryInterface(&ipFeatWksp)))
    return hr;

  return ipFeatWksp->CreateFeatureDataset(name, ipSRef, ppOutFeatureDataset);
}






Development licensing Deployment licensing
Engine Developer Kit Engine