arcengine 数据转换和迁移函数说明

http://edndoc.esri.com/arcobjects/9.2/NET/c45379b5-fbf2-405c-9a36-ea6690f295b2.htm SummaryThis topic discusses the different classes and interfaces that can beused to transfer datasets from one geodatabase to another, includingthe advantages and disadvantages of each. Development licensingDeployment licensingArcViewArcViewArcEditorArcEditorArcInfoArcInfoEngine Developer KitEngine Runtime In this topic
Overview of data conversion and transferWithinthe geodatabase and geodatabase user interface (UI) libraries, thereare five main interfaces involved with transferring datasets fromone workspace to another. See the following topics: Inaddition to these classes and interfaces, other options fortransferring data exist. The following table gives an overview of thebenefits and drawbacks of each: MethodWhat is transferredWorks with query filterCrosses data sourcesWorks with edit sessionArcGIS Desktop/ ArcGIS EngineIFeatureDataConverter[2]Single table, feature class, or feature datasetTrueTrueFalseBothIGeoDBDataTransferMultiple tables, feature classes, and/or feature datasets, and domains from geodatabasesFalseFalseFalseBothIExportOperation (GeodatabaseUI)Single table or feature classTrueTrueFalseArcGIS DesktopIDataset.CopySingle dataset from afile-based data sourceFalseFalseFalseBothIWorkspaceFactory(Copy and Move methods)Local (personal or file) geodatabase, or an SDE connection fileFalseFalseFalseBothIGdbXmlExport and IGdbXmlImport (GeoDatabaseDistributed)Entire workspace (schema, data optional), one or more datasets (schema, data optional), or a record set *FalseFalseFalseBothIObjectLoader (EditorExt)Individual rows from one dataset to another existing datasetTrueTrueTrueArcGIS Desktop*The IGdbXmlExport and IGdbXmlImport interfaces indirectly transfer databetween geodatabases by first converting the dataset schema (and,optionally, the data) to Extensible Markup Language (XML), then fromXML back to its original form. To summarize the previous table, the following situations are appropriate for each method:
  • IFeatureDataConverter—Usewhen copying a single dataset or feature dataset and fine-grainedcontrol is necessary. This includes applying a query filter to restrictthe rows that are copied, modifying the geometry definition, andapplying a configuration key. Also useful for transferring datasetsfrom one data source to another.
  • IGeoDBDataTransfer—Use when copying one or more geodatabase datasets within the same geodatabase or to another geodatabase.
  • IExportOperation—Usewhen copying a single dataset to another workspace and a query filteror selection set is necessary. Also useful for transferring datasetsfrom one data source to another.
  • IDataset.Copy—Usewhen copying a dataset from a file-based data source (such as ashapefile, a database file [DBF] table, or a coverage feature class) toanother workspace.
  • IWorkspaceFactory (Copy and Move methods)—Use when copying or moving an entire local geodatabase or an SDE connection file.
  • IGdbXmlExport and IGdbXmlImport—Use when XML data is required, or working in a disconnected environment.
  • IObjectLoader—Use when copying individual rows to an existing dataset.
The last two methods in the preceding list are outside the scope of this topic. For more information, see the following: Name objects and conversion methodsManyof the application programming interfaces (APIs) for data transferinvolve the use of name objects. A name object is a lightweightrepresentation of a dataset or a workspace that provides basicinformation, such as name and location, without requiring the client toopen the dataset or the workspace. A name object can also represent adataset that doesn't currently exist—they are used in this way with theIFeatureDataConverter and IExportOperation interfaces. To get a name object for an existing dataset, there are three main options:
  • Create a name object of the appropriate type (that is, FeatureClassName), cast it to the IDatasetNameinterface, and set the Name and WorkspaceName properties. This optionrequires having a name object for the dataset's workspace (and featuredataset, if applicable), but this can be created in a similar fashion.
  • Generate a name object from an open dataset. After casting a dataset to the IDataset interface, the FullNameproperty can be used to create a name object. This is only applicablefor existing datasets, so it isn't an option in cases where a nameobject represents a dataset to be created.
  • Browse the dataset's container for its name object. An example of this is the IWorkspace.DatasetNamesmethod, which returns an enumerator of name objects for a specificdataset type. Again, this isn't an option for datasets that don't exist.
IFeatureDataConverter and IFeatureDataConverter2The featuredata converter copies a dataset within a workspace or to anotherworkspace (of the same data source type or another data sourcetype). The IFeatureDataConverterinterface allows fine-grained control over the process of converting a dataset, including the following:
  • Application of a query filter or a spatial filter to restrict the rows transferred to the new dataset.
  • Application of a query filter's SubFields properties to restrict the fields transferred to the new dataset.
  • Modificationof the fields used in the new dataset (to some extent). Examples ofthis include changing a field's name and length, and in some cases itstype (that is, a double field can be converted to an integer field).
  • Providing a new GeometryDef object to replace the existing geometry definition.
  • Setting a configuration keyword for the dataset.
Notall of these are applicable to every type of conversion; for example, atable cannot be given a GeometryDef and a query filter cannot be usedwhen converting a feature dataset.In addition to the capabilities listed previously, the IFeatureDataConverter2 interface includes the option of providing a selection set to its ConvertFeatureClass and ConvertTable methods. This is particularly useful when creating a new dataset from the selected features of a feature layer. The ConvertFeatureClass and ConvertTable methods of both feature data converter interfaces have an IEnumInvalidObjectreturn type. This enumerator returns the Object IDs for each row orfeature that could not be successfully converted, along with a shortdescription explaining why the conversion was unsuccessful. An exampleof why a conversion can fail is when the new dataset contains a stringfield with a shorter length than its corresponding field in theoriginal dataset, and an object's value for that field exceeds thenew length; however, it is important to remember the rejection of anindividual row or feature does not cancel the entire operation. TheConvertFeatureDataset method converts a feature dataset from one datasource to another; however, relatively few data sources support featuredatasets (compared to feature classes and tables), so it isn't used asoften as the other two conversion methods, and in most cases,IGeoDBDataTransfer is a better option for copying a feature dataset.This is especially true because ConvertFeatureDataset only transferschildren that are feature classes, whereas IGeoDBDataTransfer includesother types of datasets, such as relationship classes, topologies, andgeometric networks. The options available during conversion aresignificantly less than the other two methods, but a geometrydefinition and a configuration key can still be applied. Since afeature dataset doesn't include rows or features, this method has avoid return type. For more information, see the following topics: IGeoDBDataTransferUsingthe GeoDBDataTransfer class is equivalent to using the Copy and Pastecommands within ArcMap for geodatabase datasets. It allows one or moredatasets to be copied within or across geodatabases. The optionsavailable with this interface are significantly less than those of theIFeatureDataConverter methods, but in many cases this simplifies theoverhead preparation required for the transfer. Onemajor advantage of this interface over the feature data converter isthat it can be used to transfer nearly any type of geodatabase object,including relationship classes, topologies, geometric networks. It alsotransfers datasets and objects that are associated with a copiedobject automatically. For example, if this interface is used totransfer a feature class that utilizes domains or representationclasses, the process detects these and automatically transfers themwith the feature class. The only customizable aspect of this process is through a generated name mapping enumerator. The Transfer method requires a name mapping enumerator (IEnumNameMapping) that can be generated using the GenerateNameMappingmethod. Although the main reason to modify the name mappings is toresolve name conflicts (this occurs if a dataset of the same nameexists in the target workspace), the INameMappinginterface exposes properties that can be used to set the names and configuration keywords of the new datasets. For more information, see the following topic: IExportOperationThe IExportOperationinterface is effectively a "wrapped" version of the feature dataconverter. It allows a feature class or a table to be copied within itsexisting workspace or to another workspace (of the same or anothertype). The following are the three main differences between usingIExportOperation and IFeatureDataConverter:
  • It'sslightly less configurable. In some cases this may be a disadvantage,but in cases where modification of objects like the fieldscollection isn't required, this reduces the overhead preparationinvolved.
  • IExportOperation displays a progress barduring operation. This can be useful for graphical user interface (GUI)applications, but may be inappropriate for console applications orprocesses intended to be silent.
  • IExportOperation is located in the GeodatabaseUI library, meaning it is only available to ArcGIS Desktop users.
IDataset.CopyThe IDataset.Copymethod allows a dataset from a file-based data source (such as ashapefile, a DBF table, or a coverage feature class) to be copied toanother workspace of the same type. There are virtually no configurableoptions in this process, as the method only takes two parameters—thename and workspace of the new dataset.IWorkspaceFactory.Copy and IWorkspaceFactory.MoveIWorkspaceFactory.Copy and IWorkspaceFactory.Moveallow a local geodatabase (a personal or file geodatabase) or an SDEconnection file to be copied or moved within the file system. Bothmethods require workspace name objects. See the following:
  • Copy requires a name object for the existing workspace and for the workspace to be created.
  • Move only requires a name object for the existing workspace.
原文地址:https://www.cnblogs.com/adodo1/p/4327972.html