aaa_about'-------------------------------------------------------------------------- 'Name: aaa_about 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: shows a banner for about drop down item 'Requires: 'Calls: 'It is called by: 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- 'show banner anImageFile = "g:\ptw_workdir\flowchart.bmp".asFileName msgBox.Banner(anImageFile,0,"about") '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_add_data'-------------------------------------------------------------------------- 'Name: aaa_add_data 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: adds grids for analysis 'Requires: 'Calls: aaa_getGrid and aaa_getGrid_setfalse 'It is called by: 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- theView = av.getactivedoc theView.setName("Least Cost Path From Point A to Point B") 'add all grids for analysis rec_fleoString = "fleo99" av.run("aaa_grid_setfalse", rec_fleoString) rec_habString = "habitat" av.run("aaa_grid_setfalse", rec_habString) rec_landuseString = "landuse" av.run("aaa_grid_setfalse", rec_landuseString) rec_nearcityString = "near_city" av.run("aaa_grid_setfalse", rec_nearcityString) rec2_clan99String = "clan99" av.run("aaa_grid_setfalse", rec2_clan99String) rec2_fnaiString = "fnaic" av.run("aaa_grid_setfalse", rec2_fnaiString) rec_demString = "usgsdem" av.run("aaa_grid_setfalse", rec_demString) rec_femaString = "fema96" av.run("aaa_grid_setfalse", rec_femaString) 'add the cities mask which will be used rec2_citiesString = "city_mask" av.run("aaa_getGrid", rec2_citiesString) '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_display marker'-------------------------------------------------------------------------- 'Name: aaa_display marker 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: display marker for tool button 'Requires: 'Calls: 'It is called by: 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- if ((av.GetSymbolWin.GetPanel = #SYMBOLWIN_PANEL_COLOR).not) then av.GetSymbolWin.SetPanel(#SYMBOLWIN_PANEL_MARKER) end '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_getGrid'-------------------------------------------------------------------------- 'Name: aaa_getGrid 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: gets grids that don't need to set visible 'Requires: 'Calls: 'It is called by: aaa_add_data 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- theSrc = "b:/ptw_workdir/"+self 'msgBox.info(theSrc,"") aGridSrc = Grid.MakeSrcName(theSrc) if (aGridSrc = nil) then MsgBox.warning("Could not create a source object for "++theSrc+NL+ "Something Must Be Wrong!!!", "") return nil end aGridObj = Grid.Make(aGridSrc) if (aGridObj.HasError) then MsgBox.warning("Grid"++theSrc++"has errors" + NL + "your grid is corrupt - take a break","") return nil end aGridTheme = GTheme.Make(aGridObj) theView = av.GetActiveDoc theTheme = theView.addtheme(aGridTheme) aGridTheme.setVisible(true) 'else 'MsgBox.Info ("You will need to select a theme to do an analysis","") 'end '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_grid_setfalse'-------------------------------------------------------------------------- 'Name: aaa_grid_setfalse 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: gets grids that are not to be set visible 'Requires: 'Calls: 'It is called by: aaa_add_data 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- theSrc = "b:/ptw_workdir/"+self 'msgBox.info(theSrc,"") aGridSrc = Grid.MakeSrcName(theSrc) if (aGridSrc = nil) then MsgBox.warning("Could not create a source object for "++theSrc+NL+ "Something Must Be Wrong!!!", "") return nil end aGridObj = Grid.Make(aGridSrc) if (aGridObj.HasError) then MsgBox.warning("Grid"++theSrc++"has errors" + NL + "your grid is corrupt, you are S.O.L.","") return nil end aGridTheme = GTheme.Make(aGridObj) theView = av.GetActiveDoc theTheme = theView.addtheme(aGridTheme) 'aGridTheme.setVisible(true) 'else 'MsgBox.Info ("You will need to select a theme to do an analysis","") 'end return theTheme '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_LCP'-------------------------------------------------------------------------- 'Name: aaa_LCP 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: finds least cost path with user entered values 'Requires: 'Calls: 'It is called by: 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- 'check to make sure shape files (pointA and pointB are in view) 'cost distance can not be created with out theView = av.getActiveDoc themeName = "pointA.shp" PointATheme = theView.FindTheme(themeName) if (PointATheme = NIL) then MsgBox.Info ("You Must Add Point A From The Tool Menu Before Excuting This Script","") return nil end themeName = "pointB.shp" PointBTheme = theView.FindTheme(themeName) if (PointBTheme = NIL) then MsgBox.Info ("You Must Add Point B From The Tool Menu Before Excuting This Script","") return nil end 'set cell size and analysis extent theView = av.GetActiveDoc themeName = "city_mask" theTheme = theView.FindTheme(themeName) theExtentsGrid = theTheme.getGrid if(theTheme = nil) then msgBox.Warning ("Can't Find Theme"++themeName++ "Please use the drop down menu"+NL+ "to add appropriate themes") end theCellSize = theExtentsGrid.GetCellSize theAE = theView.GetExtension(AnalysisEnvironment) theAE.SetCellSize(#ANALYSISENV_VALUE, theCellSize) theAE.SetExtent(#ANALYSISENV_VALUE, theExtentsGrid.getExtent) 'theAE.Activate 'set mask to rec2_cities(no major roads would go through a city) theAE.SetMask (theTheme) theAE.Activate theView = av.GetActiveDoc theThemes = theView.GetThemes gridThemes = {} for each t in theThemes if (t.Is(Gtheme)) then gridThemes.Add(t) end end if (gridThemes.IsEmpty) then msgBox.Info("No grid themes.","") return nil end while (true) selectedGThemes = MsgBox.MultiListAsString(gridThemes, "Please Select Grid(s) for Anaylsis","Choose Grid") if (selectedGThemes = nil) then '.IsEmpty) then return nil end themesNames = {} for each t in selectedGThemes themesNames.Add(t.GetName) end weightsList = MsgBox.MultiInput ("Values must add to 1", "Enter Criteria Weights", themesNames, {}) if (weightsList.count = 0) then return nil end '--------------------------------- 'check weights here must equal 1 '--------------------------------- sum = 0 for each element in weightsList sum = sum + element.asnumber end if (sum.AsString = "1") then break else msgBox.error("The Criteria Values Must Add to 1!!!","") end end finalGrid = Grid.MakeFromNumb(0) counter = 0 for each t in selectedGthemes tempGrid = t.GetGrid * weightsList.Get(counter).AsNumber.AsGrid finalGrid = finalGrid + tempGrid counter = counter + 1 end 'theView.AddTheme(gTheme.Make(finalGrid)) gTheme.Make(finalGrid) 'find cost distance from pointA.shp theView = av.getActiveDoc themeName = "pointA.shp" PointATheme = theView.FindTheme(themeName) if (PointATheme = NIL) then MsgBox.Info ("You Must Add Point A From The Tool Menu Before Excuting This Script","") return nil end themeName = "pointB.shp" PointBTheme = theView.FindTheme(themeName) if (PointBTheme = NIL) then MsgBox.Info ("You Must Add Point B From The Tool Menu Before Excuting This Script","") return nil end '----------------------------------------------------------- 'convert points to grid then find distance and pat '---------------------------------------------------------- theView = av.GetActiveDoc thetheme = theView.FindTheme ("PointA.shp") theAE = theView.GetExtension (AnalysisEnvironment) theExtent = Rect.Make(0@0,1@1) theCellSize = 1 if ((theAE.GetExtent(theExtent) <> #ANALYSISENV_VALUE) or (theAE.GetCellSize(theCellSize) <> #ANALYSISENV_VALUE)) then theCE = AnalysisPropertiesDialog.Show(theView,TRUE,"Conversion Extent") ' check for Cancel from dialog if (theCE = NIL) then return NIL end theCE.GetCellSize(theCellSize) theCE.GetExtent(theExtent) end ' actually do conversion aPrj = theView.GetProjection aGrid = Grid.MakeFromFTab(theTheme.GetFTab,aPrj,NIL,{theCellSize,theExtent}) theGTheme = GTheme.Make(aGrid) if (aGrid.HasError) then return NIL end 'theView.AddTheme(theGTheme) 'same for point B thetheme = theView.FindTheme ("PointB.shp") theAE = theView.GetExtension (AnalysisEnvironment) theExtent = Rect.Make(0@0,1@1) theCellSize = 1 if ((theAE.GetExtent(theExtent) <> #ANALYSISENV_VALUE) or (theAE.GetCellSize(theCellSize) <> #ANALYSISENV_VALUE)) then theCE = AnalysisPropertiesDialog.Show(theView,TRUE,"Conversion Extent") ' check for Cancel from dialog if (theCE = NIL) then return NIL end theCE.GetCellSize(theCellSize) theCE.GetExtent(theExtent) end ' actually do conversion aPrj = theView.GetProjection bGrid = Grid.MakeFromFTab(theTheme.GetFTab,aPrj,NIL,{theCellSize,theExtent}) theGTheme = GTheme.Make(bGrid) if (bGrid.HasError) then return NIL end 'theView.AddTheme(theGTheme) 'use this if you want to add grid to view 'start costpath DirA = av.GetProject.GetWorkDir.MakeTmp("Direct","") costdist = agrid.CostDistance(finalGrid,DirA,NIL,NIL) aGridASrc = grid.makeSrcName(DirA.AsString) aGridAdir = Grid.make (aGridASrc) thecostpath = bGrid.CostPath (costdist,aGridAdir,true) thePath = GTheme.Make (thecostpath) theView.AddTheme (thePath) thePath.Setname ("Best_path") thePath.setVisible(true) '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_pointA'-------------------------------------------------------------------------- 'Name: aaa_pointA 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: adds Point A shape file from user entered point 'Requires: 'Calls: 'It is called by: 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- theView= av.getActiveDoc editThm = theView.GetEditableTheme if (editThm <> nil) then doSave = MsgBox.YesNoCancel("Save edits to "+editThm.GetName+"?", "Stop Editing",true) if (doSave = nil) then return nil end if (editThm.StopEditing(doSave).Not) then MsgBox.Info("Unable to Save Edits to " + editThm.GetName + ", please use the Save Edits As option", "") return nil else theView.SetEditableTheme(NIL) end end class = Point 'def = av.GetProject.MakeFileName("Pnt_A", "shp") PointAFileName = "pointA".asfilename def = FileDialog.Put(PointAFileName, "*.shp", "DO NOT CHANGE FILE NAME USE DEFAULT!!!") if (def <> nil) then tbl = FTab.MakeNew(def, class) if (tbl.HasError) then if (tbl.HasLockError) then MsgBox.Error("Unable to acquire Write Lock for file " + def.GetBaseName, "") else MsgBox.Error("Unable to create " + def.GetBaseName, "") end return nil end fld = Field.Make("ID", #FIELD_DECIMAL, 8, 0) fld.SetVisible( TRUE ) tbl.AddFields({fld}) tbl.SetEditable(False) theTheme = FTheme.Make(tbl) theView.AddTheme(theTheme) theTheme.SetActive(TRUE) theTheme.SetVisible(TRUE) theView.SetEditableTheme(theTheme) av.GetProject.SetModified(true) end '------------------------------------------------------- 'point tool '------------------------------------------------------ theView = av.GetActiveDoc pt = theView.GetDisplay.ReturnUserPoint theTheme = theView.GetEditableTheme if (theTheme <> nil) then thePrj = theView.GetProjection if (thePrj.IsNull.Not) then pt = pt.ReturnUnprojected(thePrj) end theField = theTheme.GetFTab.FindField("Shape") theTheme.GetFTab.BeginTransaction rec = theTheme.GetFTab.AddRecord theTheme.GetFTab.SetValue(theField, rec, pt) theTheme.GetFTab.EndTransaction theTheme.GetFTab.GetSelection.ClearAll theTheme.GetFTab.GetSelection.Set(rec) theTheme.GetFTab.UpdateSelection else gp = GraphicShape.Make(pt) theView.GetGraphics.UnselectAll gp.SetSelected(TRUE) theView.GetGraphics.Add(gp) end av.GetProject.SetModified(true) 'my attempt to remove selection theView.GetGraphics.UnselectAll 'if user hits cancel if (theTheme = Nil) then return nil end doSave = true theTheme.StopEditing(doSave) 'my attempt to unselect selected shape file point 'theTheme.Getvtab.ClearSelection ' msgbox.info("successful creation of start point" +NL+ "Now Add point B", "") theFtab = theTheme.GetFtab theSel = theFtab.getSelection theQuery = "[id] < 0" theFtab.query(theQuery,theSel,#VTAB_SELTYPE_NEW) theFtab.UpdateSelection '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top
aaa_pointB'-------------------------------------------------------------------------- 'Name: aaa_pointB_ 'Written: 12-4-2000, sam_palmer_and_bob_ehrman 'Prepared at: GeoPlan Center, University of Florida '-------------------------------------------------------------------------- 'Description: adds Point B shape file from user entered point 'Requires: 'Calls: 'It is called by: 'Self: 'Returns: 'FileName: '-------------------------------------------------------------------------- ' Initialize Constants '-------------------------------------------------------------------------- '-------------------------------------------------------------------------- ' Initialize Variables '-------------------------------------------------------------------------- theView = av.GetActiveDoc editThm = theView.GetEditableTheme if (editThm <> nil) then doSave = MsgBox.YesNoCancel("Save edits to "+editThm.GetName+"?", "Stop Editing",true) if (doSave = nil) then return nil end if (editThm.StopEditing(doSave).Not) then MsgBox.Info("Unable to Save Edits to " + editThm.GetName + ", please use the Save Edits As option", "") return nil else theView.SetEditableTheme(NIL) end end class = Point 'def = av.GetProject.MakeFileName("point_B", "shp") PointBFileName = "pointB".asfilename def = FileDialog.Put(PointBFileName, "*.shp", "DO NOT CHANGE FILENAME - USE DEFAULT!!!") if (def <> nil) then tbl = FTab.MakeNew(def, class) if (tbl.HasError) then if (tbl.HasLockError) then MsgBox.Error("Unable to acquire Write Lock for file " + def.GetBaseName, "") else MsgBox.Error("Unable to create " + def.GetBaseName, "") end return nil end fld = Field.Make("ID", #FIELD_DECIMAL, 8, 0) fld.SetVisible( TRUE ) tbl.AddFields({fld}) tbl.SetEditable(False) theTheme = FTheme.Make(tbl) theView.AddTheme(theTheme) theTheme.SetActive(TRUE) theTheme.SetVisible(TRUE) theView.SetEditableTheme(theTheme) av.GetProject.SetModified(true) end '------------------------------------------------------- 'point tool '------------------------------------------------------ theView = av.GetActiveDoc pt = theView.GetDisplay.ReturnUserPoint theTheme = theView.GetEditableTheme if (theTheme <> nil) then thePrj = theView.GetProjection if (thePrj.IsNull.Not) then pt = pt.ReturnUnprojected(thePrj) end theField = theTheme.GetFTab.FindField("Shape") theTheme.GetFTab.BeginTransaction rec = theTheme.GetFTab.AddRecord theTheme.GetFTab.SetValue(theField, rec, pt) theTheme.GetFTab.EndTransaction theTheme.GetFTab.GetSelection.ClearAll theTheme.GetFTab.GetSelection.Set(rec) theTheme.GetFTab.UpdateSelection else gp = GraphicShape.Make(pt) theView.GetGraphics.UnselectAll gp.SetSelected(TRUE) theView.GetGraphics.Add(gp) end av.GetProject.SetModified(true) 'my attempt to remove selection theView.GetGraphics.UnselectAll if (theTheme = nil) then return nil end doSave = true theTheme.StopEditing(doSave) 'my attempt to unselect selected shape file point 'theTheme.Getvtab.ClearSelection ' msgbox.info("successful creation of start point"+NL+ "Now Run LCP From Drop Down Menu", "") theFtab = theTheme.GetFtab theSel = theFtab.getSelection theQuery = "[id] < 0" theFtab.query(theQuery,theSel,#VTAB_SELTYPE_NEW) theFtab.UpdateSelection '***** Modified: 12-12-2000, sam_palmer_and_bob_ehrman ******************** '***** End of modification ************************************************ '-------------------------------------------------------------------------- ' END OF SCRIPT '--------------------------------------------------------------------------
Back to Top