Hey @Jonathan3,
Ahh, yes, that does make a lot more sense. So, we don’t have an API like that in ThinkGeo, but that doesn’t mean that it can’t be done. NetTopologySuite has a way to get what’s called an offset curve that basically creates a parallel of a line that you describe. We have to do some simple converting between our LineShape
and their Coordinate[]
, but it works with a limiting factor being the distance to sharp angle:
private LineShape GetOffsetCurve(LineShape lineShape, double offsetDistance)
{
OffsetCurveBuilder ocb = new OffsetCurveBuilder(new PrecisionModel(), new BufferParameters(8, EndCapStyle.Round, JoinStyle.Mitre, 4));
Coordinate[] coordinates = new Coordinate[lineShape.Vertices.Count];
for (int i = 0; i < lineShape.Vertices.Count; i++)
{
coordinates[i] = new Coordinate(lineShape.Vertices[i].X, lineShape.Vertices[i].Y);
}
var offsetCurve = ocb.GetOffsetCurve(coordinates, offsetDistance);
LineShape result = new LineShape();
foreach (var coordinate in offsetCurve)
{
result.Vertices.Add(new Vertex(coordinate.X, coordinate.Y));
}
return result;
}
Thanks,
Kyle