﻿
 Initialization:Function: Environment Ensure the map view has data layers Retrieve the view, the projection, the data layer, and the attribute table Ensure only a single theme is active Ensure the active data layer is a polyline data layer (not point or polygon)Ensure the active data layer is editable Function: Map Units Exit if there are no Map Units Retrieve Map Units If Distance Units are set, then convert to Map Units Main Algorithm Function: Update Working Data Layer Retrieve the number of shapes or features (i.e., polylines) in the data layer, n Features Check for the existence of the fields CrowFlies, CalfPath, and Sinuosity in the attribute table; If they don’t exist, create them.Function: Compute Sinuosity Loop through the attribute table and, for each polyline shape, do the following:Calculate the projected curvilinear length, CalfPath[Example Avenue syntax: CalfPath = theShape.ReturnLength)]Set the CalfPath field value in the attribute table Add CalfPath for the current shape to running total: Sum_CalfPath = Sum_CalfPath + CalfPath Retrieve coordinates of endpoints Create point objects for endpoints (Point1 and Point2)Calculate the straight-line distance between the endpoints[Example Avenue syntax: CrowFlies = Point1. Distance(Point2)]Set the CrowFlies field value in the attribute table Calculate Sinuosity = CalfPath/CrowFlies Set the Sinuosity field value in the attribute table Add Sinuosity for current shape to running total: Sum_Sinuosity = Sum_Sinuosity + Sinuosity Function: Finalization and Display Calculate the average CalfPath: Avg_CalfPath = Sum_CalfPath/nFeatures Calculate the average Sinuosity: Avg_Sinuosity = Sum_Sinuosity/nFeatures Display the following:Total Feature Length (Sum_CalfPath)Average Feature Length (Avg_CalfPath)Average Sinuosity (Avg_Sinousity)