Jan 23, 2010

How to find the layers that intersect with an envelope or geometry + ArcGIS .Net web ADF

Layers Intersection with an Envelope:
As we know Layers intersection is a common task in GIS, here we achieve this using Identity method.
Below is the code used to find the layers in the mapresource which are being intersected 
with an envelope.

Method Call:
DataTable dt  = GetIntersectionLayers(Map1.GetFunctionalities(0),x1,y1,x2,y2);

Method Definition:
public DataTable[] GetIntersectionLayers(
ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality gisFunctionality, double minX, 
double minY, double maxX, double maxY)
        int pixelTolerance = 1;
        DataTable[] dt = null;
        ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisResource =   gisFunctionality.Resource;
        ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality queryFunctionality =
            (typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);

        string[] layerIDs = null;
        string[] layerNames = null;
        queryFunctionality.GetQueryableLayers(null, out layerIDs, out layerNames);            

        ESRI.ArcGIS.ADF.Web.Geometry.Envelope adfEnvelope =
            new ESRI.ArcGIS.ADF.Web.Geometry.Envelope(minX, minY, maxX, maxY);            

        dt = queryFunctionality.Identify(gisFunctionality.Name, adfEnvelope,
            pixelTolerance, ESRI.ArcGIS.ADF.Web.IdentifyOption.AllLayers, layerIDs);
        return dt;                

The method returns the data table with a collection of intersected layers.

1 comment:

Anonymous said...

Dear Friend, Identity Geometry doesn't support adfEnvelope and has an exception that identity support only point geometry. plz help me how does it work with a polygon geometry. thank you very much.