// build a polyline
var polyline = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint(1, 1, 10, 20),
MapPointBuilder.CreateMapPoint(0, 0, 10, 20),
MapPointBuilder.CreateMapPoint(1, -1, 10, 20)
});
// build the extender line
var extender = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint(2, 2),
MapPointBuilder.CreateMapPoint(2, -2),
});
// extend
var result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes);
Polyline extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 10, 20
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// result.Parts[0].Points[4] = 2, -2, 10, 20
// change the flags
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.NoEndAttributes);
extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 0
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// result.Parts[0].Points[4] = 2, -2, 0
// extend
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.KeepEndAttributes | ExtendFlags.NoExtendAtTo);
extendedLine = result as Polyline;
// result.Parts[0].Points[0] = 2, 2, 10, 20
// result.parts[0].Points[1] = 1, 1, 10, 20
// result.Parts[0].Points[2] = 0, 0, 10, 20
// result.Parts[0].Points[3] = 1, -1, 10, 20
// extend with no intersection
polyline = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint(1, 1),
MapPointBuilder.CreateMapPoint(3, 1)
});
extender = PolylineBuilder.CreatePolyline(new[]
{
MapPointBuilder.CreateMapPoint(1, 4),
MapPointBuilder.CreateMapPoint(3, 4)
});
result = GeometryEngine.Instance.Extend(polyline, extender, ExtendFlags.Default);
// result = null