I am using NetTopologySuite for some simplificaiton of lines.
The issue I am facing is I have my own class that store list of Point3D (System.Windows.Media) and NetTopology has its own Coordinate class with almost the same properties and functions.
To convert the point3D list to coorinate array I am using this function:
public static GeoApiInterfaces.ICoordinate[] ToCoordinateArray(this IEnumerable<Point3D> listToClone,
bool isClosed = false)
{
// if geometry is to be closed the size of array will be one more than the
// current point count
var coordinateList = new GeoApiInterfaces.ICoordinate[isClosed ?
listToClone.Count() + 1
: listToClone.Count()];
// loop through all the point in the list to create the array
int elementIndex = 0;
foreach (var point in listToClone)
{
var coordinate = new GeoApiGeometries.Coordinate(point.X,
point.Y,
point.Z);
coordinateList[elementIndex] = coordinate;
elementIndex++;
} // foreach
// if geometry is closed the add the first point to the last
if (isClosed)
{
var coordinate = new GeoApiGeometries.Coordinate(listToClone.ElementAt(0).X,
listToClone.ElementAt(0).Y,
listToClone.ElementAt(0).Z);
coordinateList[elementIndex] = coordinate;
} // if isClosed
return coordinateList;
}
Everything works fine, but when I profiled my code almost 95% time is taken by this function. I am wondering, are there any other ways to convert the list of System.Windows.Media.Point3D to Coordinate[].
Same will be true from one class to another conversion.
Coordinateobjects? Something else?