/** * 多边形裁剪处理事件 * @param e * */ public void clipLayer() { if (this.IMSCatalog.ActiveLayerObj == null || this.IMSCatalog.ActiveLayerObj.ActiveLayerAccessInfo == null) { return; } GRegion region = new GRegion(); region.Rings = new AnyLine[1]; region.Rings[0] = new AnyLine(); region.Rings[0].Arcs = new Arc[1]; region.Rings[0].Arcs[0] = new Arc(); region.Rings[0].Arcs[0].Dots = dot; this.setClipRegion(region); this.Show(); CLayerAccessInfo layerAccessInfo = new CLayerAccessInfo(); layerAccessInfo.GdbInfo = this.IMSCatalog.ActiveLayerObj.ActiveLayerAccessInfo.GdbInfo; layerAccessInfo.LayerInfoList = new CLayerInfo[1]; int idx = this.IMSCatalog.ActiveLayerObj.ActiveLayerIndex; layerAccessInfo.LayerInfoList[0] = this.IMSCatalog.ActiveLayerObj.ActiveLayerAccessInfo.LayerInfoList[idx]; this._clipLayerAcsInfo = layerAccessInfo; this._serverAddr = this.IMSCatalog.ActiveLayerObj.ServerAddress; this._spatial = new SpacialAnalyse(this.IMSCatalog.ActiveLayerObj); }
//设置裁剪分析的参数 private void CircleClip() { if (this.iMSCatalog1.ActiveMapDoc != null) { //删除绘制的图形 this.m_gpLayer.RemoveAll(); //GRegion多区 GRegion region = new GRegion(); //AnyLine任意线 region.Rings = new AnyLine[1]; region.Rings[0] = new AnyLine(); region.Rings[0].Arcs = new Arc[1]; region.Rings[0].Arcs[0] = new Arc(); region.Rings[0].Arcs[0].Dots = new Dot_2D[dot.Length]; region.Rings[0].Arcs[0].Dots = dot; //将圆形区域上的所有的边界点赋值给多区的对象 this._clipRegion = region; // 设置图层的访问信息 this._clipLayerAcsInfo = new CLayerAccessInfo(); this._clipLayerAcsInfo = this.iMSCatalog1.ActiveMapDoc.ActiveLayerAccessInfo; this._serverAddr = this.iMSCatalog1.ActiveMapDoc.ServerAddress; //设置裁剪分析参数 CClipByPolygon clip = new CClipByPolygon(); //设置要裁剪的区 clip.Region = this._clipRegion; CLayerAccessInfo clipLayer = this._clipLayerAcsInfo; clip.GdbInfo = clipLayer.GdbInfo; clip.LayerName = clipLayer.LayerInfoList[0].LayerDataName; clip.XClsType = clipLayer.LayerInfoList[0].LayerType; clip.FClsNameRtn = "clip" + clip.LayerName; clip.Radius = 0.0001; clip.Username = ""; clip.UserIP = ""; clip.ClipFlg = 3; clip.IsReCalculate = false; //空间分析类 this._spatial = new SpacialAnalyse(this.iMSCatalog1.ActiveMapDoc); //裁剪分析 this._spatial.ClipByPolygon(clip, new UploadStringCompletedEventHandler(onSubmit)); } else { MessageBox.Show("矢量文档中没有激活的图层!"); } }
private void DrawPolygons(GRegion regions) { GRegion _tmp = regions; List <Point> logPnts = new List <Point>(); this.GraphicsLayer.MapContainer.Refresh(); for (int i = 0; i < _tmp.Rings.Length; i++) { logPnts = GetLogPnts(_tmp.Rings[i]); IMSPolygon polygon = new IMSPolygon(ZDIMS.Interface.CoordinateType.Logic); this.GraphicsLayer.AddGraphics(polygon); this.GraphicsLayer.MapContainer.Refresh(); polygon.StrokeThickness = 1; // polygon.Shape.Fill = new SolidColorBrush(Colors.Red);// new SolidColorBrush(t.ToColor("#ee0000")); polygon.Points = logPnts; polygon.Flicker(); polygon.FlickerOverCallback += new GraphicsFlickerOverDelegate(fickerover); } }
public IMSPolygon drawGetFeature(SFeatureGeometry sfeatureTemp) { GRegion reg = sfeatureTemp.RegGeom[0]; AnyLine arcLine = reg.Rings[0]; Arc arc = arcLine.Arcs[0]; //获取要素边界的点 Dot_2D[] Arcpnts = arc.Dots; int arcpntNum = Arcpnts.Length; //绘制多边形 IMSPolygon poly = new IMSPolygon(CoordinateType.Logic); m_gpLayer.AddGraphics(poly); for (int i = 0; i < arcpntNum; i++) { poly.Points.Add(new Point(arc.Dots[i].x, arc.Dots[i].y)); } poly.Draw(); return(poly); }
/// <summary> /// 圆裁剪地图文档 /// </summary> /// <param name="?"></param> /// <returns></returns> public void clipDoc() { if (this.IMSCatalog.ActiveMapDoc.ActiveLayerIndex == -1) { MessageBox.Show("矢量文档中没有激活的图层!"); return; } GRegion region = new GRegion(); region.Rings = new AnyLine[1]; region.Rings[0] = new AnyLine(); region.Rings[0].Arcs = new Arc[1]; region.Rings[0].Arcs[0] = new Arc(); region.Rings[0].Arcs[0].Dots = new Dot_2D[dot.Length]; region.Rings[0].Arcs[0].Dots = dot; this.setClipRegion(region); this.Show(); this._clipLayerAcsInfo = this.IMSCatalog.ActiveMapDoc.ActiveLayerAccessInfo; this._serverAddr = this.IMSCatalog.ActiveMapDoc.ServerAddress; this._spatial = new SpacialAnalyse(this.IMSCatalog.ActiveMapDoc); }
public void setClipRegion(GRegion region) { this._clipRegion = region; }
private void changeGeobject_Click(object sender, EventArgs e) { if (catalog == null) { MessageBox.Show("Сначала выберите файл для считывания"); return; } if (dataGridView1.CurrentRow == null || dataGridView1.CurrentRow.Cells[1] == null) { MessageBox.Show("Не выбран элемент для изменения."); return; } int i = searchcomboBox1.SelectedIndex; switch (i) { case 0: { t = new Town(); t.Name = dataGridView1.SelectedCells[0].Value.ToString(); t.Country = dataGridView1.SelectedCells[1].Value.ToString(); t.Materic = dataGridView1.SelectedCells[2].Value.ToString(); t.Citizens = Convert.ToDouble(dataGridView1.SelectedCells[3].Value.ToString()); t.Geopos = dataGridView1.SelectedCells[4].Value.ToString(); t.Area = Convert.ToDouble(dataGridView1.SelectedCells[5].Value.ToString()); r = null; c = null; break; } case 1: { r = new GRegion(); r.Name = dataGridView1.SelectedCells[0].Value.ToString(); r.Country = dataGridView1.SelectedCells[1].Value.ToString(); r.Materic = dataGridView1.SelectedCells[2].Value.ToString(); r.Citizens = Convert.ToDouble(dataGridView1.SelectedCells[3].Value.ToString()); r.TypeRegion = dataGridView1.SelectedCells[4].Value.ToString(); r.Capital = dataGridView1.SelectedCells[5].Value.ToString(); t = null; c = null; break; } case 2: { c = new Country(); c.Name = dataGridView1.SelectedCells[0].Value.ToString(); c.Capital = dataGridView1.SelectedCells[1].Value.ToString(); c.Materic = dataGridView1.SelectedCells[2].Value.ToString(); c.Citizens = Convert.ToDouble(dataGridView1.SelectedCells[3].Value.ToString()); c.Politic = dataGridView1.SelectedCells[4].Value.ToString(); c.Area = Convert.ToDouble(dataGridView1.SelectedCells[5].Value.ToString()); r = null; t = null; break; } } Add_ChangeForm form2 = new Add_ChangeForm(catalog, t, r, c); form2.Text = "Изменение географического объекта"; if (form2.ShowDialog() == DialogResult.OK) { form2.ChangeGeo(); change = true; } catalog = form2.UseCatalog; button1_Click(sender, e); if (DialogResult == DialogResult.OK) { MessageBox.Show("Изменение элемента прошло успешно."); } }
/// <summary> /// 获取要素信息 /// </summary> /// <returns></returns> private CMapFeatureInfo GetMapFeatureInfo() { CMapFeatureInfo fInfo = new CMapFeatureInfo(); SFeature sf = new SFeature(); sf.AttValue = new string[m_attStruct.FldNumber]; for (int i = 0; i < m_attStruct.FldNumber; i++) { sf.AttValue[i] = m_textBoxArr[i].Text; switch (this.m_attStruct.FldType[i]) { case "double": case "integer": case "long": case "short": if (!CommFun.IsNumber(sf.AttValue[i])) { MessageBox.Show("字段【Fld_" + this.m_attStruct.FldName[i] + "】输入的数据格式不正确。请重新输入!", "提示", MessageBoxButton.OK); return(null); } break; } } SFeatureGeometry sfGeo = null; SFclsGeomType curFGeoType; if (m_targetGeo != null) { sfGeo = m_targetGeo as SFeatureGeometry; if (sfGeo == null) //add feature { sfGeo = new SFeatureGeometry(); switch ((m_targetGeo as IWebGeometry).GetGeomType()) { case WebGeomType.Point: sf.ftype = SFclsGeomType.Pnt; GPoint pnt = new GPoint(); pnt.Dot = m_targetGeo as Dot_2D; sfGeo.PntGeom = new GPoint[] { pnt }; break; case WebGeomType.Line: sf.ftype = SFclsGeomType.Lin; GLine line = new GLine(); line.Line = m_targetGeo as AnyLine; sfGeo.LinGeom = new GLine[] { line }; break; case WebGeomType.Polygon: sf.ftype = SFclsGeomType.Reg; GRegion polygon = new GRegion(); AnyLine circle = new AnyLine(); circle.Arcs = new Arc[1]; circle.Arcs[0] = new Arc(); circle.Arcs[0].Dots = (m_targetGeo as ZDIMS.BaseLib.Polygon).Dots; polygon.Rings = new AnyLine[] { circle }; sfGeo.RegGeom = new GRegion[] { polygon }; break; default: sfGeo = null; break; } } } curFGeoType = ActiveMapDoc.ActiveLayerGeoType; if (this.m_featureStyle == null) { this.m_featureStyle = new WebGraphicsInfo(); } this.m_style.Update(); switch (curFGeoType) { case SFclsGeomType.Pnt: this.m_featureStyle.InfoType = GInfoType.PntInfo; PointStyle newPntStyle = this.m_style as PointStyle; this.m_featureStyle.PntInfo = new CPointInfo(); if (newPntStyle.patternAngle.Text == "") { this.m_featureStyle.PntInfo.Angle = 0.0; } else { this.m_featureStyle.PntInfo.Angle = Convert.ToDouble(newPntStyle.patternAngle.Text); } if (newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.PntInfo.Color = 0; } else { this.m_featureStyle.PntInfo.Color = Convert.ToInt32(newPntStyle.patternColor._TextBoxInput.Text.Split(':')[0]); } if (newPntStyle.patternHeight.Text == "") { this.m_featureStyle.PntInfo.SymHeight = 0.0; } else { this.m_featureStyle.PntInfo.SymHeight = Convert.ToDouble(newPntStyle.patternHeight.Text); } if (newPntStyle.patternID._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.PntInfo.SymID = 0; } else { this.m_featureStyle.PntInfo.SymID = Convert.ToInt32(newPntStyle.patternID._TextBoxInput.Text.Split(':')[0]); } if (newPntStyle.patternWidth.Text == "") { this.m_featureStyle.PntInfo.SymWidth = 0.0; } else { this.m_featureStyle.PntInfo.SymWidth = Convert.ToDouble(newPntStyle.patternWidth.Text); } break; case SFclsGeomType.Lin: this.m_featureStyle.InfoType = GInfoType.LinInfo; LineStyle newLineStyle = this.m_style as LineStyle; this.m_featureStyle.LinInfo = new CLineInfo(); if (newLineStyle.color._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.LinInfo.Color = 0; } else { this.m_featureStyle.LinInfo.Color = Convert.ToInt32(newLineStyle.color._TextBoxInput.Text.Split(':')[0]); } if (newLineStyle.patternID._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.LinInfo.LinStyleID = 0; } else { this.m_featureStyle.LinInfo.LinStyleID = Convert.ToInt32(newLineStyle.patternID._TextBoxInput.Text.Split(':')[0]); } if (newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.LinInfo.LinStyleID2 = 0; } else { this.m_featureStyle.LinInfo.LinStyleID2 = Convert.ToInt32(newLineStyle.patternID2._TextBoxInput.Text.Split(':')[0]); } if (newLineStyle.penWidth.Text == "") { this.m_featureStyle.LinInfo.LinWidth = 0.0; } else { this.m_featureStyle.LinInfo.LinWidth = Convert.ToDouble(newLineStyle.penWidth.Text); } if (newLineStyle.lineScaleX.Text == "") { this.m_featureStyle.LinInfo.Xscale = 0.0; } else { this.m_featureStyle.LinInfo.Xscale = Convert.ToDouble(newLineStyle.lineScaleX.Text); } if (newLineStyle.lineScaleY.Text == "") { this.m_featureStyle.LinInfo.Yscale = 0.0; } else { this.m_featureStyle.LinInfo.Yscale = Convert.ToDouble(newLineStyle.lineScaleY.Text); } break; case SFclsGeomType.Reg: this.m_featureStyle.InfoType = GInfoType.RegInfo; PolygonStyle newRegStyle = this.m_style as PolygonStyle; this.m_featureStyle.RegInfo = new CRegionInfo(); if (newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.RegInfo.FillColor = 0; } else { this.m_featureStyle.RegInfo.FillColor = Convert.ToInt32(newRegStyle.fillcolor._TextBoxInput.Text.Split(':')[0]); } if (newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.RegInfo.PatColor = 0; } else { this.m_featureStyle.RegInfo.PatColor = Convert.ToInt32(newRegStyle.patternColor._TextBoxInput.Text.Split(':')[0]); } if (newRegStyle.patternHeight.Text == "") { this.m_featureStyle.RegInfo.PatHeight = 0.0; } else { this.m_featureStyle.RegInfo.PatHeight = Convert.ToDouble(newRegStyle.patternHeight.Text); } if (newRegStyle.patternID._TextBoxInput.Text.Split(':')[0] == "") { this.m_featureStyle.RegInfo.PatID = 0; } else { this.m_featureStyle.RegInfo.PatID = Convert.ToInt32(newRegStyle.patternID._TextBoxInput.Text.Split(':')[0]); } if (newRegStyle.patternPenWidth.Text == "") { this.m_featureStyle.RegInfo.OutPenWidth = 0.0; } else { this.m_featureStyle.RegInfo.OutPenWidth = Convert.ToDouble(newRegStyle.patternPenWidth.Text); } if (newRegStyle.patternWidth.Text == "") { this.m_featureStyle.RegInfo.PatWidth = 0.0; } else { this.m_featureStyle.RegInfo.PatWidth = Convert.ToDouble(newRegStyle.patternWidth.Text); } break; } sf.fGeom = sfGeo; sf.FID = m_featureID; fInfo.GInfo = this.m_featureStyle; fInfo.FSet = sf; fInfo.LayerIndex = ActiveMapDoc.ActiveLayerIndex; fInfo.MapName = new COpenMap(); fInfo.MapName.MapName = new string[] { ActiveMapDoc.MapDocName }; return(fInfo); }