Hi Steph,
I found a way to make the shape valid so that it is editable but the issue is that a shape in that form cannot be edited into an acceptable shape as its control points do not allow it.
Using the TrackAndEditShapes sample application as a base I setup the following for the edit button:
case "btnTrackEdit":
wpfMap1.TrackOverlay.TrackMode = TrackMode.None;
foreach (Feature feature in wpfMap1.TrackOverlay.TrackShapeLayer.InternalFeatures)
{
Feature featureMadeValid = new Feature();
if (feature.IsValid())
{
wpfMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature);
}
else
featureMadeValid = feature.MakeValid();
wpfMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(featureMadeValid);
//ShapeValidationResult result = feature.GetShape().Validate(ShapeValidationMode.Advanced);
}
Once this code runs you get control points for the shape but you will find that the center control point where the lines of the polygon overlap will only allow you to move this center section, not resize it to make it a truly valid polygon. This is a bit of a difficult issue in that there are many reasons why a particular shape might be invalid and and depending on why the shape is invalid can determine what needs to be done with the shape. For this particular instance one could override the CalculateAllControlPoint() to find the shared point of the two polygons and perform some special logic to seperate the two polygons so that they could be manipulated seperately. Another idea is to use the following to create two seperate features so they each have Editing Control Points.
case "btnTrackEdit":
wpfMap1.TrackOverlay.TrackMode = TrackMode.None;
foreach (Feature feature in wpfMap1.TrackOverlay.TrackShapeLayer.InternalFeatures)
{
Feature featureMadeValid = new Feature();
if (feature.IsValid())
{
wpfMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(feature);
}
else
{
featureMadeValid = feature.MakeValid();
foreach (PolygonShape polygon in ((MultipolygonShape)featureMadeValid.GetShape()).Polygons)
{
Feature seperateFeature = new Feature(polygon);
wpfMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(seperateFeature);
}
}
//wpfMap1.EditOverlay.EditShapesLayer.InternalFeatures.Add(featureMadeValid);
//ShapeValidationResult result = feature.GetShape().Validate(ShapeValidationMode.Advanced);
}
wpfMap1.TrackOverlay.TrackShapeLayer.InternalFeatures.Clear();
wpfMap1.EditOverlay.CalculateAllControlPoints();
wpfMap1.Refresh(new Overlay[] { wpfMap1.EditOverlay, wpfMap1.TrackOverlay });
break;
Here are some screenshots showing the invalid feature, and the seperated features each with their own Controls: