Sample code that demonstrates how to calculate the length of a linestring.

Imports DotSpatial.Geometries
Imports DotSpatial.Topology.Geometries

		Private Sub btnLength_Click(sender As Object, e As EventArgs)
			Try
				'Creates a coordinate arrary
				Dim coords As Coordinate() = New Coordinate(35) {}
				'Creates a random number generator
				Dim rnd As New Random()
				'A for loop that will generate random coordinate's and add those coordinates to the array
				For i As Integer = 0 To 35

					coords(i) = New Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90)
				Next
				'Creates a linestring from the array of coordinates
				Dim ls As New LineString(coords)
				'Calculates the length of the linestring
				Dim length As [Double]
				length = ls.Length
			Catch ex As Exception
				MessageBox.Show(ex.Message)
			End Try
		End Sub

Last edited Jul 13, 2010 at 3:39 PM by AlamoMan, version 4