| | |
| | | |
| | | string angleGroupName = "角量算"; |
| | | |
| | | string shpGroupName = "矢量数据"; |
| | | |
| | | string mainUrl = Application.StartupPath; |
| | | |
| | | public FrmWin() |
| | |
| | | InvokeOsgbLab(); break; |
| | | case 0xd7: // 打开fly |
| | | SG.Open(this.fly); break; |
| | | case 0xd8: // 加载shp |
| | | LoadShp(); break; |
| | | } |
| | | } |
| | | |
| | |
| | | ExecCmd(new List<string> { "taskkill /f /t /im OSGBLab.exe" }); |
| | | RunExe(GetAbsolutePath("osgblabPath"), null, false); |
| | | } |
| | | |
| | | private void LoadShp() |
| | | { |
| | | OpenFileDialog dialog = new OpenFileDialog(); |
| | | dialog.Filter = "Shapefile文件 (*.shp)|*.shp"; |
| | | dialog.RestoreDirectory = true; |
| | | |
| | | if (dialog.ShowDialog() == DialogResult.OK) |
| | | { |
| | | LoadShp(dialog.FileName); |
| | | } |
| | | } |
| | | |
| | | private void LoadShp(string shpFile) |
| | | { |
| | | string gid = GetGroupIdByName(shpGroupName); |
| | | string conn = "FileName=" + shpFile + ";TEPlugName=OGR;"; // 连接字符串 |
| | | string shpName = Path.GetFileNameWithoutExtension(shpFile); |
| | | |
| | | IFeatureLayer71 layer = SG.Creator.CreateFeatureLayer(shpName, conn, gid); // 加载shp |
| | | layer.Refresh(); |
| | | |
| | | SG.Navigate.FlyTo(layer.ID); |
| | | } |
| | | |
| | | private string GetGroupIdByName(string groupName) |
| | | { |
| | | string gid = SG.ProjectTree.FindItem(groupName); |
| | | if (string.IsNullOrEmpty(gid) || !SG.ProjectTree.IsGroup(gid)) |
| | | { |
| | | gid = SG.ProjectTree.CreateGroup(groupName, SG.ProjectTree.RootID); |
| | | } |
| | | |
| | | return gid; |
| | | } |
| | | } |
| | | } |