⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwebform new.aspx.cs

📁 supermap开发的基站管理系统
💻 CS
📖 第 1 页 / 共 5 页
字号:
            else
            {
                //Response.Write("<script language=javascript > alert('此次查询没有对应的台站链路,请确认查的条件是否正确!')</script>");
            }
        }
        else 
        {
            ShowDialog("没有满足条件的数据!");
            return;
        }
    }
    /// <summary>
    /// 通过台站Guid进行台站定位
    /// </summary>
    /// <param name="guids"></param>
    private void QueryGuids(string guids)
    {
        ArrayList tzList = this.getMapCoorsRange.getStationSpecialInfo(guids);

        TZResult = this.getMapCoorsRange.objDs;
        DataBinderTZ();
        if (tzList == null || tzList.Count == 0)
        {
            ShowDialog("没有满足条件的数据!");
            return;
        }
        InsertTZIntoMap(tzList);
      //   GetCoord(tzList);
    }
    #endregion


    #region 通用方法
    /// <summary>
    /// 判断坐标是否再地图范围内
    /// </summary>
    /// <param name="x"></param>
    /// <param name="y"></param>
    /// <returns></returns>
    private bool IsXYInMap(double x, double y)
    {
        double left_x, left_y, right_x, right_y;
        bool isIn = false;
        try
        {
            if (ConfigurationManager.AppSettings["Map_Left_Bottom_X"] == null || ConfigurationManager.AppSettings["Map_Left_Bottom_Y"] == null || ConfigurationManager.AppSettings["Map_Right_Top_X"] == null || ConfigurationManager.AppSettings["Map_Right_Top_Y"] == null)
                isIn = true;
            else
            {

                left_x = Convert.ToDouble(ConfigurationManager.AppSettings["Map_Left_Bottom_X"]);
                left_y = Convert.ToDouble(ConfigurationManager.AppSettings["Map_Left_Bottom_Y"]);
                right_x = Convert.ToDouble(ConfigurationManager.AppSettings["Map_Right_Top_X"]);
                right_y = Convert.ToDouble(ConfigurationManager.AppSettings["Map_Right_Top_Y"]);
                if (x <= right_x && x >= left_x && y <= right_y && y >= left_y)
                    isIn = true;
                else
                    isIn = false;
            }
        }
        catch
        {
            isIn = true;
        }
        return isIn;
    }
    /// <summary>
    /// 把台站信息画在地图上
    /// </summary>
    /// <param name="tzList"></param>
    private void InsertTZIntoMap(ArrayList tzList)
    {
        try
        {
            CurTZList = tzList;           
            int index = 0;
            tranStationInfo stationInfo;
            double x = 0, y = 0;
            int count = 0;
            MapControl1.CustomLayer.Visible = true;
            foreach (object tz in tzList)
            {
                //if (!ChcekTZPosition(tzList))
                //    return;
                stationInfo = (tranStationInfo)tz;
                if (stationInfo.STAT_LG == "" || stationInfo.STAT_LA == "")
                    continue;
                if (IsXYInMap(Convert.ToDouble(stationInfo.STAT_LA), Convert.ToDouble(stationInfo.STAT_LG)))
                {
                    index = MapControl1.CustomLayer.Marks.Count + 1;
                    string image = StaticClass.GetImageStrByType(stationInfo);
                    MapControl1.CustomLayer.Marks.Add(string.Format("image{0}", index), Convert.ToDouble(stationInfo.STAT_LG), Convert.ToDouble(stationInfo.STAT_LA), image,SuperMap.IS.WebControls.Utility.CustomMarkAlignStyle.CenterMiddle);
                   
                }
                else
                {
                    count++;
                }
                //if (index != 0)
                //{
                //    MapControl1.CustomLayer.Lines.Add("line" + index.ToString(), new MapCoord[] { new MapCoord(x, y), new MapCoord(Convert.ToDouble(stationInfo.STAT_LG), Convert.ToDouble(stationInfo.STAT_LA)) }, "0,0001", "Red");
                //}
                //x = Convert.ToDouble(stationInfo.STAT_LG);
                //y = Convert.ToDouble(stationInfo.STAT_LA);
            }
            if (count > 0)
                ShowDialog("有" + count.ToString () +"个台站超出范围!");
           // MapControl1.Update();
            GetCoord(tzList);
        }
        catch (Exception e)
        {
            ShowDialog("台站信息有错误,请验证台站信息!");
        }
       
    }
    /// <summary>
    /// 确定台站是否要继续画
    /// </summary>
    /// <param name="tzList"></param>
    /// <returns></returns>
    private bool IsDrawTZ(ArrayList tzList)
    {
        
        bool isDraw =true ;
        int total=100;
        try
        {
            total = Convert.ToInt16(ConfigurationManager.AppSettings["DrawTZMaxCount"]);
        }
        catch { }
        if (tzList.Count > total)
        {
            StringBuilder js = new StringBuilder();
            js.AppendFormat("< script> function draw(){ var ok=confirm('选择的台站已经超过{0},如果您确定要定位,可能需要的时间很长,确定要定位?'); if(ok!='0') {document.getElementById ('TZCount').value=true;} else  {document.getElementById ('TZCount').value=false;}</script> draw();",total);
            this.Page.RegisterClientScriptBlock("draw", js.ToString());
            isDraw = Convert.ToBoolean(TZCount.Value);

        }
        return isDraw;
        
    }
    /// <summary>
    /// 根据台站集合得到包含所有台站的最小矩形
    /// </summary>
    /// <param name="tzList"></param>
    /// <returns></returns>
    private void GetCoord(ArrayList tzList)
    {
        if (tzList == null || tzList.Count == 0)
            return;
        double minX = 0, minY = 0, maxX = 0, maxY = 0;
        double space = 0.01;
        int index = 0;
        foreach (object item in tzList)
        {
            tranStationInfo stationInfo = (tranStationInfo)item;
            if (index++ == 0)
            {
                minX = Convert.ToDouble(stationInfo.STAT_LG);
                minY = Convert.ToDouble(stationInfo.STAT_LA);
                maxX = Convert.ToDouble(stationInfo.STAT_LG);
                maxY = Convert.ToDouble(stationInfo.STAT_LA);
            }
            else
            {
                minX = Math.Min(minX, Convert.ToDouble(stationInfo.STAT_LG));
                minY = Math.Min(minY,Convert.ToDouble(stationInfo.STAT_LA));
                maxX =Math.Max(maxX, Convert.ToDouble(stationInfo.STAT_LG));
                maxY =Math.Max(maxY, Convert.ToDouble(stationInfo.STAT_LA));
            }
        }
        if (tzList.Count > 1)
        {
            this.MapCurRect = new MapRect(minX - space, minY - space, maxX + space, maxY + space);
            MapControl1.ViewByBounds(this.MapCurRect);
            //MapControl1.Update(); 
        }
        else
        {
            MapControl1.CenterPoint = new MapCoord(minX, minY);
            this.CurMapScale = 0.00002;
            
        }
      //  MapControl1.Update();
    }
   
    private void ShowDialog(string text)
    {
        StringBuilder js = new StringBuilder();
        js.AppendFormat("<script>msg='{0}';</script>", text);
     //   this.Page.RegisterClientScriptBlock("mesure", js.ToString ());
        Response.Write(js);

    }
    private bool ChcekTZPosition(ArrayList tzList)
    {
        foreach(object item in  tzList)
        {
            tranStationInfo stationInfo = (tranStationInfo)item;
            if (stationInfo.STAT_LG == "" || stationInfo.STAT_LA == "" || Convert.ToDouble(stationInfo.STAT_LG) < 75 || Convert.ToDouble(stationInfo.STAT_LG) > 160 || Convert.ToDouble(stationInfo.STAT_LA) < 10 || Convert.ToDouble(stationInfo.STAT_LA) > 60)
            {
                ShowDialog("地理坐标不合理,坐标超出范围或空!");
                return false;
            }
        }
        return true;
    }
    #endregion 
   
 
    #region 地图操作事件
   
    protected void MapControl1_AreaMeasured(object sender, SuperMap.IS.WebControls.EventArguments.MeasuredEventArgs e)
    {

        ShowDialog(string.Format("测量面积:{0}平方千米", Math.Round( e.Area/1000000,2)));
      //  InitMap2();
    }
    protected void MapControl1_DistanceMeasured(object sender, SuperMap.IS.WebControls.EventArguments.MeasuredEventArgs e)
    {
       // ShowAlertDialog("distance", string.Format("测量长度:{0}米", e.Distance));
        ShowDialog(string.Format("测量长度:{0}千米",Math.Round( e.Distance/1000,2)));
      //  InitMap2();
    }
    protected void MapControl1_QueryCompleted(object sender, SuperMap.IS.WebControls.EventArguments.QueryCompletedEventArgs e)
    {
    }
    protected void MapControl1_Querying(object sender, SuperMap.IS.WebControls.EventArguments.QueryingEventArgs e)
    {
        e.Params.Highlight.HighlightQueryArea = true;
        e.Params.Highlight.QueryAreaStyle = new SuperMap.IS.Utility.Style();
        e.Params.Highlight.QueryAreaStyle.PenColor = Convertor.SystemColorToIntegerColor(Color.Blue);
        e.Params.Highlight.QueryAreaStyle.BrushColor = Convertor.SystemColorToIntegerColor(Color.Blue);
        e.Params.Highlight.QueryAreaStyle.BrushBackTransparent = true;
        e.Params.Highlight.QueryAreaStyle.BrushStyle = 2;
        e.Params.Layers = new QueryLayer[0];
        e.Params.IsAllLayer = false;
        // e.ClientActionArgs.ActionParams.
        ClearMap();
        if (e.ClientActionArgs.MapCoords.Length >= 2)
        {
            this.QueryMapType = MapControl1.Action.Name;
            this.MapQueryMapCoords = e.ClientActionArgs.MapCoords;
        }
        if (MapControl1.Action.Name == "CIRCLEQUERY")
        {
           
            if (e.ClientActionArgs.MapCoords.Length < 1)
                return;
            string type = selectType.Value;
            ArrayList tzList = this.getMapCoorsRange.GetStatInfoByXYByType(e.ClientActionArgs.MapCoords[0].X, e.ClientActionArgs.MapCoords[0].Y, e.ClientActionArgs.MapCoords[1].X, e.ClientActionArgs.MapCoords[1].Y,selectType.Value);

             TZResult = this.getMapCoorsRange.objDs;
            DataBinderTZ();
            if (tzList == null || tzList.Count == 0)
            {
                ShowDialog("没有满足条件的数据!");
                return;
            }
            InsertTZIntoMap(tzList);
        }
        else
        {
            if (e.ClientActionArgs.MapCoords == null || e.ClientActionArgs.MapCoords.Length < 2)
                return;
            string type = selectType.Value;
           
            MapControl1.CustomLayer.Visible = true;
            QueryTZ(e.ClientActionArgs.MapCoords[0].X, e.ClientActionArgs.MapCoords[0].Y, e.ClientActionArgs.MapCoords[1].X, e.ClientActionArgs.MapCoords[1].Y);
          
        }
       //  e.Cancel = true;

    }


    /// <summary>
    /// 根据界面上选择区域进行选择台站信息
    /// </summary>
    /// <param name="leftX"></param>
    /// <param name="leftY"></param>
    /// <param name="rightX"></param>
    /// <param name="rightY"></param>
    private void QueryTZ(double leftX, double leftY, double rightX, double rightY)
    {
        ArrayList tzList = this.getMapCoorsRange.getStationCoorsListByType(Convert.ToString(Math.Min(leftX, rightX)), Convert.ToString(Math.Min(leftY, rightY)), Convert.ToString(Math.Max(leftX, rightX)), Convert.ToString(Math.Max(leftY, rightY)),selectType.Value);
        TZResult = this.getMapCoorsRange.objDs;
        DataBinderTZ();
        if (tzList.Count == 0)
        {
            this.ShowDialog("没有匹配的结果!");
        }
        else
        {
            InsertTZIntoMap(tzList);
        }
    }
    private double GetDistance(double x1, double y1, double x2, double y2)
    {

        return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    }
    protected void MapControl1_PreRender(object sender, EventArgs e)
    {
        if (Request["width"] != null && Request["height"] != null)
        {
            ResetMapControlSize(Convert.ToInt16(Request["width"]), Convert.ToInt16(Request["height"]));

        }
        if (CurMapScale != 0.0)
        {
            
            MapControl1.ViewScale = CurMapScale;
            MapControl1.Update();
            CurMapScale = 0.0;
            labelScale.Text = Math.Round(1 / MapControl1.ViewScale, 1).ToString();
           // MapCurRect = MapControl1.ViewBounds;
        }
        if (!IsPostBack)
        {
            //MapControlWidth = 1208 - 80;
            //MapControlHeight = height - 305;

            //this.MapControl1.Width = 1200;
            //this.MapControl1.Height = 500;
            MapControlCallBack();
            //this.MapControl1.ViewEntire();
            //this.MapControl1.Update();
        }
        //if(!IsPostBack)
        //    InitLayerConfig(); 
     
        //System.Text.StringBuilder sb = new System.Text.StringBuilder();
        //sb.Append("<script language=javascript>");
        //sb.Append("var mapLeft = " + this.MapControl1.ViewBounds.LeftBottom.X + ";");
        //sb.Append("var mapRight = " + this.MapControl1.ViewBounds.RightTop.X + ";");
        //sb.Append("var mapTop = " + this.MapControl1.ViewBounds.RightTop.Y + ";");
        //sb.Append("var mapBottom = " + this.MapControl1.ViewBounds.LeftBottom.Y + ";");
        //sb.Append("var mapWidth = " + this.MapControl1.Width.Value + ";");
        //sb.Append("var mapHeight = " + this.MapControl1.Height.Value + ";");
        //sb.Append("var borderWidth = " + this.MapControl1.BorderWidth.Value + ";");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -