1

Re: how can set GeographicalFilter using c#

hi i have a problem is using  GeographicalFilter with SpeciesList can anybody help me how can i set GeographicalFilter with in c#

this is the jsp code for setting  GeographicalFilter
***********************************************

GeographicalFilter gf = new GeographicalFilter();
    gf.setGridSquare(gs);
***********************************************
plz nay one can tell me how can i do this in c#

2

Re: how can set GeographicalFilter using c#

Hi,

apologies for my slow reply.  I don't know if you still need this question answering, but this code contains the information you want about setting a geographic filter using a GridSquare in c#.  It is for a OneSiteDataRequest, but you would do the same thing using a SpeciesListRequest.

Jon

        private void button1_Click(object sender, System.EventArgs e)
        {
            //Jon Cooper 7th November 06
            //This example shows how to query the Gateway webservice for all butterfly records for a single
            //10km square.  The service returns records and a map of the 10km square with records overlayed.

            //Create the grid square to be used as a geographic filter
            GridSquare gs = new GridSquare();
            gs.key = "TL27";//This specifies a single 10km grid square on the British National grid

            //Create the geographic filter, apply the grid square and specifiy a minimum resolution for the data returned (exclude 10km and 2km records)
            GeographicalFilter gf = new GeographicalFilter();
            gf.Item = gs;
            gf.MinimumResolution = Resolution._1km;
            gf.MinimumResolutionSpecified = true;
            
            //Sort out the map settings (how it will appear) and apply to the GeographicFilter
            MapSettings ms = new MapSettings();
            ms.width = 400;
            ms.height = 400;
            ms.outlineColour = "#000000";
            ms.outlineWidth = 2;
            ms.outlineWidthSpecified = true;
            ms.fillTransparency = 0.0;
            ms.fillTransparencySpecified = true;
            gf.MapSettings = ms;

            //Create the query object and get the data
            OneSiteDataRequest osdr = new OneSiteDataRequest();
            osdr.TaxonReportingCategoryKey = "NHMSYS0000080067";  //Limit the query to just butterflies (see http://www.searchnbn.net/library/webservices/resources.jsp)
            osdr.GeographicalFilter = gf;
            GatewayWebService gws = new GatewayWebService();
            GatewayData gd = gws.GetSiteData(osdr);
            Data d = gd.Data;

            //Add the map to the form (this requires a reference to System.Web.Services)
            HttpWebRequest req = (HttpWebRequest) WebRequest.Create(d.Map.Url.ToString());
            req.Method = "GET";
            WebResponse resp = req.GetResponse();
            Stream st = resp.GetResponseStream();
            Bitmap bmp = new Bitmap(Image.FromStream(st));
            pictureBox1.Image = bmp;

        }