clase para hacer consultas sobre el mapa

Ver el tema anterior Ver el tema siguiente Ir abajo

clase para hacer consultas sobre el mapa

Mensaje  ltorresc el Vie Jul 09, 2010 4:36 am

Esta clase es para hacer cualquier tipo de consulta a las capas del mapa

Código:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.DataSources;
using ESRI.ArcGIS.ADF.Web.DataSources.Graphics;

namespace ArcGisFilter
{
    public class QueryFilter
    {
        private int m_Resource_Index;
        private ESRI.ArcGIS.ADF.Web.UI.WebControls.Map m_Map;
        private string m_Field_List;
        private string m_Where_Condition;
        private string m_Layer_Name;
        private string m_Resource_name;

   
    public ESRI.ArcGIS.ADF.Web.UI.WebControls.Map Map
    {
        get { return Map; }
        set { m_Map = value; }
    }

   
    public string Where_Condition
    {
    get { return Where_Condition; }
    set { m_Where_Condition = value; }
    }

    public string Layer_Name
    {
    get { return Layer_Name; }
    set { m_Layer_Name = value; }
    }
    public string Resource_name
    {
        get { return Resource_name; }
        set { m_Resource_name = value; }
    }
    public System.Data.DataTable Run_Query()
    {
        DataTable QueryTable2 = new DataTable();
       
        try
        {
            MapFunctionality ags_mf = null;
            IGISFunctionality gisFunctionality_1 = null;
            foreach (ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality gisFunctionality in m_Map.GetFunctionalities())
            {
                if (gisFunctionality.Resource.Name == m_Resource_name)
            {
                    gisFunctionality_1 = gisFunctionality;
                    if (gisFunctionality is MapFunctionality)
                    {
                        ags_mf = (MapFunctionality)gisFunctionality;
                        break;
                    }
                }
            }

            string[] layerIDs = null;
            string[] layerNames = null;
            ESRI.ArcGIS.ADF.Web.DataSources.IGISResource gisResource = gisFunctionality_1.Resource;
            bool supported = gisResource.SupportsFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality));
            IQueryFunctionality queryFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality)gisResource.CreateFunctionality(typeof(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), null);

            queryFunctionality.GetQueryableLayers(null, out layerIDs, out layerNames);
           
            ESRI.ArcGIS.ADF.Web.SpatialFilter filtro = new ESRI.ArcGIS.ADF.Web.SpatialFilter();
            filtro.ReturnADFGeometries = true;
            filtro.MaxRecords = 100;
            m_Map.Extent = m_Map.GetFullExtent();
            filtro.Geometry = m_Map.Extent;
            filtro.WhereClause = m_Where_Condition;

            int i = 0;
            for (int x = 0; x < layerNames.Length; x++)
            {
                if (layerNames[x] == m_Layer_Name)
                {
                    i = x;
                    break;
                }
            }

         
            DataTable queryResultsDataTable = new DataTable();
            queryResultsDataTable = queryFunctionality.Query(gisFunctionality_1.Name, layerIDs[i], filtro);
            QueryTable2 = queryResultsDataTable;
                     
       
        }
            catch  { }
     
            return QueryTable2;
     
      }
    }
}

ltorresc
Admin

Mensajes: 12
Fecha de inscripción: 09/07/2010

Ver perfil de usuario

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba

- Temas similares

Permiso de este foro:
No puedes responder a temas en este foro.