Select to view content in your preferred language

Cannot set metadata from rasters

3392
5
05-09-2011 01:40 AM
by Anonymous User
Not applicable
Original User: eddy scheper

In the FGDB API beta 3 version there are no methods to set of change the metadata/documentation of raster datasets.

For Feature Classes and Tables you can use Geodatabase.OpenTable to open the dataset and use Table.SetDocumentation to set the metadata. However, you can not open Raster Datasets with this Geodatabase method.

The Geodatabase class has a method to directly get the metadata of a dataset: Geodatabase.GetDatasetDocumentation. But a method Geodatabase.SetDatasetDocumentation is not available.

Will this method be available in the Final Release?

With kind regards,

Eddy Scheper
0 Kudos
5 Replies
LanceShipman
Esri Regular Contributor
While raster data will not be supported for this release of the API, you should be able to open the table and use SetDocumentation. I will investigate this and get back to you .
0 Kudos
by Anonymous User
Not applicable
Original User: lshipman

I've taken a look at this and I had no problem opening a RasterDataset and reading/writing it's Documentation. Take a look at the following code.

  
  // Open a RasterDataset table.
  Table table;
  if ((hr = geodatabase.OpenTable(L"\\RasterDataset", table)) != S_OK)
  {
    wcout << "An error occurred while opening the table." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  // GetDefitition
  wcout << "Test GetDefitition:" << endl;
  string xmlDef;
  if ((hr = table.GetDefinition(xmlDef)) != S_OK)
  {
    wcout << "An error occurred getting the table definition." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  wcout << wstring(xmlDef.begin(), xmlDef.end()) << endl;

  // GetDocumentation
  wcout << "Test GetDocumentation:" << endl;
  string xmlDef2;
  if ((hr = table.GetDocumentation(xmlDef2)) != S_OK)
  {
    wcout << "An error occurred getting the table documentation." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  wcout << wstring(xmlDef2.begin(), xmlDef2.end()) << endl;

  ofstream myfile;
  myfile.open("../SchemaRetrieval/example.xml", ios::out);
  myfile << xmlDef;
  xmlDef.clear();
  myfile.close();

  // Open the newDoc.xml to load documentation for the feature class.
  string docDef;
  string docLine;
  ifstream docFile("../SchemaRetrieval/newDoc.xml");
  while (getline(docFile, docLine))
    docDef.append(docLine + "\n");
  docFile.close();

  // SetDocumentation
  wcout << "Test SetDocumentation:" << endl;
  if ((hr = table.SetDocumentation(docDef)) != S_OK)
  {
    wcout << "An error occurred setting the table documentation." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  // Validate that the doc was set.
  wcout << "Validate that the doc was set:" << endl;
  if ((hr = table.GetDocumentation(xmlDef2)) != S_OK)
  {
    wcout << "An error occurred getting the table documentation." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  wcout << wstring(xmlDef2.begin(), xmlDef2.end()) << endl;
0 Kudos
by Anonymous User
Not applicable
Original User: eddy scheper

Hello Lance,

I did some tests using a part of your code (see below).

int main()
{
  long hr;

  wstring errorText;

  // Open the geodatabase.
  Geodatabase geodatabase;
  if ((hr = OpenGeodatabase(L"C:/Project/Mpt/Data/TestFileGeodatabase10.gdb", geodatabase)) != S_OK)
  {
    wcout << "An error occurred while opening the geodatabase." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  // Open the table.
  Table table;
  //if ((hr = geodatabase.OpenTable(L"\\basis2", table)) != S_OK)
  //if ((hr = geodatabase.OpenTable(L"\\basis2xx", table)) != S_OK)
  if ((hr = geodatabase.OpenTable(L"\\bodem5000", table)) != S_OK)
  {
    wcout << "An error occurred while opening the table." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  // Open the metadata.
  string xml;
  if ((hr = table.GetDocumentation(xml)) != S_OK)
  {
    wcout << "An error occurred while getting the metadata." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  cout << xml;

  return 0;
}


These are my results.
- Using the Feature Class \\basis2 >> OK, I get the metadata.
- Using a non existent Feature Class \\basis2xx >> OK, I get a proper error message.
- Using the Raster Dataset bodem5000 >> NOK, I get an windows error (in VS2010: Unhandled exception at 0x1038b235 (FileGDBAPID.dll) in MptFgdbExe.exe: 0xC0000005: Access violation reading location 0x00000000.).

When using the following code instead, I get the proper metadata.

  string xml;
  if ((hr = geodatabase.GetDatasetDocumentation(L"\\bodem5000",L"Raster Dataset",xml)) != S_OK) {
    wcout << "An error occurred while getting the metadata." << endl;
 ErrorInfo::GetErrorDescription(hr, errorText);
 wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }


I'm using the FileGeodatabase I send you today. It contains both the basis2 and bodem5000 datasets.

Hopefully this helps to solve the problem.

With kind regards,

Eddy Scheper
0 Kudos
LanceShipman
Esri Regular Contributor
I was able to get and set the documentation for both the basis2 and bodem5000 datasets using the current build of the API. This using table.GetDocumentation and table.SetDocumentation. We should be posting final soon.
0 Kudos
by Anonymous User
Not applicable
Original User: eddy scheper

Great! I can't wait.

Eddy
0 Kudos