'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Name: CELLGIS.TrafficFlow ' ' ' 'Description: Calculates the final location of people moving during ' ' the morning commute. ' ' ' ' ' 'Input: tower coverage with range values ' ' ' 'Output: polygon coverage of tower access areas ' ' ' 'Written By: Allan Glen and Jeff Nash ' 'Date: Spring 2000 ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' theCensusTheme = Self.Get(0) theFlowTheme = Self.Get(1) avgvehiclecapacity = Self.Get(2) scalingFactor = Self.Get(3) time = Self.Get(4) theView = av.GetActiveDoc '*** Theme names to be used *** 'theFlowTheme = theView.FindTheme("traffic.shp") '*** ADJUST THESE VALUES AS NECESSARY*** 'scalingFactor = MsgBox.Input( "Enter the scaling factor (total volume expected for morning pop'n flow as compared to 7:30 - 8:30 rush)", "Input Parameters", "1.50" ).AsNumber 'avgvehiclecapacity = MsgBox.Input( "Enter the average vehicle capacity (average capacity of all vehicles)", "Input Parameters", "1.2" ).AsNumber if ((scalingFactor = nil) Or (avgvehiclecapacity = nil)) then exit end 'scalingFactor = 1.50 '(total volume expected for morning pop'n flow as compared to 7:30 - 8:30 rush) 'avgvehiclecapacity = 1.2 '(average capacity of vehicles) '*** Get the FTabs, set the census theme editable *** theFlowThemeFtab = theFlowTheme.getFtab theCensusThemeFtab = theCensusTheme.getFtab theCensusThemeFtab.SetEditable(True) '*** Confirm (or create) the appropriate fields in the CensusFtab '(I need to add this piece to create th necessary fields...) '*** Find the Fields for the CensusTheme *** censusShape = theCensusThemeFtab.FindField("Shape") 'censusFlowIn = theCensusThemeFtab.FindField("In") 'censusFlowOut = theCensusThemeFtab.FindField("Out") 'censusChange = theCensusThemeFtab.FindField("Change") censusPOP = theCensusThemeFtab.FindField("cen_pop") '*** Find the Fields for the FlowTheme *** flowShape = theFlowThemeFtab.FindField("Shape") flowTrafficVolume = theFlowThemeFtab.FindField("Vehicle_vo") flowTransitVolume = theFlowThemeFtab.FindField("Transit_pa") flowFromX= theFlowThemeFtab.FindField("From_x") flowFromY= theFlowThemeFtab.FindField("From_y") flowToX= theFlowThemeFtab.FindField("To_x") flowToY= theFlowThemeFtab.FindField("To_y") '*** Initialize the progress bar av.ShowStopButton av.ShowMsg ("Processing traffic flow...") i = 0 numTracts = 0 for each count in theCensusThemeFtab numTracts = numTracts + 1 end '*** Tally up values for each census tract *** for each rec in theCensusThemeFtab inTract = 0.00 outTract = 0.00 theTract = theCensusThemeFtab.ReturnValue(CensusShape, rec).AsPolygon theTractBorder = theCensusThemeFtab.ReturnValue(CensusShape, rec).AsPolyLine theTractList = { theTractBorder } theFlowThemeFtab.SelectByShapes(theTractList, #VTAB_SELTYPE_NEW) '*** Tally up the ins and outs for each flowline intersecting the census tract boundary *** for each record in theFlowThemeFtab.GetSelection '*** Read the fields from the attribute table flowLine = theFlowThemeFtab.ReturnValue(flowShape, record).AsLine flowTraffic = theFlowThemeFtab.ReturnValue(flowTrafficVolume, record) flowTransit = theFlowThemeFtab.REturnValue(flowTransitVolume, record) flowFromXValue = theFlowThemeFtab.ReturnValue(flowFromX, record) flowFromYValue = theFlowThemeFtab.ReturnValue(flowFromY, record) flowToXValue = theFlowThemeFtab.ReturnValue(flowToX, record) flowToYValue = theFlowThemeFtab.ReturnValue(flowToY, record) cen_pop = theFlowThemeFtab.ReturnValue(censuspop, record) '*** Make the points for the fromNode and toNode toNode = Point.Make(flowToXValue, flowToYValue) fromNode = Point.Make(flowFromXValue, flowFromYValue) '*** Add to inTract if toNode is inside the census tract if ( theTract.Intersects(toNode) ) then inTract = inTract + ( flowTraffic * avgvehiclecapacity ) + flowTransit end '*** Add to outTract if fromNode is inside the census tract if ( theTract.Intersects(fromNode) ) then outTract = outTract + ( flowTraffic * avgvehiclecapacity ) + flowTransit end end '*** Multiply flow values by the scalingFactor to approximate entire morning flow inTract = inTract * scalingFactor outTract = outTract * scalingFactor 'theChange = inTract - outTract '*** Dump the movement values to the attribute table 'theCensusThemeFtab.SetValue (censusFlowIn, rec, inTract) 'theCensusThemeFtab.SetValue (censusFlowOut, rec, outTract) 'theCensusThemeFtab.setValue (censusChange, rec, theChange) popval = (intract - outtract) + cen_pop theCensusThemeFtab.setValue (censusPop, rec, popval) '*** Increment the Progress Bar i = i + 1 progress = (i/numTracts) * 100 doMore = av.SetStatus( progress ) if (not doMore) then break end end av.ShowMsg ("") return theCensusTheme