A while back I created some query-helper classes in C# to make querying layers in a Web.ADF map application much easier to setup and use. I created a base class called "CA.Map.Query.QueryBase.cs" that holds many of the common elements that go into most types of queries. Then I created 3 other classes that inherit the base class. These are "CA.Map.Query.AttributeQuery.cs," "CA.Map.Query.DefinitionQuery.cs," and "CA.Map.Query.Spatial.cs." After writing these classes I recognized opportunities for further simplification, but haven't had time to implement them.
Here is pseudo code that shows how to implement a spatial query. This assumes you have put the classes into your App_Code folder of your application.
------example-------
// Create a new instance of the spatial query class
CA.Map.Query.Spatial spatialQry = new CA.Map.Query.Spatial(Map1_MapControl, "Map_Resource_Name", "Layer_Name", 50 , true);
// Where "50" is the number of records returned and
// the last argument "true" indicates that ADF Geometries of
// each selected feature will be included in the results table
// Perform the selection
ESRI.ArcGIS.Web.Display.Graphics.GraphicsLayer graphicsLayer =
spatialQry.GetGraphicsLayer(myGeometry);
// Where "myGeometry" is of type ESRI.ArcGIS.Web.Geometry.Geometry. You
// can cast points, polygons, lines, etc... into the generic geometry type
I've included a link in "View it live" showing how an address location, captured as a "point" is used to do a spatial query. |