This section provides a venue for sharing GIS-related programming code and custom scripts in a variety of languages. Posts can be viewed by category or as a whole in blog format (below).
This script is built to be a "script tool" that you fire off from ArcGIS Toolbox. The user points to a feature class and specifies a number of random features to return, and the tool will add a random subset of your data as a .lyr back to ArcMap. I'll be using this for quality control.
The solution to this problem might seem obvious to .NET pros, but it took a bit of digging around for me to figure this one out.
Below is a class that handles events from a tool that allows the user to draw a polygon on the map. Since it is in the file "ToolbarActions.cs" it can't directly reference an asp control by its ID from the Default.aspx page, in this case "chkDrawPolygon", like it could if the asp control was a local variable. In this case if the checkbox is checked the polygon will be added to the graphics layer and displayed to the user.
The simple solution to this problem is to get a reference to the Page, which has a method that will find a control based on it's name. args.Control refers to the Map from which we can get the Page object. This is a much more elegant solution than dealing with Session variables and the like.
public class DrawPolygonTool : IMapServerToolAction { public void ServerAction(ToolEventArgs args) { PolygonEventArgs events = args as PolygonEventArgs; ESRI.ArcGIS.ADF.Web.Geometry.Polygon polygon = AGRC.Utilities.Geometry.CreatePolygonFromPolygon(events); System.Web.UI.WebControls.CheckBox chkDrawPolygon = args.Control.Page.FindControl("chkDrawPolygon") as System.Web.UI.WebControls.CheckBox;
if (chkDrawPolygon.Checked = true) { System.Drawing.Color color = System.Drawing.Color.White;
//send the polygon, color and transparency to a method that will draw it on the graphics layer// AGRC.Utilities.Functionality.AddGeometryToGraphics(polygon as ESRI.ArcGIS.ADF.Web.Geometry.Geometry, color, 50); }
With the popularity of ArcGIS Server and the expertise in it AGRC has gained, AGRC has evolved it's GIS role from a GIS shop that dabbled with VBA and python to a GIS shop that is pushing out custom applications for clients. With this change of gears, AGRC has had to adapt it's methods to cope with the requirements and deadlines of software development.
AGRC has been trying to build its programming expertise and with this push multiple employees are working on the same project simultaneously. ESRI provides a versioned geodatabase for multiple GIS professionals editing the same dataset and AGRC needed the same functionality for its project source code files.
After many months of dealing without this functionality and looking into what we needed we finally took the plunge. We installed another open source solution for source code management: Subversion. We are using subversion and its GUI partner TortoiseSVN to manage our projects source code in our multi-user editing environment.
As we explore the in's and out's of this solution we will post about our findings.
AGRC has installed an instance ofBugNet. BugNet is a powerful, open source application that allows users to submit bugs, enhancement requests or other project issues. Bugnet allows users to register and submit bugs. Developers can then be assigned to them with the ability to track their progress.
We are finding this tool very useful so far. It is a simple to set up solution that makes managing issues much easier than it has been in the past. We are using it on an actual project, an ArcGIS Server site for the Utah Department of Environmental Quality.
We will post updates when we have put BugNet through its paces.