LinestringVB - sindizzy/DSW GitHub Wiki
Sample code for creating a new linestring and calculating it's length.
Imports DotSpatial.Geometries
Imports DotSpatial.Common
Private Sub btnLineString_Click(sender As Object, e As EventArgs)
'creates a new coordinate array
Dim coords As Coordinate() = New Coordinate(35) {}
'creates a random point variable
Dim rnd As New Random()
'a for loop that generates a new random X and Y value and feeds those values into the coordinate array
For i As Integer = 0 To 35
coords(i) = New Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90)
Next
'creates a new linstring from the array of coordinates
Dim ls As New LineString(coords)
'new variable for the length of the linstring
Dim length As [Double](Double)
length = ls.Length
'Displays the length of the linstring
MessageBox.Show("The length of the linstring is: " & length)
End Sub