/// <summary> /// 添加分析经过点。 /// Add points along the path /// </summary> public void AddPoint(Point2D mapPoint) { try { // 在跟踪图层上添加点 // Add points on the tracking layer m_Points.Add(mapPoint); GeoPoint geoPoint = new GeoPoint(mapPoint); m_style.LineColor = Color.Green; m_style.MarkerSize = new Size2D(8, 8); geoPoint.Style = m_style; m_trackingLayer.Add(geoPoint, "Point"); // 在跟踪图层上添加文本对象 // Add text objects on the tracking layer TextPart part = new TextPart(); part.X = geoPoint.X; part.Y = geoPoint.Y; part.Text = m_flag.ToString(); m_flag++; GeoText geoText = new GeoText(part); m_trackingLayer.Add(geoText, "Point"); m_mapControl.Map.RefreshTrackingLayer(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void toolStripButton1_Click(object sender, EventArgs e) { GeoText text = new GeoText(); // 设置文本子对象的属性 TextPart textPart = new TextPart(); textPart.AnchorPoint = new Point2D(250, 500); textPart.Rotation = 30; textPart.Text = "城市地籍图"; textPart.X = 250; textPart.Y = 500; textPart.Offset(10.0, 20.0); // 设置文本风格 TextStyle textStyle = new TextStyle(); textStyle.Shadow = true; textStyle.Alignment = TextAlignment.TopCenter; textStyle.FontName = "宋体"; textStyle.FontHeight = 10.0; textStyle.FontWidth = 10.0; textStyle.Weight = 500; textStyle.BackColor = System.Drawing.Color.White; textStyle.ForeColor = System.Drawing.Color.Black; Geometry geometry = new GeoText(textPart, textStyle); LayoutElements elements = mapLayoutControl1.MapLayout.Elements; elements.AddNew(geometry); }
private void AddPointToDatasets(Point3D Point3D, int ModelIndex, string strID, string strNOID) { CreateDatasets(); try { Datasource datasource = m_workspace.Datasources[0]; DatasetVector pointDataset = datasource.Datasets[UserHelper.sDeviceName[ModelIndex]] as DatasetVector; if (pointDataset != null) { GeoPoint geoPoint = new GeoPoint(Point3D.X, Point3D.Y); Recordset recordset = pointDataset.GetRecordset(false, CursorType.Dynamic); recordset.MoveLast(); recordset.AddNew(geoPoint); recordset.SetFieldValue(m_filedName, strID); recordset.Update(); recordset.Close(); recordset.Dispose(); } m_MapControl.Map.Refresh(); DatasetVector textDataset = datasource.Datasets[UserHelper.sTextName] as DatasetVector; if (textDataset != null) { Recordset textRecordset = textDataset.GetRecordset(false, CursorType.Dynamic); TextPart part = new TextPart(); part.Text = strNOID; Point2D point2D = new Point2D(Point3D.X, Point3D.Y); part.AnchorPoint = point2D; GeoText geoText = new GeoText(part); geoText.TextStyle.ForeColor = Color.Green; geoText.TextStyle.FontHeight = 8; textRecordset.MoveLast(); textRecordset.AddNew(geoText); textRecordset.Update(); textRecordset.Close(); textRecordset.Dispose(); } m_MapControl.Map.Refresh(); } catch (Exception e) { MessageBox.Show(e.Message); } }
public TextGisLayer(Game game, int capacity, GlobeCamera camera) : base(game) { GlobeCamera = camera; TextSpriteLayer = new SpriteLayer(Game.RenderSystem, 2048); GeoTextArray = new GeoText[capacity]; LinesCountToDraw = capacity; Font = Game.Content.Load<DiscTexture>("conchars"); //spriteFont = Game.Content.Load<SpriteFont>(@"Fonts\textFont"); MinZoom = 6380; MaxZoom = 6500; Scale = 1.0f; MaxScale = 1.5f; }
/// <summary> /// 添加配送目的地。 /// Add it to the destination /// </summary> public void AddTarget(Point2D mapPoint) { try { // 在跟踪图层上添加点 // Add points on the tracking layer m_targets.Add(mapPoint); GeoPoint geoPoint = new GeoPoint(mapPoint); GeoStyle style = new GeoStyle(); style.LineColor = Color.FromArgb(252, 144, 0); style.MarkerSize = new Size2D(6, 6); geoPoint.Style = style; m_trackingLayer.Add(geoPoint, "Target"); // 在跟踪图层上添加文本对象 // Add text objects on the tracking layer TextPart part = new TextPart(); part.X = geoPoint.X; part.Y = geoPoint.Y; if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { part.Text = "Destination" + m_targetCount.ToString(); } else { part.Text = "目的地" + m_targetCount.ToString(); } m_targetCount++; GeoText text = new GeoText(part); TextStyle textStyle = new TextStyle(); textStyle.FontName = "微软雅黑"; textStyle.FontHeight = 4; textStyle.ForeColor = Color.Black; textStyle.Bold = true; text.TextStyle = textStyle; m_trackingLayer.Add(text, "text"); m_mapControl.Map.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 添加配送中心点。 /// Add it to the center /// </summary> public void AddCenter(Point2D mapPoint) { try { m_centers.Add(mapPoint); GeoPoint geoPoint = new GeoPoint(mapPoint); GeoStyle style = new GeoStyle(); style.LineColor = Color.Green; style.MarkerSize = new Size2D(6, 6); geoPoint.Style = style; m_trackingLayer.Add(geoPoint, "center"); TextPart part = new TextPart(); part.X = geoPoint.X; part.Y = geoPoint.Y; if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { part.Text = "Center" + m_centerCount.ToString(); } else { part.Text = "中心点" + m_centerCount.ToString(); } m_centerCount++; GeoText text = new GeoText(part); TextStyle textStyle = new TextStyle(); textStyle.FontName = "微软雅黑"; textStyle.FontHeight = 4; textStyle.ForeColor = Color.Black; textStyle.Bold = true; text.TextStyle = textStyle; m_trackingLayer.Add(text, "text"); m_mapControl.Map.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> //跟踪层绘制事件,用于添加文本对象---绘制完几何对象后,判断 是否要继续绘制文本 或者 绘制沿线文本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_mapControl_Tracked(Object sender, TrackedEventArgs e) { try { //绘制文本 if (mMapControl.Action.Equals(SuperMap.UI.Action.CreateText)) //若 地图操作状态为添加注记 { GeoText geoText = e.Geometry as GeoText; //获取刚刚绘制完成的几何图形 转为 GeoText文本类 geoText.TextStyle.ForeColor = Color.Green; //设置文本风格--前景色 geoText.TextStyle.FontHeight = 32; //文本字体的高度为32 if (mTextLayer.IsEditable) //若 文本类图层 可编辑 { String text = Microsoft.VisualBasic.Interaction.InputBox("请输入文本", "绘制文本", "", mMapControl.Size.Width / 2 - 150, mMapControl.Size.Height / 2); // public static string InputBox(string Prompt, string Title = "", string DefaultResponse = "", int XPos = -1, int YPos = -1); geoText[0].Text = text;//文本内容赋值 } } //绘制沿线文本 if (mMapControl.Action == SuperMap.UI.Action.CreateAlongLineText) //若 地图操作状态为添加沿线标注 { GeoCompound geoCompound = e.Geometry as GeoCompound; //转为 复合几何对象类 if (mTextLayer.IsEditable) //若 文本类图层 可编辑 { String text = Microsoft.VisualBasic.Interaction.InputBox("请输入沿线文本", "绘制沿线文本", "", mMapControl.Size.Width / 2 - 150, mMapControl.Size.Height / 2); GeoText geoText = geoCompound[0] as GeoText; geoText.TextStyle.ForeColor = Color.Green; geoText.TextStyle.FontHeight = 32; geoText[0].Text = text; } } mMapControl.Map.Refresh();//重新绘制当前地图 } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
private void RenderGrid() { floatPanelVis.ClearDrawObjects(); for (int y = 0; y < numRows; y++) { for (int x = 0; x < numCols; x++) { if (enabled[y, x]) { floatPanelVis.AddDrawObject(grid[y, x]); } } } GeoText timestamp = new GeoText(Color.White, new Point(50, 50), System.Diagnostics.Stopwatch.GetTimestamp().ToString(), floatPanelVis.CurrentImageToScreenTransform); floatPanelVis.AddDrawObject(timestamp); Thread.Sleep(10); floatPanelVis.Invalidate(); }
private void 添加标题ToolStripMenuItem_Click(object sender, EventArgs e) { gk066 addTitle = new gk066(); addTitle.StartPosition = FormStartPosition.CenterScreen; //窗体居中 addTitle.ShowDialog(); #region 添加标文本题 //标题添加 TextStyle textStyle = new TextStyle(); textStyle.Alignment = TextAlignment.TopCenter; textStyle.BackColor = Color.FromArgb(65, 65, 65); textStyle.ForeColor = Color.FromArgb(174, 241, 176); textStyle.BackOpaque = false; textStyle.Bold = true; textStyle.FontName = "楷体"; textStyle.FontHeight = addTitle.FontHeight; textStyle.FontWidth = addTitle.FontWidth; textStyle.IsSizeFixed = false; textStyle.Italic = true; textStyle.Outline = true; textStyle.Weight = 500; //添加文本 TextPart textPart = new TextPart(addTitle.title, new Point2D(850, 2150), 0); geoText = new GeoText(textPart, textStyle); //先删除后添加实现刷新效果 if (ElementsId != -1) { ElementsIdS[0] = ElementsId; mapLayoutControl1.MapLayout.Elements.Delete(ElementsIdS); } //添加地图 mapLayoutControl1.MapLayout.Elements.AddNew(geoText); //取得id 下次设定时删除用 ElementsId = mapLayoutControl1.MapLayout.Elements.GetID(); mapLayoutControl1.MapLayout.Elements.Refresh(); #endregion #region 设定图层颜色 与显示比例尺 geoMapUse = mapLayoutControl1.MapLayout.Elements.GetGeometry() as GeoMap; Map map = new Map(); map.Workspace = workspace1; map.FromXML(workspace1.Maps.GetMapXML(geoMapUse.MapName)); LayerSettingVector setting = map.Layers[0].AdditionalSetting as LayerSettingVector; setting.Style.FillForeColor = addTitle.selectColor; map.Layers[0].AdditionalSetting = setting; workspace1.Maps.SetMapXML(geoMapUse.MapName, map.ToXML()); workspace1.Save(); geoMapUse = new GeoMap(); geoMapUse.MapName = "temp"; //设置GeoMap对象的外切矩形 Rectangle2D rect = new Rectangle2D(new Point2D(850, 1300), new Size2D( 1500, 1500)); GeoRectangle geoRect = new GeoRectangle(rect, 0); geoMapUse.Shape = geoRect; //动态设置缩放比例尺 geoMapUse.MapScale = addTitle.scaleNumerator / addTitle.scaleDenominato; mapLayoutControl1.MapLayout.Elements.AddNew(geoMapUse); //记录下mapid ElementsIdMap = mapLayoutControl1.MapLayout.Elements.GetID(); mapLayoutControl1.MapLayout.Elements.Refresh(); #endregion #region 添加地图比例标尺 //添加地图带比例标尺 geoMapScale = new GeoMapScale(ElementsIdMap, new Point2D(1050, 515), 550, 18); geoMapScale.ScaleUnit = Unit.Kilometer; geoMapScale.LeftDivisionCount = 2; geoMapScale.SegmentCount = 2; geoMapScale.ScaleType = GeoMapScaleType.Railway; ////先删除后添加实现刷新效果 if (ElementsIdScale != -1) { ElementsIdScaleArrar[0] = ElementsIdScale; mapLayoutControl1.MapLayout.Elements.Delete(ElementsIdScaleArrar); } //取得id 下次设定时删除用 mapLayoutControl1.MapLayout.Elements.AddNew(geoMapScale); ElementsIdScale = mapLayoutControl1.MapLayout.Elements.GetID(); mapLayoutControl1.MapLayout.Elements.Refresh(); #endregion addTitle.Close(); }
/// <summary> /// 在地图上显示换乘的图形导引,在DataGridView中显示详细信息 /// Display the graphical guide on the map. And display the details on DataGridView /// </summary> public void ShowReslut() { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { m_dataGridView.Columns[1].HeaderText = "Guilde"; m_dataGridView.Columns[2].HeaderText = "Distance"; m_dataGridView.Columns[3].HeaderText = "Cost"; } else { m_dataGridView.Columns[1].HeaderText = "导引"; m_dataGridView.Columns[2].HeaderText = "距离"; m_dataGridView.Columns[3].HeaderText = "费用"; } // 删除跟踪图层上除起始、终止站点及其名称外的几何对象 // Delete objects on the tracking layer except the start and end stop for (Int32 i = m_trackingLayer.Count - 1; i >= 0; i--) { String tag = m_trackingLayer.GetTag(i); if (tag != "StartStop" && tag != "EndStop" && tag != "StartStopName" && tag != "EndStopName") { m_trackingLayer.Remove(i); } } m_mapControl.Map.RefreshTrackingLayer(); TransferSolution solution = null; if (m_comboGuide.SelectedIndex == -1) { solution = m_solutions[0]; } else { solution = m_solutions[m_comboGuide.SelectedIndex]; } // 提取换乘方案中的第一条换乘路线,即每段乘车段集合中的第一段乘车路线的组合对应的完整路线 // Extract the first transfer path TransferLine[] linesOnOne = new TransferLine[solution.TransferTime + 1]; for (int j = 0; j < solution.TransferTime + 1; j++) { linesOnOne[j] = solution[j][0]; } // 获取换乘导引 // gat the transfer guide TransferGuide transferGuide = m_transferAnalyst.GetDetailInfo(m_startStopID, m_endStopID, linesOnOne); // 从换乘导引中提取详细的导引信息 // Extract the details from transfer guide if (transferGuide != null) { for (Int32 i = 0; i < transferGuide.Count; i++) { TransferGuideItem item = transferGuide[i]; // 获取换乘导引子项的路径对象 // Get the path objects of the guide items GeoLine path = item.Route; GeoStyle style = new GeoStyle(); if (item.IsWalking) { style.LineColor = Color.FromArgb(255, 87, 87); style.LineWidth = 0.6; style.LineSymbolID = 12; } else { style.LineColor = Color.Blue; style.LineWidth = 1.0; } path.Style = style; // 在跟踪层上绘制每个换乘导引子项的路径对象 // Draw the path object of transfer guide item on the tracking layer m_trackingLayer.Add(path, "Path"); // 绘制中间站点 // Draw mid-stops GeoPoint transferStop = new GeoPoint(item.StartPosition.X, item.StartPosition.Y); transferStop.Style = GetStopStyle(new Size2D(5, 5), Color.FromArgb(87, 255, 255)); GeoText transferStopName = new GeoText(); TextPart part = new TextPart(item.StartName, new Point2D(transferStop.X, transferStop.Y)); transferStopName.AddPart(part); transferStopName.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(89, 89, 89)); if (i != 0) { m_trackingLayer.Add(transferStop, "transferStop"); } m_trackingLayer.Add(transferStopName, "transferStopName"); transferStop = new GeoPoint(item.EndPosition.X, item.EndPosition.Y); transferStop.Style = GetStopStyle(new Size2D(5, 5), Color.FromArgb(87, 255, 255)); transferStopName = new GeoText(); part = new TextPart(item.EndName, new Point2D(transferStop.X, transferStop.Y)); transferStopName.AddPart(part); transferStopName.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(89, 89, 89)); if (i != transferGuide.Count - 1) { m_trackingLayer.Add(transferStop, "transferStop"); } m_trackingLayer.Add(transferStopName, "transferStopName"); m_mapControl.Map.RefreshTrackingLayer(); } m_mapControl.Map.RefreshTrackingLayer(); // 添加信息到DataGridView // Add information to DataGridView FillGuidesInfo(transferGuide); } else { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { MessageBox.Show("Sorry! There is no proper transfer line!"); } else { MessageBox.Show("抱歉!公交方案详细信息提取出错!"); } } }
/// <summary> /// 捕捉公交站点 /// Snap the bus stops /// </summary> public void SnapPoint() { try { if (m_selection != null) { // 获取被选中的站点对象 // Get the selected stop object Recordset recordset = m_selection.ToRecordset(); GeoPoint snapPoint = recordset.GetGeometry() as GeoPoint; // 构造文本对象,用于在跟踪层上显示站点的名称 // Construct the text object, which is used to display the stop name on the tracking name GeoText stopText = new GeoText(); // 站点名称 // Stop name String stopName = ""; if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { stopName = recordset.GetFieldValue("Name_en").ToString(); } else { stopName = recordset.GetFieldValue("Name").ToString(); } TextPart textPart = new TextPart(stopName, new Point2D(snapPoint.X, snapPoint.Y)); stopText.AddPart(textPart); if (m_isStartPoint) { // 绘制之前先清空跟踪层上的点和文字 // Clear all points and words on the tracking layer before drawing Int32 indexStartStop = m_trackingLayer.IndexOf("StartStop"); if (indexStartStop != -1) { m_trackingLayer.Remove(indexStartStop); } Int32 indexStartText = m_trackingLayer.IndexOf("StartStopName"); if (indexStartText != -1) { m_trackingLayer.Remove(indexStartText); } // 分别设置站点及其名称文本的风格,并添加到跟踪层上 // Set the stop and name style and add them to the tracking layer snapPoint.Style = GetStopStyle(new Size2D(8, 8), Color.FromArgb(236, 118, 0)); m_trackingLayer.Add(snapPoint, "StartStop"); stopText.TextStyle = GetStopTextStyle(6.0, Color.FromArgb(0, 0, 0)); m_trackingLayer.Add(stopText, "StartStopName"); // 设置为起始站点ID // Set the strat stop ID m_startStopID = recordset.GetInt64("STOPID"); } else { // 绘制之前先清空跟踪层上的点和文字 // Clear all points and words on the tracking layer before drawing Int32 indexEndStop = m_trackingLayer.IndexOf("EndStop"); if (indexEndStop != -1) { m_trackingLayer.Remove(indexEndStop); } Int32 indexEndText = m_trackingLayer.IndexOf("EndStopName"); if (indexEndText != -1) { m_trackingLayer.Remove(indexEndText); } // 分别设置站点及其名称文本的风格,并添加到跟踪层上 // Set the stop and name style and add them to the tracking layer snapPoint.Style = GetStopStyle(new Size2D(8, 8), Color.FromArgb(22, 255, 0)); m_trackingLayer.Add(snapPoint, "EndStop"); stopText.TextStyle = GetStopTextStyle(6.0, Color.FromArgb(0, 0, 0)); m_trackingLayer.Add(stopText, "EndStopName"); // 设置为起始站点ID // Set the strat stop ID m_endStopID = recordset.GetInt64("STOPID"); } recordset.Dispose(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 根据线路查询站点 /// Query stop by the path /// </summary> /// <param name="lineID"></param> public void FindStopsByLine(Int64 lineID) { try { if (m_isLoad) { m_comboGuide.Items.Clear(); m_dataGridView.Rows.Clear(); if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { m_dataGridView.Columns[1].HeaderText = "Stop ID"; m_dataGridView.Columns[2].HeaderText = "Name"; } else { m_dataGridView.Columns[1].HeaderText = "站点ID"; m_dataGridView.Columns[2].HeaderText = "名称"; } m_dataGridView.Columns[3].HeaderText = "----"; // 清除跟踪层上的对象 // Clear object on the tracking layer m_trackingLayer.Clear(); m_mapControl.Map.RefreshTrackingLayer(); // 查询经过指定站点的线路 // Query the path by stops StopInfo[] stopInfos = m_transferAnalyst.FindStopsByLine(lineID); if (stopInfos.Length > 0) { // 将该线路添加到跟踪层上显示 // Add the path to the tracking layer LineInfo[] lineInfos = m_transferAnalyst.FindLinesByStop(stopInfos[0].StopID); for (Int32 i = 0; i < lineInfos.Length; i++) { if (lineInfos[i].LineID == lineID) { GeoLine line = lineInfos[i].TotalLine; m_mapControl.Map.CustomBounds = line.Bounds; m_mapControl.Map.IsCustomBoundsEnabled = true; m_mapControl.Map.ViewEntire(); GeoStyle style = new GeoStyle(); style.LineColor = Color.DeepSkyBlue; style.LineWidth = 1.0; line.Style = style; m_trackingLayer.Add(line, "Line"); break; } } // 添加站点信息 // Add the stops for (Int32 j = 0; j < stopInfos.Length; j++) { // 将线路信息添加到DataGridView中 // Add the line information to DataGridView Object[] values = new Object[4]; values[0] = j + 1; values[1] = stopInfos[j].StopID; values[2] = stopInfos[j].Name; values[3] = "----"; m_dataGridView.Rows.Add(values); // 在跟踪图层中绘制查询出的站点及其名称 // Draw stops and names on the tracking layer Point2D point2D = stopInfos[j].Position; GeoPoint point = new GeoPoint(point2D); point.Style = GetStopStyle(new Size2D(5, 5), Color.Orange); m_trackingLayer.Add(point, "Stops"); GeoText geoText = new GeoText(); TextPart part = new TextPart(stopInfos[j].Name, point2D); geoText.AddPart(part); geoText.TextStyle = GetStopTextStyle(5.0, Color.FromArgb(153, 0, 255)); m_trackingLayer.Add(geoText, "StopNames"); } m_mapControl.Map.RefreshTrackingLayer(); } } else { if (SuperMap.Data.Environment.CurrentCulture != "zh-CN") { MessageBox.Show("Sorry! There is no stop on this path!"); } else { MessageBox.Show("抱歉!没有查找到该线路上的站点!"); } } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }