Select to view content in your preferred language

Spatial Reference Info

3517
11
02-18-2011 01:28 AM
ahuarte
Deactivated User
Hi!

I need read the SpatialReference info of a FeatureClass.

XML samples in the doc-SDK contains this description (WKT, WKID...) but calling to Table::GetDefinition() function it always returns no data.

I have test all sample gdb files and other personal gdb files FgdbV10.
What it's wrong?

thank you very much
0 Kudos
11 Replies
LanceShipman
Esri Regular Contributor
The following code produces XML with the spatial information:

  // Open the geodatabase.
  int hr;
  Geodatabase geodatabase;
  if ((hr = OpenGeodatabase(L"../data/ctg94AllDataset.gdb", geodatabase)) != S_OK)
  {
    wcout << "An error occurred while opening the geodatabase." << endl;
    wcout << "Error code: " << hr << endl;
    return -1;
  }

  // Open the ManyFieldTypes table.
  Table table;
  if ((hr = geodatabase.OpenTable(L"\\ctg83FDS\\ctg83FCinTopo", table)) != S_OK)
  {
    wcout << "An error occurred while opening the table." << endl;
    wcout << "Error code: " << 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;
    wcout << "Error code: " << hr << endl;
    return -1;
  }

  cout << xmlDef << endl;


I've attached the XML that this code produces.
0 Kudos
ahuarte
Deactivated User
thanks your reply

I am confused. I get this XML reading the ExecuteSQL-cities gdb sample from the sdk.

It have not WKT and WKID info and Table::getDefinition returns me the -2147211775 error code.

The table was opened success.

All samples from SDK and my gdbv10 files return equals.
why ¿?
0 Kudos
LanceShipman
Esri Regular Contributor
thanks your reply

I am confused. I get this XML reading the ExecuteSQL-cities gdb sample from the sdk.

It have not WKT and WKID info and Table::getDefinition returns me the -2147211775 error code.

What beta are you using we have released 2. I get the WKT in the XML. When does the error get returned? It's an item not found error. Can you post your code?


All samples from SDK and my gdbv10 files return equals.
why ¿?


I'm sorry, I don't understand. What returns equals?
0 Kudos
ahuarte
Deactivated User
I use the beta release 2.

my code...

  std::wstring tempString = L"";
  Helper_MarshalString(tableName, tempString);

  m_pDatabase = database->m_pDatabase;
  m_pTable = new FileGDBAPI::Table();
  long hr = m_pDatabase->OpenTable(tempString, *m_pTable);
  if (hr==S_OK) return false;
 
  std::string tempString2 = "";
  long hr = m_pTable->GetDefinition(tempString2); //-> ### ERROR -2147211775

tempString2 has XML content but NO WKT info!
all samples and my FGDB files (Imported in ArcCatalog 10 from shapefiles) return this error.


Sorry my bad english!
Thank you very much
0 Kudos
LanceShipman
Esri Regular Contributor
I use the beta release 2.

my code...

  std::wstring tempString = L"";
  Helper_MarshalString(tableName, tempString);

  m_pDatabase = database->m_pDatabase;
  m_pTable = new FileGDBAPI::Table();
  long hr = m_pDatabase->OpenTable(tempString, *m_pTable);
  if (hr==S_OK) return false;
 
  std::string tempString2 = "";
  long hr = m_pTable->GetDefinition(tempString2); //-> ### ERROR -2147211775

tempString2 has XML content but NO WKT info!
all samples and my FGDB files (Imported in ArcCatalog 10 from shapefiles) return this error.


Sorry my bad english!
Thank you very much


What version of Winodow and Visual Studio are you using?
0 Kudos
ahuarte
Deactivated User
I use

- Windows XP 32bits SP3 (spanish)
- Visual Studio 2008 9.0.30729.1 SP (english)
0 Kudos
LanceShipman
Esri Regular Contributor
std::wstring tempString = L"";
Helper_MarshalString(tableName, tempString);

m_pDatabase = database->m_pDatabase;
m_pTable = new FileGDBAPI::Table();
long hr = m_pDatabase->OpenTable(tempString, *m_pTable);
if (hr==S_OK) return false; <- this is incorrect. 

std::string tempString2 = "";
long hr = m_pTable->GetDefinition(tempString2); //-> ### ERROR -2147211775


if (hr != S_OK) return false 


S_OK (0) indicates success. The likely problem is that the table name is incorrect. Using
if(hr==S_OK) return false
the code will only continue executing if OpenTable fails. Any results from the GetDefinition is an error.

Do the samples execute for you?
0 Kudos
ahuarte
Deactivated User
I'm sorry, I copied the wrong code.

Please, ignore... "if (hr==S_OK) return false;" <- this is incorrect

XML file that I sent is the example "ExecuteSQL.gdb"


thak you very much!!!!
0 Kudos
LanceShipman
Esri Regular Contributor
Do the samples execute? This is important. We have tested the samples on most Windows platforms and have never seen a problem.
0 Kudos