private void btnExportCAD_Click(object sender, EventArgs e) { globeControl1.Globe.MemoryLayer.RemoveAllFeature(); int id = GeoScene.Data.GSOProjectManager.AddProject("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs"); for (int i = 0; i < listPoint.Count; i++) { GSOPoint3d geoPoint = (GSOPoint3d)listPoint[i]; GSOFeature feature = listFeat[i] as GSOFeature; if (feature != null) { if (feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOPipeLineStyle3D style = feature.Geometry.Style as GSOPipeLineStyle3D; double r = style.Radius; //ExportCAD(double.Parse(sortIndex[i, 0].ToString()), geoPoint.Z, r); Export(geoPoint, r); } } } GSOLayer layer = globeControl1.Globe.MemoryLayer; layer.Dataset.ImportProjectionRefFromProj4("+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=555484.8092 +y_0=-4114948.631 +ellps=krass +units=m +no_defs"); SaveFileDialog dlg = new SaveFileDialog(); dlg.Filter = "*.dxf|*.dxf"; if (dlg.ShowDialog() == DialogResult.OK) { layer.SaveAs(dlg.FileName); globeControl1.Globe.MemoryLayer.RemoveAllFeature(); MessageBox.Show("导出CAD完成!", "提示"); } }
private void buttonMerge_Click(object sender, EventArgs e) { GSOLayer layerlgd = mGlobeControl.Globe.Layers.Add(textBoxLgdPath.Text.Trim()); GSOLayer layerkml = mGlobeControl.Globe.Layers.Add(textBoxKmlPath.Text.Trim()); GSOLayer newlayer = mGlobeControl.Globe.Layers.Add(textBoxSavePath.Text.Trim()); if (layerlgd.GetAllFeatures().Length > 0) { GSOFeatures features = layerlgd.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; newlayer = AddFeatureAndFeatureFolder(feature, newlayer); } } if (layerkml.GetAllFeatures().Length > 0) { GSOFeatures features = layerkml.GetAllFeatures(); for (int i = 0; i < features.Length; i++) { GSOFeature feature = features[i]; newlayer = AddFeatureAndFeatureFolder(feature, newlayer); } } if (newlayer.GetAllFeatures().Length > 0) { newlayer.SaveAs(textBoxSavePath.Text.Trim()); MessageBox.Show("合并成功", "提示"); } else { MessageBox.Show("将要合并的图层不符合要求", "提示"); } this.Close(); }
private void buttonOK_Click(object sender, EventArgs e) { string filename = textbox1.Text.Trim(); GSOLayer newlayer = mGlobeControl.Globe.Layers.Add(filename); int indexCount = filename.LastIndexOf('.') - filename.LastIndexOf('\\') - 1; string newlayerCaption = ""; if (indexCount > 0) { newlayerCaption = filename.Substring(filename.LastIndexOf('\\') + 1, indexCount); newlayer.Caption = newlayerCaption; } for (int i = 0; i < mListPolygon.Count; i++) { GSOGeoPolygon3D polygon = mListPolygon[i]; string caption = ""; if (comboBoxLayerName.SelectedIndex >= 0) { caption = comboBoxLayerName.SelectedItem.ToString().Trim(); } GSOLayer layer = mGlobeControl.Globe.Layers.GetLayerByCaption(caption); GSOFeatures feats = new GSOFeatures(); if (layer != null) { feats = layer.FindFeaturesInPolygon(polygon, false); } if (feats != null) { newlayer.AddFeatures(feats); } } if (newlayer != null) { newlayer.SaveAs(filename); MessageBox.Show("导出成功!", "提示"); } this.Close(); }
private void buttonOK_Click(object sender, EventArgs e) { string layerPath = textBoxLayerPath.Text.Trim(); if (layerPath == "") { MessageBox.Show("请选择目标文件!", "提示"); return; } string featureMinLength = textBoxFeatureMinLength.Text.Trim(); double minLength = 0; if (!double.TryParse(featureMinLength, out minLength)) { MessageBox.Show("请输入正确的最小长度值!", "提示"); return; } string featureMaxLength = textBoxFeatureMaxLength.Text.Trim(); double maxLength = 0; if (!double.TryParse(featureMaxLength, out maxLength)) { MessageBox.Show("请输入正确的最大长度值!", "提示"); return; } string featureCount = textBoxFeatureCount.Text.Trim(); int count = 0; if (checkBoxFeatureCount.Checked) { if (!int.TryParse(featureCount, out count)) { MessageBox.Show("请输入正确的要素个数值!", "提示"); return; } } GSOLayer layer = globeControl1.Globe.Layers.Add(layerPath); if (layer != null) { do { for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) { GSOFeature feature = layer.GetAt(i); if (feature != null && feature.Geometry != null && feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; double length = line.GetSpaceLength(false, 6378137.0); if (length >= minLength && length <= maxLength) { feature.Delete(); } } //else //{ // feature.Delete(); //} } maxLength++; }while (checkBoxFeatureCount.Checked && layer.GetAllFeatures().Length > 30000); layer.SaveAs(Path.GetDirectoryName(textBoxLayerPath.Text.Trim()) + "/" + layer.Caption + "-处理后" + Path.GetExtension(textBoxLayerPath.Text.Trim())); MessageBox.Show("删除成功!", "提示"); } }
private void button2_Click(object sender, EventArgs e) { double dMinLon = 0, dMaxLon = 0, dMinLat = 0, dMaxLat = 0; string strLayerPath = saveFileDialog1.FileName; string path = Application.StartupPath + "\\Resource\\image\\DefaultIcon.png"; if (string.IsNullOrEmpty(saveFileDialog1.FileName)) { MessageBox.Show("请选择存储目录"); return; } globeControl1.Globe.MemoryLayer.SaveAs(strLayerPath); layerTemp = globeControl1.Globe.Layers.Add(strLayerPath); layerTemp.RemoveAllFeature(); GSOGeoPolyline3D polyLine = new GSOGeoPolyline3D(); GSOPoint3ds pois = new GSOPoint3ds(); for (int i = 0; i < listView1.Items.Count; i++) { ListViewItem item = listView1.Items[i]; double lon, lat; if (!double.TryParse(item.SubItems[3].Text.ToString() == "" ? "0" : item.SubItems[3].Text.ToString(), out lon)) { MessageBox.Show("经度参数不合法"); return; } if (!double.TryParse(item.SubItems[4].Text.ToString() == "" ? "0" : item.SubItems[4].Text.ToString(), out lat)) { MessageBox.Show("纬度参数不合法"); return; } if (i == 0) { dMaxLon = lon; dMinLon = lon; dMinLat = lat; dMaxLat = lat; } GSOPoint3d node = new GSOPoint3d(lon, lat, 0); pois.Add(node); string strDescriptionPrefix = "<![CDATA[<!-- <BALLOON><CONTENT_CX>800</CONTENT_CX><CONTENT_CY>600</CONTENT_CY>" + "<CONTENT_TYPE>link</CONTENT_TYPE><SHOW_MODE>balloonex</SHOW_MODE>-->"; string strDescription = strDescriptionPrefix + "file:\\\\" + Application.StartupPath + "\\Resource\\Page\\pic_route.html"; strDescription += "?URL=" + item.SubItems[5].Text.ToString(); //strDescription += "]]>"; AddMarker(item.SubItems[1].Text.ToString(), lon, lat, path, strDescription, layerTemp); if (lon < dMinLon) { dMinLon = lon; } else if (lon > dMaxLon) { dMaxLon = lon; } if (lat < dMinLat) { dMinLat = lat; } else if (lat > dMaxLat) { dMaxLat = lat; } } if (layerTemp == null) { MessageBox.Show("没有生成轨迹的数据"); return; } polyLine.AddPart(pois); GSOFeature feature = new GSOFeature(); feature.Geometry = polyLine; layerTemp.AddFeature(feature);//添加线 layerTemp.SaveAs(strLayerPath); globeControl1.Globe.FlyToFeature(feature); }