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


C# SharpMap.ZoomToBox方法代码示例

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


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

示例1: GetFeatureInfo

    /// <summary>
    /// 
    /// </summary>
    /// <param name="map"></param>
    /// <param name="context"></param>
    private static void GetFeatureInfo(SharpMap.Map map, System.Web.HttpContext context)
    {
      //Check for required parameters
      if (context.Request.Params["LAYERS"] == null)
      { WmsException.ThrowWmsException("Required parameter LAYERS not specified"); return; }
      if (context.Request.Params["QUERY_LAYERS"] == null)
      { WmsException.ThrowWmsException("Required parameter QUERY_LAYERS not specified"); return; }
      if (context.Request.Params["STYLES"] == null)
      { WmsException.ThrowWmsException("Required parameter STYLES not specified"); return; }
      if (context.Request.Params["SRS"] == null)
      { WmsException.ThrowWmsException("Required parameter CRS not specified"); return; }
      /*else if (context.Request.Params["SRS"] != "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["INFO_FORMAT"] == null)
      { WmsException.ThrowWmsException("Required parameter INFO_FORMAT not specified"); return; }
      if (context.Request.Params["FEATURE_COUNT"] == null)
      { WmsException.ThrowWmsException("Required parameter FEATURE_COUNT not specified"); return; }
      if (context.Request.Params["X"] == null)
      { WmsException.ThrowWmsException("Required parameter X not specified"); return; }
      if (context.Request.Params["Y"] == null)
      { WmsException.ThrowWmsException("Required parameter Y not specified"); return; }


      //Set layers on/off
      if (context.Request.Params["LAYERS"] != "") //If LAYERS is empty, use all layers
      {
        string[] layers = context.Request.Params["LAYERS"].Split(new char[] { ',' });
        foreach (SharpMap.Layers.ILayer layer in map.Layers)
          layer.Enabled = false;

        bool layerNotFound = true;
        string layerNotFoundName = "";
        foreach (string layer in layers)
        {
          SharpMap.Layers.ILayer lay = map.Layers.Find(delegate(SharpMap.Layers.ILayer findlay) { return findlay.LayerName == layer; });
          if (lay == null)
          {
            WmsException.ThrowWmsException(WmsException.WmsExceptionCode.LayerNotDefined, "Unknown layer '" + layer + "'");
            return;
          }
          else
          {
            if (lay is SharpMap.Layers.VectorLayer)
            {
              lay.Enabled = true;
              layerNotFound = false;
            }
            else
            {
              lay.Enabled = false;
              layerNotFoundName = layer;
            }
          }
        }
        if (layerNotFound)
          WmsException.ThrowWmsException(WmsException.WmsExceptionCode.LayerNotQueryable, "No se puede consultar la capa '" + layerNotFoundName + "'");
      }
      else
      {
        foreach (SharpMap.Layers.ILayer lay in map.Layers)
        {
          if (lay is SharpMap.Layers.VectorLayer)
            lay.Enabled = true;
          else
            lay.Enabled = false;
        }
      }

      
      SharpMap.Geometries.BoundingBox bbox = ParseBBOX(context.Request.Params["bbox"]);
      if (bbox == null)
      {
        WmsException.ThrowWmsException("Invalid parameter BBOX");
        return;
      }

      int w = 0;
      int h = 0;
      if (!int.TryParse(context.Request.Params["WIDTH"], out w))
        WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidFormat, "Invalid WIDTH");
      if (!int.TryParse(context.Request.Params["HEIGHT"], out h))
        WmsException.ThrowWmsException(WmsException.WmsExceptionCode.InvalidFormat, "Invalid HEIGHT");

      map.Size = new System.Drawing.Size(w, h);
      map.ZoomToBox(bbox);

      float x = 0;
      float y = 0;
      if (!float.TryParse(context.Request.Params["X"], System.Globalization.NumberStyles.Float, SharpMap.Map.numberFormat_EnUS, out x))
//.........这里部分代码省略.........
开发者ID:diegowald,项目名称:intellitrack,代码行数:101,代码来源:WmsServer.cs


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