private void CtrlPoint3DSpaceInfo_Load(object sender, EventArgs e) { GSOGeoPoint3D geoPoint3D = m_Geometry as GSOGeoPoint3D; if (geoPoint3D != null) { textBoxLat.Text = geoPoint3D.Position.Y.ToString(); textBoxLon.Text = geoPoint3D.Position.X.ToString(); textBoxAlt.Text = geoPoint3D.Position.Z.ToString(); // 高度模式 switch (geoPoint3D.AltitudeMode) { case EnumAltitudeMode.Absolute: comboBoxAltMode.SelectedIndex = 0; break; case EnumAltitudeMode.ClampToGround: comboBoxAltMode.SelectedIndex = 1; textBoxAlt.Enabled = false; break; case EnumAltitudeMode.RelativeToGround: comboBoxAltMode.SelectedIndex = 2; break; } } }
private void txtNewChange() { decimal x; decimal y; if (txtNewLon.Text.Trim() == "") { txtNewLon.Text = 0 + ""; } bool bl = decimal.TryParse(txtNewLon.Text.Trim(), out x); if (!bl) { MessageBox.Show("数据不符合要求!"); return; } if (txtNewLat.Text.Trim() == "") { txtNewLat.Text = 0 + ""; } bl = decimal.TryParse(txtNewLat.Text.Trim(), out y); if (!bl) { MessageBox.Show("数据不符合要求!"); return; } GSOPoint3d point = ctl.Globe.ScreenToScene((int)Math.Round(x), (int)Math.Round(y)); if (endFeat == null || endFeat.IsDeleted) { endFeat = new GSOFeature(); GSOGeoMarker p = new GSOGeoMarker(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png"; p.Style = style; p.AltitudeMode = EnumAltitudeMode.ClampToGround; endFeat.Name = "目标点"; endFeat.CustomID = 001; p.X = (double)Math.Round(x); p.Y = (double)Math.Round(y); p.Z = 0; endFeat.Geometry = p; endFeat = ctl.Globe.MemoryLayer.AddFeature(endFeat); } else { GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D; if (endpoint != null) { endpoint.X = (double)Math.Round(x); endpoint.Y = (double)Math.Round(y); endpoint.Z = 0; } } ctl.Refresh(); }
private void buttonOk_Click(object sender, EventArgs e)//确定 { if (comboBox1.Text.Trim() == "") { MessageBox.Show("图层不能为空"); return; } if (txtPath.Text.Trim() == "") { MessageBox.Show("模型路径不能为空"); return; } if (textBoxLayerPath.Text.Trim() == "") { MessageBox.Show("图层保存路径不能为空"); return; } GSOLayer newlayer = globeControl1.Globe.Layers.Add(textBoxLayerPath.Text.Trim()); newlayer.Caption = Path.GetFileNameWithoutExtension(txtPath.Text.Trim()); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBox1.Text.Trim()); if (layer != null) { GSOFeatures features = layer.GetAllFeatures(); if (features.Length > 0) { for (int i = 0; i < features.Length; i++) { if (features[i] != null && features[i].Geometry != null) { if (features[i].Geometry.Type == EnumGeometryType.GeoPoint3D) { GSOFeature feature = new GSOFeature(); GSOGeoPoint3D point3d = features[i].Geometry as GSOGeoPoint3D; if (point3d != null) { GSOGeoModel model = new GSOGeoModel(); model.FilePath = txtPath.Text.Trim(); model.Position = point3d.Position; feature.Geometry = model; newlayer.AddFeature(feature); } } } } globeControl1.Globe.Refresh(); } } this.Close(); }
private void CheckSelFeaturePoint() { if (m_nCurSelected >= 0 && m_nCurSelected < listViewNodeList.Items.Count) { GSOGeoPoint3D geoPoint3D = null; if (m_FeatureSelPoint == null || m_FeatureSelPoint.IsDeleted) { m_FeatureSelPoint = new GSOFeature(); geoPoint3D = new GSOGeoMarker(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png"; geoPoint3D.Style = style; m_FeatureSelPoint.Geometry = geoPoint3D; if (m_GlobeControl != null) { m_GlobeControl.Globe.MemoryLayer.AddFeature(m_FeatureSelPoint); m_GlobeControl.Refresh(); } } /* * else * { * geoPoint3D = m_FeatureSelPoint.Geometry as GSOGeoPoint3D; * } */ geoPoint3D = m_FeatureSelPoint.Geometry as GSOGeoPoint3D; geoPoint3D.AltitudeMode = m_Geometry.AltitudeMode; try { ListViewItem itemSel = listViewNodeList.Items[m_nCurSelected]; geoPoint3D.X = Double.Parse(itemSel.SubItems[1].Text); geoPoint3D.Y = Double.Parse(itemSel.SubItems[2].Text); geoPoint3D.Z = Double.Parse(itemSel.SubItems[3].Text); } catch (System.Exception exp) { Log.PublishTxt(exp); } if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } }
private void positionChanged() { GSOGeoPoint3D geoPoint3D = m_Geometry as GSOGeoPoint3D; if (geoPoint3D != null) { try { geoPoint3D.X = Convert.ToDouble(textBoxLon.Text); geoPoint3D.Y = Convert.ToDouble(textBoxLat.Text); geoPoint3D.Z = Convert.ToDouble(textBoxAlt.Text); if (m_GlobeControl != null) { m_GlobeControl.Refresh(); } } catch (System.Exception exp) { Log.PublishTxt(exp); } } }
private void button3_Click(object sender, EventArgs e) { if (comboBoxDataSourceList.SelectedItem == null) { MessageBox.Show("请选择一个目标数据源!", "提示"); return; } GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim()); if (ds == null) { MessageBox.Show("选择的目标数据源为空!", "提示"); return; } if (textBoxModelFolder.Text == "") { return; } if (comboBoxShpLayerList.SelectedIndex < 0) { return; } try { Regex regNum = new Regex("^[0-9]"); DirectoryInfo theFolder = new DirectoryInfo(textBoxModelFolder.Text); foreach (FileInfo nextFile in theFolder.GetFiles()) { if (nextFile.Name.ToLower().IndexOf("3ds") > -1 || nextFile.Name.ToLower().IndexOf("gcm") > -1) { files.Add(nextFile.Name); string temp = nextFile.Name.Substring(nextFile.Name.IndexOf("-") + 1, nextFile.Name.LastIndexOf(".") - nextFile.Name.IndexOf("-") - 1); string modeltype = nextFile.Name.Substring(0, nextFile.Name.IndexOf("-")); modeltypes.Add(modeltype); double Num; bool isNum = double.TryParse(temp, out Num); if (isNum) { deeps.Add(Convert.ToDouble(temp)); } } } GSODataset dataset = ds.GetDatasetByName(textBoxNewLayerName.Text.Trim()); GSOFeatureDataset featdataset; if (dataset != null) { DialogResult result = MessageBox.Show("工井图层名称在数据库中已存在!是否向该表追加", "提示", MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } else if (result == DialogResult.Yes) { featdataset = dataset as GSOFeatureDataset; } else { return; } } else { featdataset = CreateDBFeatureDataset(textBoxNewLayerName.Text.Trim()); } if (featdataset == null) { return; } featdataset.Open(); GSOLayer shpLayer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxShpLayerList.SelectedItem.ToString().Trim()); if (shpLayer == null) { return; } GSOFeatures features = shpLayer.GetAllFeatures(true); string message = ""; for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D shpPoint = f.Geometry as GSOGeoPoint3D; double x; double y; double rotateAngle = 0; string currentModelType = f.GetValue(combCode.SelectedItem.ToString()).ToString(); double z = Convert.ToDouble(txtUpGround.Text); double deep = f.GetFieldAsDouble(combDeep.SelectedItem.ToString()); int index = -1; double diff = double.MaxValue; for (int i = 0; i < deeps.Count; i++) { double tempdeep = Convert.ToDouble(deeps[i]); string modeltype = modeltypes[i].ToString(); if (modeltype != currentModelType) { continue; } if (tempdeep > deep) { double chazhi = tempdeep - deep; if (diff > chazhi) { diff = chazhi; index = i; } } } if (index < 0) { message += "ID为" + f.ID + "的对象没有找到符合井深的工井模型\r\n"; continue; } GSOFeature feature = featdataset.CreateFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = shpPoint.X; pt.Y = shpPoint.Y; pt.Z = z; model.Position = pt; model.Align = EnumEntityAlign.TopCenter; //接口已修复作用 model.AltitudeMode = EnumAltitudeMode.RelativeToGround; model.RotateZ = 0 - rotateAngle * 180 / Math.PI + 90; model.FilePath = textBoxModelFolder.Text + "\\" + files[index]; model.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Geometry = model; for (int i = 0; i < f.GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i)); if (fielddef == null) { continue; } if (!gj_cns.ContainsKey(fielddef.Name)) { continue; } object obu = f.GetValue(fielddef.Name); if (obu != null) { string fieldName = gj_cns.ContainsKey(fielddef.Name) == true ? gj_cns[fielddef.Name].ToString() : fielddef.Name; feature.SetValue(fieldName, obu); } } featdataset.AddFeature(feature); } featdataset.Save(); featdataset.Close(); string strMessage = "shp文件中共" + features.Length + "个对象,实际入库" + featdataset.GetAllFeatures().Length + "个对象!\r\n"; if (message == "") { MessageBox.Show(strMessage, "提示"); } else { FrmMessageShow frm = new FrmMessageShow(strMessage + message); frm.ShowDialog(); } this.Close(); } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message); } }
private void button3_Click(object sender, EventArgs e) { if (txtFolder.Text == "") { return; } //if (txtPath.Text == "") // return; try { Regex regNum = new Regex("^[0-9]"); DirectoryInfo theFolder = new DirectoryInfo(txtFolder.Text); foreach (FileInfo nextFile in theFolder.GetFiles()) { if (nextFile.Name.ToLower().IndexOf("3ds") > -1 || nextFile.Name.ToLower().IndexOf("gcm") > -1) { files.Add(nextFile.Name); string temp = nextFile.Name.Substring(nextFile.Name.IndexOf("-") + 1, nextFile.Name.LastIndexOf(".") - nextFile.Name.IndexOf("-") - 1); string modeltype = nextFile.Name.Substring(0, nextFile.Name.IndexOf("-")); modeltypes.Add(modeltype); double Num; bool isNum = double.TryParse(temp, out Num); if (isNum) { deeps.Add(Convert.ToDouble(temp)); } } } // TextReader tr = new StreamReader(txtPath.Text); // string line = tr.ReadLine(); // GSOFeatureDataset featdataset = CreateDBFeatureDataset(txtLayerName.Text); // 创建 数据库要素集 // return; if (string.IsNullOrEmpty(txtLayerName.Text)) { MessageBox.Show("管线图层无效!", "提示"); return; } GSODataset dataset = ds.GetDatasetByName(txtLayerName.Text.Trim()); GSOFeatureDataset layer; if (dataset != null) { DialogResult restult = MessageBox.Show("管线图层名称在数据库中已存在!是否向该表追加", "提示", MessageBoxButtons.YesNo); if (restult == DialogResult.No) { return; } else if (restult == DialogResult.Yes) { layer = dataset as GSOFeatureDataset; } else { return; } } else { layer = CreateDBFeatureDataset(txtLayerName.Text.Trim()); } if (layer == null) { return; } GSOLayer sourceLayer = globeControl1.Globe.Layers[cmbLayer.SelectedIndex]; MessageBox.Show("创建成功!"); layer.Open(); lgdFilePath = txtLayerName.Text; if (layer != null) { GSOFeatures features = sourceLayer.GetAllFeatures(true); for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D lineeee = f.Geometry as GSOGeoPoint3D; //double x; //double y; //double rotateAngle = 0; //string currentModelType = f.GetValue("管线点编码").ToString(); // paras[6]; //double z = Convert.ToDouble(txtUpGround.Text); //double deep = f.GetFieldAsDouble("井深"); //int index = -1; //double diff = double.MaxValue; //for (int i = 0; i < deeps.Count; i++) //{ // double tempdeep = Convert.ToDouble(deeps[i]); // string modeltype = modeltypes[i].ToString(); // if (modeltype != currentModelType) // { // continue; // } // if (tempdeep > deep) // { // double chazhi = tempdeep - deep; // if (diff > chazhi) // { // diff = chazhi; // index = i; // } // } //} //if (index < 0) //{ // continue; //} //GSOFeature newFeature = layer.CreateFeature(); //GSOGeoModel model = new GSOGeoModel(); //GSOPoint3d pt = new GSOPoint3d(); //pt.X = lineeee.X; //pt.Y = lineeee.Y; //pt.Z = z; //model.Position = pt; //model.Align = EnumEntityAlign.TopCenter; //接口已修复作用 //model.AltitudeMode = EnumAltitudeMode.RelativeToGround; //model.RotateZ = 0 - rotateAngle * 180 / Math.PI + 90; //model.FilePath = txtFolder.Text + "\\" + files[index]; GSOFeature newFeature = layer.CreateFeature(); for (int i = 0; i < features[0].GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(features[0].GetFieldDefn(i)); if (!en_cns.ContainsKey(fielddef.Name)) { continue; } object fieldvalue = convertFieldValue(fielddef.Name, f.GetValue(fielddef.Name)); if (fielddef == null) { continue; } newFeature.SetValue(en_cns[fielddef.Name].ToString(), fieldvalue); } layer.AddFeature(newFeature); } } globeControl1.Refresh(); layer.Save(); layer.Caption = layer.Name; globeControl1.Globe.Layers.Add(layer); this.Close(); //创建 //featdataset.Open(); //while (line != null) //{ // string[] paras = line.Split(','); // if (paras.Length != 16) // { // line = tr.ReadLine(); // continue; // } // if (paras.Length <= 15) // { // line = tr.ReadLine(); // continue; // } // if (paras[4] == "" || paras[5] == "" || paras[6] == "") // { // line = tr.ReadLine(); // continue; // } // double x; // double y; // if (!double.TryParse(paras[5], out x)) // { // line = tr.ReadLine(); // continue; // } // if (!double.TryParse(paras[4], out y)) // { // line = tr.ReadLine(); // continue; // } // double rotateAngle = 0; // if (!double.TryParse(paras[15], out rotateAngle)) // { // line = tr.ReadLine(); // continue; // } // string currentModelType = paras[6]; // if (currentModelType.Length == 0) // { // line = tr.ReadLine(); // continue; // } // int id = GeoScene.Data.GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=-50000 +y_0=-4210000 +ellps=krass +units=m +no_defs"); // GeoScene.Data.GSOPoint2d pt2d = new GeoScene.Data.GSOPoint2d(x, y); // GeoScene.Data.GSOPoint2d result = GeoScene.Data.GSOProjectManager.Inverse(pt2d, id); //double z = Convert.ToDouble(txtUpGround.Text); //GSOFeature feature = featdataset.CreateFeature(); //double deep; //if (!double.TryParse(paras[8], out deep)) //{ // line = tr.ReadLine(); // continue; //} //int index = -1; //double diff = double.MaxValue; //for (int i = 0; i < deeps.Count; i++) //{ // double tempdeep = Convert.ToDouble(deeps[i]); // string modeltype = modeltypes[i].ToString(); // if (modeltype != currentModelType) // { // continue; // } // if (tempdeep > deep) // { // double chazhi = tempdeep - deep; // if (diff > chazhi) // { // diff = chazhi; // index = i; // } // } //} //if (index < 0) //{ // line = tr.ReadLine(); // continue; //} //GSOGeoModel model = new GSOGeoModel(); //GSOPoint3d pt = new GSOPoint3d(); //pt.X = result.X; //pt.Y = result.Y; //pt.Z = z; //model.Position = pt; //model.Align = EnumEntityAlign.TopCenter; //接口已修复作用 //model.AltitudeMode = EnumAltitudeMode.RelativeToGround; //model.RotateZ = 0 - rotateAngle * 180 / Math.PI + 90; //model.FilePath = txtFolder.Text + "\\" + files[index]; //model.Name = paras[0]; //feature.Name = paras[0]; //feature.Geometry = model; // if (paras[9].Length > 0) // feature.SetValue("图片编码", paras[9]); // // feature.SetValue("旋转角度", 0 - rotateAngle * 180 / Math.PI + 90); // feature.SetValue("编号", paras[0]); // // feature.SetValue("模型路径", txtFolder.Text + "\\" + files[index]); // feature.SetValue("建设年代",paras[10]); // feature.SetValue("建设单位", paras[12]); // feature.SetValue("权属单位",paras[13]); // feature.SetValue("备注",paras[14]); // featdataset.AddFeature(feature); // line = tr.ReadLine(); //} //featdataset.Save(); //this.Close(); } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message); } }
void ctl_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { GSOPoint3d point = ctl.Globe.ScreenToScene(e.X, e.Y); if (radioOld.Checked) { txtOldLon.Text = point.X.ToString(); txtOldLat.Text = point.Y.ToString(); if (startFeat == null || startFeat.IsDeleted) { startFeat = new GSOFeature(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); GSOGeoMarker p = new GSOGeoMarker(); style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png"; p.Style = style; p.AltitudeMode = EnumAltitudeMode.ClampToGround; p.X = point.X; p.Y = point.Y; p.Z = point.Z; startFeat.Name = "起点"; startFeat.CustomID = 000; startFeat.Geometry = p; startFeat = ctl.Globe.MemoryLayer.AddFeature(startFeat); } else { GSOGeoPoint3D startpoint = startFeat.Geometry as GSOGeoPoint3D; if (startpoint != null) { startpoint.X = point.X; startpoint.Y = point.Y; startpoint.Z = 0; } } } else { txtNewLon.Text = point.X.ToString(); txtNewLat.Text = point.Y.ToString(); if (endFeat == null || endFeat.IsDeleted) { endFeat = new GSOFeature(); GSOGeoMarker p = new GSOGeoMarker(); GSOMarkerStyle3D style = new GSOMarkerStyle3D(); style.IconPath = Path.GetDirectoryName(Application.ExecutablePath) + "/Resource/CrossIcon.png"; p.Style = style; p.AltitudeMode = EnumAltitudeMode.ClampToGround; endFeat.Name = "目标点"; endFeat.CustomID = 001; p.X = point.X; p.Y = point.Y; p.Z = point.Z; endFeat.Geometry = p; endFeat = ctl.Globe.MemoryLayer.AddFeature(endFeat); } else { GSOGeoPoint3D endpoint = endFeat.Geometry as GSOGeoPoint3D; if (endpoint != null) { endpoint.X = point.X; endpoint.Y = point.Y; endpoint.Z = 0; } } } ctl.Refresh(); } }
private void button3_Click(object sender, EventArgs e) { if (txtFolder.Text == "") { return; } if (cmbLayer.SelectedIndex < 0) { return; } try { Regex regNum = new Regex("^[0-9]"); DirectoryInfo theFolder = new DirectoryInfo(txtFolder.Text); foreach (FileInfo nextFile in theFolder.GetFiles()) { if (nextFile.Name.ToLower().IndexOf("3ds") > -1 || nextFile.Name.ToLower().IndexOf("gcm") > -1) { files.Add(nextFile.Name); string temp = nextFile.Name.Substring(nextFile.Name.IndexOf("-") + 1, nextFile.Name.LastIndexOf(".") - nextFile.Name.IndexOf("-") - 1); string modeltype = nextFile.Name.Substring(0, nextFile.Name.IndexOf("-")); modeltypes.Add(modeltype); double Num; bool isNum = double.TryParse(temp, out Num); if (isNum) { deeps.Add(Convert.ToDouble(temp)); } } } GSOFeatureDataset featdataset = CreateDBFeatureDataset(txtLayerName.Text); featdataset.Open(); GSOLayer shpLayer = globeControl1.Globe.Layers[cmbLayer.SelectedIndex]; if (shpLayer == null) { return; } GSOFeatures features = shpLayer.GetAllFeatures(true); for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D shpPoint = f.Geometry as GSOGeoPoint3D; double x; double y; double rotateAngle = 0; rotateAngle = (double)f.GetValue(combAngle.SelectedItem.ToString()); string currentModelType = f.GetValue(combCode.SelectedItem.ToString()).ToString(); double z = Convert.ToDouble(txtUpGround.Text); double deep = f.GetFieldAsDouble(combDeep.SelectedItem.ToString()); int index = -1; double diff = double.MaxValue; for (int i = 0; i < deeps.Count; i++) { double tempdeep = Convert.ToDouble(deeps[i]); string modeltype = modeltypes[i].ToString(); if (modeltype != currentModelType) { continue; } if (tempdeep > deep) { double chazhi = tempdeep - deep; if (diff > chazhi) { diff = chazhi; index = i; } } } if (index < 0) { continue; } GSOFeature feature = featdataset.CreateFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = shpPoint.X; pt.Y = shpPoint.Y; pt.Z = z; model.Position = pt; model.Align = EnumEntityAlign.TopCenter; //接口已修复作用 model.AltitudeMode = EnumAltitudeMode.RelativeToGround; model.RotateZ = 0 - rotateAngle * 180 / Math.PI + 90; model.FilePath = txtFolder.Text + "\\" + files[index]; model.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Geometry = model; for (int i = 0; i < feature.GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i)); //if (!en_cns.ContainsKey(fielddef.Name)) // continue; // object fieldvalue = convertFieldValue(fielddef.Name, f.GetValue(fielddef.Name)); if (fielddef == null) { continue; } feature.SetValue(fielddef.Name, f.GetValue(fielddef.Name)); } featdataset.AddFeature(feature); } featdataset.Save(); this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button2_Click(object sender, EventArgs e) { if (comboBoxLayers.Text == "") { MessageBox.Show("请选择一个图层!"); return; } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(comboBoxLayers.Text.Trim()); if (layer == null) { MessageBox.Show("您选择的图层不存在!"); return; } string iconPath = textBoxIconPath.Text.Trim(); if (iconPath == "") { iconPath = Application.StartupPath + "\\Resource\\DefaultIcon.png"; } Color lineColor = textBoxLineColor.BackColor; string strLineWidth = textBoxLineWidth.Text.Trim(); double lineWidth = 1; bool blIsLineWidth = double.TryParse(strLineWidth, out lineWidth); Color outlineColor = textBoxOutlineColor.BackColor; string strOutlineWidth = textBoxOutlineWidth.Text.Trim(); double outlineWidth = 1; bool blIsOutlineWidth = double.TryParse(strOutlineWidth, out outlineWidth); Color polygonColor = textBoxPolygonColor.BackColor; string strPolygonAlpha = textBoxPolygonAlpha.Text.Trim(); int polygonAlpha = 255; bool blIsPolygonAlpha = int.TryParse(strPolygonAlpha, out polygonAlpha); polygonColor = Color.FromArgb(polygonAlpha, polygonColor); for (int i = 0; i < layer.GetAllFeatures().Length; i++) { GSOFeature feature = layer.GetAt(i); if (feature.Geometry != null) { switch (feature.Geometry.Type) { case EnumGeometryType.GeoPoint3D: if (panelPoints.Enabled) { GSOGeoPoint3D point = (GSOGeoPoint3D)feature.Geometry; GSOGeoMarker marker = new GSOGeoMarker(); marker.Position = point.Position; marker.Name = point.Name; marker.CameraState = point.CameraState; marker.Label = point.Label; GSOFeature newFeature = new GSOFeature(); newFeature.Name = feature.Name; newFeature.Geometry = marker; layer.RemoveAt(i); layer.AddFeature(newFeature); i--; } break; case EnumGeometryType.GeoMarker: if (panelPoints.Enabled) { GSOGeoMarker marker = (GSOGeoMarker)feature.Geometry; GSOMarkerStyle3D style = null; if (marker.Style == null) { style = new GSOMarkerStyle3D(); } else { style = (GSOMarkerStyle3D)marker.Style; } style.TextVisible = !checkBoxHideLabelOfMarker.Checked; style.IconPath = iconPath.Trim(); marker.Style = style; } break; case EnumGeometryType.GeoPolyline3D: if (panelLines.Enabled) { GSOGeoPolyline3D line = (GSOGeoPolyline3D)feature.Geometry; if (line.Label != null) { line.Label.Visible = !checkBoxHideLabelOfLine.Checked; } if (line.Style == null) { GSOSimpleLineStyle3D styleLine = new GSOSimpleLineStyle3D(); styleLine.LineColor = lineColor; styleLine.LineWidth = lineWidth; line.Style = styleLine; } else { GSOSimpleLineStyle3D styleLine = (GSOSimpleLineStyle3D)line.Style; if (styleLine == null) { GSOPipeLineStyle3D pipeStyle = (GSOPipeLineStyle3D)line.Style; if (pipeStyle != null) { pipeStyle.LineColor = lineColor; pipeStyle.Radius = lineWidth / 2; line.Style = pipeStyle; } } else { styleLine.LineColor = lineColor; styleLine.LineWidth = lineWidth; line.Style = styleLine; } } } break; case EnumGeometryType.GeoPolygon3D: if (panelPolygons.Enabled) { GSOGeoPolygon3D polygon = (GSOGeoPolygon3D)feature.Geometry; if (polygon.Label != null) { polygon.Label.Visible = !checkBoxHideLabelOfPolygon.Checked; } GSOSimplePolygonStyle3D stylePolygon = (polygon.Style == null ? new GSOSimplePolygonStyle3D() : (GSOSimplePolygonStyle3D)polygon.Style); stylePolygon.FillColor = polygonColor; stylePolygon.OutLineVisible = true; GSOSimpleLineStyle3D styleOutline = (GSOSimpleLineStyle3D)stylePolygon.OutlineStyle; if (styleOutline == null) { styleOutline = new GSOSimpleLineStyle3D(); } styleOutline.LineWidth = outlineWidth; styleOutline.LineColor = outlineColor; stylePolygon.OutlineStyle = styleOutline; polygon.Style = stylePolygon; } break; } } } mGlobeControl.Globe.Refresh(); this.Close(); }
private void button3_Click(object sender, EventArgs e) { if (comboBoxDataSourceList.SelectedItem == null) { MessageBox.Show("请选择一个目标数据源!", "提示"); return; } GSODataSource ds = Utility.getDataSourceByFullName(globeControl1, comboBoxDataSourceList.SelectedItem.ToString().Trim()); if (ds == null) { MessageBox.Show("选择的目标数据源为空!", "提示"); return; } if (comboBoxShpLayerList.SelectedIndex < 0) { return; } try { if (valiValvedata()) { GSOFeatureDataset featdataset = CreateDBFeatureDataset(textBoxNewLayerName.Text); if (featdataset == null) { return; } featdataset.Open(); GSOLayer shpLayer = globeControl1.Globe.Layers[comboBoxShpLayerList.SelectedIndex]; if (shpLayer == null) { return; } GSOFeatures features = shpLayer.GetAllFeatures(true); string message = ""; for (int j = 0; j < features.Length; j++) { GSOFeature f = features[j]; GSOGeoPoint3D shpPoint = f.Geometry as GSOGeoPoint3D; double z = f.GetFieldAsDouble(combZ.SelectedItem.ToString()); double deep = f.GetFieldAsDouble(combZ.SelectedItem.ToString()); GSOFeature feature = featdataset.CreateFeature(); GSOGeoModel model = new GSOGeoModel(); GSOPoint3d pt = new GSOPoint3d(); pt.X = shpPoint.X; pt.Y = shpPoint.Y; pt.Z = z; model.Position = pt; model.AltitudeMode = EnumAltitudeMode.RelativeToGround; string modelPath = f.GetFieldAsString(combPath.SelectedItem.ToString()); model.FilePath = Application.StartupPath + "\\" + modelPath; model.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Name = f.GetValue(combModelName.SelectedItem.ToString()).ToString(); feature.Geometry = model; for (int i = 0; i < f.GetFieldCount(); i++) { GeoScene.Data.GSOFieldDefn fielddef = (GeoScene.Data.GSOFieldDefn)(f.GetFieldDefn(i)); if (fielddef == null) { continue; } if (!fm_cns.ContainsKey(fielddef.Name)) { continue; } object obu = f.GetValue(fielddef.Name); if (obu != null) { string fieldName = fm_cns.ContainsKey(fielddef.Name) == true ? fm_cns[fielddef.Name].ToString() : fielddef.Name; feature.SetValue(fieldName, obu); } } featdataset.AddFeature(feature); } featdataset.Save(); string strMessage = "shp文件中共" + features.Length + "个对象,实际入库" + featdataset.GetAllFeatures().Length + "个对象!\r\n"; if (message == "") { MessageBox.Show(strMessage, "提示"); } else { FrmMessageShow frm = new FrmMessageShow(strMessage + message); frm.ShowDialog(); } this.Close(); } } catch (Exception ex) { Log.PublishTxt(ex); MessageBox.Show(ex.Message); } }