Select to view content in your preferred language

Creating feature class with unknown coordinate system - XML definition

5979
14
07-12-2011 02:02 AM
ChrisMorgan1
Occasional Contributor
Hi,
I am trying to create feature classes with an unknown coordinate system using the FGDB API.
The feature classes appear to create OK, and I can add features, but I then get drawing errors
in Arcmap, and errors in ArcCatalog if I try to copy/paste the feature class or export it as XML.

Can you tell me what I am missing from my XML feature class definition? Please see attached XML feature class definition.

Thanks very much,

Chris
0 Kudos
14 Replies
ChrisMorgan1
Occasional Contributor
Some additional information.
Here's my sample code to create an empty feature class

int main()
{
  fgdbError hr;
  wstring   errorText;

  // create geodatabase
  Geodatabase geodatabase;
  if ((hr = CreateGeodatabase(L"c:\\testing.gdb", geodatabase)) != S_OK) {
 wcout << "Geodatabase create error" << endl;
 ErrorInfo::GetErrorDescription(hr, errorText);
 wcout << errorText << "(" << hr << ")." << endl;
 return -1;
  }

  // load XML table def
  string tableDef;
  string defLine;
  ifstream defFile("C:\\create-chris1.xml");
  while (getline(defFile,defLine))
   tableDef.append(defLine+"\n");
  defFile.close();

  // create table from XML def
  Table table;
  if ((hr = geodatabase.CreateTable(tableDef,L"",table)) != S_OK) {
    wcout << "CreateTable error" << endl;
 ErrorInfo::GetErrorDescription(hr, errorText);
 wcout << errorText << "(" << hr << ")." << endl;
 return -1;
  }

  if ((hr = geodatabase.CloseTable(table)) != S_OK) {
    wcout << "CloseTable error" << endl;
 ErrorInfo::GetErrorDescription(hr, errorText);
 wcout << errorText << "(" << hr << ")." << endl;
 return -1;
  }

  // Close the geodatabase
  if ((hr = CloseGeodatabase(geodatabase)) != S_OK)
  {
    wcout << "An error occurred while closing the geodatabase." << endl;
    ErrorInfo::GetErrorDescription(hr, errorText);
    wcout << errorText << "(" << hr << ")." << endl;
    return -1;
  }

  return 0;
}


This creates the FGDB and feature class without any apparent errors.

Then, in ArcCatalog (10 SP2), I try to copy/paste the feature class, and receive this error:
Failed to paste chris1
The XML being loaded could not be parsed. [physical name: CHRIS1]
The item does not have a definition.
The XML being loaded could not be parsed. [physical name: CHRIS1]

This would appear to imply to me that my initial XML feature class definition is missing some required field. Help would be very much appreciated! Thanks.

Chris
0 Kudos
VinceAngelo
Esri Esteemed Contributor
The folks most likely to able to answer this are probably swamped with UC attendance.
You might get quicker response by contacting Tech Support.

It looks to me like you're missing the AliasName and ModelName tags within Field; though
the XSD doesn't seem to require them, all the examples do include both.

- V
0 Kudos
ChrisMorgan1
Occasional Contributor
Hi,
Thanks for the reply.
I had tried adding the AliasName and ModelName to each field, but it appears to make no difference.
In my actual application I am attempting to create the XML dynamically, using
IXMLDomDocument, and I already have have a screen full of node.addChildElement(...) etc, so I'm
just trying to cut the XML down to the bare essentials.
I'll keep on experimenting. I can create correct feature classes if I already know the spatial reference, but the trouble is, I don't, The API does not seem to have any mechanism for choosing a valid one (a redistributable XML file of valid spatial references would be useful). I was planning to create feature classes with an undefined spatial reference, and then let the user define the spatial reference later using ArcCatalog.
So I'm still trying to find the minimum required XML for a feature class with an undefined spatial reference.

cheers,

Chris
0 Kudos
VinceAngelo
Esri Esteemed Contributor
It isn't particularly wise to leave the coordinate system undefined. Using an impossibly large
spatial reference does more harm than good, and origin and scale parameters cannot be
adjusted later with the coordsys.

There are several thousand "standard" coordinate systems, and an infinite number of
potential spatial references. The Esri Projection Engine is used to define coordinate
systems; it is based on the EPSG reference standard. Samples of the most common
forms ship with every copy of ArcGIS. The projection gurus established a standard set
of parameters for each spatial reference used by ArcGIS, but any of them can (and really
should) be overridden to optimize performance for any particular dataset.

I agree that the XML definition process leaves a lot to be desired, but coming from the
ArcSDE side of the house, and knowing that the Projection Engine and Coordinate Reference
code represents nearly half of the ArcSDE functions, I can see how this could be a slippery
slope that could have delayed the FileGDB API delivery by years.

- V
0 Kudos
ChrisMorgan1
Occasional Contributor
It isn't particularly wise to leave the coordinate system undefined. Using an impossibly large
spatial reference does more harm than good, and origin and scale parameters cannot be
adjusted later with the coordsys.


Hi Vince,
I am aware that it is far from ideal to create a feature class with an unknown spatial reference,
but the FGDB API seems to allow it, and ArcCatalog allows it as well.
I am intending that the spatial reference will be defined later, within ArcCatalog, since at this stage
I wish to avoid having to develop an entire spatial reference selection/editing mechanism - that is
what ArcGIS does, and I have no wish to duplicate it at this stage!

The FGDB API samples XMLSamples dir even includes a sample XML table def FC_Unknown_PolygonMin.xml which is supposed to have the minimal required spatial reference info,
but this fails when called with CreateTable (General function failure (-2147467259)).

I tried constructing a feature class in ArcCatalog with undefined spatial reference, then exported the schema as XML, and used that as the basis for my XML used in CreateTable. This is the basis for my create-chris1.xml table def. However, I am still missing something, as ArcCatalog does not fully recognise the new feature class.

cheers,

Chris
0 Kudos
VinceAngelo
Esri Esteemed Contributor
Unfortunately, when you set out to use the FileGDB API to create new tables, you are choosing to
take over ArcGIS' role in feature class creation.  Using generic parameters for table creation may
be possible, but it's unlikely to generate high quality datasets -- if you don't know, at a minimum,
the spatial units being used and the range of possible values (and alter the spatial reference to
correspond to them) then I'd argue that it's not really worth the effort of loading the data.

I know the samples execute cleanly on the reference machines, so this should probably be your
first line of inquiry with Tech Support.

- V
0 Kudos
ChrisMorgan1
Occasional Contributor
Unfortunately, when you set out to use the FileGDB API to create new tables, you are choosing to
take over ArcGIS' role in feature class creation.  Using generic parameters for table creation may
be possible, but it's unlikely to generate high quality datasets -- if you don't know, at a minimum,
the spatial units being used and the range of possible values (and alter the spatial reference to
correspond to them) then I'd argue that it's not really worth the effort of loading the data.


Hi Vince,
The problem I am having is that the XML definition for an undefined spatial reference in the sample XML seems to be incomplete, and will not create a valid feature class - even an empty one. If I can get a working definition of an undefined spatial reference, then I can adjust the range and tolerance accordingly. But, as I have said, the spatial reference will be set later, before the feature class in ever used, within the ArcGIS environment.

cheers,

Chris
0 Kudos
ChrisMorgan1
Occasional Contributor
OK, let's try another tack. The unknown coordinate system turns out to be too much of a distraction.
I now have an XML feature class definition with a defined spatial reference - see attachment.

This creates an empty polyline-M feature class 'chris1'.
I have code which successfully adds features to this feature class, but I have not included that here.

However, ArcCatalog still does not fully recognise this feature class as valid.
The features can be viewed, but when attempting to copy/paste the feature class in
ArcCatalog, I now get the error message

Failed to paste chris1
Unable to create object class instance COM component
Unable to create object class instance COM component

I have concluded that my XML definition is still incomplete. What am I missing?

Thanks,

Chris
0 Kudos
LanceShipman
Esri Regular Contributor
We have duplicated your issue and are debugging it. I will be on vacation next week, so I will not get back to you until the week of July the 25th.
0 Kudos