当前位置: 首页>>代码示例>>C#>>正文


C# SharpMap.GetMap方法代码示例

本文整理汇总了C#中SharpMap.GetMap方法的典型用法代码示例。如果您正苦于以下问题:C# SharpMap.GetMap方法的具体用法?C# SharpMap.GetMap怎么用?C# SharpMap.GetMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpMap的用法示例。


在下文中一共展示了SharpMap.GetMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseQueryString


//.........这里部分代码省略.........
            //Request parameter is mandatory
            if (context.Request.Params["REQUEST"] == null)
                { WmsException.ThrowWmsException("Required parameter REQUEST not specified"); return; }
            //Check if version is supported
            if (context.Request.Params["VERSION"] != null)
            {
                if (String.Compare(context.Request.Params["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(context.Request.Params["REQUEST"], "GetCapabilities", ignorecase) != 0)
                    { WmsException.ThrowWmsException("VERSION parameter not supplied"); return; }
            }

            //If Capabilities was requested
            if (String.Compare(context.Request.Params["REQUEST"], "GetCapabilities", ignorecase) == 0)
            {
                //Service parameter is mandatory for GetCapabilities request
                if (context.Request.Params["SERVICE"] == null)
                { WmsException.ThrowWmsException("Required parameter SERVICE not specified"); return; }

                if (String.Compare(context.Request.Params["SERVICE"], "WMS") != 0)
                    WmsException.ThrowWmsException("Invalid service for GetCapabilities Request. Service parameter must be 'WMS'");

                System.Xml.XmlDocument capabilities = Wms.Capabilities.GetCapabilities(map, description);
                context.Response.Clear();
                context.Response.ContentType = "text/xml";
                System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(context.Response.OutputStream);
                capabilities.WriteTo(writer);
                writer.Close();
                context.Response.End();
            }
            else if (String.Compare(context.Request.Params["REQUEST"], "GetMap", ignorecase) == 0) //Map requested
            {
                //Check for required parameters
                if (context.Request.Params["LAYERS"] == null)
                    { WmsException.ThrowWmsException("Required parameter LAYERS not specified"); return; }
                if (context.Request.Params["STYLES"] == null)
                    { WmsException.ThrowWmsException("Required parameter STYLES not specified"); return; }
                if (context.Request.Params["CRS"] == null)
                    { WmsException.ThrowWmsException("Required parameter CRS not specified"); return; }
                else if (context.Request.Params["CRS"] != "EPSG:" + map.Layers[0].SRID.ToString())
                    { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidCRS, "CRS not supported"); return; }
                if (context.Request.Params["BBOX"] == null)
                    { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Required parameter BBOX not specified"); return; }
                if (context.Request.Params["WIDTH"] == null)
                    { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Required parameter WIDTH not specified"); return; }
                if (context.Request.Params["HEIGHT"] == null)
                    { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Required parameter HEIGHT not specified"); return; }
                if (context.Request.Params["FORMAT"] == null)
                    { WmsException.ThrowWmsException("Required parameter FORMAT not specified"); return; }

                //Set background color of map
                if (String.Compare(context.Request.Params["TRANSPARENT"], "TRUE", ignorecase) == 0)
                    map.BackColor = System.Drawing.Color.Transparent;
                else if (context.Request.Params["BGCOLOR"] != null)
                {
                    try { map.BackColor = System.Drawing.ColorTranslator.FromHtml(context.Request.Params["BGCOLOR"]); }
                    catch { WmsException.ThrowWmsException("Invalid parameter BGCOLOR"); return; };
                }
                else
                    map.BackColor = System.Drawing.Color.White;

                //Get the image format requested
                System.Drawing.Imaging.ImageCodecInfo imageEncoder = GetEncoderInfo(context.Request.Params["FORMAT"]);
开发者ID:stophun,项目名称:fdotoolbox,代码行数:67,代码来源:WmsServer.cs

示例2: GetMap

    /// <summary>
    /// 
    /// </summary>
    /// <param name="map"></param>
    /// <param name="description"></param>
    /// <param name="context"></param>
    /// <param name="ignorecase"></param>
    private static void GetMap(SharpMap.Map map, ref Capabilities.WmsServiceDescription description, System.Web.HttpContext context, bool ignorecase)
    {
      string QueryString = context.Request.QueryString.ToString();
      System.Diagnostics.Debug.WriteLine(context.Request.QueryString);
      if (RequestIsCached(QueryString))
      {
        SendCachedData(context);
      }
      else
      {
        bool MapIsStatic = true;
        //Check for required parameters
        if (context.Request.Params["LAYERS"] == null)
        { WmsException.ThrowWmsException("Required parameter LAYERS not specified"); return; }
        if (context.Request.Params["STYLES"] == null)
        { WmsException.ThrowWmsException("Required parameter STYLES not specified"); return; }
        if (context.Request.Params["CRS"] == null)
        { WmsException.ThrowWmsException("Required parameter CRS not specified"); return; }
        else if (context.Request.Params["CRS"] != "EPSG:" + map.Layers[0].SRID.ToString())
        { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidCRS, "CRS not supported"); return; }
        if (context.Request.Params["BBOX"] == null)
        { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Required parameter BBOX not specified"); return; }
        if (context.Request.Params["WIDTH"] == null)
        { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Required parameter WIDTH not specified"); return; }
        if (context.Request.Params["HEIGHT"] == null)
        { WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Required parameter HEIGHT not specified"); return; }
        if (context.Request.Params["FORMAT"] == null)
        { WmsException.ThrowWmsException("Required parameter FORMAT not specified"); return; }

        //Set background color of map
        if (String.Compare(context.Request.Params["TRANSPARENT"], "TRUE", ignorecase) == 0)
          map.BackColor = System.Drawing.Color.Transparent;
        else if (context.Request.Params["BGCOLOR"] != null)
        {
          try { map.BackColor = System.Drawing.ColorTranslator.FromHtml(context.Request.Params["BGCOLOR"]); }
          catch { WmsException.ThrowWmsException("Invalid parameter BGCOLOR"); return; };
        }
        else
          map.BackColor = System.Drawing.Color.White;

        //Get the image format requested
        System.Drawing.Imaging.ImageCodecInfo imageEncoder = GetEncoderInfo(context.Request.Params["FORMAT"]);
        if (imageEncoder == null)
        {
          WmsException.ThrowWmsException("Invalid MimeType specified in FORMAT parameter");
          return;
        }

        //Parse map size
        int width = 0;
        int height = 0;
        if (!int.TryParse(context.Request.Params["WIDTH"], out width))
        {
          WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Invalid parameter WIDTH");
          return;
        }
        else if (description.MaxWidth > 0 && width > description.MaxWidth)
        {
          WmsException.ThrowWmsException(WmsException.WmsExceptionCode.OperationNotSupported, "Parameter WIDTH too large");
          return;
        }
        if (!int.TryParse(context.Request.Params["HEIGHT"], out height))
        {
          WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidDimensionValue, "Invalid parameter HEIGHT");
          return;
        }
        else if (description.MaxHeight > 0 && height > description.MaxHeight)
        {
          WmsException.ThrowWmsException(WmsException.WmsExceptionCode.OperationNotSupported, "Parameter HEIGHT too large");
          return;
        }
        map.Size = new System.Drawing.Size(width, height);

        SharpMap.Geometries.BoundingBox bbox = ParseBBOX(context.Request.Params["bbox"]);
        if (bbox == null)
        {
          WmsException.ThrowWmsException("Invalid parameter BBOX");
          return;
        }
        map.PixelAspectRatio = ((double)width / (double)height) / (bbox.Width / bbox.Height);
        map.Center = bbox.GetCentroid();
        map.Zoom = bbox.Width;

        //Set layers on/off
        if (context.Request.Params["LAYERS"] != "") //If LAYERS is empty, use default layer on/off settings
        {
          string[] layers = context.Request.Params["LAYERS"].Split(new char[] { ',' });
          if (description.LayerLimit > 0)
          {
            if (layers.Length == 0 && map.Layers.Count > description.LayerLimit ||
              layers.Length > description.LayerLimit)
            {
              WmsException.ThrowWmsException(WmsException.WmsExceptionCode.OperationNotSupported, "Too many layers requested");
//.........这里部分代码省略.........
开发者ID:diegowald,项目名称:intellitrack,代码行数:101,代码来源:WmsServer.cs

示例3: RepeatedRendering

        private static void RepeatedRendering(SharpMap.Map map, int numberOfFeatures, int numberOfTimes, out long avgRenderTime)
        {
            System.Console.WriteLine("Rendering Map with " + numberOfFeatures + " features");
            var totalRenderTime = 0L;
            var sw = new System.Diagnostics.Stopwatch();
            for (var i = 1; i <= numberOfTimes; i++)
            {
                System.Console.Write(string.Format("Rendering {0}x time(s)", i));
                sw.Start();
                map.GetMap();
                sw.Stop();
                System.Console.WriteLine(" in " +
                                         sw.ElapsedMilliseconds.ToString(
                                             System.Globalization.NumberFormatInfo.CurrentInfo) + "ms.");
                totalRenderTime += sw.ElapsedMilliseconds;
                sw.Reset();
            }

            avgRenderTime = totalRenderTime/numberOfTimes;
            System.Console.WriteLine("\n Average rendering time:" + avgRenderTime.ToString(
                                         System.Globalization.NumberFormatInfo.CurrentInfo) + "ms.");
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:22,代码来源:ShapeFileProviderTests.cs


注:本文中的SharpMap.GetMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。