我有将要被转换成一组折线点的文件。一些线是多部分,我想将它们转换为单部分。 处理点并将多段线添加到临时要素类(用于备份目的)。如果一行是多部分,则它将作为多部分添加到此临时要素类中。 然后读取临时要素类,并将其复制到基本要素类中。这适用于单部件特征,但在将多部件转换为单部件时,我始终得到'不支持此几何类型'的错误。问题是,要从一组点创建多部分功能,我必须将一个段集合用作Path。我试着把它设置成多段线,但是向它添加线段会导致错误(错误的几何类型)。IGeometryCollection折线的返回路径
当我到多的功能添加到临时要素类的几何形状折线。当我稍后检索它们(通过将形状放入新的GeometryCollection中)时,几何集合是Polyline,但各个几何体是Paths(?)。
的代码是:
1. Add points to interim featureclass by putting them in a pointcollection.
pPtColl = (IPointCollection4)new Polyline();
pGeomColl = (IGeometryCollection)new Polyline();
// Fill point collection
.......
// Create a path made up of segments from the point collection
ISegment pSegment;
ISegmentCollection pSegColl = (ISegmentCollection)new ESRI.ArcGIS.Geometry.Path(); // Fails if changed to new Polyline()
// M and Z aware
if (bHasZ == true)
{
pZAware = (IZAware)pSegColl;
pZAware.ZAware = true;
}
if (bHasM == true)
{
pMAware = (IMAware)pSegColl;
pMAware.MAware = true;
}
for (int n = 1; n < pPtColl.PointCount; n++)
{
pSegment = (ISegment)new Line();
pSegment.SpatialReference = pSpRef;
pSegment.FromPoint = pPtColl.Point[n - 1];
pSegment.ToPoint = pPtColl.Point[n];
pSegColl.AddSegment(pSegment, oMissing, oMissing);
}
pGeomColl.AddGeometry(pSegColl as IGeometry, oMissing, oMissing);
pGeom = (IGeometry)pGeomColl; // pGeom has geometry type = Polyline
pGeom.SpatialReference = pSpRef;
pFeat.Shape = pGeom;
代码一切工作正常的这一部分。 处理临时要素类中的这些要素以将它们添加到基础要素类时,我收到一个错误,因为几何集合中的几何类型是'路径'而不是'折线'。
// Read the geometry from the interim feature into a geometry collection
pGeomColl = (IGeometryCollection)new Polyline();
pGeomColl = (IGeometryCollection)pFromFeature.ShapeCopy;
for (int j = 0; j < pGeomColl.GeometryCount; j++)
{
// Create a new (Polyline) feature pToFeat and populate its attributes
pToFeat = pToFC.CreateFeature();
....
// pGeomColl has geometry type = Polyline
pGeom = pGeomColl.Geometry[j]; // pGeom has geometry type = Path
pToFeat.Shape = pGeom; // Fails. pToFeat is a Polyline.
}
如何确保几何集合包含带多段线而不是路径的几何?
感谢,
JM