I have a group of Multipart Polyline Geometries which have measures. I am trying to re-order the geometries to better follow the traffic flow. I am using a GeometryBridge to add the re-orderd segments to an ISegmentCollection. The problem is that my segments have their M values reset so they must be IMSegmentation4 segments. When I try to add these to an ISegmentCollection VS the program won't compile. I am using VS2010, ArcGis 10.2 and Windows 7.
pExGeomColl = (IGeometryCollection)new Polyline();
pExGeomColl = (IGeometryCollection)pBaseFeat.ShapeCopy;
for (int i = 0; i < hGeomToFrom.Count; i++)
{
iTo = i;
iFrom = (int)hGeomToFrom[i];
pGeom = pExGeomColl.Geometry[iFrom];
pGeom.SpatialReference = pSpRef;
pMAware = (IMAware)pGeom;
pMAware.MAware = true;
pPolyline = (IPolyline6)new PolylineClass();
if (pGeom.GeometryType != esriGeometryType.esriGeometryPolyline)
{
pPolyline = geometryToPolyline(pGeom, false, true, ref sError);
if (sError.Length > 0)
{
sError = "cmdReset\r\n" + sError;
clsMain.write_log(sError, clsMain.m_eLogType.FATAL);
MessageBox.Show(sError);
return;
}
}
else
{
pPolyline = (IPolyline)pGeom;
}
dLen = pPolyline.Length;
dFrom = dMeasure;
dTo = dFrom + dLen;
pSeg = (IMSegmentation4)pPolyline;
pSeg.SetAndInterpolateMsBetween(dFrom, dTo);
dMeasure = dTo;
pSegArray[i] = pSeg;
ProgressBar1.Value = iCount;
iCount++;
}
// Add the segment array to a segment collection
pNewSegColl = (ISegmentCollection)new PolylineClass();
pMAware = (IMAware)pNewSegColl;
pMAware.MAware = true;
pGeomBridge = new GeometryEnvironmentClass();
pGeomBridge.AddSegments(pNewSegColl, pSegArray); // This doesn't work
pGeom = (IGeometry)pNewSegColl;
pGeom.SpatialReference = pSpRef;
pBaseFeat.Shape = pGeom;
pBaseFeat.Store();
Can anyone tell me how to accumulate a set of measure segments?