private void AddGPSHistoryDataToOracle(string strDEVICE_BM, int [] IDS) { string strTableName = "T_BUSI_POS_HIST"; try { Point2Ds pt2Ds = GetPoint2DsFromLine(IDS); if (pt2Ds.Count > 0) { string strPoints = JSONHelper.ObjectToJSON(pt2Ds); string strDT_ST = "to_date('2013-09-10','yyyy-mm-dd')"; string strDT_ET = "to_date('2013-10-10','yyyy-mm-dd')"; string strSQL = string.Format("insert into {0}(ID,DEVICE_BM,REC_DATETIME_ST,REC_DATETIME_ET,REC_POS_CONTENT) values(get_guid(),'{1}',{2},{3},empty_blob())", strTableName, strDEVICE_BM, strDT_ST, strDT_ET); string strROWID = DbHelperOra.ExecuteOracleSql(DbHelperOra.connectionString_172, strSQL); string strWhere = string.Format("rowid = '{0}'", strROWID); DbHelperOra.RwiteBlobToTable(DbHelperOra.connectionString_172, strTableName, "REC_POS_CONTENT", strWhere, strPoints); } } catch (SystemException sysEx) { } }
/// <summary> /// 清除分析结果。 /// Clear the analysis result /// </summary> public void Clear() { try { if (m_timer != null) { m_timer.Stop(); } for (int i = m_comboBoxRoutes.Items.Count - 1; i >= 0; i--) { m_comboBoxRoutes.Items.RemoveAt(i); } m_comboBoxRoutes.Text = String.Empty; m_comboBoxRoutes.Refresh(); m_dataGridView.Rows.Clear(); m_centerCount = 1; m_targetCount = 1; m_targets = new Point2Ds(); m_centers = new Point2Ds(); m_barrierNodes = new List <Int32>(); m_barrierEdges = new List <Int32>(); m_layerLine.Selection.Clear(); m_layerPoint.Selection.Clear(); m_mapControl.Map.TrackingLayer.Clear(); m_mapControl.Map.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 初始化控件及数据。 /// Initialize data and control /// </summary> private void Initialize() { try { DatasourceConnectionInfo connectionInfo = new DatasourceConnectionInfo( @"..\..\SampleData\City\Changchun.udb", "findClosestFacility", ""); connectionInfo.EngineType = EngineType.UDB; m_workspace.Datasources.Open(connectionInfo); m_datasetLine = (DatasetVector)m_workspace.Datasources[0] .Datasets[m_datasetName] as DatasetVector; m_datasetPoint = m_datasetLine.ChildDataset; m_selectFacilityNode = true; m_selectBarrier = false; m_selectEventNode = false; m_Points = new Point2Ds(); m_barrierEdges = new List <Int32>(); m_barrierNodes = new List <Int32>(); m_selectMode = SelectMode.SELECTPOINT; m_nodesList = new List <Int32>(); m_trackingLayer = m_mapControl.Map.TrackingLayer; // 加载点数据集及线数据集并设置各自风格 // Add point, line datasets and set their styles m_layerLine = m_mapControl.Map.Layers.Add(m_datasetLine, true); LayerSettingVector lineSetting = (LayerSettingVector)m_layerLine .AdditionalSetting; GeoStyle lineStyle = new GeoStyle(); lineStyle.LineColor = Color.LightGray; lineStyle.LineWidth = 0.1; lineSetting.Style = lineStyle; m_layerPoint = m_mapControl.Map.Layers.Add( m_datasetPoint, true); LayerSettingVector pointSetting = (LayerSettingVector)m_layerPoint .AdditionalSetting; GeoStyle pointStyle = new GeoStyle(); pointStyle.LineColor = Color.DarkGray; pointStyle.MarkerSize = new Size2D(2.5, 2.5); pointSetting.Style = pointStyle; // 调整mapControl的状态 // Adjust the status of mapControl m_mapControl.Action = SuperMap.UI.Action.Select; m_mapControl.IsWaitCursorEnabled = false; m_mapControl.Map.Refresh(); m_mapControl.MouseDown += new MouseEventHandler(m_mapControl_MouseDown); m_mapControl.MouseMove += new MouseEventHandler(m_mapControl_MouseMove); // 加载模型 // Add model Load(); } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
private Point3Ds ConvertPoint2DsToPoint3Ds(Point2Ds point2Ds) { m_point3DsAll.Clear(); for (int i = 0; i < point2Ds.Count; i++) { m_point3DsAll.Add(new Point3D(point2Ds[i].X, point2Ds[i].Y, scontrol.Scene.GetAltitude(point2Ds[i].X, point2Ds[i].Y) + 30)); } return(m_point3DsAll); }
private void 开始模拟ToolStripMenuItem_Click(object sender, EventArgs e) { try { geoStyle_P.MarkerAngle = 14.0; geoStyle_P.MarkerSize = new Size2D(5, 5); geoStyle_P.LineColor = Color.Red; 平抛运动 open = new 平抛运动(); open.ShowDialog(); str = open.name(); ts = open.con(); Map map = mapControl1.Map; bool h = true; Point2D p = map.Center; Point2D pl = map.Center; int m = 0; Xx = ts.Keys.ToList <double>(); Yy = ts.Values.ToList <double>(); Point2Ds point2Ds = new Point2Ds(); for (int i = 0; i < Xx.Count; i++) { Point2D point2D = new Point2D(Xx[i], Yy[i]); point2Ds.Add(point2D); } GeoLine geoLine = new GeoLine(point2Ds); mapControl1.Map.TrackingLayer.Add(geoLine, "线"); mapControl1.Map.Refresh(); foreach (var t in ts) { if (h) { p.X = t.Key; p.Y = t.Value + 10; h = false; } m++; if (m == ts.Count) { pl.X = t.Key; pl.Y = t.Value; } } Rectangle2D rectangle = new Rectangle2D(p, pl); mapControl1.Map.ViewBounds = rectangle; mapControl1.Map.Refresh(); this.timer1.Enabled = true; } catch { MessageBox.Show("模拟失败,请确保参数输入正确"); } }
/// <summary> /// MapControl MouseMove事件。 /// MapControl MouseMove event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void m_mapControl_MouseMove(object sender, MouseEventArgs e) { try { m_mapControl.DoMouseMove(e); if (m_mapControl.Action == SuperMap.UI.Action.Select || m_mapControl.Action == SuperMap.UI.Action.Select2) { // 获取鼠标点对应的地图点 // Get the map point that corresponds to the mouse point m_mousePoint = new Point(e.X, e.Y); Point2D point2D = m_mapControl.Map.PixelToMap(m_mousePoint); // 根据当前比例尺设置捕捉框的大小 // Set the snap box size according to the current scale double scale = (3 * 10E-4) / m_mapControl.Map.Scale; Selection selection = m_layerPoint.HitTest(point2D, 4 / 3 * scale); int index = m_trackingLayer.IndexOf("geoLine"); if (index != -1) { m_trackingLayer.Remove(index); } if (selection != null && selection.Count > 0) { Recordset recordset = selection.ToRecordset(); GeoPoint geoPoint = (GeoPoint)recordset.GetGeometry(); recordset.Dispose(); double pointX = geoPoint.X; double pointY = geoPoint.Y; // 构造捕捉框 // Build snap box Point2Ds point2Ds = new Point2Ds(); point2Ds.Add(new Point2D(pointX - scale, pointY - scale)); point2Ds.Add(new Point2D(pointX + scale, pointY - scale)); point2Ds.Add(new Point2D(pointX + scale, pointY + scale)); point2Ds.Add(new Point2D(pointX - scale, pointY + scale)); point2Ds.Add(new Point2D(pointX - scale, pointY - scale)); GeoLine geoLine = new GeoLine(point2Ds); // 刷新地图 // Refresh the map m_mapControl.SelectionTolerance = 2; m_trackingLayer.Add(geoLine, "geoLine"); m_mapControl.Map.Refresh(); } } } catch (System.Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 打开需要的工作空间文件及地图 /// </summary> private void Initialize() { try { //初始化点线面 m_point = new GeoPoint(25, 25); Point2Ds point2DsLine = new Point2Ds(); point2DsLine.Add(new Point2D(5, 35)); point2DsLine.Add(new Point2D(65, 35)); m_line = new GeoLine(point2DsLine); Point2Ds point2DsRegion = new Point2Ds(); point2DsRegion.Add(new Point2D(5, 5)); point2DsRegion.Add(new Point2D(5, 69)); point2DsRegion.Add(new Point2D(69, 69)); point2DsRegion.Add(new Point2D(69, 5)); m_region = new GeoRegion(point2DsRegion); //初始化点线面符号的风格 m_markerGeoStyle = new GeoStyle(); m_markerGeoStyle.LineColor = Color.Blue; m_markerGeoStyle.MarkerSize = new Size2D(12, 12); m_point.Style = m_markerGeoStyle; m_lineGeoStyle = new GeoStyle(); m_lineGeoStyle.LineColor = Color.Blue; m_lineGeoStyle.LineWidth = 0.5; m_line.Style = m_lineGeoStyle; m_fillGeoStyle = new GeoStyle(); m_fillGeoStyle.FillForeColor = Color.Blue; m_fillGeoStyle.FillBackOpaque = false; m_region.Style = m_fillGeoStyle; // 得到点线面的RootGroup Resources resources = m_workspace.Resources; SymbolLibrary symbolMarkerLibrary = resources.MarkerLibrary; m_symbolMarkerRootGroup = symbolMarkerLibrary.RootGroup; SetTreeGroup(m_symbolMarkerRootGroup); SymbolLibrary symbolLineLibrary = resources.LineLibrary; m_symbolLineRootGroup = symbolLineLibrary.RootGroup; SymbolLibrary symbolFillLibrary = resources.FillLibrary; m_symbolFillRootGroup = symbolFillLibrary.RootGroup; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
void m_sceneControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (m_customButtonEnable && m_point3Ds.Count > 0 && !Double.IsNaN(scontrol.Scene.PixelToGlobe(e.Location).X)) { Point2Ds point2Ds = m_point3Ds.ToPoint2Ds(); Point3D point3D = scontrol.Scene.PixelToGlobe(e.Location); point3D.Z = scontrol.Scene.GetAltitude(point3D.X, point3D.Y); point2Ds.Add(new Point2D(point3D.X, point3D.Y)); SetGeoLine3DToTrackingLayer(point2Ds, 20); } }
/// <summary> /// 鼠标移动时绘制捕捉框 /// Draw the snap box when the mouse moves /// </summary> /// <param name="point"></param> public void SetBound(Point point) { try { // 清除跟踪图层上的捕捉框 // Clear snap box on the tracking layer Int32 indexSnapPane = m_trackingLayer.IndexOf("snapPane"); if (indexSnapPane != -1) { m_trackingLayer.Remove(indexSnapPane); m_mapControl.Map.RefreshTrackingLayer(); } // 将屏幕坐标转换为地图坐标 // Transform the pixel coordinates to the map coordinates Point2D mapPoint = m_mapControl.Map.PixelToMap(point); Double scale = (3 * 10E-4) / m_mapControl.Map.Scale; m_selection = m_layerStop.HitTest(mapPoint, 4 / 3 * scale); if (m_selection != null && m_selection.Count > 0) { Recordset recordset = m_selection.ToRecordset(); GeoPoint stopPoint = recordset.GetGeometry() as GeoPoint; // 构造捕捉框 // Build the snap box Point2Ds points = new Point2Ds(); points.Add(new Point2D(stopPoint.X - scale, stopPoint.Y - scale)); points.Add(new Point2D(stopPoint.X + scale, stopPoint.Y - scale)); points.Add(new Point2D(stopPoint.X + scale, stopPoint.Y + scale)); points.Add(new Point2D(stopPoint.X - scale, stopPoint.Y + scale)); points.Add(new Point2D(stopPoint.X - scale, stopPoint.Y - scale)); GeoLine snapPane = new GeoLine(points); m_mapControl.SelectionTolerance = 2.0; m_trackingLayer.Add(snapPane, "snapPane"); m_mapControl.Map.RefreshTrackingLayer(); recordset.Dispose(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public void InterpolateHeight(Int32 count) { Point2Ds curPoint2Ds = new Point2Ds(); Point2Ds point2Ds = new Point2Ds(); for (int i = 0; i < m_point3Ds.Count; i++) { curPoint2Ds.Add(new Point2D(m_point3Ds[i].X, m_point3Ds[i].Y)); GeoCardinal geoCardinal = new GeoCardinal(curPoint2Ds); GeoLine geoLine = geoCardinal.ConvertToLine(count); double dLength = geoLine.Length; Point2D point2D = new Point2D(dLength, m_point3Ds[i].Z); point2Ds.Add(point2D); } GeoCardinal geoCardinalHeight = new GeoCardinal(point2Ds); GeoLine geoLineHeight = geoCardinalHeight.ConvertToLine(count); for (Int32 i = 0; i < m_point3DsAll.Count; i++) { Point3D point3D = new Point3D(m_point3DsAll[i].X, m_point3DsAll[i].Y, geoLineHeight[0][i].Y); m_point3DsAll[i] = point3D; } Int32 indexLine = scontrol.Scene.TrackingLayer.IndexOf("line"); m_geoLine3D.SetEmpty(); m_geoLine3D.AddPart(m_point3DsAll); if (indexLine > 0) { scontrol.Scene.TrackingLayer.Set(indexLine, m_geoLine3D); } else { scontrol.Scene.TrackingLayer.Add(m_geoLine3D, "line"); } SetPointStyle3D(m_index.ToString(), true); m_flyManager.Routes.Remove(0); m_flyManager.Routes.Add(GetRoute()); }
/// <summary> /// 设置网络分析参数 /// </summary> public void SetParameter() { try { Point2D startPoint = new Point2D(mStartPoint.X, mStartPoint.Y); Point2D endPoint = new Point2D(mEndPoint.X, mEndPoint.Y); Point2Ds points = new Point2Ds(new Point2D[] { startPoint, endPoint }); mAnalystParameter.IsRoutesReturn = true; mAnalystParameter.WeightName = "Smlength"; mAnalystParameter.IsEdgesReturn = true; mAnalystParameter.Points = points; } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
//获取线数据的点集 private Point2Ds GetPoint2DsFromLine(string strFilter) { Point2Ds resPts = null; try { Datasource dtSource = m_Workspace.Datasources[0]; Dataset dtSet = dtSource.Datasets["公路"]; DatasetVector dtVector = dtSet as DatasetVector; Recordset recdst = dtVector.Query(strFilter, CursorType.Static); if (recdst != null && recdst.RecordCount > 0) { Point2Ds pt2Ds = new Point2Ds(); if (recdst.RecordCount > 2) { Random r = new Random(); int iAt = r.Next(0, recdst.RecordCount - 2); recdst.MoveTo(iAt); } while (!recdst.IsEOF) { GeoLine geoLine = recdst.GetGeometry() as GeoLine; if (geoLine != null) { pt2Ds.AddRange(geoLine[0].ToArray()); } recdst.MoveNext(); } if (pt2Ds != null && pt2Ds.Count > 0) { resPts = pt2Ds.Clone(); //对线进行插值平滑处理 int smoothness = 8; resPts = Geometrist.Smooth(pt2Ds, smoothness); } } } catch { } return(resPts); }
private void ImportExeclData(DataTable table) { pts = new Point2Ds(); Point2D pnt = new Point2D(); for (int p = 0; p < table.Rows.Count; p++) { pnt.X = Convert.ToDouble(table.Rows[p][0].ToString()); pnt.Y = Convert.ToDouble(table.Rows[p][1].ToString()); pts.Add(pnt); } trackLine = new GeoLine(); trackLine.AddPart(pts); trackLine.Style = pStyle; //添加轨迹路线 m_MapControl.Map.TrackingLayer.Add(trackLine, "GPSTrack"); m_MapControl.Map.EnsureVisible(trackLine); m_MapControl.Map.Zoom(0.7); m_MapControl.Map.Refresh(); }
private void SetGeoLine3DToTrackingLayer(Point2Ds point2Ds, Int32 count) { Int32 index = scontrol.Scene.TrackingLayer.IndexOf("line"); GeoCardinal geoCardinal = new GeoCardinal(point2Ds); GeoLine geoLine = geoCardinal.ConvertToLine(count); if (m_geoLine3D.Length > 0) { m_geoLine3D.RemovePart(0); } m_geoLine3D.AddPart(ConvertPoint2DsToPoint3Ds(geoLine[0])); if (index > 0) { scontrol.Scene.TrackingLayer.Set(index, m_geoLine3D); } else { scontrol.Scene.TrackingLayer.Add(m_geoLine3D, "line"); } }
/// <summary> /// 地理坐标向投影坐标转换 /// </summary> /// <param name="point3Ds"></param> /// <returns></returns> private Point3Ds coordinateTrans3D(Point3Ds point3Ds) { Point2Ds point2Ds = new Point2Ds(); foreach (Point3D p3d in point3Ds) { Point2D point2D = new Point2D(p3d.X, p3d.Y); point2Ds.Add(point2D); } //Assume Wgs1984WorldMercator as target project coordinate system PrjCoordSys prjTarget = new PrjCoordSys(PrjCoordSysType.Wgs1984Utm50N); bool b = CoordSysTranslator.Forward(point2Ds, prjTarget); Point3Ds result = new Point3Ds(); for (int i = 0; i < point2Ds.Count; i++) { Point3D point3D = new Point3D(point2Ds[i].X, point2Ds[i].Y, point3Ds[i].Z); result.Add(point3D); } return(result); }
private void DisplayRect(Rectangle2D rectangleDisplay) { try { m_engleRectangle = rectangleDisplay; m_mapControlEagleEye.Cursor = Cursors.Cross; Double rectangleWidth = rectangleDisplay.Width; Double rectangleHeight = rectangleDisplay.Height; Double pntLeftTopX = rectangleDisplay.Left; Double pntLeftTopY = rectangleDisplay.Top; Point2Ds points = new Point2Ds(); Point2D pntLeftTop = new Point2D(pntLeftTopX, pntLeftTopY); points.Add(pntLeftTop); Point2D pntLeftBottom = new Point2D(pntLeftTopX, pntLeftTopY - rectangleHeight); points.Add(pntLeftBottom); Point2D pntRightBottom = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY - rectangleHeight); points.Add(pntRightBottom); Point2D pntRightTop = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY); points.Add(pntRightTop); points.Add(pntLeftTop); GeoLine rectangleBoundary = new GeoLine(); rectangleBoundary.AddPart(points); GeoStyle rectangleStyle = new GeoStyle(); rectangleStyle.LineColor = Color.FromArgb(255, 0, 0); rectangleStyle.LineWidth = 0.5; rectangleBoundary.Style = rectangleStyle; m_mapControlEagleEye.Map.TrackingLayer.Clear(); m_mapControlEagleEye.Map.TrackingLayer.Add((Geometry)rectangleBoundary, ""); m_mapControlEagleEye.Map.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 按照指定风格显示矩形框 /// </summary> /// <param name="rectDisplay"></param> private void DisplayRect(Rectangle2D rectangleDisplay) { try { m_engleRectangle = rectangleDisplay; Double rectangleWidth = rectangleDisplay.Width; Double rectangleHeight = rectangleDisplay.Height; Double pntLeftTopX = rectangleDisplay.Left; Double pntLeftTopY = rectangleDisplay.Top; //设置图框四点坐标 Point2Ds points = new Point2Ds(); Point2D pntLeftTop = new Point2D(pntLeftTopX, pntLeftTopY); points.Add(pntLeftTop); Point2D pntLeftBottom = new Point2D(pntLeftTopX, pntLeftTopY - rectangleHeight); points.Add(pntLeftBottom); Point2D pntRightBottom = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY - rectangleHeight); points.Add(pntRightBottom); Point2D pntRightTop = new Point2D(pntLeftTopX + rectangleWidth, pntLeftTopY); points.Add(pntRightTop); points.Add(pntLeftTop); //将点连成线,并设置样式 GeoLine rectangleBoundary = new GeoLine(); rectangleBoundary.AddPart(points); GeoStyle rectangleStyle = new GeoStyle(); rectangleStyle.LineColor = Color.FromArgb(255, 0, 0); rectangleStyle.LineWidth = 0.5; rectangleBoundary.Style = rectangleStyle; } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
/// <summary> /// 清除分析结果。 /// Clear the analysis result /// </summary> public void Clear() { try { if (m_timer != null) { m_timer.Stop(); } m_dataGridView.Rows.Clear(); m_flag = 1; m_Points = new Point2Ds(); m_barrierNodes = new List <Int32>(); m_barrierEdges = new List <Int32>(); m_mapControl.Map.Layers[0].Selection.Clear(); m_mapControl.Map.Layers[1].Selection.Clear(); m_mapControl.Map.TrackingLayer.Clear(); m_mapControl.Map.Refresh(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } }
public void AddModel_Click(Point2Ds Point2Ds, string strID, string strNOID) { Point3D Point3D = new Point3D(Point2Ds[0].X, Point2Ds[0].Y, Point2Ds[1].X); AddModel_Click(Point3D, (int)Point2Ds[1].Y, strID, strNOID); }
private void button2_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "导出txt坐标文件(*.txt)|*.txt"; sfd.FileName = "坐标导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss"); if (sfd.ShowDialog() == DialogResult.OK) { FileStream fs = new FileStream(sfd.FileName, FileMode.Create); StreamWriter sw = new StreamWriter(fs); if (dataGridView1.CurrentRow == null) { return; } DataGridViewRow dgvr = dataGridView1.CurrentRow; string strSmid = dgvr.Cells["地块编号"].Value.ToString();//获取smid值 // 构造一个查询参数对象,查询选中的记录 QueryParameter para = new QueryParameter(); para.AttributeFilter = "SMID =" + strSmid; para.CursorType = CursorType.Dynamic; DatasetVector importResultShp = null; SuperMap.Data.Workspace workspace1; workspace1 = new SuperMap.Data.Workspace(); workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo()); string tableName = gkfqd.Common.DbUse.GetTownCode(comboBox4.Text); importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()]; importResultShp = importDatasource.Datasets[tableName] as DatasetVector; Recordset recordset = null; try { recordset = importResultShp.Query(para); while (!recordset.IsEOF) { Geometry geometry = recordset.GetGeometry(); GeoRegion region = geometry as GeoRegion; for (int i = 0; i < region.PartCount; i++) { Point2Ds point2ds = region[i]; for (int k = 0; k < point2ds.Count; k++) { Point2D point2d = point2ds[k]; sw.WriteLine(point2d.X.ToString() + "," + point2d.Y.ToString()); } } recordset.MoveNext(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } finally { recordset.Dispose(); } //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); MessageBox.Show("坐标导出成功!"); } }
private void button4_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "导出建新地块信息文件(*.xml)|*.xml"; sfd.FileName = "建新地块信息导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss"); if (sfd.ShowDialog() == DialogResult.OK) { FileStream fs = new FileStream(sfd.FileName, FileMode.Create); StreamWriter sw = new StreamWriter(fs); if (dataGridView2.CurrentRow == null) { MessageBox.Show("请点击地块表行头,选择地块信息!"); return; } DataGridViewRow dgvr = dataGridView2.CurrentRow; //取得当前行项目名称值 string strProjectName = dgvr.Cells["项目名称"].Value.ToString(); //取得当前行地块编号该编号为用户输入的 string strDkbh = dgvr.Cells["地块逻辑编号"].Value.ToString(); string tableName = gkfqd.Common.DbUse.GetTownCodeByProjectNameJx(strProjectName); sqlQuery.Clear(); sqlQuery.Append("SELECT DKBH AS 建新地块编号, "); sqlQuery.Append(" DKWZ AS 位置, "); sqlQuery.Append(" DKMC AS 地块名称, "); sqlQuery.Append(" DKMJ AS 地块面积, "); sqlQuery.Append(" ZBX AS 坐标系, "); sqlQuery.Append(" JDFD AS 几度分带, "); sqlQuery.Append(" TYLX AS 投影类型, "); sqlQuery.Append(" JLDW AS 计量单位, "); sqlQuery.Append(" JD AS 精度, "); sqlQuery.Append(" JZDS AS 界址点数, "); sqlQuery.Append(" JLTCSX AS 记录图形属性 "); sqlQuery.Append(" FROM " + tableName); sqlQuery.Append(" WHERE FKXMMC = '" + strProjectName + "'"); sqlQuery.Append(" AND DKBH = '" + strDkbh + "'"); gkfqd.Common.DbUse.GetOleDbconnection().Close(); gkfqd.Common.DbUse.GetOleDbconnection().Open(); dataSetOutPut.Clear(); OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection()); MyAdapter.Fill(dataSetOutPut); gkfqd.Common.DbUse.GetOleDbconnection().Close(); sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\" ?>"); sw.WriteLine("<CL_BUILD_NEW_BLOCK>"); sw.WriteLine(" <BUILDNLANDNO name=\"建新地块编号\">" + dataSetOutPut.Tables[0].Rows[0]["建新地块编号"].ToString() + "</BUILDNLANDNO>"); sw.WriteLine(" <BLOCATION name=\"位置\"> " + dataSetOutPut.Tables[0].Rows[0]["位置"].ToString() + "</BLOCATION>"); sw.WriteLine(" <LANDNAME name=\"地块名称\">" + dataSetOutPut.Tables[0].Rows[0]["地块名称"].ToString() + "</LANDNAME>"); sw.WriteLine(" <LANDAREA name=\"地块面积\">" + dataSetOutPut.Tables[0].Rows[0]["地块面积"].ToString() + "</LANDAREA>"); sw.WriteLine(" <COORSYSTEM name=\"坐标系\">" + dataSetOutPut.Tables[0].Rows[0]["坐标系"].ToString() + "</COORSYSTEM>"); sw.WriteLine(" <CUTNU name=\"几度分带\">" + dataSetOutPut.Tables[0].Rows[0]["几度分带"].ToString() + "</CUTNU>"); sw.WriteLine(" <SHADOWTYPE name=\"投影类型\">" + dataSetOutPut.Tables[0].Rows[0]["投影类型"].ToString() + "</SHADOWTYPE>"); sw.WriteLine(" <MEASUREMENT name=\"计量单位\">" + dataSetOutPut.Tables[0].Rows[0]["计量单位"].ToString() + "</MEASUREMENT>"); sw.WriteLine(" <PRECISION name=\"精度\">" + dataSetOutPut.Tables[0].Rows[0]["精度"].ToString() + "</PRECISION>"); sw.WriteLine(" <DROPNU name=\"界址点数\">" + dataSetOutPut.Tables[0].Rows[0]["界址点数"].ToString() + "</DROPNU>"); sw.WriteLine(" <DRAWINGPROPERTY name=\"记录图形属性\"> " + dataSetOutPut.Tables[0].Rows[0]["记录图形属性"].ToString() + "</DRAWINGPROPERTY>"); sw.Write(" <param ZB=\"@1$"); //"1,3795840.7720,39534660.2200;2,3795836.7200,39534645.9400;3,3795824.1590,39534648.6700;4,3795780.9330,39534495.1600;5,3796003.2890,39534435.7600;6,3796049.6000,39534601.4200;7,3795840.7720,39534660.2200;" />"); DataGridViewRow dgvr1 = dataGridView2.CurrentRow; string strSmid = dgvr1.Cells["地块编号"].Value.ToString(); // 构造一个查询参数对象,查询选中的记录 QueryParameter para = new QueryParameter(); para.AttributeFilter = "SMID =" + strSmid; para.CursorType = CursorType.Dynamic; DatasetVector importResultShp = null; SuperMap.Data.Workspace workspace1; workspace1 = new SuperMap.Data.Workspace(); /*WorkspaceconnectionInfo workspaceconnectionInfo = new WorkspaceconnectionInfo(); * workspaceconnectionInfo.Type = WorkspaceType.Oracle; * workspaceconnectionInfo.Server = "ORCL"; * workspaceconnectionInfo.Database = ""; * workspaceconnectionInfo.Name = "workspace"; * workspaceconnectionInfo.User = "******"; * workspaceconnectionInfo.Password = "******"; * workspace1.Open(workspaceconnectionInfo);*/ workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo()); importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()]; importResultShp = importDatasource.Datasets[tableName] as DatasetVector; Recordset recordset = null; try { recordset = importResultShp.Query(para); while (!recordset.IsEOF) { Geometry geometry = recordset.GetGeometry(); GeoRegion region = geometry as GeoRegion; for (int i = 0; i < region.PartCount; i++) { Point2Ds point2ds = region[i]; for (int k = 0; k < point2ds.Count; k++) { Point2D point2d = point2ds[k]; sw.Write((k + 1).ToString() + "," + point2d.X.ToString() + "," + point2d.Y.ToString() + ";"); } } recordset.MoveNext(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } finally { recordset.Dispose(); } sw.WriteLine(" \" />"); sw.WriteLine("</CL_BUILD_NEW_BLOCK>"); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); MessageBox.Show("建新地块信息导出成功!"); } }
public string TransFile(byte[] fileBt, string fileName, bool ifCreate) { // 0长度文件返回 0 string rst = "0"; if (fileBt.Length == 0) { return(rst); } string filePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["CSVPath"].ToString()); //存储文件路径 //创建系统日期文件夹,避免同一文件夹下文件太多问题,避免同一地图应文档重名 // filePath = filePath + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (!Directory.Exists(filePath)) { // Create the directory it does not exist. Directory.CreateDirectory(filePath); } FileStream fstream; //是否创建新文件 if (ifCreate) { fstream = new FileStream(filePath + fileName, FileMode.Create); } else { fstream = new FileStream(filePath + fileName, FileMode.Append); } try { fstream.Write(fileBt, 0, fileBt.Length); //二进制转换成文件 //上传成功返回 1 fstream.Close(); } catch (Exception ex) { //上传失败返回 1 rst = "error"; } finally { fstream.Close(); } //读取坐标文件转换面积 string imgPath = "d:/zuobiao.txt"; //坐标点导入处理 StreamReader objReader = new StreamReader(imgPath); string sLine = ""; ArrayList LineList = new ArrayList(); while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null && !sLine.Equals("")) { LineList.Add(sLine); } } objReader.Close(); this.fileWorkspace = new SuperMap.Data.Workspace(); try { //打开工作空间及地图文件类型 WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(@"d:\testG.smwu"); fileWorkspace.Open(conInfo); fileDatasource = fileWorkspace.Datasources["test"]; sourceDatasetVector = fileDatasource.Datasets["dataT"] as DatasetVector; //Recordset recordset = new Recordset(); Recordset recordset = (sourceDatasetVector as DatasetVector).GetRecordset(false, CursorType.Dynamic); // 获得记录集对应的批量更新对象 Recordset.BatchEditor editor = recordset.Batch; // 开始批量添加,将 example 数据集每条记录对应的几何对象添加到数据集中 editor.Begin(); //删除所有记录 recordset.DeleteAll(); Point2Ds points = new Point2Ds(); for (int i = 1; i < LineList.Count - 1; i++) { string[] fieldInfoListZ = LineList[i].ToString().Split(','); Point2D point2D = new Point2D(); point2D.X = double.Parse(fieldInfoListZ[0].ToString()); point2D.Y = double.Parse(fieldInfoListZ[1].ToString()); points.Add(point2D); } GeoLine geolineE = new GeoLine(); geolineE.AddPart(points); recordset.AddNew(geolineE); editor.Update(); //调用创建矢量数据集缓冲区方法 //设置缓冲区分析参数 BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter(); bufferAnalystParam.EndType = BufferEndType.Flat; bufferAnalystParam.LeftDistance = 50; bufferAnalystParam.RightDistance = 50; String bufferName = "bufferRegionDt"; bufferName = fileDatasource.Datasets.GetAvailableDatasetName(bufferName); m_bufferDataset = fileDatasource.Datasets.Create(new DatasetVectorInfo(bufferName, DatasetType.Region)); Boolean isTrue = SuperMap.Analyst.SpatialAnalyst.BufferAnalyst.CreateBuffer(recordset, m_bufferDataset, bufferAnalystParam, false, true); Recordset formatRecordset = m_bufferDataset.GetRecordset(false, CursorType.Dynamic); GeoRegion geometrySearch = (GeoRegion)formatRecordset.GetGeometry(); pfm = geometrySearch.Area; mu = pfm * 0.0015; double gongqing = 0.0666667 * mu; // 释放记录集 // recordset.Dispose(); } catch (Exception ex) { Trace.WriteLine(ex.Message); } rst = pfm.ToString(); fileWorkspace.Close(); return(rst); }
/// <summary> /// PictureBox的点击事件,分不同的面板,响应不同 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void pictureBox_Click(Object sender, EventArgs e) { try { PictureBox pictureBox = sender as PictureBox; pictureBox.BorderStyle = BorderStyle.Fixed3D; m_symbol = pictureBox.Tag as Symbol; //不同的面板不同的响应 if (pictureBox.Parent == flowLayoutPanelMarker) { flowLayoutPanelMarker.Select(); panelMarkerSetting.Enabled = true; textBoxMarkerID.Text = m_symbol.ID.ToString(); textBoxMarkerName.Text = m_symbol.Name; //绘制预览符号 GeoPoint point = new GeoPoint(pictureBoxMarker.Size.Width / 2, pictureBoxMarker.Size.Height / 2); point.Style = m_pointStyle; pictureBoxMarker.Tag = point; DrawSymbol(m_symbol, point, pictureBoxMarker.Size.Width, pictureBoxMarker.Size.Height, pictureBoxMarker); comboBoxMarkerAngle.SelectedIndex = Convert.ToInt32(point.Style.MarkerAngle); buttonMarkerColor.BackColor = point.Style.LineColor; comboBoxMarkerSize.SelectedIndex = Convert.ToInt32(((point.Style.MarkerSize.Width * point.Style.MarkerSize.Height) / 10)); if (SymbolMarkerCtrl != null) { sender = m_symbol.ID; SymbolMarkerCtrl(sender, e); } } if (pictureBox.Parent == flowLayoutPanelLine) { flowLayoutPanelLine.Select(); panelLine.Enabled = true; textBoxLineID.Text = m_symbol.ID.ToString(); textBoxLineName.Text = m_symbol.Name; //绘制预览线型 Point2Ds point2Ds = new Point2Ds(); point2Ds.Add(new Point2D(5, pictureBoxLine.Size.Height / 2)); point2Ds.Add(new Point2D(pictureBoxLine.Size.Width - 5, pictureBoxLine.Size.Height / 2)); GeoLine line = new GeoLine(point2Ds); line.Style = m_lineStyle; pictureBoxLine.Tag = line; DrawSymbol(m_symbol, line, pictureBoxLine.Size.Width, pictureBoxLine.Size.Height, pictureBoxLine); buttonLineColor.BackColor = line.Style.LineColor; if (line.Style.LineWidth == 0.5) { comboBoxLineWith.SelectedIndex = 0; } else { comboBoxLineWith.SelectedItem = Convert.ToInt32(line.Style.LineWidth); } } if (pictureBox.Parent == flowLayoutPanelFill) { flowLayoutPanelFill.Select(); panelFill.Enabled = true; textBoxFillID.Text = m_symbol.ID.ToString(); textBoxFillName.Text = m_symbol.Name; //绘制预览填充符号 Point2Ds point2Ds = new Point2Ds(); point2Ds.Add(new Point2D(10, 20)); point2Ds.Add(new Point2D(10, pictureBoxFill.Size.Height - 20)); point2Ds.Add(new Point2D(pictureBoxFill.Size.Width - 10, pictureBoxFill.Size.Height - 20)); point2Ds.Add(new Point2D(pictureBoxFill.Size.Width - 10, 20)); GeoRegion region = new GeoRegion(point2Ds); region.Style = m_fillStyle; pictureBoxFill.Tag = region; DrawSymbol(m_symbol, region, pictureBoxFill.Size.Width - 20, pictureBoxFill.Size.Height - 40, pictureBoxFill); buttonFillForeColor.BackColor = region.Style.FillForeColor; checkBoxFillBackOpaque.Checked = !region.Style.FillBackOpaque; buttonFillBackColor.BackColor = checkBoxFillBackOpaque.Checked ? Color.FromKnownColor(KnownColor.Control) : m_fillStyle.FillBackColor; comboBoxFillGradientMode.SelectedItem = region.Style.FillGradientMode; comboBoxFillGradientAngle.SelectedIndex = Convert.ToInt32(region.Style.FillGradientAngle); comboBoxFillGradientOffsetRatioX.SelectedIndex = region.Style.FillGradientOffsetRatioX; comboBoxFillGradientOffsetRatioY.SelectedIndex = region.Style.FillGradientOffsetRatioY; if (SymbolFillCtrl != null) { sender = m_symbol.ID; SymbolFillCtrl(sender, e); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// 打开网络数据集并初始化相应变量。 /// Open the network dataset and initialize variables /// </summary> private void Initialize() { try { // 打开数据源,得到点线数据集 // Open datasource and get the point , line datasets DatasourceConnectionInfo connectionInfo = new DatasourceConnectionInfo( @"..\..\SampleData\City\Changchun.udb", "FindPath2D", ""); connectionInfo.EngineType = EngineType.UDB; m_workspace.Datasources.Open(connectionInfo); m_datasetLine = (DatasetVector)m_workspace.Datasources[0].Datasets[m_datasetName]; m_datasetPoint = m_datasetLine.ChildDataset; m_trackingLayer = m_mapControl.Map.TrackingLayer; m_trackingLayer.IsAntialias = true; // 初始化各变量 // Initialzie variables m_flag = 1; m_Points = new Point2Ds(); m_style = new GeoStyle(); m_barrierNodes = new List <Int32>(); m_barrierEdges = new List <Int32>(); m_selectMode = SelectMode.SelectPoint; m_timer = new Timer(); m_timer.Interval = 200; m_timer.Enabled = false; // 加载点数据集及线数据集并设置各自风格 // Add point, line datasets and set their styles m_layerLine = m_mapControl.Map.Layers.Add(m_datasetLine, true); m_layerLine.IsSelectable = false; LayerSettingVector lineSetting = (LayerSettingVector)m_layerLine.AdditionalSetting; GeoStyle lineStyle = new GeoStyle(); lineStyle.LineColor = Color.LightGray; lineStyle.LineWidth = 0.1; lineSetting.Style = lineStyle; m_layerPoint = m_mapControl.Map.Layers.Add(m_datasetPoint, true); LayerSettingVector pointSetting = (LayerSettingVector)m_layerPoint.AdditionalSetting; GeoStyle pointStyle = new GeoStyle(); pointStyle.LineColor = Color.DarkGray; pointStyle.MarkerSize = new Size2D(2.5, 2.5); pointSetting.Style = pointStyle; // 调整mapControl的状态 // Adjust the status of mapControl m_mapControl.Action = SuperMap.UI.Action.Select; m_mapControl.Map.IsAntialias = true; m_mapControl.IsWaitCursorEnabled = false; m_mapControl.Map.Refresh(); m_mapControl.MouseDown += new MouseEventHandler(m_mapControl_MouseDown); m_mapControl.GeometrySelected += new GeometrySelectedEventHandler(m_mapControl_GeometrySelected); m_timer.Tick += new EventHandler(m_timer_Tick); Load(); } catch (Exception e) { Trace.WriteLine(e.Message); } }
public csRoadLine() { roadline = new Point2Ds(); }
public string TransFile(byte[] fileBt, double width, string fileName, bool ifCreate) { // 0长度文件返回 0 string rst = "0"; if (fileBt.Length == 0) { return(rst); } string filePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["CSVPath"].ToString()); //存储文件路径 //创建系统日期文件夹,避免同一文件夹下文件太多问题,避免同一地图应文档重名 filePath = filePath + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } FileStream fstream; //是否创建新文件 if (ifCreate) { fstream = new FileStream(filePath + fileName, FileMode.Create); } else { fstream = new FileStream(filePath + fileName, FileMode.Append); } try { fstream.Write(fileBt, 0, fileBt.Length); //二进制转换成文件 //上传成功返回 1 fstream.Close(); } catch (Exception ex) { //上传失败返回 1 rst = "error"; } finally { fstream.Close(); } //读取坐标文件转换面积 //设置为实际值 string imgPath = filePath + fileName; //坐标点导入处理 StreamReader objReader = new StreamReader(imgPath); string sLine = ""; ArrayList LineList = new ArrayList(); while (sLine != null) { sLine = objReader.ReadLine(); if (sLine != null && !sLine.Equals("")) { LineList.Add(sLine); } } objReader.Close(); bool isrewrite = true; string sourcePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["sourcePath"].ToString()); //存储文件路径 string targetPath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["targetPath"].ToString()); //存储文件路径 String targetPath = str + "\\tempFolder\\temp_gkfqd.shp"; string temp = GenerateRandomCode(10); targetPath = targetPath + DateTime.Now.ToString("yyyyMMdd") + "\\"; if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } targetPath = targetPath + temp + "\\"; if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } System.IO.File.Copy(sourcePath + "testG.smwu", targetPath + "testG.smwu", isrewrite); System.IO.File.Copy(sourcePath + "test.udd", targetPath + "test.udd", isrewrite); System.IO.File.Copy(sourcePath + "test.udb", targetPath + "test.udb", isrewrite); this.fileWorkspace = new SuperMap.Data.Workspace(); string workSpaceFilePath = Server.MapPath(System.Configuration.ConfigurationManager.AppSettings["BinPath"].ToString()); //存储文件路径 try { //打开工作空间及地图文件类型 WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(targetPath + "testG.smwu"); fileWorkspace.Open(conInfo); fileDatasource = fileWorkspace.Datasources["test"]; sourceDatasetVector = fileDatasource.Datasets["dataT"] as DatasetVector; Recordset recordset = (sourceDatasetVector as DatasetVector).GetRecordset(false, CursorType.Dynamic); // 获得记录集对应的批量更新对象 Recordset.BatchEditor editor = recordset.Batch; // 开始批量添加,将 example 数据集每条记录对应的几何对象添加到数据集中 editor.Begin(); //删除所有记录 recordset.DeleteAll(); Point2Ds points = new Point2Ds(); for (int i = 1; i < LineList.Count - 1; i++) { string[] fieldInfoListZ = LineList[i].ToString().Split(','); Point2D point2D = new Point2D(); point2D.X = double.Parse(fieldInfoListZ[0].ToString()); point2D.Y = double.Parse(fieldInfoListZ[1].ToString()); points.Add(point2D); } GeoLine geolineE = new GeoLine(); geolineE.AddPart(points); recordset.AddNew(geolineE); editor.Update(); //调用创建矢量数据集缓冲区方法 //设置缓冲区分析参数 BufferAnalystParameter bufferAnalystParam = new BufferAnalystParameter(); //FLAT:平头缓冲。ROUND:圆头缓冲。 bufferAnalystParam.EndType = BufferEndType.Flat; //左侧缓冲距离,单位:米。 bufferAnalystParam.LeftDistance = width / 2; //右侧缓冲距离,单位:米。 bufferAnalystParam.RightDistance = width / 2; String bufferName = "bufferRegionDt"; bufferName = fileDatasource.Datasets.GetAvailableDatasetName(bufferName); m_bufferDataset = fileDatasource.Datasets.Create(new DatasetVectorInfo(bufferName, DatasetType.Region)); //设置投影信息 不设置 报投影不一致错误 m_bufferDataset.Datasource.Datasets["bufferRegionDt"].PrjCoordSys = (fileDatasource.Datasets["dataT"] as DatasetVector).PrjCoordSys; Boolean isTrue = SuperMap.Analyst.SpatialAnalyst.BufferAnalyst.CreateBuffer(recordset, m_bufferDataset, bufferAnalystParam, false, true); Recordset recordsetS = m_bufferDataset.Query("SmID=1", CursorType.Static); pfm = double.Parse(recordsetS.GetFieldValue("SMAREA").ToString()); mu = pfm * 0.0015; double gongqing = 0.0666667 * mu; } catch (Exception ex) { Trace.WriteLine(ex.Message); } rst = String.Format("{0:F2}", mu); fileWorkspace.Close(); return(rst); }
private void AddModel_Ctrl(object sender) { Point2Ds Point2Ds = (Point2Ds)sender; AddModel_Click(Point2Ds, m_ModelId, m_ModelNOId); }
public csRoadLine(Point2Ds pt2Ds) { roadline = pt2Ds; }
/// <summary> /// 在查询结果面板上初始化查询结果列表 /// </summary> /// <param name="type">查询方式,默认为属性查询-Attribute,空间查询-Spatial</param> private void ExecuteQueryListBox(string type, Point3Ds TempPoints3Ds=null, string actionStr=null) { string layerName = ""; if (this.QueryLayerList.Items.Count > 0) { layerName = this.QueryLayerList.SelectedValue.ToString(); } if (layerName != "")//关键字为空时查询全部要素 { string queryTxt = this.QueryNameTxt.Text.Trim(); Workspace ws = MainWindow.m_workspace; if (ws != null) { string sourceName = ConfigurationManager.AppSettings.Get(queryDataSource); Datasource dSource = ws.Datasources[sourceName]; if (dSource != null) { DatasetVector dSetV = (DatasetVector)dSource.Datasets[layerName]; if (dSetV != null) { string fieldName = ConfigurationManager.AppSettings.Get(queryNameField); string fieldCode = ConfigurationManager.AppSettings.Get(queryCodeField); Recordset recordset = null; if (type != ATTRIBUTE_QUERY) { double queryBuffer = 0.0; SuperMap.Data.Geometry queryGeometry = null; switch (actionStr) { case "createpoint": queryBuffer = 0.01; if (TempPoints3Ds.Count == 1) { GeoPoint geoPoint = new GeoPoint(TempPoints3Ds[0].X, TempPoints3Ds[0].Y); queryGeometry = geoPoint; } break; case "createline": if (TempPoints3Ds.Count == 2) { Point2D point2D = new Point2D(TempPoints3Ds[0].X, TempPoints3Ds[0].Y); Point2D point2D1 = new Point2D(TempPoints3Ds[1].X, TempPoints3Ds[1].Y); double radius = Geometrist.Distance(new GeoPoint(point2D), new GeoPoint(point2D1)); GeoCircle geoCircle = new GeoCircle(point2D, radius); GeoRegion geoRegion = geoCircle.ConvertToRegion(72); queryGeometry = geoRegion; } break; case "createpolygon": if (TempPoints3Ds.Count > 2) { Point2Ds tempPoint2Ds = new Point2Ds(); for (int i = 0; i < TempPoints3Ds.Count; i++) { tempPoint2Ds.Add(new Point2D(TempPoints3Ds[i].X, TempPoints3Ds[i].Y)); } GeoRegion geoRegion = new GeoRegion(tempPoint2Ds); queryGeometry = geoRegion; } break; default: break; } if (queryGeometry != null) { recordset = dSetV.Query(queryGeometry, queryBuffer, SuperMap.Data.CursorType.Static); } } else { QueryParameter queryParameter = new QueryParameter(); queryParameter.CursorType = SuperMap.Data.CursorType.Static; queryParameter.HasGeometry = true; if (this.QueryNameTxt.Text.Trim() != "") { queryParameter.AttributeFilter = fieldName + " like '%" + queryTxt + "%'"; } recordset = dSetV.Query(queryParameter); } if (recordset != null && recordset.RecordCount > 0) { ObservableCollection<QueryRecordVO> recordList = SysModelLocator.getInstance().recordList; recordList.Clear(); bool isExist = false; FieldInfos fis = recordset.GetFieldInfos(); for (int j = 0; j < fis.Count; j++) { FieldInfo fi = fis[j]; if (fi != null) { if (fi.Name.ToString().ToUpper() == fieldName) { isExist = true; break; } continue; } } if (isExist) { for (recordset.MoveFirst(); recordset.IsEOF == false; recordset.MoveNext()) { QueryRecordVO qVO = new QueryRecordVO(); qVO.RecordLayerId = layerName; qVO.RecordName = recordset.GetFieldValue(fieldName).ToString(); qVO.RecordIndex = recordset.GetFieldValue(fieldCode).ToString(); qVO.RecordCenterX = recordset.GetGeometry().InnerPoint.X.ToString(); qVO.RecordCenterY = recordset.GetGeometry().InnerPoint.Y.ToString(); recordList.Add(qVO); } this.QueryListBox.ItemsSource = recordList; this.QueryInfo.Text = "查询结果合计:" + recordList.Count + "条"; } else { this.QueryListBox.ItemsSource = null; this.QueryInfo.Text = ""; } } else { SysModelLocator.getInstance().recordList.Clear(); this.QueryListBox.ItemsSource = null; this.QueryInfo.Text = "查询结果合计:0条"; } } } } } }
private void button5_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "导出txt坐标文件(*.txt)|*.txt"; sfd.FileName = "坐标导出文件" + DateTime.Now.ToString("yyyyMMddhhmmss"); if (sfd.ShowDialog() == DialogResult.OK) { FileStream fs = new FileStream(sfd.FileName, FileMode.Create); StreamWriter sw = new StreamWriter(fs); if (dataGridView2.CurrentRow == null) { return; } DataGridViewRow dgvr = dataGridView2.CurrentRow; string strSmid = dgvr.Cells["地块编号"].Value.ToString();//获取smid值 // 构造一个查询参数对象,查询选中的记录 QueryParameter para = new QueryParameter(); para.AttributeFilter = "SMID =" + strSmid; para.CursorType = CursorType.Dynamic; // DataGridViewRow dgvr1 = dataGridView2.CurrentRow; //取得当前行项目名称值 string strProjectName = dgvr.Cells["项目名称"].Value.ToString(); //取得当前行地块编号该编号为用户输入的 string strDkbh = dgvr.Cells["地块逻辑编号"].Value.ToString(); string tableName = gkfqd.Common.DbUse.GetTownCodeByProjectNameJx(strProjectName); DatasetVector importResultShp = null; SuperMap.Data.Workspace workspace1; workspace1 = new SuperMap.Data.Workspace(); workspace1.Open(gkfqd.Common.Tool.GetConnectionInfo()); importDatasource = workspace1.Datasources[gkfqd.Common.Tool.GetWorkspaceDataDatasources()]; importResultShp = importDatasource.Datasets[tableName] as DatasetVector; Recordset recordset = null; //取系统时间 DateTime dt = DateTime.Now; if (dataGridView2.CurrentRow == null) { MessageBox.Show("请点击地块表行头,选择地块信息!"); return; } sqlQuery.Clear(); sqlQuery.Append("SELECT DKMC AS 地块名称, "); sqlQuery.Append(" DKMJ AS 地块面积, "); sqlQuery.Append(" ZBX AS 坐标系, "); sqlQuery.Append(" JZDS AS 界址点数, "); sqlQuery.Append(" JDFD AS 几度分带, "); sqlQuery.Append(" JD AS 精度, "); sqlQuery.Append(" JLDW AS 计量单位, "); sqlQuery.Append(" JLTCSX AS 记录图形属性, "); sqlQuery.Append(" TYLX AS 投影类型 "); sqlQuery.Append(" FROM " + tableName); sqlQuery.Append(" WHERE FKXMMC = '" + strProjectName + "'"); sqlQuery.Append(" AND DKBH = '" + strDkbh + "'"); gkfqd.Common.DbUse.GetOleDbconnection().Close(); gkfqd.Common.DbUse.GetOleDbconnection().Open(); dataSetOutPutZb.Clear(); OleDbDataAdapter MyAdapter = new OleDbDataAdapter(sqlQuery.ToString(), gkfqd.Common.DbUse.GetOleDbconnection()); MyAdapter.Fill(dataSetOutPutZb); gkfqd.Common.DbUse.GetOleDbconnection().Close(); sw.WriteLine("[属性描述]"); sw.WriteLine("格式版本号=1.01版本"); sw.WriteLine("数据产生单位=国土资源部"); sw.WriteLine("数据产生日期=" + dt.ToLongDateString().ToString()); sw.WriteLine("坐标系=" + dataSetOutPutZb.Tables[0].Rows[0]["坐标系"].ToString()); sw.WriteLine("几度分带=" + dataSetOutPutZb.Tables[0].Rows[0]["几度分带"].ToString()); sw.WriteLine("投影类型=" + dataSetOutPutZb.Tables[0].Rows[0]["投影类型"].ToString()); sw.WriteLine("计量单位=" + dataSetOutPutZb.Tables[0].Rows[0]["计量单位"].ToString()); sw.WriteLine("带号=" + dataSetOutPutZb.Tables[0].Rows[0]["几度分带"].ToString()); sw.WriteLine("精度=" + dataSetOutPutZb.Tables[0].Rows[0]["精度"].ToString()); sw.WriteLine("转换参数=0,0,0,0,0,0,0"); sw.WriteLine("[地块坐标]"); //保留该行记录导出结果,界址点数,地块面积,地块编号,地块名称,记录图形属性(点、线、面),图幅号,地块用途,地类编码,@ //以上记录信息如界址点数、地块面积、地块用途、地类编码需进一步编码取得 //sw.WriteLine("9,0.018,2003-10,双桥乡地块1,面,I-50-77-(22),公共基础设施,,@"); try { recordset = importResultShp.Query(para); while (!recordset.IsEOF) { Geometry geometry = recordset.GetGeometry(); GeoRegion region = geometry as GeoRegion; for (int i = 0; i < region.PartCount; i++) { Point2Ds point2ds = region[i]; for (int k = 0; k < point2ds.Count; k++) { Point2D point2d = point2ds[k]; //点号,地块圈号,X坐标,Y坐标 sw.WriteLine((k + 1).ToString() + "," + (i + 1).ToString() + "," + point2d.X.ToString() + "," + point2d.Y.ToString()); } } recordset.MoveNext(); } } catch (Exception ex) { Trace.WriteLine(ex.Message); } finally { recordset.Dispose(); } //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); MessageBox.Show("建新属性坐标信息导出成功!"); } }
private void AddModel_Ctrl(object sender, EventArgs e) { Point2Ds Point2Ds = (Point2Ds)sender; m_WorkSpaceCtrl.AddModel_Click(Point2Ds, m_ModelId, m_ModelNOId); }