-2

I want to build a temporary FeatureClass which contains temporary Features , such as points, which are useless later in programming.

While, I searched for ArcObject API reference, but I can't find an efficient way to solve this problem. So how can I build temporary "container" to store some temporary Features ?

Should I first use CreateFeatureClass to build a real FeatureClass and later delete it? I don't think this method is cool for I have to deal with some CLSID thing.

PS:This "container" must have the ability to return a Cursor.

k.xf
  • 359
  • 1
  • 3
  • 10
  • Creating a feature-class and delete it afterwards is exactly the way to go. Of course you need some workspace this feature-class is created in. There are plenty of different workspace-factories for every kind of datasource, personal gdb, shapefile, remote workspace, raster... The `CLSID` by the way is not mandatory, you can leave it of as it simply references the class-extension related to your feature-class. However I suppose you won´t need it. – MakePeaceGreatAgain Sep 08 '16 at 12:48

2 Answers2

0

I think you should to use InMemoryWorkspace.

IWorkspaceFactory2 objWorkspaceFactory = new InMemoryWorkspaceFactoryClass(); IWorkspaceName objWorkspaceName = objWorkspaceFactory.Create(string.Empty, p_strName, null, 0); IName objName = (IName)objWorkspaceName; IWorkspace objWorkspace = (IWorkspace)objName.Open();

Now using this workspace you can to create Temprorary Feature Classes (perform search, get cursor and than delete the feature class). I believe that in your case InMemory Workspace is more efficient than working with ShapeFile or Personal Geodatabase.

Dima S.
  • 56
  • 2
0

You can use the IScratchWorkspaceFactory2 interface, which is used to create temporary personal geodatabases in the temp directory. You can find this directory by looking at the %TEMP% environment variable. The scratch personal geodatabase will have the name mx.mdb where is the lowest positive number that uniquely identifies the geodatabase.

IScratchWorkspaceFactory2 factory = new ScratchWorkspaceFactoryClass();
var selectionContainer = factory.DefaultScratchWorkspace;