/3.0 (Extension.1 Name: "Convert NTAD Data" FirstRootClassName: "Space" Roots: 2 Roots: 3 Roots: 4 Roots: 5 Roots: 6 Roots: 7 Roots: 8 Version: 30 About: "Converts geographic data files from the National Transportation Atlas Database to shapefiles" InstallScript: 9 UninstallScript: 10 ExtVersion: 1 ) (Space.2 Tag: "NTAD" ) (Choice.3 Help: "Converts National Transportation Atlas data to shapefiles" Tag: "NTAD" Label: "Convert NTAD data" Click: "NTAD.Convert" Shortcut: "Keys.None" ) (Script.4 Name: "NTAD.Convert" SourceCode: "'\n' NTAD.Convert -- User Interface for Converting NTAD Data to Shapefiles\n' Peter Girard ESRI-Boston 9/96\n'\n'----------------------------------------------------------------------------------\n\nthisScript = \"NTAD to Shapefile\"\n\n' -- get the existing directory preferences\n\ntheExtension = Extension.Find(\"Convert NTAD Data\")\ntheView = av.GetActiveDoc\nif (theExtension <> nil) then\n prefList = theExtension.GetPreferences.Get(\"ntad\")\n if (prefList = nil) then\n prefList = {nil,nil}\n end\n theExtensi on.GetPreferences.Set(\"ntad\",prefList)\nelse\n prefList = theView.GetObjectTag\n if (prefList = nil) then\n prefList = {nil,nil}\n end\n theView.SetObjectTag(prefList)\n end\n\n' -- get the input data file\n\nif (prefList.Get(0) <> nil) then\n prefList.Get(0).SetCWD\n end\n\ndataFileName = FileDialog.Show(\"*.*\",\"NTAD File (.are .lin .nod .pnt)\",\n thisScript + \": Choose a file to convert\")\n \nif (dataFileName = nil) then\n return nil\n end\n\ntheDir = dataFileName.Clone\ntheDir.StripFile\nprefList.Set(0,theDir )\n\n' -- make sure the datafile has the right extension\n\ntheExt = dataFileName.GetExtension\n\nif ({\"lnk\",\"nod\",\"pnt\",\"are\"}.FindByValue(theExt) < 0) then\n MsgBox.Info(\"Invalid file selected for conversion\",thisScript)\n return nil\n end\n\n' -- make sure a geography file exists if a link or area data file was selected\n\nif ((theExt = \"lnk\") or (theExt = \"are\")) then\n geoFileName = dataFileName.Clone\n geoFileName.SetExtension(\"geo\")\n if (File.Exists(geoFileName).Not) then\n MsgBox.Info(\"Could not find geogr aphy file,\"++geoFileName.GetBaseName,\n thisScript)\n return nil\n end\n end\n\n' -- get the FIPS codes of the states/territories to convert\n\nreturnList = av.Run(\"NTAD.FIPSDictionary\",nil)\nstateNames = returnList.Get(0)\nfipsDict = returnList.Get(1)\nstateList = MsgBox.MultiListAsString(stateNames,\"Select states/territories\",\n thisScript)\nif ((stateList = nil) or (stateList.Count = 0)) then\n return nil\n end\n\n' -- send an empty FIPS list to the converter if the \"All States\" pick was\n' -- selected, otherwise get the FIPS codes for the selected states\n\nfipsList = List.Make\nif (stateList.FindByValue(\"-- All Records --\") < 0) then\n for each s in stateList\n fipsList.Add(fipsDict.Get(s))\n end\n end\n\n' -- get the output shapefile name\n\nif (prefList.Get(1) <> nil) then\n theDir = prefList.Get(1)\nelse\n theDir = dataFileName.Clone\n theDir.StripFile\n end\n\nif (File.IsWritable(theDir).Not) then\n theDir = System.GetEnvVar(\"HOME\").AsFileName\n end\nshapeFileName = theDir.MakeTmp(\"ntad\"+theExt,\"shp\")\nshap eFileName = FileDialog.Put(shapeFileName,\"*.shp\",\n \"Save converted shapefile as\")\n\nif (shapeFileName = nil) then \n return nil \n end\n\ntheDir = shapeFileName.Clone\ntheDir.StripFile\nif (File.IsWritable(theDir).Not) then\n MsgBox.Info(\"You do not have write access to that directory\",thisScript)\n return nil\nelse\n prefList.Set(1,theDir)\n end\n\n' -- convert the data file to a shapefile\n\nif ((theExt = \"pnt\") or (theExt = \"nod\")) then\n newFTab = av.Run(\"NTAD.LoadPoints\",{dataFileName,shapeFileName,fipsList}) \nelseif (theExt = \"lnk\") then\n newFTab = av.Run(\"NTAD.LoadLines\",{dataFileName,geoFileName,shapeFileName,fipsList})\nelseif (theExt = \"are\") then\n newFTab = av.Run(\"NTAD.LoadPolygons\",{dataFileName,geoFileName,shapeFileName,fipsList})\n end\n\nif (newFTab = nil) then\n return nil\n end\n\n' -- add the shapefile as a theme to a view\n\ntheView = av.GetActiveDoc\nif (MsgBox.YesNo(\"Add shapefile as theme to the view?\",thisScript,true).Not) then\n return nil\n end\n\ntheTheme = FTheme.Make(newFTab)\ntheView.AddTheme(the Theme)\ntheView.GetWin.Activate\n\n" ) (Script.5 Name: "NTAD.FIPSDictionary" SourceCode: "'\n' NTAD.FIPSDictionary -- Build a FIPS Look Up\n' Peter Girard ESRI-Boston 9/96\n'\n' Input: none\n'\n' Output: list\n' 0) list of strings, state/territory names\n' 1) dictionary\n' key) string, state/territory name\n' value) string, two-digit FIPS code\n'\n'------------------------------------------------------------------------------\n\nsList = List.Make\nfList = List.Make\n\nsList.Add(\"-- All Records --\")\nfList.Add( \"\")\nsList.Add(\"Alabama \")\nfList.Add( \"01\")\nsList.Add(\"Alaska\")\nfList.Add( \"02\")\nsList.Add(\"Arizona\")\nfList.Add( \"04\")\nsList.Add(\"Arkansas\")\nfList.Add( \"05\")\nsList.Add(\"California\")\nfList.Add( \"06\")\nsList.Add(\"Colorado\")\nfList.Add( \"08\")\nsList.Add(\"Connecticut\")\nfList.Add( \"09\")\nsList.Add(\"Delaware\")\nfList.Add( \"10\")\nsList.Add(\"District of Columbia\")\nfList.Add( \"11\")\nsList.Add(\"Florida\")\nfList.Add( \"12\")\nsList.Add(\"Georgia\")\nfList.Add( \"13\")\nsList.Add(\"Hawaii\")\nfList.Add( \"15\")\nsList.Add(\"Idaho\")\nfList.Add( \"16\")\nsLis t.Add(\"Illinois\")\nfList.Add( \"17\")\nsList.Add(\"Indiana\")\nfList.Add( \"18\")\nsList.Add(\"Iowa\")\nfList.Add( \"19\")\nsList.Add(\"Kansas\")\nfList.Add( \"20\")\nsList.Add(\"Kentucky\")\nfList.Add( \"21\")\nsList.Add(\"Louisiana\")\nfList.Add( \"22\")\nsList.Add(\"Maine\")\nfList.Add( \"23\")\nsList.Add(\"Maryland\")\nfList.Add( \"24\")\nsList.Add(\"Massachusetts\")\nfList.Add( \"25\")\nsList.Add(\"Michigan\")\nfList.Add( \"26\")\nsList.Add(\"Minnesota\")\nfList.Add( \"27\")\nsList.Add(\"Mississippi\")\nfList.Add( \"28\")\nsList.Add(\"Missouri\")\nfList.Add( \"2 9\")\nsList.Add(\"Montana\")\nfList.Add( \"30\")\nsList.Add(\"Nebraska\")\nfList.Add( \"31\")\nsList.Add(\"Nevada\")\nfList.Add( \"32\")\nsList.Add(\"New Hampshire\")\nfList.Add( \"33\")\nsList.Add(\"New Jersey\")\nfList.Add( \"34\")\nsList.Add(\"New Mexico\")\nfList.Add( \"35\")\nsList.Add(\"New York\")\nfList.Add( \"36\")\nsList.Add(\"North Carolina\")\nfList.Add( \"37\")\nsList.Add(\"North Dakota\")\nfList.Add( \"38\")\nsList.Add(\"Ohio\")\nfList.Add( \"39\")\nsList.Add(\"Oklahoma\")\nfList.Add( \"40\")\nsList.Add(\"Oregon\")\nfList.Add( \"41\")\nsList.Add(\"Pennsyl vania\")\nfList.Add( \"42\")\nsList.Add(\"Rhode Island\")\nfList.Add( \"44\")\nsList.Add(\"South Carolina\")\nfList.Add( \"45\")\nsList.Add(\"South Dakota\")\nfList.Add( \"46\")\nsList.Add(\"Tennessee\")\nfList.Add( \"47\")\nsList.Add(\"Texas\")\nfList.Add( \"48\")\nsList.Add(\"Utah\")\nfList.Add( \"49\")\nsList.Add(\"Vermont\")\nfList.Add( \"50\")\nsList.Add(\"Virginia\")\nfList.Add( \"51\")\nsList.Add(\"Washington\")\nfList.Add( \"53\")\nsList.Add(\"West Virginia\")\nfList.Add( \"54\")\nsList.Add(\"Wisconsin\")\nfList.Add( \"55\")\nsList.Add(\"Wyoming\")\nfList.Add( \"56\")\nsList.Add(\"American Samoa\")\nfList.Add( \"60\")\nsList.Add(\"Caroline Islands\")\nfList.Add( \"64\")\nsList.Add(\"Guam\")\nfList.Add( \"66\")\nsList.Add(\"Marshall Islands\")\nfList.Add( \"68\")\nsList.Add(\"Mariana Islands\")\nfList.Add( \"69\")\nsList.Add(\"Midway Island\")\nfList.Add( \"74\")\nsList.Add(\"Puerto Rico\")\nfList.Add( \"72\")\nsList.Add(\"Virgin Islands\")\nfList.Add( \"78\")\nsList.Add(\"not U.S. territory\")\nfList.Add( \"99\")\n\nfipsDict = Dictionary.Make(sList.Count)\nfor each i in 0..(sList.Count - 1)\n fipsDict.Add(sLis t.Get(i),fList.Get(i))\n end\n\nreturn {sList,fipsDict}\n" ) (Script.6 Name: "NTAD.LoadLines" SourceCode: "'\n' NTAD.LoadLines -- Load NTAD Link Data\n' Peter Girard ESRI-Boston 9/96\n'\n'\n' Input: list\n' 0) filename, name of link data file\n' 1) filename, name of geography file\n' 2) filename, name of the output shapefile\n' 3) list of strings, list of state FIPS codes to match\n'\n' Output: FTab, the output shapefile\n'\n'----------------------------------------------------------------------------\n\nreadBufferSize = 2000\n\n' -- get the input arguments\n\ndataFileNa me = SELF.Get(0)\ngeoFileName = SELF.Get(1)\nshapeFileName = SELF.Get(2)\nfipsList = SELF.Get(3)\nallRecords = (fipsList.Count = 0)\n\n' -- open the data file and geography file for reading, create the new \n' -- shapefile\n\nav.ShowMsg(\"Opening files, please wait ...\")\nav.SetStatus(0)\n\ndataFile = LineFile.Make(dataFileName,#FILE_PERM_READ)\ngeoFile = LineFile.Make(geoFileName,#FILE_PERM_READ)\n\n' -- scan the geography file, build a dictionary of polygon IDs and\n' -- associated link IDs, and build a list of offsets fo r each link in\n' -- the geography file\n\nnumGeo = geoFile.GetSize\nnumLines = dataFile.GetSize\noffsetList = List.Make\noffsetList.Add(nil)\nsizeList = offsetList.Clone\n\nav.ShowMsg(\"Scanning geography file ...\")\nav.ShowStopButton\nav.SetStatus(0)\n\ngeoLine = geoFile.ReadElt\nindex = 0\n\nwhile (geoLine <> nil)\n linkID = geoLine.Middle(13,10).AsNumber\n vertLines = ((geoLine.Middle(43,3).AsNumber - 1) / 4).Truncate + 1\n index = index + 1\n\n while (index < linkID)\n offsetList.Add(nil)\n sizeList.Add(nil)\n ind ex = index + 1\n end\n offsetList.Add(geoFile.GetPos)\n sizeList.Add(vertLines)\n\n geoFile.SetPos(geoFile.GetPos + vertLines)\n geoLine = geoFile.ReadElt\n\n if (av.SetStatus((geoFile.GetPos/numGeo) * 100).Not) then\n dataFile.Close\n geoFile.Close\n av.ClearMsg\n return nil\n end\n end\n\n' -- create the new shapefile\n\nshapeFTab = FTab.MakeNew(shapeFileName,Polyline)\nshapeField = shapeFTab.FindField(\"shape\")\ndataFields = List.Make\ndataFields.Add(Field.Make(\"rectype\",#FIELD_CHAR,1,0))\ndataFields.Ad d(Field.Make(\"version\",#FIELD_CHAR,2,0))\ndataFields.Add(Field.Make(\"revision\",#FIELD_CHAR,2,0))\ndataFields.Add(Field.Make(\"moddate\",#FIELD_LONG,8,0))\ndataFields.Add(Field.Make(\"linkid\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"featureid\",#FIELD_CHAR,10,0))\ndataFields.Add(Field.Make(\"anode\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"bnode\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"descript\",#FIELD_CHAR,35,0))\ndataFields.Add(Field.Make(\"stfips1\",#FIELD_SHORT,2,0))\ndataFields.Add(Field.Make(\"stfips2 \",#FIELD_SHORT,2,0))\nshapeFTab.AddFields(dataFields)\nfieldMax = dataFields.Count - 1\n\n' -- loop to process each line in the data file\n\nlinesRemaining = numLines\ncount = 0\nav.ShowMsg(\"Loading NTAD lines ...\")\nav.ShowStopButton\nav.SetStatus(0)\n\nwhile (linesRemaining > 0)\n\n ' -- load lines of text from the data file into a list\n \n lineList = List.Make\n dataFile.Read(lineList,readBufferSize)\n linesRemaining = linesRemaining - readBufferSize\n\n ' -- loop for each string in the list\n \n for each dataLine in lineList\n \n ' -- break the line of text from the data file into its component values; \n ' -- process if the FIPS code matches\n \n values = dataLine.Split({1,3,5,13,23,33,43,53,88,90},\"|\").AsTokens(\"|\")\n if (allRecords or (fipsList.FindByValue(values.Get(9)) >= 0) or\n (fipsList.FindByValue(values.Get(10)) >= 0)) then\n \n ' -- build a polyline from the coordinates in the geography file\n \n linkID = values.Get(4).AsNumber\n geoFile.SetPos(offsetList.Get(linkID))\n ver tList = List.Make\n geoFile.Read(vertList,sizeList.Get(linkID))\n \n pntList = List.Make\n for each geoLine in vertList\n geoLine = geoLine.BasicTrim(\"\",\" \")\n for each i in 0..(geoLine.Count - 20) by 20\n pntList.Add((geoLine.Middle(i,10).AsNumber/1000000)@\n (geoLine.Middle(i+10,10).AsNumber/1000000))\n end\n end \n theShape = PolyLine.Make({pntList})\n\n ' -- create a new record in the shapefile, add the polyline and other\n ' -- data file values\n \n rec = shapeFTab.AddRecord\n shapeFTab.SetValue(shapeField,rec,theShape)\n for each i in 0..fieldMax\n shapeFTab.SetValueString(dataFields.Get(i),rec,values.Get(i))\n end\n end\n \n count = count + 1\n stopped = av.SetStatus((count/numLines)*100).Not\n if (stopped) then\n break\n end\n end\n\n lineList = nil\n av.PurgeObjects\n\n if (stopped) then\n break\n end\n end\n\ndataFile.Close\ngeoFile.Close\n\nav.ClearMsg\nav.ClearStatus\n\nretur n shapeFTab\n \n \n" ) (Script.7 Name: "NTAD.LoadPoints" SourceCode: "'\n' NTAD.LoadPoints -- Load NTAD Point/Node Data\n' Peter Girard ESRI-Boston 9/96\n'\n'\n' Input: list\n' 0) filename, name of PNT or NOD file\n' 1) filename, name of the output shapefile\n' 2) list of strings, list of state FIPS codes to match\n'\n' Output: FTab, the output shapefile\n'\n'----------------------------------------------------------------------------\n\nreadBufferSize = 2000\n\n' -- get the input arguments\n\ndataFileName = SELF.Get(0)\nshapeFileName = SELF.Get( 1)\nfipsList = SELF.Get(2)\n\nif (dataFileName.GetExtension = \"pnt\") then\n ftype = \"point\"\nelse\n ftype = \"node\"\n end\nallRecords = (fipsList.Count = 0)\n\n' -- open the data file for reading, create the new shapefile\n\nav.ShowMsg(\"Opening files, please wait ...\")\nav.SetStatus(0)\n\ndataFile = LineFile.Make(dataFileName,#FILE_PERM_READ)\n\nshapeFTab = FTab.MakeNew(shapeFileName,Point)\nshapeField = shapeFTab.FindField(\"shape\")\ndataFields = List.Make\ndataFields.Add(Field.Make(\"rectype\",#FIELD_CHAR,1,0))\ndataFields.Add (Field.Make(\"version\",#FIELD_CHAR,2,0))\ndataFields.Add(Field.Make(\"revision\",#FIELD_CHAR,2,0))\ndataFields.Add(Field.Make(\"moddate\",#FIELD_LONG,8,0))\ndataFields.Add(Field.Make(ftype+\"id\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"featureid\",#FIELD_CHAR,10,0))\ndataFields.Add(Field.Make(\"longitude\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"latitude\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"descript\",#FIELD_CHAR,35,0))\ndataFields.Add(Field.Make(\"stfips\",#FIELD_SHORT,2,0))\nshapeFTab.AddFields(dataFie lds)\nfieldMax = dataFields.Count - 1\n\n' -- loop while lines of input data can be processed\n\nnumPoints = dataFile.GetSize\nlinesRemaining = numPoints\ncount = 0\nav.ShowMsg(\"Loading NTAD points ...\")\nav.ShowStopButton\nav.SetStatus(0)\n\nwhile (linesRemaining > 0)\n\n ' -- load lines of text from the data file into a list\n \n lineList = List.Make\n dataFile.Read(lineList,readBufferSize)\n linesRemaining = linesRemaining - readBufferSize\n\n ' -- loop for each string in the list\n \n for each l in lineList\n \n ' -- break the string into its component values; if the FIPS code\n ' -- matches, add the point shape to the shapefile\n \n values = l.Split({1,3,5,13,23,33,43,53,88},\"|\").AsTokens(\"|\")\n if (allRecords or (fipsList.FindByValue(values.Get(9)) >= 0)) then\n rec = shapeFTab.AddRecord\n shapeFTab.SetValue(shapeField,rec,\n (values.Get(6).AsNumber/1000000)@(values.Get(7).AsNumber/1000000))\n for each i in 0..fieldMax\n shapeFTab.SetValueString(dataFields.Get(i),rec,values.Get(i ))\n end\n end\n\n count = count + 1\n stopped = av.SetStatus((count/numPoints)*100).Not\n if (stopped) then\n break\n end\n end\n\n lineList = nil\n av.PurgeObjects\n\n if (stopped) then\n break\n end\n end\n\ndataFile.Close\n\nav.ClearMsg\nav.ClearStatus\n\nreturn shapeFTab\n \n \n" ) (Script.8 Name: "NTAD.LoadPolygons" SourceCode: "'\n' NTAD.LoadPolygons -- Load NTAD Area Data\n' Peter Girard ESRI-Boston 9/96\n'\n'\n' Input: list\n' 0) filename, name of link data file\n' 1) filename, name of geography file\n' 2) filename, name of the output shapefile\n' 3) list of strings, list of state FIPS codes to match\n'\n' Output: FTab, the output shapefile\n'\n'----------------------------------------------------------------------------\n\nreadBufferSize = 2000\n\n' -- get the input arguments\n\ndataFil eName = SELF.Get(0)\ngeoFileName = SELF.Get(1)\nshapeFileName = SELF.Get(2)\nfipsList = SELF.Get(3)\nallRecords = (fipsList.Count = 0)\n\n' -- open the data file and geography file for reading, create the new \n' -- shapefile\n\nav.ShowMsg(\"Opening files, please wait ...\")\nav.SetStatus(0)\n\ndataFile = LineFile.Make(dataFileName,#FILE_PERM_READ)\ngeoFile = LineFile.Make(geoFileName,#FILE_PERM_READ)\n\n' -- scan the geography file, build a dictionary of polygon IDs and\n' -- associated link IDs, and build a list of offsets for each link in\n' -- the geography file\n\nnumGeo = geoFile.GetSize\nav.ShowMsg(\"Scanning geography file ...\")\nav.ShowStopButton\nav.SetStatus(0)\n\nnumPolys = dataFile.GetSize\npolyDict = Dictionary.Make(numPolys)\nshapeList = List.Make\nshapeList.Add(nil)\nsizeList = shapeList.Clone\n\ngeoLine = geoFile.ReadElt\nindex = 0\n\nwhile (geoLine <> nil)\n linkID = geoLine.Middle(13,10).AsNumber\n leftPoly = geoLine.Middle(23,10).AsNumber\n rightPoly = geoLine.Middle(33,10).AsNumber\n vertLines = ((geoLine.Middle(43,3).AsNum ber - 1) / 4).Truncate + 1\n index = index + 1\n\n while (index < linkID)\n shapeList.Add(nil)\n sizeList.Add(nil)\n index = index + 1\n end\n shapeList.Add(geoFile.GetPos)\n sizeList.Add(vertLines)\n\n partList = polyDict.Get(leftPoly)\n if (partList = nil) then\n partList = List.Make\n polyDict.Add(leftPoly,partList)\n end\n partList.Add(linkID)\n partList.Add(\"L\")\n \n partList = polyDict.Get(rightPoly)\n if (partList = nil) then\n partList = List.Make\n polyDict.Add(rightPoly,partList)\n end\n partList.Add(linkID)\n partList.Add(\"R\")\n \n geoFile.SetPos(geoFile.GetPos + vertLines)\n geoLine = geoFile.ReadElt\n\n if (av.SetStatus((geoFile.GetPos/numGeo) * 100).Not) then\n dataFile.Close\n geoFile.Close\n av.ClearMsg\n return nil\n end\n end\n\n' -- create the new shapefile\n\nshapeFTab = FTab.MakeNew(shapeFileName,Polygon)\nshapeField = shapeFTab.FindField(\"shape\")\ndataFields = List.Make\ndataFields.Add(Field.Make(\"rectype\",#FIELD_CHAR,1,0))\ndataFields.Add(Field.Make(\"version\",#FIELD_C HAR,2,0))\ndataFields.Add(Field.Make(\"revision\",#FIELD_CHAR,2,0))\ndataFields.Add(Field.Make(\"moddate\",#FIELD_LONG,8,0))\ndataFields.Add(Field.Make(\"polyid\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"featureid\",#FIELD_CHAR,10,0))\ndataFields.Add(Field.Make(\"cntrlon\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"cntrlat\",#FIELD_LONG,10,0))\ndataFields.Add(Field.Make(\"descript\",#FIELD_CHAR,35,0))\ndataFields.Add(Field.Make(\"stfips\",#FIELD_SHORT,2,0))\nshapeFTab.AddFields(dataFields)\nfieldMax = dataFields.Count - 1\n\n' -- now start building the polygons\n\nlinesRemaining = numPolys\ncount = 0\nav.ShowMsg(\"Loading NTAD polygons ...\")\nav.ShowStopButton\nav.SetStatus(0)\n\nwhile (linesRemaining > 0)\n\n ' -- load lines of text from the data file into a list\n \n lineList = List.Make\n dataFile.Read(lineList,readBufferSize)\n linesRemaining = linesRemaining - readBufferSize\n\n ' -- loop for each string in the list\n \n for each dataLine in lineList\n \n ' -- break the line of text from the data file into its component values ; \n ' -- process if the FIPS code matches\n \n values = dataLine.Split({1,3,5,13,23,33,43,53,88},\"|\").AsTokens(\"|\")\n if (allRecords or (fipsList.FindByValue(values.Get(9)) >= 0)) then\n \n ' -- get the list of link IDs for this polygon ID; create a list to\n ' -- store the polyline shapes for this polygon\n \n polyID = values.Get(4).AsNumber\n partList = polyDict.Get(polyID)\n if (partList = nil) then\n continue\n end\n polyList = List.Make\n \n ' -- f or each link ID in the list ...\n \n for each l in 0..(partList.Count - 2) by 2\n \n ' -- get the shape from the shape list\n \n linkID = partList.Get(l)\n side = partList.Get(l+1)\n theShape = shapeList.Get(linkID)\n \n ' -- if the shape is a number, it is the offset into the geography\n ' -- file for this shape; read in the coordinates and build the\n ' -- polyline\n \n if (theShape.Is(Number)) then\n geoFile.SetPos(theShape)\n vertList = List.Make\n geoFile.Read(vertList,sizeList.Get(linkID))\n \n pntList = List.Make\n for each geoLine in vertList\n geoLine = geoLine.BasicTrim(\"\",\" \")\n for each i in 0..(geoLine.Count - 20) by 20\n pntList.Add((geoLine.Middle(i,10).AsNumber/1000000)@\n (geoLine.Middle(i+10,10).AsNumber/1000000))\n end\n end \n theShape = Polyline.Make({pntList})\n \n ' -- save the polyl ine in the shape list for next time\n \n shapeList.Set(linkID,theShape)\n end\n \n ' -- flip the polyline so that it points clockwise relative to the\n ' -- polygon\n \n if (side = \"L\") then\n theShape = theShape.Clone\n theShape.Flip\n end\n \n ' -- add the polyline to the list of polylines for this polygon\n \n polyList.Add(theShape)\n end\n \n ' -- order the polylines into rings\n \n if (polyList.Count > 2) then\n for each i in 0..(polyList.Count - 3)\n endVert = polyList.Get(i).AsList.Get(0).Count - 1\n endPoint = polyList.Get(i).AsList.Get(0).Get(endVert)\n j = i + 1\n while ((j < polyList.Count) and \n (polyList.Get(j).AsList.Get(0).Get(0).GetX <> endPoint.GetX) and\n (polyList.Get(j).AsList.Get(0).Get(0).GetY <> endPoint.GetY))\n j = j + 1\n end\n if (j < polyList.Count) then\n polyList.Shuffle(polyLis t.Get(j),i+1)\n end\n end\n end\n \n ' -- convert the rings into lists of points and make the polygon\n \n pointList = List.Make\n startPoint = nil\n \n for each i in 0..(polyList.Count - 1)\n if (startPoint = nil) then\n ringList = List.Make\n pointList.Add(ringList)\n startPoint = polyList.Get(i).AsList.Get(0).Get(0)\n ringList.Add(startPoint)\n end\n linePoints = polyList.Get(i).AsList.Get(0)\n linePoint s.Remove(0)\n endPoint = linePoints.Get(linePoints.Count - 1)\n ringList = ringList.Merge(linePoints)\n if ((endPoint.GetX = startPoint.GetX) and \n (endPoint.GetY = startPoint.GetY) and\n (i < (polyList.Count - 1))) then\n startPoint = nil\n end\n end\n \n thePolygon = Polygon.Make(pointList)\n \n ' -- create a new record in the shapefile, add the polyline and other\n ' -- data file values\n \n rec = shapeFTab.AddRecord \n shapeFTab.SetValue(shapeField,rec,thePolygon)\n for each i in 0..fieldMax\n shapeFTab.SetValueString(dataFields.Get(i),rec,values.Get(i))\n end\n end\n \n count = count + 1\n stopped = av.SetStatus((count/numPolys)*100).Not\n if (stopped) then\n break\n end\n end\n\n lineList = nil\n av.PurgeObjects\n\n if (stopped) then\n break\n end\n end\n\ndataFile.Close\ngeoFile.Close\n\nav.ClearMsg\nav.ClearStatus\n\nreturn shapeFTab\n \n \n" ) (Script.9 Name: "NTAD_Install" SourceCode: "'\n' BTS_Install -- Install the Extension\n' Peter Girard ESRI-Boston 9/96\n'\n'--------------------------------------------------------------------------------\n\n' -- install only if there is an active project\n\nif (av.GetProject = nil) then\n return nil\n end\n\n' -- install the choices under the Project pulldown\n\ntheGUI = av.GetProject.FindGUI(\"View\")\nif (theGUI <> nil) then\n thePulldown = theGUI.GetMenuBar.GetControls.Get(0)\n prevChoice = thePulldown.FindByScript(\"View.ExportDisp\")\n pos = thePulldown .GetControls.Find(prevChoice)\n if (pos = -1) then\n pos = thePulldown.GetControls.Count\n end\n for each i in 0..1\n thePulldown.Add(SELF.Get(i),pos+i)\n end\n end\n\n' -- install the scripts\n\nfor each i in 2..(SELF.Count - 1)\n av.GetProject.AddScript(SELF.Get(i))\n end" ) (Script.10 Name: "NTAD_Uninstall" SourceCode: "'\n' NTAD_Uninstall -- Uninstall the Extension\n' Peter Girard ESRI-Boston 9/96\n'\n'--------------------------------------------------------------------------------\n\n' -- uninstall only if there is an active project\n\nif (av.GetProject = nil) then\n return nil\n end\n\n' -- don't uninstall extension objects if project is closing\n\nif (av.GetProject.IsClosing) then\n return nil\n end\n\n' -- uninstall menus choices\n\ntheGUI = av.GetProject.FindGUI(\"View\")\nif (theGUI <> nil) then\n thePulldown = theGUI.GetMenuB ar.GetControls.Get(0)\n for each i in 0..1\n thePulldown.Remove(SELF.Get(i))\n end\n end\n\n' -- uninstall scripts\n\nfor each i in 2..(SELF.Count - 1)\n av.GetProject.RemoveScript(SELF.Get(i).GetName)\n end\n" )