'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Name: CELLGIS.CreateTowerAccessAreas ' ' ' 'Description: Creates a modified thiessen coverage. Thiessen polygons ' ' are limited by a range value. ' ' ' 'Input: tower coverage with range values ' ' ' 'Output: polygon coverage of tower access areas ' ' ' 'Written By: Allan Glen and Jeff Nash ' 'Date: Spring 2000 ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' theProject = av.GetProject theView = av.GetActivedoc towerTheme = Self.Get(0) storagedir = _tempdir '(global) 'directory to store new coverage towerFTab = towerTheme.GetFTab selbitmap = towerFtab.getselection selbitmap.clearall ' *** sorts the tower coverage by range. sortfld = towerFtab.findField("range") if (sortfld = nil) then msgbox.info("could not find sortfld!","error") exit end ' *** makes a table from the Ftab for the "lists unique range values" part. towertab = table.make(towerFtab) towertab.getWin.Open towertab.getWin towertab.sort(sortfld, false) difrangelist = list.make 'record number of unique range values difrangevallist = list.make 'actual range values avalue = 0 ' *** lists unique range values to make the boundary of the individual ' *** thiessen poly coverages the right size. for each rec in towerFtab arecordnumber = towertab.convertrowtorecord(rec) comparisonstring = towerFtab.returnvaluestring(sortfld, arecordnumber) if (comparisonstring = avalue) then continue else difrangelist.Add(arecordnumber) difrangevallist.Add(comparisonstring) avalue = comparisonstring end end ' *** makes a thiessen coverage for each unique range value. ' *** the thiessen coverage made from the largest range is ' *** named "Base_r_" because later on, it is needed to pile ' *** other coverages on to. ' *** note: Thiessen polygons need at least 2 points to ' *** create coverage. In the case that a range value has ' *** one tower, the script "Onepoly" returns a coverage ' *** of a buffer around the one point equal to the range. shapefld = towerFtab.FindField("shape") thiessenthms = list.make for each rangeval in difrangelist towerFtab.Query("[Range] = " + towerFtab.returnvalue(sortfld, rangeval).AsString, selbitmap, #VTAB_SELTYPE_NEW) if (difrangelist.find(rangeval) = ((difrangelist.count)-1)) then outfile = filename.make(storagedir + "BASE_r_" + towerftab.returnvalue(sortfld, rangeval).AsString) if (selbitmap.count < 2) then for each onesel in selbitmap basethm = (av.Run("CELLGIS.Onepoly", {towerFtab, selbitmap, towertheme, theview, outfile, rangeval})) end else Basethm = (av.Run("CELLGIS.shortthiessen", {towerFtab, selbitmap, towertheme, theview, outfile})) end else outfile = filename.make(storagedir + "r_" + towerftab.returnvalue(sortfld, rangeval).AsString) if (selbitmap.count < 2) then for each onesel in selbitmap thiessenthms.Add(av.Run("CELLGIS.Onepoly", {towerFtab, selbitmap, towertheme, theview, outfile, rangeval})) end else thiessenthms.Add(av.Run("CELLGIS.shortthiessen", {towerFtab, selbitmap, towertheme, theview, outfile})) end end end flist = list.make difrangevallist.sort(true) numranges = difrangevallist.count ' *** creates a new coverage from the individually made ' *** thiessen coverages (thm). In this new coverage, the polys ' *** are clipped to a thiessen coverage including all ' *** towers with ranges equal to or greater to the range ' *** of the (thm) coverage. for each thm in thiessenthms '** make the clip coverage namestr = thm.GetName.BasicTrim ("R_", ".shp") rangeval = namestr.AsNumber towerFtab.Query("[Range] >= " + rangeval.AsString, selbitmap, #VTAB_SELTYPE_NEW) outfile = filename.make(storagedir + "clipfor_" + namestr + ".shp") tempclipthm = av.Run("CELLGIS.shortthiessen", {towerFtab, selbitmap, towertheme, theview, outfile}) tempclipFtab = tempclipthm.GetFtab tempclipidfld = tempclipFtab.FindField("twr_id") tempclipshapefld = tempclipFtab.FindField("shape") tempcliptab = table.make(tempclipFtab) tempcliptab.getwin.open tempFtab = thm.GetFtab idfld = tempFtab.FindField("twr_id") shapefld = tempFtab.FindField("shape") rangefld = tempFtab.FindField("range") capfld = tempFtab.FindField("twr_cap") tempfile = filename.make(storagedir + "clipped_" + namestr + ".shp") outfTab = FTab.MakeNew(tempfile, polygon) outshapefld = shapefld.clone outidfld = idfld.clone outrangefld = rangefld.clone outcapfld = capfld.clone outfTab.AddFields({outidfld, outrangefld, outcapfld}) outshapefld = outfTab.FindField("shape") for each rec in tempFtab i = outfTab.AddRecord inid = tempFtab.ReturnValue(idfld, rec) inshp = tempFtab.ReturnValue(shapefld, rec) inrange = tempFtab.ReturnValue(rangefld, rec) incap = tempFtab.ReturnValue(capfld, rec) clipshp = tempclipFtab.ReturnValue(tempclipshapefld, tempcliptab.find(inid.AsString)) outshp = inshp.ReturnIntersection(clipshp) outFtab.BeginTransaction outfTab.SetValue(outshapefld, i, outshp) outfTab.SetValue(outidfld, i, inid) outfTab.SetValue(outrangefld, i, inrange) outfTab.SetValue(outcapfld, i, incap) outFtab.EndTransaction end outfTab.Flush outfTab.Refresh newthm =ftheme.make(outfTab) flist.add(newthm) theView.AddTheme(newthm) theView.DeleteTheme(tempclipthm) theProject.RemoveDoc (tempcliptab) end ' *** the clipped coverages made in the last step are ' *** added to the "base_r_" theme. theview.SetEditableTheme(basethm) baseftab = basethm.GetFtab baseshapefld = baseftab.findField("shape") baseidfld = baseftab.findfield("twr_id") basecapfld = baseftab.findfield("twr_cap") baserangefld = baseftab.findfield("range") baseidstringfld = baseftab.findfield("id_string") thmnum = flist.count for each thmspot in (thmnum-1)..0 thm = flist.get(thmspot) thmFtab = thm.GetFtab numrecs = thmFtab.GetNumrecords shapefld = thmFtab.findfield("shape") idfld = thmFtab.findfield("twr_id") capfld = thmFtab.findfield("twr_cap") rangefld = thmftab.findfield("range") thmFtab.GetSelection.SetAll reccount = thmFtab.GetSelection.count if (reccount = 1) then theovermultishape = thmFtab.returnvalue(shapefld,0) else theovermultishape = thmFtab.ReturnValue(shapefld, 1) end i = 0 for each i in 0..(numrecs - 1) theovershape = thmFtab.returnvalue(shapefld, i) theovermultishape = theovermultishape.returnunion(theovershape) end basethm.selectbyshapes({theovermultishape}, #VTAB_SELTYPE_NEW) basethm.subtractShape(theovermultishape) i = 0 for each i in 0..(numrecs - 1) theovershape = thmFtab.returnvalue(shapefld, i) theoverid = thmFtab.returnvalue(idfld, i) theovercap = thmFtab.returnvalue(capfld, i) theoverrange = thmFtab.returnvalue(rangefld, i) thenewrec = baseFtab.AddRecord baseFtab.SetValue(baseshapefld, thenewrec, theovershape) baseFtab.SetValue(baseidfld, thenewrec, theoverid) baseFtab.SetValue(basecapfld, thenewrec, theovercap) baseFtab.SetValue(baserangefld, thenewrec, theoverrange) baseFtab.SetValue(baseidstringfld, thenewrec, theoverid.AsString) i = i + 1 end end baseftab.getSelection.clearall ' *** removes all themes created in this process except ' *** the final coverage (basethm). for each thm in flist theView.DeleteTheme (thm) end for each thm in thiessenthms theView.DeleteTheme (thm) end theProject.RemoveDoc (towertab) for each thm in theView.Getthemes if (thm = basethm) then thm.SetActive(true) else thm.SetActive(false) end end ' *** makes and calculates the area field. The area is ' *** used in STAGE 6 (CELLGIS.AssignToTowers) twrareafld = Field.Make("twr_area", #FIELD_DECIMAL, 16 ,5) baseFtab.AddFields({twrareafld}) baseFtab.Calculate("[shape].ReturnArea",twrareafld) baseFTab.StopEditingWithRecovery (true) return Basethm