更改多部件几何的顺序

时间:2017-04-13 03:07:20

标签: arcobjects

我有一组具有测量值的Multipart Polyline Geometries。我正在尝试重新排序几何图形以更好地遵循交通流量。 我正在使用GeometryBridge将重新排序的段添加到ISegmentCollection。 问题是我的段重置了M值,所以它们必须是IMSegmentation4段。当我尝试将这些添加到ISegmentCollection VS时,程序将无法编译。 我正在使用VS2010,ArcGis 10.2和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();

有谁能告诉我如何累积一组度量段?

1 个答案:

答案 0 :(得分:0)

我发现使用Segment Collection是错误的方法。段是折线顶点之间的线段。

诀窍是将折线放入几何集合中,然后将该几何集合的部分添加到新的(重新排序的)集合中。

$.ajax({
  url: "http://pokeapi.co/api/v2/pokemon/",
  dataType: "json",
  method: "GET",
  cache: false,
  success: function(data) {
    for (var i = 0; i<data.results.length ;i++){
      $("#root ul").append('<li class="box"></li>');
      $("li").eq(i).append('<h2>' + data.results[i].name +'</h2>');
    }
    setPkmImage(data.results);
    console.log(data);
  },
  error: function(data) {
    console.log("Error");
  }

});