ポリラインのセットに変換されるポイントのファイルがあります。いくつかの行はマルチパートであり、それらをsinglepartに変換したい。 ポイントが処理され、ポリラインが暫定フィーチャクラスに追加されます(バックアップ用)。ラインがマルチパートである場合、ラインはこの暫定フィーチャクラスにマルチパートとして追加されます。 暫定フィーチャクラスが読み込まれ、フィーチャがベースフィーチャクラスにコピーされます。これは単一部品の機能では問題なく機能しますが、マルチパートを単一部品に変換する際に、このジオメトリのタイプがサポートされていません。問題は、ポイントの集合からマルチパートフィーチャを作成するには、セグメントコレクションをパスとして使用する必要があるということです。これをポリラインに設定しようとしましたが、線分を追加するとエラーが発生します(間違ったジオメトリタイプ)。ポリラインのIGeometryCollectionはパスを返します
暫定フィーチャクラスにマルチパートフィーチャを追加すると、ジオメトリはポリラインになります。後でそれらを取得すると(新しいGeometryCollectionにthteシェイプを挿入することによって)、ジオメトリコレクションはポリラインですが、個々のジオメトリはパス(?)です。
コードは次のとおりです。
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;
コードのこの部分すべてが正常に動作します。 暫定フィーチャクラスからこれらのフィーチャを処理してベースフィーチャクラスに追加するとき、ジオメトリコレクションのジオメトリタイプが 'ポリライン'ではなく 'Path'であるため、エラーが発生します。
// 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