Esempio n. 1
0
        public override void ProcessRequest(IContext context)
        {
            IContextRequest  request  = context.Request;
            IContextResponse response = context.Response;

            try
            {
                string s = request.GetParam("BBOX");
                if (String.IsNullOrEmpty(s))
                {
                    throw new WmsInvalidParameterException("BBOX");
                }


                Map             map    = GetMap(request);
                LayerCollection layers = map.Layers;
                ILayer          first  = layers.First();
                bool            flip   = first.TargetSRID == 4326;
                BoundingBox     bbox   = AbstractHandler.ParseBBOX(s, flip);
                if (bbox == null)
                {
                    throw new WmsInvalidBboxException(s);
                }

                string ls = request.GetParam("LAYERS");
                if (!String.IsNullOrEmpty(ls))
                {
                    string[] strings = ls.Split(',');
                    foreach (ILayer layer in layers)
                    {
                        if (!strings.Contains(layer.LayerName))
                        {
                            layer.Enabled = false;
                        }
                    }
                }

                IEnumerable <GeoJSON> items  = GetData(map, bbox);
                StringWriter          writer = new StringWriter();
                GeoJSONWriter.Write(items, writer);
                string buffer = writer.ToString();

                IHandlerResponse result = new GetFeatureInfoResponseJson(buffer);
                result.WriteToContextAndFlush(response);
            }
            catch (WmsExceptionBase ex)
            {
                ex.WriteToContextAndFlush(response);
            }
        }