Hi guys,
In addition to my previous post re removing lines from multilineshape, now I'm trying to add lines to an existing multilineshape using the following code:
private void AddLineToMultiLineShape(string lineLayerKey, string lineKey, string wellKnownText)
{
LayerOverlay lineLayerOverlay = (LayerOverlay)Map1.Overlays[DEFAULT_LINE_LAYER_OVERLAY_KEY];
InMemoryFeatureLayer lineLayer = null;
if (TryToGetLineLayer(lineLayerKey, out lineLayer, true))
{
if (lineLayer.InternalFeatures.Contains(lineKey))
{
MultilineShape multilineShape = (MultilineShape)lineLayer.InternalFeatures[lineKey].GetShape();
MultilineShape newLineSegment = new MultilineShape(wellKnownText);
for (int i = 0; i < newLineSegment.Lines.Count; i++)
{
multilineShape.Lines.Add(newLineSegment.Lines[i]);
}
lineLayer.Open();
if (lineLayer.EditTools.IsEditable)
{
lineLayer.EditTools.BeginTransaction();
Dictionary<string, string> columnValues = lineLayer.InternalFeatures[lineKey].ColumnValues;
lineLayer.EditTools.Update(multilineShape, columnValues);
lineLayer.EditTools.CommitTransaction();
}
else
{
lineLayer.Close();
throw new InvalidOperationException("The line layer not editable.");
}
lineLayer.Close();
}
else
{
throw new KeyNotFoundException("Line cannnot be found on the line layer.");
}
lineLayerOverlay.Refresh();
}
else
{
throw new KeyNotFoundException("Line layer cannnot be found on the line overlay.");
}
}
But the new lines are not being rendered on the map. I'm not sure if adding vertices to a lineshape is working either. As far as I remember, it used to work in the pre 16/11/09 build:
lineShape.Vertices.Add(vertex);
lineLayer.Open();
if (lineLayer.EditTools.IsEditable)
{
lineLayer.EditTools.BeginTransaction();
lineLayer.EditTools.Update(lineShape);
lineLayer.EditTools.CommitTransaction();
}
lineLayer.Close();
Thanks in advance,
Nirish