/3.1 (Extension.1 Name: "Grid Projector" Dependencies: "$AVHOME/Ext32/Spatial.avx\n" FirstRootClassName: "Butn" Roots: 2 Roots: 4 Version: 31 About: "This extension allows one to project a grid from one projection to another" InstallScript: 5 UninstallScript: 6 ExtVersion: 1 ) (Butn.2 Help: "Grid Projector//Start grid projector" Icon: 3 Click: "GridReproject.Go" ) (AVIcon.3 Name: "grdico.gif" Data: 4e442049 6d616765 0001000f 000f0000 Data: 00e1d7d7 d7d7d7d7 d7d7d7d7 d7d7d7d7 Data: d7d70505 050505d7 d7d7d7d7 d7d7d7d7 Data: d7050505 0505d7d7 d7d7d7d7 d7d7d7d7 Data: 05050505 05000000 000000d7 d7d7d705 Data: 05050505 d7d7d7d7 d700d7d7 d7d70505 Data: 050505d7 d7d7d7d7 00d7d7d7 d7d7d7d7 Data: d7d7d7d7 d700d700 d700d7d7 d7d7d7d7 Data: d7d7d7d7 d7000000 d7d7d7d7 d7d7d7d7 Data: d7d7d7d7 d700d7d7 d7d7d7d7 d7d7d7d7 Data: d7d7b4b4 b4b4b4d7 d7d7d7d7 d7d7d7d7 Data: b4b4b4b4 b4b4d7d7 d7d7d7d7 d7d7b4b4 Data: b4b4b4b4 d7d7d7d7 d7d7d7d7 b4b4b4b4 Data: b4b4d7d7 d7d7d7d7 d7d7b4b4 b4b4b4b4 Data: d7d7d7d7 d7d7d7d7 d7d7d7d7 d7d7d7d7 Data: d7d7d700 00040000 00000000 00003300 Data: 00006600 00009900 0000cc00 0000ff00 Data: 00330000 00333300 00336600 00339900 Data: 0033cc00 0033ff00 00660000 00663300 Data: 00666600 00669900 0066cc00 0066ff00 Data: 00990000 00993300 00996600 00999900 Data: 0099cc00 0099ff00 00cc0000 00cc3300 Data: 00cc6600 00cc9900 00cccc00 00ccff00 Data: 00ff0000 00ff3300 00ff6600 00ff9900 Data: 00ffcc00 00ffff00 33000000 33003300 Data: 33006600 33009900 3300cc00 3300ff00 Data: 33330000 33333300 33336600 33339900 Data: 3333cc00 3333ff00 33660000 33663300 Data: 33666600 33669900 3366cc00 3366ff00 Data: 33990000 33993300 33996600 33999900 Data: 3399cc00 3399ff00 33cc0000 33cc3300 Data: 33cc6600 33cc9900 33cccc00 33ccff00 Data: 33ff0000 33ff3300 33ff6600 33ff9900 Data: 33ffcc00 33ffff00 66000000 66003300 Data: 66006600 66009900 6600cc00 6600ff00 Data: 66330000 66333300 66336600 66339900 Data: 6633cc00 6633ff00 66660000 66663300 Data: 66666600 66669900 6666cc00 6666ff00 Data: 66990000 66993300 66996600 66999900 Data: 6699cc00 6699ff00 66cc0000 66cc3300 Data: 66cc6600 66cc9900 66cccc00 66ccff00 Data: 66ff0000 66ff3300 66ff6600 66ff9900 Data: 66ffcc00 66ffff00 99000000 99003300 Data: 99006600 99009900 9900cc00 9900ff00 Data: 99330000 99333300 99336600 99339900 Data: 9933cc00 9933ff00 99660000 99663300 Data: 99666600 99669900 9966cc00 9966ff00 Data: 99990000 99993300 99996600 99999900 Data: 9999cc00 9999ff00 99cc0000 99cc3300 Data: 99cc6600 99cc9900 99cccc00 99ccff00 Data: 99ff0000 99ff3300 99ff6600 99ff9900 Data: 99ffcc00 99ffff00 cc000000 cc003300 Data: cc006600 cc009900 cc00cc00 cc00ff00 Data: cc330000 cc333300 cc336600 cc339900 Data: cc33cc00 cc33ff00 cc660000 cc663300 Data: cc666600 cc669900 cc66cc00 cc66ff00 Data: cc990000 cc993300 cc996600 cc999900 Data: cc99cc00 cc99ff00 cccc0000 cccc3300 Data: cccc6600 cccc9900 cccccc00 ccccff00 Data: ccff0000 ccff3300 ccff6600 ccff9900 Data: ccffcc00 ccffff00 ff000000 ff003300 Data: ff006600 ff009900 ff00cc00 ff00ff00 Data: ff330000 ff333300 ff336600 ff339900 Data: ff33cc00 ff33ff00 ff660000 ff663300 Data: ff666600 ff669900 ff66cc00 ff66ff00 Data: ff990000 ff993300 ff996600 ff999900 Data: ff99cc00 ff99ff00 ffcc0000 ffcc3300 Data: ffcc6600 ffcc9900 ffcccc00 ffccff00 Data: ffff0000 ffff3300 ffff6600 ffff9900 Data: ffffcc02 ffffff00 00000000 0d0d0d00 Data: 1a1a1a00 28282800 35353500 43434300 Data: 50505000 5d5d5d00 6b6b6b00 78787800 Data: 86868600 93939300 a1a1a100 aeaeae00 Data: bbbbbb00 c9c9c900 d6d6d600 e4e4e400 Data: f1f1f100 ffffff00 00000000 00000000 Data: 00000000 00000000 00000000 00000000 Data: 00000000 00000000 00000000 00000000 Data: 00000000 00000000 00000000 00000000 Data: 00000000 00000000 00000000 00000000 Data: 00000000 00000000 02000800 0a002000 Data: 00000000 00000000 000000 ) (Script.4 Name: "GridReproject.Go" SourceCode: "' Name: GridReproject.Go\n'\n' Author: Kenneth R. McVay\n' Date: Fri May 28 14:40:25 1999\n' Revised by: \n' Revision Date: \n' Revisions: \n' -------------------------------------------------------------------\n' Description: takes a grid with known projection and allows user to\n' reproject grid into a new projection\n' Requires: spatial analyst and active grid theme\n' Runs: \n' Run by: button on view gui\n' Self: \n' Returns: \n' -------------------------------------------------------------------\n\nDEBUG = true\nDEBUGNO T = false\n\n\n\n\n\ntheView = av.GetActiveDoc\n\nactiveThemes = theView.GetActiveThemes\n\nif(activeThemes.isEmpty) then\n msgBox.Info(\"There are no active themes\",\"\")\n return nil\nend\n\nactiveTheme = activeThemes.Get(0)\n\nif(activeTheme = nil) then\n msgBox.Info(\"There are no active grid themes\",\"\")\n return nil\nend\n\nif(activeTheme.Is(GTheme).Not) then\n msgBox.Info(\"The active theme is not a grid theme\",\"\")\n return nil\nend\n\n\n'THE SECTION OF CODE BETWEEN THE ########### I BORROWED FROM THE PROJECTOR EXTENSION\n'##### ############################\nsourceunits = av.getactivedoc.getdisplay.getunits\n\nif (sourceunits = #UNITS_LINEAR_UNKNOWN) then\n MsgBox.Error(\"View units must be set before projecting. Stopping.\",\n \"Error!\")\n return nil\nend\n\n'Get the projection of the view\n\nmyprj=av.getactivedoc.getprojection\n\n'Try to figure out if the source data is geographic \n' If our Prj.AsString <> \"\" then we have a projection and we are\n' geographic, or if our sourceunits are set to decimal degrees without\n' a project ion we are too\n\ninputgeographic =((myprj.AsString <> \"\") or\n ((sourceunits = #UNITS_LINEAR_DEGREES) and (myprj.AsString = \"\")))\n\n'If not, then let user pick input and output\n\nif (inputgeographic.Not) then\n\n Msgbox.Info(\"Please select the input projection\"++\n \"in the next dialog box\",\"Projector!\")\n \n 'Pop up dialog box, to get input projection\n 'and check for cancel button (nil)\n \n inputPrj = ProjectionDialog.Show(theView,sourceunits)\n if (inputPrj.IsNull) then\n return nil\n end\n \n 'Pop up dialog box, to get output projection\n 'and check for cancel button (nil)\n \nelse 'your input projection is geographic\n sourceunits = #UNITS_LINEAR_DEGREES\n inputPrj = myprj\nend\n\nunitslist1 = {\"meters\",\"feet\",\"decimal degrees\",\"miles\",\"kilometers\",\"yards\",\n \"centimeters\",\"inches\",\"millimeters\"}\n\nunitslist2 = {#UNITS_LINEAR_METERS, #UNITS_LINEAR_FEET,\n #UNITS_LINEAR_DEGREES, #UNITS_LINEAR_MILES,\n #UNITS_LINEAR_KILOMETERS, #UNITS_LINEAR_YARDS,\n #UNITS_LINEAR_CENTIMETERS, #UNITS_LINEAR_INCHES,\n #UNITS_LINEAR_MILLIMETERS}\n \noutputunits = MsgBox.ChoiceAsString(unitslist1,\n \"Please pick output units\",\"Projector!\")\n\n\nif (outputunits = nil) then\n return nil\nelse \n outunits = unitslist2.Get(unitslist1.FindByValue(outputunits))\nend\n\n'get the output projection, using the dialog box and check for cancel (nil)\nif (outputunits = \"decimal degrees\") then\n outputPrj = prj.MakeNull\n outputPrj.SetDescription (\"Geographic\")\n outputgeographic = true\nelse\n outputPrj = ProjectionDialog.Show(theView,outunits)\nend\n\nif (outputPrj = nil) then\n return nil\nend\n\n'check to see if they are the same. If so, exit\n '(inputgeographic.Not) and \nif ( ((outputPrj = inputPrj) and (sourceunits = outunits))) then\n MsgBox.Error(\"Input projection same as output projection.\",\"Error\")\n return nil\nend\n\n\n'check to see if output projection is geographic. If it is, we won't need\n'to do as much work below\n\noutputgeographic = outputPrj.R eturnDescription.Contains(\"Geographic\")\n\n'if both input and output are geographic, quit here\n\n'if (inputgeographic and outputgeographic) then\n' MsgBox.Error(\"Both input and output are geographic. Stopping.\",\"Error\")\n' return nil\n'end\n'#################################\n'END OF PROJECTOR EXTENSION CODE\n\n\n'make a list of views\nviewlist = List.Make\nfor each d in av.GetProject.GetDocs\n if (d.Is(View)) then\n viewlist.Add(d)\n end\nend 'for each d\n \n'provide a choice for a new view\nviewlist.Add(\"\") \nAddToView = MsgBox.ListAsString(viewlist,\"Add Theme to:\",\"\")\nif (AddToView = nil) then\n return nil\nend\n\n\n\n\n'get the grid to be reprojected\noldGrid = activeTheme.GetGrid\n\n'get the grid extents\noldExtent = oldGrid.GetExtent\noLeft = oldExtent.GetLeft\noRight = oldExtent.GetRight\noTop = oldExtent.GetTop\noBottom = oldExtent.GetBottom\noHeight = oTop - oBottom\noWidth = oRight - oLeft\n\n'set the vertical and horizontal step size for control points\nverticalStep = oHeight/100\nhorizontalStep = oWidth/100\n\n\n'set the current position to the top and left of extent\ncurrentVert = oBottom\ncurrentHorz = oLeft\n\n'create a list to hold the FROM control points\noPointList = list.Make\n\n'Now create the FROM CONTROL POINTS as a regular grided points across the extent of the grid\nfor each i in 1..100\n for each j in 1..100\n oPointList.Add(Point.Make(currentHorz,currentVert))\n currentHorz = currentHorz + horizontalStep\n end\n oPointList.Add(Point.Make(oRight,currentVert))\n currentVert = currentVert + verticalStep\n curren tHorz = oLeft\nend\ncurrentHorz = oLeft\nfor each i in 1..100\n oPointlist.Add(Point.Make(currentHorz,oTop))\n currentHorz = currentHorz + horizontalStep\nend\noPointlist.Add(Point.Make(oRight,oTop))\n\n\n\notempshape = Filename.GetCWD.MakeTmp(\"FROMPRJ\",\"shp\")\notempftab = ftab.MakeNew(otempShape,Point)\noIDfld = field.Make(\"FldID\",#FIELD_LONG,25,0)\notempftab.AddFields({oIDfld})\noShapeFld = otempftab.FindField(\"Shape\")\n\n\n\n\nfor each p in oPointlist\n r = otempftab.addRecord\n otempftab.setValue(oShapeFld,r,p)\nend\n\n\nout putfile = Filename.GetCWD.MakeTmp(\"NEWPRJ\",\"shp\")\n\n'MORE PROJECTOR EXTENSION CODE\n'Create the TO Control points\n'############################################\nif (outputgeographic) then\n newFtab = otempFtab.ExportUnprojected(outputfile,inputPrj,\n otempFtab.GetSelection.Count >0)\n elseif (inputgeographic) then\n newFtab = otempFtab.ExportProjected(outputfile,outputPrj,\n otempFtab.GetSelection.Count > 0)\n else 'need to go to geographic, then to something else\n 'make a temporary shape file\n tempshape = Filename.GetCWD.MakeTmp(\"TMPPRJ\",\"shp\")\n tempftab = otempFtab.ExportUnprojected(tempshape,\n inputPrj,otempFtab.GetSelection.Count >0)\n newFtab = tempFtab.ExportProjected(outputfile,outputPrj,false)\n 'now clean up\n tempftab.DeActivate\n tempftab = nil\n av.PurgeObjects\n tempshpname = tempshape.GetBaseName.AsTokens(\".\").Get(0)\n tempshpdir = tempshape.GetFullName.Clone.AsFilename\n tempshpdir.Stripfile\n filesToDelete = tempshpdir.Readfiles(tempshpname+\".*\") \n for each f in filesToDelete\n File.Delete(f)\n end\nend\n'############################################\n'end of projector extension code\n\nnShapeFld = newFtab.FindField(\"Shape\")\n\nlineList = list.Make\n\nfor each r in otempftab\n p1 = otempftab.ReturnValue(oShapeFld,r)\n p2 = newFtab.ReturnValue(nShapeFld,r)\n L = Line.Make(p1,p2)\n lineList.Add(L)\nend\n\n\n'Now clean up the two temporary shapes FROM and TO that hold the control points\notempftab.DeActivate\notempftab = nil\ntempshpname = otempShape.GetBaseName.AsTokens(\".\").Get(0)\ntempshpdir = otempShape.GetFullName.Clone.AsFilename\ntempshpdir.Stripfile\nfilesToDelete = tempshpdir.Readfiles(tempshpname+\".*\")\nfor each f in filesToDelete\n File.Delete(f)\nend\n\nnewFtab.DeActivate\nnewFtab = nil\ntempshpname = outputfile.GetBaseName.AsTokens(\".\").Get(0)\ntempshpdir = outputfile.GetFullName.Clone.AsFilename\ntempshpdir.Stripfile\nfilesToDelete = tempshpdir.Readfiles(tempshpname+\".*\")\nfor each f in filesToDelete\n File.Delete(f)\nend \n\nav.PurgeObjects\n\n\ngrid.reset\nnewGrid = oldGrid.Warp(lineList,3,#GRID_RESTYPE_NEAREST,units.Convert(oldGrid.GetCellSize,sourceunits,outunits))\nif(newGrid.HasError) then\n msgBox.Error(\"There is an error reading the projected grid. Could be there is not enough drive space\",\"\")\n return nil\nend\ntheGtheme = Gtheme.Make(newGrid)\n\nif (AddToView = \"\") then\n AddToView = View.Make\n AddToView.GetWin.Open\n end\nif (AddtoView.GetDisplay.GetUnits = #UNITS_LINEAR_UNKNOWN) then\n AddtoView.GetDisplay.Set Units(outunits)\nend\nAddToView.AddTheme(theGtheme)\nAddToView.InvalidateTOC(nil)\nAddToView.GetWin.Activate\n\n\n\n\n" ) (Script.5 Name: "Install" SourceCode: "\nif (av.Getproject = nil) then\n return nil\nend\n\n\ntheButtonBar = av.GetProject.FindGUI(\"View\").GetButtonBar\ntheButtonBar.Add(self.Get(0),999)" ) (Script.6 Name: "uninstall" SourceCode: "\n\nif (av.GetProject = nil) then\n return nil\nend\n\ntheButtonBar = av.GetProject.FindGUI(\"View\").GetButtonBar\ntheButtonBar.Remove(self.Get(0))" )