-
Notifications
You must be signed in to change notification settings - Fork 0
linestringCS
sindizzy edited this page Dec 30, 2020
·
4 revisions
Creating a new linestring and calculating the length
using DotSpatial.Topology;
using DotSpatial.Common;
private void btnLineString_Click(object sender, EventArgs e)
{
//creates a new coordinate array
Coordinate[]() coords = new Coordinate[36](36);
//creates a random point variable
Random rnd = new Random();
//a for loop that generates a new random X and Y value and feeds those values into the coordinate array
for (int i = 0; i < 36; i++)
{
coords[i](i) = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
}
//creates a new linstring from the array of coordinates
LineString ls = new LineString(coords);
//new variable for the length of the linstring
Double length;
length = ls.Length;
//Displays the length of the linstring
MessageBox.Show("The length of the linstring is: " + length);
}