📄 mainwebform.aspx.cs
字号:
{
// Response.Write(Request["Guids"].ToString());
if (!Request.Params["Guids"].Contains(str))
{
ClearMap();
QueryGuids(Request.Params["Guids"]);
}
// Request.Params["Guids"] = null;
this.Page.RegisterHiddenField("Guids", str);
}
}
/// <summary>
/// 传入的netGuid和要查询的类型,画链路
/// </summary>
/// <param name="strGuid"></param>
/// <param name="strGuidType"></param>
private void addStatLink(string strGuid, string strGuidType)
{
ArrayList llTZlist = this.CurLLMapCoordList;
ArrayList statList = new ArrayList();//查询到的台站列表
ArrayList centerPointList = new ArrayList();//保存计算中心点结果集
double douLg = 0.0, douLa = 0.0;//临时保存经纬度坐标
int index = 0;//记录链路名称序号
string strTemp = "";
strTemp = strGuidType;
string strNetGuid = "";
string sql="";
string strNetLinkSql="";
if (strGuidType == "net")
{
sql = "select station.station_guid guid,station.stat_name stat_name,station.stat_lg stat_lg,station.stat_la stat_la,station.stat_app_type stat_app_type,station.stat_tdi stat_tdi,station.app_code app_code,station.app_org_name app_org_name,station.apply_guid apply_guid,station.stat_app_type||','||station.stat_tdi stat_type_tdi,station.net_name net_name from v_rsbt_station_apply_net station where station.net_guid='" + strGuid + "' order by station.app_code,station.stat_tdi asc";
strNetLinkSql = "select station.guid guid ,station.app_code app_code,station.stat_lg stat_lg,station.stat_la stat_la,station.stat_name stat_name,station.stat_app_type stat_app_type,station.stat_tdi stat_tdi,org.org_name org_name from rsbt_station station,rsbt_org org,rsbt_net net where net.guid=station.net_guid and net.org_guid=org.guid and station.net_guid='" + strGuid + "'";
}
else if (strGuidType == "statInfo")
{
strNetGuid = this.getMapCoorsRange.getNetGuidByStatGuid(strGuid);
//sql = "select guid,stat_lg,stat_la,stat_name,stat_app_type,stat_tdi from rsbt_station station where station.net_guid='" + strNetGuid + "'";
sql = "select station.station_guid guid,station.stat_name stat_name,station.stat_lg stat_lg,station.stat_la stat_la,station.stat_app_type stat_app_type,station.stat_tdi stat_tdi,station.app_code app_code,station.app_org_name app_org_name,station.apply_guid apply_guid,station.stat_app_type||','||station.stat_tdi stat_type_tdi,station.net_name net_name from v_rsbt_station_apply_net station where station.net_guid='" + strNetGuid + "' order by station.app_code,station.stat_tdi asc";
strNetLinkSql = "select station.guid guid ,station.app_code app_code,station.stat_lg stat_lg,station.stat_la stat_la,station.stat_name stat_name,station.stat_app_type stat_app_type,station.stat_tdi stat_tdi,org.org_name org_name from rsbt_station station,rsbt_org org,rsbt_net net where net.guid=station.net_guid and net.org_guid=org.guid and station.net_guid='" + strNetGuid + "'";
strGuidType = "net";
}
statList = this.getMapCoorsRange.QueryStationList(sql, strGuidType);
TZResult = this.getMapCoorsRange.objDs;
DataBinderTZ();
centerPointList = statList;
if (statList.Count > 0)
{
InsertTZIntoMap(statList);
if (strGuidType == "net" && strTemp == "")
{
statList = this.getMapCoorsRange.getStatLinkByNetGuid(strGuid, strGuidType);
}
if (strTemp == "statInfo")
{
statList = this.getMapCoorsRange.getStatLinkByNetGuid(strNetGuid, strGuidType);
}
if (statList.Count > 0)
{
centerPointList = this.getMapCoorsRange.getCenterMapCoord(centerPointList);
for (int j = 0; j < statList.Count; j++)
{
sql = "select station.station_guid guid,station.stat_name stat_name,station.stat_lg stat_lg,station.stat_la stat_la,station.stat_app_type stat_app_type,station.stat_tdi stat_tdi,station.app_code app_code,station.app_org_name app_org_name,station.apply_guid apply_guid,station.stat_app_type||','||station.stat_tdi stat_type_tdi,station.net_name net_name from v_rsbt_station_apply_net station where station.station_guid in('" + ((radio_stationLinkObj)statList[j]).LINK_STATION_GUID_A + "','" + ((radio_stationLinkObj)statList[j]).LINK_STATION_GUID_B + "') order by station.app_code,station.stat_tdi asc";
ArrayList tempList = this.getMapCoorsRange.QueryStationList(sql, strGuidType);
if (tempList.Count > 0)
{
MapCoord[] statLinkMapCoord = new MapCoord[2];
for (int k = 0; k < tempList.Count; k++)
{
statLinkMapCoord[k] = new MapCoord(double.Parse(((tranStationInfo)tempList[k]).STAT_LG), double.Parse(((tranStationInfo)tempList[k]).STAT_LA));
}
if (statLinkMapCoord.Length > 0)
{
index = MapControl1.CustomLayer.Lines.Count + 1;
string gName = "testStatLine" + index.ToString();
this.MapControl1.CustomLayer.Lines.Add("line" + index.ToString(), statLinkMapCoord, "0.0001", "Red");
this.MapControl1.CustomLayer.Visible = true;
llTZlist.Add(statLinkMapCoord);
// index++;
}
}
}
this.MapControl1.Update();
this.CurLLMapCoordList = llTZlist;
}
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="tzList"></param>
private void InsertTZIntoMap(ArrayList tzList)
{
try
{
CurTZList = tzList;
int index = 0;
tranStationInfo stationInfo;
double x = 0, y = 0;
foreach (object tz in tzList)
{
if (!ChcekTZPosition(tzList))
return;
stationInfo = (tranStationInfo)tz;
if (stationInfo.STAT_LG == "" || stationInfo.STAT_LA == "")
continue;
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);
MapControl1.CustomLayer.Visible = true;
//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);
}
MapControl1.Update();
GetCoord(tzList);
}
catch (Exception e)
{
ShowDialog("台站信息有错误,请验证台站信息!");
}
}
/// <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.2;
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*2, maxX + space, maxY + space*2);
MapControl1.ViewByBounds(this.MapCurRect);
}
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(!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 + ";");
//sb.Append("var mapScaleReciprocal = " + (int)(1 / this.MapControl1.ViewScale) + ";");
////sb.Append("document.all.MapControl1.onmousemove = \"ShowCursorPos()\";");
//sb.Append("</script>");
//Page.RegisterStartupScript("viriables", sb.ToString());
//放大地图控件
InitLayerConfigAndGridViewLayerByMapCongtrol();
}
protected void MapControl1_MapSwitched(object sender, SuperMap.IS.WebControls.EventArguments.MapSwitchedEventArgs e)
{
// InitMap2();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -