You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sindizzy edited this page Dec 23, 2020
·
5 revisions
Sample code that demonstrates how to calculate the length of a linestring.
ImportsDotSpatial.GeometriesImportsDotSpatial.Topology.GeometriesPrivateSubbtnLength_Click(senderAsObject,eAsEventArgs)Try'Creates a coordinate arraryDimcoordsAsCoordinate()=NewCoordinate(35){}'Creates a random number generatorDimrndAsNewRandom()'A for loop that will generate random coordinate's and add those coordinates to the arrayForiAsInteger=0To35coords(i)=NewCoordinate((rnd.NextDouble()*360)-180,(rnd.NextDouble()*180)-90)Next'Creates a linestring from the array of coordinatesDimlsAsNewLineString(coords)'Calculates the length of the linestringDimlengthAs[Double](Double)length=ls.LengthCatchexAsExceptionMessageBox.Show(ex.Message)EndTryEndSub