public static void AddPaths([NotNull] IList <Linestring> linestringsToAdd, [NotNull] IPolyline toResult) { Func <Pnt3D, WKSPointZ> createPoint; if (GeometryUtils.IsZAware(toResult)) { createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, p.Z); } else { createPoint = p => WKSPointZUtils.CreatePoint(p.X, p.Y, double.NaN); } IPath pathTemplate = GeometryFactory.CreateEmptyPath(toResult); foreach (Linestring resultLinestring in linestringsToAdd) { var pathPoints = new WKSPointZ[resultLinestring.SegmentCount + 1]; var i = 0; foreach (Line3D line3D in resultLinestring) { pathPoints[i++] = createPoint(line3D.StartPoint); } Pnt3D last = resultLinestring[resultLinestring.SegmentCount - 1].EndPoint; pathPoints[i] = createPoint(last); IPath path = GeometryFactory.Clone(pathTemplate); GeometryUtils.AddWKSPointZs((IPointCollection4)path, pathPoints); ((IGeometryCollection)toResult).AddGeometry(path); } }
private static IPath CreateEmptyPath(Ordinates ordinates) { bool zAware = ordinates == Ordinates.Xyz || ordinates == Ordinates.Xyzm; bool mAware = ordinates == Ordinates.Xym || ordinates == Ordinates.Xyzm; // NOTE: Somtimes this takes ca. 250ms (may be when the license is checked?)! IPath result = GeometryFactory.CreateEmptyPath(zAware, mAware); return(result); }