Inheritance: MonoBehaviour
Ejemplo n.º 1
0
        public void bgcolor_html_known_name()
        {
            MockRepository  mocks = new MockRepository();
            IContextRequest req   = mocks.StrictMock <IContextRequest>();

            With.Mocks(mocks)
            .Expecting(() =>
            {
                Expect.Call(req.GetParam("VERSION")).Return("1.3.0");
                Expect.Call(req.GetParam("LAYERS")).Return("poly_landmarks,tiger_roads,poi");
                Expect.Call(req.GetParam("STYLES")).Return("");
                Expect.Call(req.GetParam("CRS")).Return("EPSG:4326");
                Expect.Call(req.GetParam("BBOX")).Return("40.68,-74.02,40.69,-74.01");
                Expect.Call(req.GetParam("WIDTH")).Return("256");
                Expect.Call(req.GetParam("HEIGHT")).Return("256");
                Expect.Call(req.GetParam("FORMAT")).Return("image/png");
                Expect.Call(req.GetParam("CQL_FILTER")).Return(null);
                Expect.Call(req.GetParam("TRANSPARENT")).Return("FALSE");
                Expect.Call(req.GetParam("BGCOLOR")).Return("lightgrey");
            })
            .Verify(() =>
            {
                IHandler handler      = new GetMap(Desc);
                IHandlerResponse resp = handler.Handle(Map, req);
                Assert.That(resp, Is.Not.Null);
                Assert.IsInstanceOf <GetMapResponse>(resp);
            });
        }
Ejemplo n.º 2
0
        public void bbox_must_be_valid()
        {
            MockRepository  mocks = new MockRepository();
            IContextRequest req   = mocks.StrictMock <IContextRequest>();

            With.Mocks(mocks)
            .Expecting(() =>
            {
                Expect.Call(req.GetParam("VERSION")).Return("1.3.0");
                Expect.Call(req.GetParam("LAYERS")).Return("poly_landmarks");
                Expect.Call(req.GetParam("STYLES")).Return("");
                Expect.Call(req.GetParam("CRS")).Return("EPSG:4326");
                Expect.Call(req.GetParam("BBOX")).Return("45,75,35,65");     // min-max flipped!
                Expect.Call(req.GetParam("WIDTH")).Return("256");
                Expect.Call(req.GetParam("HEIGHT")).Return("256");
                Expect.Call(req.GetParam("FORMAT")).Return("image/png");
                Expect.Call(req.GetParam("CQL_FILTER")).Return(null);
                Expect.Call(req.GetParam("TRANSPARENT")).Return("TRUE");
            })
            .Verify(() =>
            {
                IHandler handler      = new GetMap(Desc);
                IHandlerResponse resp = handler.Handle(Map, req);
                Assert.That(resp, Is.Not.Null);
            });
        }
Ejemplo n.º 3
0
        public void request_generates_transparent_image()
        {
            MockRepository  mocks = new MockRepository();
            IContextRequest req   = mocks.StrictMock <IContextRequest>();

            With.Mocks(mocks)
            .Expecting(() =>
            {
                Expect.Call(req.GetParam("VERSION")).Return("1.3.0");
                Expect.Call(req.GetParam("LAYERS")).Return("poly_landmarks,tiger_roads,poi");
                Expect.Call(req.GetParam("STYLES")).Return("");
                Expect.Call(req.GetParam("CRS")).Return("EPSG:4326");
                Expect.Call(req.GetParam("BBOX")).Return("40.68,-74.02,40.69,-74.01");
                Expect.Call(req.GetParam("WIDTH")).Return("256");
                Expect.Call(req.GetParam("HEIGHT")).Return("256");
                Expect.Call(req.GetParam("FORMAT")).Return("image/png");
                Expect.Call(req.GetParam("CQL_FILTER")).Return(null);
                Expect.Call(req.GetParam("TRANSPARENT")).Return("TRUE");
                DoNotExpect.Call(req.GetParam("BGCOLOR"));
            })
            .Verify(() =>
            {
                IHandler handler      = new GetMap(Desc);
                IHandlerResponse resp = handler.Handle(Map, req);
                Assert.That(resp, Is.Not.Null);
                Assert.IsInstanceOf <GetMapResponse>(resp);
                GetMapResponse img   = (GetMapResponse)resp;
                ImageCodecInfo codec = img.CodecInfo;
                Assert.That(codec, Is.Not.Null);
                Assert.That(codec.MimeType, Is.EqualTo("image/png"));
                Assert.That(img.Image, Is.Not.Null);
            });
        }
        public override async Task<string> OnGetEvaluatedPropertyValueAsync(string propertyName, string evaluatedPropertyValue, IProjectProperties defaultProperties)
        {
            ConfigurationGeneral configuration = await _properties.GetConfigurationGeneralPropertiesAsync();
            string value = await configuration.OutputType.GetEvaluatedValueAtEndAsync();
            if (GetMap.TryGetValue(value, out string returnValue))
            {
                return returnValue;
            }

            return DefaultGetValue;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AppiumConfig"/> class.
        /// Configuration method for wiring up the information needed for the appium drivers and application
        /// </summary>
        /// <param name="deviceName">Name of the device</param>
        public AppiumConfig(string deviceName = null)
        {
            operatingSystem = Environment.OSVersion;
            platform        = operatingSystem.Platform;

            buildDir    = AppDomain.CurrentDomain.BaseDirectory;
            solutionDir = Directory.GetParent(buildDir).Parent.Parent.Parent.FullName;

            DeviceMap = GetMap.Get(devicesDir, deviceName).Map;
            appPath   = SetAppPath.Get(DeviceMap).AppPath;

            DeviceMap.Add("app", appPath);
        }
        public override async Task <string> OnGetEvaluatedPropertyValueAsync(string evaluatedPropertyValue, IProjectProperties defaultProperties)
        {
            var configuration = await _properties.GetConfigurationGeneralPropertiesAsync().ConfigureAwait(false);

            var value = await configuration.OutputType.GetEvaluatedValueAtEndAsync().ConfigureAwait(false);

            if (GetMap.TryGetValue(value, out string returnValue))
            {
                return(returnValue);
            }

            return(DefaultGetValue);
        }
Ejemplo n.º 7
0
        // GET: Catan
        public ActionResult Index()
        {
            GetMap         getmap    = new GetMap();
            CatanViewmodel viewmodel = new CatanViewmodel
            {
                Hexagons      = getmap.GetHexagons(),
                DockLines     = getmap.GetDockLines(),
                BestPositions = getmap.GetTopPositions()
            };

            //RetrieveSavesData Retrievedata = new RetrieveSavesData();
            //List<Save> saves = Retrievedata.GetSavesInfo();
            //viewmodel.Saves = saves;
            return(View(viewmodel));
        }
Ejemplo n.º 8
0
        public void only_wms_130_is_supported()
        {
            MockRepository  mocks = new MockRepository();
            IContextRequest req   = mocks.StrictMock <IContextRequest>();

            With.Mocks(mocks)
            .Expecting(() => Expect.Call(req.GetParam("VERSION")).Return("1.1.1"))
            .Verify(() =>
            {
                IHandler handler      = new GetMap(Desc);
                IHandlerResponse resp = handler.Handle(Map, req);
                Assert.That(resp, Is.Not.Null);
                Assert.IsInstanceOf <GetMapResponse>(resp);
            });
        }
Ejemplo n.º 9
0
Archivo: Player.cs Proyecto: 3ldh/Zappy
    private IEnumerator MoveLeft()
    {
        while (coroutineManager.IsTrackedCoroutineRunning())
        {
            yield return(waitForEndOfFrame);
        }
        Vector3 dest = GetMap.WorldToGrid(transform.position + Map.West);

        // print("MoveRIght : position before : " + transform.position + " dest : " + dest);
        if (!GetMap.Contains(dest))
        {
            SpawnParticle(transform.position + (Map.West * GetMap.ScaleFactor.x));
        }
        yield return(coroutineManager.StartTrackedCoroutine(MoveOverSeconds(transform.position + (Map.West * GetMap.ScaleFactor.x), speed)));

        if (!GetMap.Contains(dest))
        {
            transform.position = new Vector3(GetMap.GridToWorld(Map.East * (GetMap.dimension.x - 1)).x, transform.position.y, transform.position.z);
        }
    }
Ejemplo n.º 10
0
Archivo: Player.cs Proyecto: 3ldh/Zappy
    private IEnumerator MoveDown()
    {
        while (coroutineManager.IsTrackedCoroutineRunning())
        {
            yield return(waitForEndOfFrame);
        }
        // print("MoveDOwn : position before : " + transform.position);
        Vector3 dest = GetMap.WorldToGrid(transform.position + Map.South);

        if (!GetMap.Contains(dest))
        {
            SpawnParticle(transform.position + (Map.South * GetMap.ScaleFactor.z));
        }
        yield return(coroutineManager.StartTrackedCoroutine(MoveOverSeconds(transform.position + (Map.South * GetMap.ScaleFactor.z), speed)));

        if (!GetMap.Contains(dest))
        {
            transform.position = new Vector3(transform.position.x, transform.position.y, GetMap.GridToWorld(Map.North * (GetMap.dimension.y - 1)).z);
        }
    }
Ejemplo n.º 11
0
        public void crs_support_is_checked()
        {
            MockRepository  mocks = new MockRepository();
            IContextRequest req   = mocks.StrictMock <IContextRequest>();

            With.Mocks(mocks)
            .Expecting(() =>
            {
                Expect.Call(req.GetParam("VERSION")).Return("1.3.0");
                Expect.Call(req.GetParam("LAYERS")).Return("poly_landmarks");
                Expect.Call(req.GetParam("STYLES")).Return("WMS");
                Expect.Call(req.GetParam("CRS")).Return("EPSG:900913");
            })
            .Verify(() =>
            {
                IHandler handler      = new GetMap(Desc);
                IHandlerResponse resp = handler.Handle(Map, req);
                Assert.That(resp, Is.Not.Null);
                Assert.IsInstanceOf <GetMapResponse>(resp);
            });
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Generates a WMS 1.3.0 compliant response based on a <see cref="SharpMap.Map"/> and the current HttpRequest.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The Web Map Server implementation in SharpMap requires v1.3.0 compatible clients,
        /// and support the basic operations "GetCapabilities" and "GetMap"
        /// as required by the WMS v1.3.0 specification. SharpMap does not support the optional
        /// GetFeatureInfo operation for querying.
        /// </para>
        /// <example>
        /// Creating a WMS server in ASP.NET is very simple using the classes in the SharpMap.Web.Wms namespace.
        /// <code lang="C#">
        /// void page_load(object o, EventArgs e)
        /// {
        ///		//Get the path of this page
        ///		string url = (Request.Url.Query.Length>0?Request.Url.AbsoluteUri.Replace(Request.Url.Query,""):Request.Url.AbsoluteUri);
        ///		SharpMap.Web.Wms.Capabilities.WmsServiceDescription description =
        ///			new SharpMap.Web.Wms.Capabilities.WmsServiceDescription("Acme Corp. Map Server", url);
        ///
        ///		// The following service descriptions below are not strictly required by the WMS specification.
        ///
        ///		// Narrative description and keywords providing additional information
        ///		description.Abstract = "Map Server maintained by Acme Corporation. Contact: [email protected].
        ///     High-quality maps showing roadrunner nests and possible ambush locations.";
        ///		description.Keywords.Add("bird");
        ///		description.Keywords.Add("roadrunner");
        ///		description.Keywords.Add("ambush");
        ///
        ///		//Contact information
        ///		description.ContactInformation.PersonPrimary.Person = "John Doe";
        ///		description.ContactInformation.PersonPrimary.Organisation = "Acme Inc";
        ///		description.ContactInformation.Address.AddressType = "postal";
        ///		description.ContactInformation.Address.Country = "Neverland";
        ///		description.ContactInformation.VoiceTelephone = "1-800-WE DO MAPS";
        ///		//Impose WMS constraints
        ///		description.MaxWidth = 1000; //Set image request size width
        ///		description.MaxHeight = 500; //Set image request size height
        ///
        ///		//Call method that sets up the map
        ///		//We just add a dummy-size, since the wms requests will set the image-size
        ///		SharpMap.Map myMap = MapHelper.InitializeMap(new System.Drawing.Size(1,1));
        ///
        ///		//Parse the request and create a response
        ///		SharpMap.Web.Wms.WmsServer.ParseQueryString(myMap,description);
        /// }
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="map">Map to serve on WMS</param>
        /// <param name="description">Description of map service</param>
        ///<param name="pixelSensitivity">Tolerance for GetFeatureInfo requests</param>
        ///<param name="intersectDelegate">Delegate for Getfeatureinfo intersecting, when null, the WMS will default to ICanQueryLayer implementation</param>
        public static void ParseQueryString(Map map, Capabilities.WmsServiceDescription description, int pixelSensitivity, InterSectDelegate intersectDelegate)
        {
            _pixelSensitivity  = pixelSensitivity;
            _intersectDelegate = intersectDelegate;

            if (map == null)
            {
                throw (new ArgumentException("Map for WMS is null"));
            }
            if (map.Layers.Count == 0)
            {
                throw (new ArgumentException("Map doesn't contain any layers for WMS service"));
            }

            if (HttpContext.Current == null)
            {
                throw new ApplicationException("An attempt was made to access the WMS server outside a valid HttpContext");
            }

            HttpContext context = HttpContext.Current;

            //IgnoreCase value should be set according to the VERSION parameter
            //v1.3.0 is case sensitive, but since it causes a lot of problems with several WMS clients, we ignore casing anyway.
            const bool ignorecase = true;

            //Collect parameters
            string request = context.Request.Params["REQUEST"];
            string version = context.Request.Params["VERSION"];

            //Check for required parameters
            //Request parameter is mandatory
            if (request == null)
            {
                WmsException.ThrowWmsException("Required parameter REQUEST not specified");
                return;
            }

            //Check if version is supported
            if (version != null)
            {
                if (String.Compare(version, "1.3.0", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("Only version 1.3.0 supported");
                    return;
                }
            }
            else
            {
                //Version is mandatory if REQUEST!=GetCapabilities. Check if this is a capabilities request, since VERSION is null
                if (String.Compare(request, "GetCapabilities", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("VERSION parameter not supplied");
                    return;
                }
            }

            HandlerParams        @params    = new HandlerParams(context, map, description, ignorecase);
            GetFeatureInfoParams infoParams = new GetFeatureInfoParams(_pixelSensitivity, _intersectDelegate);

            IWmsHandler handler = null;

            if (String.Compare(request, "GetCapabilities", ignorecase) == 0)
            {
                handler = new GetCapabilities(@params);
            }
            else if (String.Compare(request, "GetFeatureInfo", ignorecase) == 0)
            {
                handler = new GetFeatureInfo(@params, infoParams);
            }
            else if (String.Compare(request, "GetMap", ignorecase) == 0)
            {
                handler = new GetMap(@params);
            }

            if (handler == null)
            {
                WmsException.ThrowWmsException(
                    WmsException.WmsExceptionCode.OperationNotSupported, String.Format("Invalid request: {0}", request));
            }
            else
            {
                handler.Handle();
            }
        }
Ejemplo n.º 13
0
        internal void Init(string CapabilitiesString, WFSDataset wfsDataset)
        {
            try
            {
                _themes = new List <IWebServiceTheme>();

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(CapabilitiesString);

                XmlNode CapabilitiesNode = doc.SelectSingleNode("WMT_MS_Capabilities/Capability");
                _getCapabilities          = new GetCapabilities(CapabilitiesNode.SelectSingleNode("Request/GetCapabilities"));
                _getMap                   = new GetMap(CapabilitiesNode.SelectSingleNode("Request/GetMap"));
                _getFeatureInfo           = new GetFeatureInfo(CapabilitiesNode.SelectSingleNode("Request/GetFeatureInfo"));
                _describeLayer            = new DescribeLayer(CapabilitiesNode.SelectSingleNode("Request/DescribeLayer"));
                _getLegendGraphic         = new GetLegendGraphic(CapabilitiesNode.SelectSingleNode("Request/GetLegendGraphic"));
                _getStyles                = new GetStyles(CapabilitiesNode.SelectSingleNode("Request/GetStyles"));
                _exceptions               = new WMSExceptions(CapabilitiesNode.SelectSingleNode("Exception"));
                _userDefinedSymbolization = new UserDefinedSymbolization(CapabilitiesNode.SelectSingleNode("UserDefinedSymbolization"));

                XmlNode service = CapabilitiesNode.SelectSingleNode("Layer");
                XmlNode title   = service.SelectSingleNode("Title");
                if (title != null)
                {
                    _name = title.InnerText;
                }

                _srs         = new SRS(service);
                this.SRSCode = _srs.Srs[_srs.SRSIndex];

                foreach (XmlNode layer in service.SelectNodes("Layer"))
                {
                    string  name = "", Title = "";
                    XmlNode nameNode  = layer.SelectSingleNode("Name");
                    XmlNode titleNode = layer.SelectSingleNode("Title");

                    if (nameNode == null)
                    {
                        continue;
                    }
                    name = Title = nameNode.InnerText;
                    if (titleNode != null)
                    {
                        Title = titleNode.InnerText;
                    }
                    XmlNodeList styles = layer.SelectNodes("Style");

                    WFSFeatureClass wfsFc = null;
                    if (wfsDataset != null)
                    {
                        IDatasetElement wfsElement = wfsDataset[name];
                        if (wfsElement != null && wfsElement.Class is WFSFeatureClass)
                        {
                            wfsFc = wfsElement.Class as WFSFeatureClass;
                        }
                    }

                    if (styles.Count == 0)
                    {
                        IClass wClass = null;
                        if (wfsFc != null)
                        {
                            wClass = wfsFc;
                        }
                        else if (layer.Attributes["queryable"] != null && layer.Attributes["queryable"].Value == "1")
                        {
                            wClass = new WMSQueryableThemeClass(_dataset, name, String.Empty, layer, _getFeatureInfo, _srs, _exceptions);
                        }
                        else
                        {
                            wClass = new WMSThemeClass(_dataset, name, String.Empty, layer);
                        }

                        IWebServiceTheme theme;
                        if (wClass is WFSFeatureClass)
                        {
                            theme = new WebServiceTheme2(
                                wClass, Title, name, true, this);
                        }
                        else
                        {
                            theme = new WebServiceTheme(
                                wClass, Title, name, true, this
                                );
                        }

                        _themes.Add(theme);
                    }
                    else
                    {
                        foreach (XmlNode style in styles)
                        {
                            string  sName = "", sTitle = "";
                            XmlNode sNameNode  = style.SelectSingleNode("Name");
                            XmlNode sTitleNode = style.SelectSingleNode("Title");

                            if (sNameNode == null)
                            {
                                continue;
                            }
                            sName = sTitle = sNameNode.InnerText;
                            if (sTitleNode != null)
                            {
                                sTitle = sTitleNode.InnerText;
                            }

                            IClass wClass = null;
                            if (wfsFc is WFSFeatureClass)
                            {
                                wClass = wfsFc;
                                ((WFSFeatureClass)wClass).Style = sName;
                            }
                            else if (layer.Attributes["queryable"] != null && layer.Attributes["queryable"].Value == "1")
                            {
                                wClass = new WMSQueryableThemeClass(_dataset, name, sName, layer, _getFeatureInfo, _srs, _exceptions);
                            }
                            else
                            {
                                wClass = new WMSThemeClass(_dataset, name, sName, layer);
                            }

                            IWebServiceTheme theme;
                            if (wClass is WFSFeatureClass)
                            {
                                theme = new WebServiceTheme2(
                                    wClass, Title + " (Style=" + sTitle + ")", name, true, this);
                            }
                            else
                            {
                                theme = new WebServiceTheme(
                                    wClass, Title + " (Style=" + sTitle + ")", name, true, this
                                    );
                            }

                            _themes.Add(theme);
                        }
                    }
                }
                doc = null;
            }
            catch (Exception ex)
            {
                string errMsg = ex.Message;
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Generates a WMS 1.3.0 compliant response based on a <see cref="SharpMap.Map"/> and the current HttpRequest.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The Web Map Server implementation in SharpMap requires v1.3.0 compatible clients,
        /// and support the basic operations "GetCapabilities" and "GetMap"
        /// as required by the WMS v1.3.0 specification. SharpMap does not support the optional
        /// GetFeatureInfo operation for querying.
        /// </para>
        /// <example>
        /// Creating a WMS server in ASP.NET is very simple using the classes in the SharpMap.Web.Wms namespace.
        /// <code lang="C#">
        /// void page_load(object o, EventArgs e)
        /// {
        ///		//Get the path of this page
        ///		string url = (Request.Url.Query.Length>0?Request.Url.AbsoluteUri.Replace(Request.Url.Query,""):Request.Url.AbsoluteUri);
        ///		SharpMap.Web.Wms.Capabilities.WmsServiceDescription description =
        ///			new SharpMap.Web.Wms.Capabilities.WmsServiceDescription("Acme Corp. Map Server", url);
        ///		
        ///		// The following service descriptions below are not strictly required by the WMS specification.
        ///		
        ///		// Narrative description and keywords providing additional information 
        ///		description.Abstract = "Map Server maintained by Acme Corporation. Contact: [email protected]. 
        ///     High-quality maps showing roadrunner nests and possible ambush locations.";
        ///		description.Keywords.Add("bird");
        ///		description.Keywords.Add("roadrunner");
        ///		description.Keywords.Add("ambush");
        ///		
        ///		//Contact information 
        ///		description.ContactInformation.PersonPrimary.Person = "John Doe";
        ///		description.ContactInformation.PersonPrimary.Organisation = "Acme Inc";
        ///		description.ContactInformation.Address.AddressType = "postal";
        ///		description.ContactInformation.Address.Country = "Neverland";
        ///		description.ContactInformation.VoiceTelephone = "1-800-WE DO MAPS";
        ///		//Impose WMS constraints
        ///		description.MaxWidth = 1000; //Set image request size width
        ///		description.MaxHeight = 500; //Set image request size height
        ///		
        ///		//Call method that sets up the map
        ///		//We just add a dummy-size, since the wms requests will set the image-size
        ///		SharpMap.Map myMap = MapHelper.InitializeMap(new System.Drawing.Size(1,1));
        ///		
        ///		//Parse the request and create a response
        ///		SharpMap.Web.Wms.WmsServer.ParseQueryString(myMap,description);
        /// }
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="map">Map to serve on WMS</param>
        /// <param name="description">Description of map service</param>
        ///<param name="pixelSensitivity">Tolerance for GetFeatureInfo requests</param>
        ///<param name="intersectDelegate">Delegate for Getfeatureinfo intersecting, when null, the WMS will default to ICanQueryLayer implementation</param>
        public static void ParseQueryString(Map map, Capabilities.WmsServiceDescription description, int pixelSensitivity, InterSectDelegate intersectDelegate)
        {
            _pixelSensitivity = pixelSensitivity;
            _intersectDelegate = intersectDelegate;

            if (map == null)
                throw (new ArgumentException("Map for WMS is null"));
            if (map.Layers.Count == 0)
                throw (new ArgumentException("Map doesn't contain any layers for WMS service"));

            if (HttpContext.Current == null)
                throw new ApplicationException("An attempt was made to access the WMS server outside a valid HttpContext");

            HttpContext context = HttpContext.Current;

            //IgnoreCase value should be set according to the VERSION parameter
            //v1.3.0 is case sensitive, but since it causes a lot of problems with several WMS clients, we ignore casing anyway.
            const bool ignorecase = true;

            //Collect parameters
            string request = context.Request.Params["REQUEST"];
            string version = context.Request.Params["VERSION"];

            //Check for required parameters
            //Request parameter is mandatory            
            if (request == null)
            {
                WmsException.ThrowWmsException("Required parameter REQUEST not specified");
                return;
            }

            //Check if version is supported            
            if (version != null)
            {
                if (String.Compare(version, "1.3.0", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("Only version 1.3.0 supported");
                    return;
                }
            }
            else
            {
                //Version is mandatory if REQUEST!=GetCapabilities. Check if this is a capabilities request, since VERSION is null
                if (String.Compare(request, "GetCapabilities", ignorecase) != 0)
                {
                    WmsException.ThrowWmsException("VERSION parameter not supplied");
                    return;
                }
            }

            HandlerParams @params = new HandlerParams(context, map, description, ignorecase);
            GetFeatureInfoParams infoParams = new GetFeatureInfoParams(_pixelSensitivity, _intersectDelegate);

            IWmsHandler handler = null;
            if (String.Compare(request, "GetCapabilities", ignorecase) == 0)
                handler = new GetCapabilities(@params);
            else if (String.Compare(request, "GetFeatureInfo", ignorecase) == 0)
                handler = new GetFeatureInfo(@params, infoParams);
            else if (String.Compare(request, "GetMap", ignorecase) == 0)
                handler = new GetMap(@params);

            if (handler == null)
            {
                WmsException.ThrowWmsException(
                    WmsException.WmsExceptionCode.OperationNotSupported, String.Format("Invalid request: {0}", request));
            }
            else handler.Handle();
        }
Ejemplo n.º 15
0
 protected ImmutableCompositeUserTypeBase(IReadOnlyCollection <CompositeUserTypeColumn> columnDefinitions, GetMap getMap)
     : this(columnDefinitions.Select(x => x.Type).ToArray(), columnDefinitions.Select(x => x.Name).ToArray(), getMap)
 {
 }
Ejemplo n.º 16
0
 protected ImmutableCompositeUserTypeBase(IType[] propertyTypes, string[] propertyNames, GetMap getMap)
 {
     _propertyTypes = propertyTypes;
     _propertyNames = propertyNames;
     _get           = getMap;
 }
Ejemplo n.º 17
0
        /// <summary>
        /// Generates a WMS 1.3.0 compliant response based on a <see cref="SharpMap.Map"/> and the current HttpRequest.
        /// </summary>
        /// <remarks>
        /// <para>
        /// The Web Map Server implementation in SharpMap requires v1.3.0 compatible clients,
        /// and support the basic operations "GetCapabilities" and "GetMap"
        /// as required by the WMS v1.3.0 specification. SharpMap does not support the optional
        /// GetFeatureInfo operation for querying.
        /// </para>
        /// <example>
        /// Creating a WMS server in ASP.NET is very simple using the classes in the SharpMap.Web.Wms namespace.
        /// <code lang="C#">
        /// void page_load(object o, EventArgs e)
        /// {
        ///		//Get the path of this page
        ///		string url = (Request.Url.Query.Length>0?Request.Url.AbsoluteUri.Replace(Request.Url.Query,""):Request.Url.AbsoluteUri);
        ///		SharpMap.Web.Wms.Capabilities.WmsServiceDescription description =
        ///			new SharpMap.Web.Wms.Capabilities.WmsServiceDescription("Acme Corp. Map Server", url);
        ///
        ///		// The following service descriptions below are not strictly required by the WMS specification.
        ///
        ///		// Narrative description and keywords providing additional information
        ///		description.Abstract = "Map Server maintained by Acme Corporation. Contact: [email protected]. High-quality maps showing roadrunner nests and possible ambush locations.";
        ///		description.Keywords.Add("bird");
        ///		description.Keywords.Add("roadrunner");
        ///		description.Keywords.Add("ambush");
        ///
        ///		//Contact information
        ///		description.ContactInformation.PersonPrimary.Person = "John Doe";
        ///		description.ContactInformation.PersonPrimary.Organisation = "Acme Inc";
        ///		description.ContactInformation.Address.AddressType = "postal";
        ///		description.ContactInformation.Address.Country = "Neverland";
        ///		description.ContactInformation.VoiceTelephone = "1-800-WE DO MAPS";
        ///		//Impose WMS constraints
        ///		description.MaxWidth = 1000; //Set image request size width
        ///		description.MaxHeight = 500; //Set image request size height
        ///
        ///		//Call method that sets up the map
        ///		//We just add a dummy-size, since the wms requests will set the image-size
        ///		SharpMap.Map myMap = MapHelper.InitializeMap(new System.Drawing.Size(1,1));
        ///
        ///		//Parse the request and create a response
        ///		SharpMap.Web.Wms.WmsServer.ParseQueryString(myMap,description);
        /// }
        /// </code>
        /// </example>
        /// </remarks>
        /// <param name="map">Map to serve on WMS</param>
        /// <param name="description">Description of map service</param>
        /// <param name="context">The context the <see cref="WmsServer"/> is running in.</param>
        public static void ParseQueryString(Map map, Capabilities.WmsServiceDescription description, IContext context)
        {
            const StringComparison @case    = StringComparison.InvariantCultureIgnoreCase;
            IContextRequest        request  = context.Request;
            IContextResponse       response = context.Response;

            try
            {
                if (PixelSensitivity < 0)
                {
                    PixelSensitivity = 1;
                }
                if (map == null)
                {
                    throw new WmsArgumentException("Map for WMS is null");
                }
                if (map.Layers.Count == 0)
                {
                    throw new WmsArgumentException("Map doesn't contain any layers for WMS service");
                }

                string req = request.GetParam("REQUEST");
                if (req == null)
                {
                    throw new WmsParameterNotSpecifiedException("REQUEST");
                }

                IHandler handler;
                if (String.Equals(req, "GetCapabilities", @case))
                {
                    handler = new GetCapabilities(description);
                }
                else if (String.Equals(req, "GetFeatureInfo", @case))
                {
                    // use text/plain as default handler
                    // let the default handler validate params
                    string format = request.GetParam("INFO_FORMAT") ?? String.Empty;
                    GetFeatureInfoParams @params = new GetFeatureInfoParams(PixelSensitivity,
                                                                            IntersectDelegate, FeatureInfoResponseEncoding);
                    if (String.Equals(format, "text/json", @case))
                    {
                        handler = new GetFeatureInfoJson(description, @params);
                    }
                    else if (String.Equals(format, "text/html", @case))
                    {
                        handler = new GetFeatureInfoHtml(description, @params);
                    }
                    else
                    {
                        handler = new GetFeatureInfoPlain(description, @params);
                    }
                }
                else if (String.Equals(req, "GetMap", @case))
                {
                    handler = new GetMap(description);
                }
                else
                {
                    string s = String.Format("Invalid request: {0}", req);
                    throw new WmsOperationNotSupportedException(s);
                }

                IHandlerResponse result = handler.Handle(map, request);
                result.WriteToContextAndFlush(response);
            }
            catch (WmsExceptionBase ex)
            {
                ex.WriteToContextAndFlush(response);
            }
        }