[mapserver-users] Combine Spatial & attribute queries

Venkat Rao Tammineni vtammineni at roulacglobal.com
Wed Sep 3 23:35:17 PDT 2008


Hi,

 

    I have done code  for  spatial Query..

 

 

This is Spatial Query..

                   protected void ContriesEnvelop()

        {

            layer = MapFunction.Map.getLayerByName("Countries"); // Get
Layer by name

            string strSubRegionsClassItem = "cntry_name=";

            string strDropDownSelectedItem = "'" +
lstContries.SelectedItem.Text + "'";

            string strQuery = strSubRegionsClassItem +
strDropDownSelectedItem;

 

           

                res = layer.queryByAttributes(MapFunction.Map, "CNTRY_NAME",
strQuery, 1);

 

 

                if (res == (int)EnumMap.RESULT_CODE.MS_SUCCESS)

                {

                    results = layer.getResults();

                    if (results != null)

                    {

                        resulCacheObj = results.getResult(0);

                        layer.open();

                        layer.close();

                    }

                }

 

                using (results = layer.getResults())

                {

                    if (results != null && results.numresults > 0)

                    {

                        // calculating the extent of the results

                        if (query_bounds == null)

                        { query_bounds = new rectObj(results.bounds.minx,
results.bounds.miny, results.bounds.maxx, results.bounds.maxy, 0); }

                        else

                        {

                            if (results.bounds.minx < query_bounds.minx)

                            { query_bounds.minx = results.bounds.minx; }

                            if (results.bounds.miny < query_bounds.miny)

                            { query_bounds.miny = results.bounds.miny; }

                            if (results.bounds.maxx > query_bounds.maxx)

                            { query_bounds.maxx = results.bounds.maxx; }

                            if (results.bounds.maxy > query_bounds.maxy)

                            { query_bounds.maxy = results.bounds.maxy; }

                        }

                    }

                }

                if (zoomToResults)

                {

                    try

                    {

                        MapFunction.Map.setExtent(query_bounds.minx,
query_bounds.miny, query_bounds.maxx, query_bounds.maxy);

                    }

                    catch (NullReferenceException exp)

                    {}

                }

            MapFunction.IsMapInDirectory = true;

        }

 

This Method is for Getting Non Spatial query and populates data in Listbox .
based on Listbox data zooms to the shape..

 

  public void PopulateContries()

        {

            strSelectedItem = lstSubRegions.SelectedValue;

            conn = new NpgsqlConnection(_AppSetting.GetConnection);

            conn.Open();

            String strSql = string.Format(_AppSetting.GetCntryCmdText,
strSelectedItem);

            dataAdapter = new NpgsqlDataAdapter(strSql, conn);

            dataSet = new DataSet();

            dataAdapter.Fill(dataSet, _AppSetting.GetCntryTblName);

            lstContries.DataSource =
dataSet.Tables[_AppSetting.GetCntryTblName];

            lstContries.DataTextField = _AppSetting.GetCntryDataFieldName;

            lstContries.DataBind();

            conn.Close();

        }

 

Is it same you want?let me know..But I am using Postgresql..

 

Thanks and Regards

Venkat.

India

 

 

From: mapserver-users-bounces at lists.osgeo.org
[mailto:mapserver-users-bounces at lists.osgeo.org] On Behalf Of Hallgren,
Johan
Sent: Thursday, September 04, 2008 11:49 AM
To: mapserver-users at lists.osgeo.org
Subject: [mapserver-users] Combine Spatial & attribute queries

 

Hello

 

I'm working with Mapserver 5.2 and with the C# interface. 

 

Now I use a Oracle spatial layer and we would like to query the layer with a
combination of spatial and attribute queries. Today a first use queryByRect
and then queryByAttribute. Two queries will be sent to Oracle and the
resultCache will only have the result of the latest query. 

 

How can I solve this? Primarily I only will send one query to the database,
both with the spatial and the attribute part.

 

br

Johan 

 


Johan Hallgren


Logica
Pelle Bergs backe 3
Box 1938, 791 19 Falun
Tel (och mobil): 023-547 46 (int: +46-2354746)
johan.hallgren at logica.com
http://www.logica.se <http://www.logica.se/> 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20080904/0581029d/attachment.htm>


More information about the MapServer-users mailing list