我怎么能够把国际化联会反对XML。
还有一些资源用于将IXMLSerializer用于其他ArcoObjects,但是,由于FeatureClass用于实施国际宇宙科学应用,因此赢得了该图人的工作。
我怎么能够把国际化联会反对XML。
还有一些资源用于将IXMLSerializer用于其他ArcoObjects,但是,由于FeatureClass用于实施国际宇宙科学应用,因此赢得了该图人的工作。
我实际找到了我自己对这个问题的答复。 我在此提出这个问题并作答是为了其他人的利益,也是为了对我的做法提出反馈/批评。
简称表 不能直接分类,但IRecordSet2可能。 因此,第一步是采用一种方法,将国际地联会地图册转换为国际RecordSet:
private static IRecordSet2 ConvertToRecordset(IFeatureClass fc)
{
IRecordSet recSet = new RecordSetClass();
IRecordSetInit recSetInit = recSet as IRecordSetInit;
recSetInit.SetSourceTable(fc as ITable, null);
return (IRecordSet2) recSetInit;
}
之后,很容易利用IXMLSerializer获得XML:
public static XElement StoreAsXml(IFeatureClass fc)
{
// Can t serialize a feature class directly, so convert
// to recordset first.
IRecordSet2 recordset = ConvertToRecordset(fc);
IXMLSerializer xmlSer = new XMLSerializerClass();
string sXml = xmlSer.SaveToString(recordset, null, null);
return XElement.Parse(sXml);
}
然而,当你改写为IRecordSet2时,你就失去了特征类别名称,因此,在撰写档案时,我添加了XML的内容,以掌握特征类别的名称:
public static void StoreToFile(IFeatureClass fc, string filePath)
{
XElement xdoc = StoreAsXml(fc);
XElement el = new XElement("FeatureClass", new XAttribute( "name", fc.AliasName ),
xdoc);
el.Save(filePath);
}
现在,这一进程只是将XML改为特殊类别。 认为添加了元素以储存特征类别名称:
public static IFeatureClass RetreiveFromFile(string filepath)
{
XElement xdoc = XElement.Load(filepath);
string sName = xdoc.FirstAttribute.Value;
XNode recordset = xdoc.FirstNode;
return RetreiveFromXml(recordset, sName);
}
利用IXMLSerializer获得IRecord Set2:
public static IFeatureClass RetreiveFromXml(XNode node, string sName)
{
IXMLSerializer xmlDeSer = new XMLSerializerClass();
IRecordSet2 recordset = (IRecordSet2)xmlDeSer.LoadFromString(node.ToString(), null, null);
return ConvertToFeatureClass(recordset, sName);
}
这是骗局。 I m欢迎就如何改进这一......提出建议,将IRecordSet2物体列入国际地联会:
private static IFeatureClass ConvertToFeatureClass(IRecordSet2 rs, string sName)
{
IWorkspaceFactory pWSFact = new ShapefileWorkspaceFactory();
string sTempPath = Path.GetTempPath();
IFeatureWorkspace pFWS = (IFeatureWorkspace)pWSFact.OpenFromFile( sTempPath, 0);
// Will fail (COM E_FAIL) if the dataset already exists
DeleteExistingDataset(pFWS, sName);
IFeatureClass pFeatClass = null;
pFeatClass = pFWS.CreateFeatureClass(sName, rs.Fields, null, null, esriFeatureType.esriFTSimple,
"SHAPE", "");
// Copy incoming record set table to new feature class s table
ITable table = (ITable) pFeatClass;
table = rs.Table;
IFeatureClass result = table as IFeatureClass;
// It will probably work OK without this, but it makes the XML match more closely
IClassSchemaEdit3 schema = result as IClassSchemaEdit3;
schema.AlterAliasName(sName);
schema.AlterFieldAliasName("FID", "");
schema.AlterFieldModelName("FID", "");
schema.AlterFieldAliasName("Shape", "");
schema.AlterFieldModelName("Shape", "");
// If individual fields need to be edited, do something like this:
// int nFieldIndex = result.Fields.FindField("Shape");
// IFieldEdit2 field = (IFieldEdit2)result.Fields.get_Field(nFieldIndex);
// Cleanup
DeleteExistingDataset(pFWS, sName);
return table as IFeatureClass;
}
最后,删除现有数据集的实用方法。 这本书来自某些地方,但我无法记住来文方。
public static void DeleteExistingDataset(IFeatureWorkspace pFWS, string sDatasetName)
{
IWorkspace pWS = (IWorkspace)pFWS;
IEnumDatasetName pEDSN = pWS.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
bool bDatasetExists = false;
pEDSN.Reset();
IDatasetName pDSN = pEDSN.Next();
while (pDSN != null)
{
if (pDSN.Name == sDatasetName)
{
bDatasetExists = true;
break;
}
pDSN = pEDSN.Next();
}
if (bDatasetExists)
{
IFeatureClass pFC = pFWS.OpenFeatureClass(sDatasetName);
IDataset pDataset = (IDataset)pFC;
pDataset.Delete();
}
}
I m looking for info on how to write SQL scripts to automate the creation of a versioned feature class in ArcSDE I want to be able to automate the process itself as well as put the scripts under ...
Has anyone installed ESRI mapobjects activeX controls in Delphi 2010? I get a conflict on tTable as a component name.
I would like a Visual Basic for Application Function which shows the path of the current document. For example if ArcMap is displaying map.mxd I need to display its path. I found only some examples ...
I have an ESRI dropdown control inside of an ESRI toolbar. One of the items in the dropdown needs to have an & symbol in it. As it turns out ESRI stuff builds its callback strings as & ...
I m supporting an application built on ESRI ArcObjects where the original developers are long since gone. The application after having worked fine for a couple of years has started failing with this ...
I m struggling with a really stubborn problem here. I have a FeatureClass which I want to add to my map, the problem is that every example I can find requires me to hardcore a servicestring, point to ...
I m trying to enable a double click event on a flex control without disabling the default mouseup/mousedown behaviors. I m using the ESRI Flex API for arcgis server, and I have a map control with ...
What is the preferred method of altering a layer s symbology dynamically? My web app consumes a map service via the REST API, but I don t mind using the SOAP API or ArcObjects (.NET).