diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmBufferAnalysisBSQ.cs b/FrmBufferAnalysisBSQ.cs index d887d47..e08dba3 100644 --- a/FrmBufferAnalysisBSQ.cs +++ b/FrmBufferAnalysisBSQ.cs @@ -28,13 +28,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } if (txtRadius.Text != "" && pt != null) @@ -127,34 +125,28 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) + string featNum = feats[i].GetFieldAsString("编号"); + if (feats[i].GetFieldDefn("标识器编号") != null) { - string featNum = feats[i].GetFieldAsString("编号"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - if (markList.Contains(featNum) == false) - { - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["编号"].Value = featNum; - row.Cells["图层名称"].Value = layername; - markList.Add(featNum); - } - else - { - return; - } + featNum = feats[i].GetFieldAsString("标识器编号"); + } + if (markList.Contains(featNum) == false) + { + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["编号"].Value = featNum; + row.Cells["图层名称"].Value = layername; + markList.Add(featNum); + } + else + { + return; } } } @@ -210,48 +202,42 @@ { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -263,22 +249,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -295,38 +269,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -340,23 +308,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmBufferAnalysisBSQ.cs b/FrmBufferAnalysisBSQ.cs index d887d47..e08dba3 100644 --- a/FrmBufferAnalysisBSQ.cs +++ b/FrmBufferAnalysisBSQ.cs @@ -28,13 +28,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } if (txtRadius.Text != "" && pt != null) @@ -127,34 +125,28 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) + string featNum = feats[i].GetFieldAsString("编号"); + if (feats[i].GetFieldDefn("标识器编号") != null) { - string featNum = feats[i].GetFieldAsString("编号"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - if (markList.Contains(featNum) == false) - { - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["编号"].Value = featNum; - row.Cells["图层名称"].Value = layername; - markList.Add(featNum); - } - else - { - return; - } + featNum = feats[i].GetFieldAsString("标识器编号"); + } + if (markList.Contains(featNum) == false) + { + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["编号"].Value = featNum; + row.Cells["图层名称"].Value = layername; + markList.Add(featNum); + } + else + { + return; } } } @@ -210,48 +202,42 @@ { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -263,22 +249,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -295,38 +269,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -340,23 +308,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index ac622c4..0a5d0b0 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -43,27 +43,28 @@ globeControl2.MouseClick += globeControl2_MouseClick; } - private void invalParam() + private bool InvalParam() { if (srcFeature == null || dscFeature == null) { MessageBox.Show("请选择要对比的管段!", "提示"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) { MessageBox.Show("请选择同种类型图层!"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || - srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) - return; + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return false; + return true; } private void buttonAnalysis_Click(object sender, EventArgs e) { - invalParam(); - + bool isvalid = InvalParam(); + if (!isvalid) return; dataGridViewX1.DataSource = null; lineFeatureCompare(srcFeature, dscFeature); } @@ -75,11 +76,13 @@ private void lineFeatureCompare(GSOFeature srcFeature, GSOFeature dscFeature) { GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - double srcLineLength = srcLine.GetSpaceLength(false, 6378137); + if (srcLine == null) return; GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; + if (dscLine == null) return; + double srcLineLength = srcLine.GetSpaceLength(false, 6378137); double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - + double horizonDistance, verticalDistance; ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, @@ -136,26 +139,13 @@ globeControl2.Refresh(); } - public static void clearFeatureHighLight(GSOGlobeControl glb) - { - for (int i = 0; i < glb.Globe.Layers.Count; i++) - { - GSOLayer layer = glb.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - feats[j].HighLight = false; - } - } - } void globeControl1_MouseClick(object sender, MouseEventArgs e) { if (globeControl1.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { @@ -181,10 +171,10 @@ void globeControl2_MouseClick(object sender, MouseEventArgs e) { - + if (globeControl2.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmBufferAnalysisBSQ.cs b/FrmBufferAnalysisBSQ.cs index d887d47..e08dba3 100644 --- a/FrmBufferAnalysisBSQ.cs +++ b/FrmBufferAnalysisBSQ.cs @@ -28,13 +28,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } if (txtRadius.Text != "" && pt != null) @@ -127,34 +125,28 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) + string featNum = feats[i].GetFieldAsString("编号"); + if (feats[i].GetFieldDefn("标识器编号") != null) { - string featNum = feats[i].GetFieldAsString("编号"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - if (markList.Contains(featNum) == false) - { - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["编号"].Value = featNum; - row.Cells["图层名称"].Value = layername; - markList.Add(featNum); - } - else - { - return; - } + featNum = feats[i].GetFieldAsString("标识器编号"); + } + if (markList.Contains(featNum) == false) + { + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["编号"].Value = featNum; + row.Cells["图层名称"].Value = layername; + markList.Add(featNum); + } + else + { + return; } } } @@ -210,48 +202,42 @@ { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -263,22 +249,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -295,38 +269,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -340,23 +308,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index ac622c4..0a5d0b0 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -43,27 +43,28 @@ globeControl2.MouseClick += globeControl2_MouseClick; } - private void invalParam() + private bool InvalParam() { if (srcFeature == null || dscFeature == null) { MessageBox.Show("请选择要对比的管段!", "提示"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) { MessageBox.Show("请选择同种类型图层!"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || - srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) - return; + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return false; + return true; } private void buttonAnalysis_Click(object sender, EventArgs e) { - invalParam(); - + bool isvalid = InvalParam(); + if (!isvalid) return; dataGridViewX1.DataSource = null; lineFeatureCompare(srcFeature, dscFeature); } @@ -75,11 +76,13 @@ private void lineFeatureCompare(GSOFeature srcFeature, GSOFeature dscFeature) { GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - double srcLineLength = srcLine.GetSpaceLength(false, 6378137); + if (srcLine == null) return; GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; + if (dscLine == null) return; + double srcLineLength = srcLine.GetSpaceLength(false, 6378137); double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - + double horizonDistance, verticalDistance; ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, @@ -136,26 +139,13 @@ globeControl2.Refresh(); } - public static void clearFeatureHighLight(GSOGlobeControl glb) - { - for (int i = 0; i < glb.Globe.Layers.Count; i++) - { - GSOLayer layer = glb.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - feats[j].HighLight = false; - } - } - } void globeControl1_MouseClick(object sender, MouseEventArgs e) { if (globeControl1.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { @@ -181,10 +171,10 @@ void globeControl2_MouseClick(object sender, MouseEventArgs e) { - + if (globeControl2.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { diff --git a/FrmGBJC.cs b/FrmGBJC.cs index 6c6447c..a118875 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -112,7 +112,7 @@ if (scLayer == null || sgLayer == null) return; - DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, + DataTable dt = DoublePanelAnalysis.CompareLayerByRoad(scLayer, sgLayer, comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmBufferAnalysisBSQ.cs b/FrmBufferAnalysisBSQ.cs index d887d47..e08dba3 100644 --- a/FrmBufferAnalysisBSQ.cs +++ b/FrmBufferAnalysisBSQ.cs @@ -28,13 +28,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } if (txtRadius.Text != "" && pt != null) @@ -127,34 +125,28 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) + string featNum = feats[i].GetFieldAsString("编号"); + if (feats[i].GetFieldDefn("标识器编号") != null) { - string featNum = feats[i].GetFieldAsString("编号"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - if (markList.Contains(featNum) == false) - { - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["编号"].Value = featNum; - row.Cells["图层名称"].Value = layername; - markList.Add(featNum); - } - else - { - return; - } + featNum = feats[i].GetFieldAsString("标识器编号"); + } + if (markList.Contains(featNum) == false) + { + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["编号"].Value = featNum; + row.Cells["图层名称"].Value = layername; + markList.Add(featNum); + } + else + { + return; } } } @@ -210,48 +202,42 @@ { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -263,22 +249,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -295,38 +269,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -340,23 +308,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index ac622c4..0a5d0b0 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -43,27 +43,28 @@ globeControl2.MouseClick += globeControl2_MouseClick; } - private void invalParam() + private bool InvalParam() { if (srcFeature == null || dscFeature == null) { MessageBox.Show("请选择要对比的管段!", "提示"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) { MessageBox.Show("请选择同种类型图层!"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || - srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) - return; + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return false; + return true; } private void buttonAnalysis_Click(object sender, EventArgs e) { - invalParam(); - + bool isvalid = InvalParam(); + if (!isvalid) return; dataGridViewX1.DataSource = null; lineFeatureCompare(srcFeature, dscFeature); } @@ -75,11 +76,13 @@ private void lineFeatureCompare(GSOFeature srcFeature, GSOFeature dscFeature) { GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - double srcLineLength = srcLine.GetSpaceLength(false, 6378137); + if (srcLine == null) return; GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; + if (dscLine == null) return; + double srcLineLength = srcLine.GetSpaceLength(false, 6378137); double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - + double horizonDistance, verticalDistance; ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, @@ -136,26 +139,13 @@ globeControl2.Refresh(); } - public static void clearFeatureHighLight(GSOGlobeControl glb) - { - for (int i = 0; i < glb.Globe.Layers.Count; i++) - { - GSOLayer layer = glb.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - feats[j].HighLight = false; - } - } - } void globeControl1_MouseClick(object sender, MouseEventArgs e) { if (globeControl1.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { @@ -181,10 +171,10 @@ void globeControl2_MouseClick(object sender, MouseEventArgs e) { - + if (globeControl2.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { diff --git a/FrmGBJC.cs b/FrmGBJC.cs index 6c6447c..a118875 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -112,7 +112,7 @@ if (scLayer == null || sgLayer == null) return; - DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, + DataTable dt = DoublePanelAnalysis.CompareLayerByRoad(scLayer, sgLayer, comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); diff --git a/MainFrm.cs b/MainFrm.cs index f848026..ac37ae5 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -3365,9 +3365,9 @@ return dismarker.Position; } - #region wxl重构未完成 + #region wxl /// - /// 碰撞分析 + /// wxl重构,碰撞分析 /// /// /// @@ -3423,7 +3423,7 @@ } /// - /// 垂直净距分析,暂时没有在地图上标注 + /// wxl重构,垂直净距分析 /// /// /// @@ -3533,7 +3533,6 @@ featLenth.Clear(); listBox3.Items.Clear(); layerTemp.RemoveAllFeature(); - //polygonJingJuAnalysises.RemoveAll(); clearFeatureHighLight(); dataGridViewX9.Rows.Clear(); Cursor = Cursors.WaitCursor; @@ -3572,6 +3571,7 @@ /// private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, double dis) { + Dictionary featureMap = DoublePanelAnalysis.HorizontalDistanceAnalysis(globeControl1,selectedFeature, _pipelineLayerNames, dis); if (featureMap == null) @@ -4281,10 +4281,9 @@ dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx2.SelectedItem.ToString()); - if (layer == null) - return; - + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + if (flayer == null) return; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { @@ -7414,13 +7413,17 @@ GSOFeature f; GSOLayer layer; globeControl1.Globe.GetSelectObject(i, out f, out layer); - if (f == null) continue; - f.Delete(); - if (layer != null) - globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); +// if (f == null) continue; +// f.Delete(); +// if (layer != null) +// globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); + FeatureTools.DeleteFeature(f); + globeControl1.Refresh(); + } + MessageBox.Show("删除成功!", "提示"); globeControl1.Globe.Action = EnumAction3D.ActionNull; } diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmBufferAnalysisBSQ.cs b/FrmBufferAnalysisBSQ.cs index d887d47..e08dba3 100644 --- a/FrmBufferAnalysisBSQ.cs +++ b/FrmBufferAnalysisBSQ.cs @@ -28,13 +28,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } if (txtRadius.Text != "" && pt != null) @@ -127,34 +125,28 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) + string featNum = feats[i].GetFieldAsString("编号"); + if (feats[i].GetFieldDefn("标识器编号") != null) { - string featNum = feats[i].GetFieldAsString("编号"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - if (markList.Contains(featNum) == false) - { - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["编号"].Value = featNum; - row.Cells["图层名称"].Value = layername; - markList.Add(featNum); - } - else - { - return; - } + featNum = feats[i].GetFieldAsString("标识器编号"); + } + if (markList.Contains(featNum) == false) + { + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["编号"].Value = featNum; + row.Cells["图层名称"].Value = layername; + markList.Add(featNum); + } + else + { + return; } } } @@ -210,48 +202,42 @@ { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -263,22 +249,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -295,38 +269,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -340,23 +308,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index ac622c4..0a5d0b0 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -43,27 +43,28 @@ globeControl2.MouseClick += globeControl2_MouseClick; } - private void invalParam() + private bool InvalParam() { if (srcFeature == null || dscFeature == null) { MessageBox.Show("请选择要对比的管段!", "提示"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) { MessageBox.Show("请选择同种类型图层!"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || - srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) - return; + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return false; + return true; } private void buttonAnalysis_Click(object sender, EventArgs e) { - invalParam(); - + bool isvalid = InvalParam(); + if (!isvalid) return; dataGridViewX1.DataSource = null; lineFeatureCompare(srcFeature, dscFeature); } @@ -75,11 +76,13 @@ private void lineFeatureCompare(GSOFeature srcFeature, GSOFeature dscFeature) { GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - double srcLineLength = srcLine.GetSpaceLength(false, 6378137); + if (srcLine == null) return; GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; + if (dscLine == null) return; + double srcLineLength = srcLine.GetSpaceLength(false, 6378137); double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - + double horizonDistance, verticalDistance; ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, @@ -136,26 +139,13 @@ globeControl2.Refresh(); } - public static void clearFeatureHighLight(GSOGlobeControl glb) - { - for (int i = 0; i < glb.Globe.Layers.Count; i++) - { - GSOLayer layer = glb.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - feats[j].HighLight = false; - } - } - } void globeControl1_MouseClick(object sender, MouseEventArgs e) { if (globeControl1.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { @@ -181,10 +171,10 @@ void globeControl2_MouseClick(object sender, MouseEventArgs e) { - + if (globeControl2.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { diff --git a/FrmGBJC.cs b/FrmGBJC.cs index 6c6447c..a118875 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -112,7 +112,7 @@ if (scLayer == null || sgLayer == null) return; - DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, + DataTable dt = DoublePanelAnalysis.CompareLayerByRoad(scLayer, sgLayer, comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); diff --git a/MainFrm.cs b/MainFrm.cs index f848026..ac37ae5 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -3365,9 +3365,9 @@ return dismarker.Position; } - #region wxl重构未完成 + #region wxl /// - /// 碰撞分析 + /// wxl重构,碰撞分析 /// /// /// @@ -3423,7 +3423,7 @@ } /// - /// 垂直净距分析,暂时没有在地图上标注 + /// wxl重构,垂直净距分析 /// /// /// @@ -3533,7 +3533,6 @@ featLenth.Clear(); listBox3.Items.Clear(); layerTemp.RemoveAllFeature(); - //polygonJingJuAnalysises.RemoveAll(); clearFeatureHighLight(); dataGridViewX9.Rows.Clear(); Cursor = Cursors.WaitCursor; @@ -3572,6 +3571,7 @@ /// private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, double dis) { + Dictionary featureMap = DoublePanelAnalysis.HorizontalDistanceAnalysis(globeControl1,selectedFeature, _pipelineLayerNames, dis); if (featureMap == null) @@ -4281,10 +4281,9 @@ dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx2.SelectedItem.ToString()); - if (layer == null) - return; - + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + if (flayer == null) return; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { @@ -7414,13 +7413,17 @@ GSOFeature f; GSOLayer layer; globeControl1.Globe.GetSelectObject(i, out f, out layer); - if (f == null) continue; - f.Delete(); - if (layer != null) - globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); +// if (f == null) continue; +// f.Delete(); +// if (layer != null) +// globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); + FeatureTools.DeleteFeature(f); + globeControl1.Refresh(); + } + MessageBox.Show("删除成功!", "提示"); globeControl1.Globe.Action = EnumAction3D.ActionNull; } diff --git a/NewFunction/FrmFloodAnalysis.cs b/NewFunction/FrmFloodAnalysis.cs index 2031ecf..c599ab0 100644 --- a/NewFunction/FrmFloodAnalysis.cs +++ b/NewFunction/FrmFloodAnalysis.cs @@ -103,14 +103,7 @@ GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); - if (checkBoxExtrude.Checked) - { - extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; - } - else - { - extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; - } + extrudeStyle.ExtrudeType = checkBoxExtrude.Checked ? EnumExtrudeType.ExtrudeToValue : EnumExtrudeType.ExtrudeNone; extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; @@ -151,32 +144,30 @@ private void timerPlay_Tick(object sender, EventArgs e) { - if (m_WaterFeature != null) + if (m_WaterFeature == null) return; + if (m_dBaseAlt > m_pntMaxAlt.Z) { - if (m_dBaseAlt > m_pntMaxAlt.Z) + if (checkBoxLoopPlay.Checked) { - if (checkBoxLoopPlay.Checked) - { - m_dBaseAlt = m_pntMinAlt.Z; - } - else - { - timerPlay.Stop(); - } + m_dBaseAlt = m_pntMinAlt.Z; } - - m_dBaseAlt += (double)numericUpDownAddPerTime.Value; - - m_globe.Analysis3D.FetchNoSourceFloodAnalyseResult(m_dBaseAlt, out m_dFloodArea, out m_dTotalArea, - out m_pntMaxAlt, out m_pntMinAlt); - - SetText(); - - textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); - trackBarAlt.Value = Math.Min((int)m_dBaseAlt, trackBarAlt.Maximum); - GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; - geoWater.SetAltitude(m_dBaseAlt); + else + { + timerPlay.Stop(); + } } + + m_dBaseAlt += (double)numericUpDownAddPerTime.Value; + + m_globe.Analysis3D.FetchNoSourceFloodAnalyseResult(m_dBaseAlt, out m_dFloodArea, out m_dTotalArea, + out m_pntMaxAlt, out m_pntMinAlt); + + SetText(); + + textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); + trackBarAlt.Value = Math.Min((int)m_dBaseAlt, trackBarAlt.Maximum); + GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; + geoWater.SetAltitude(m_dBaseAlt); } private void trackBarAlt_Scroll(object sender, EventArgs e) @@ -196,19 +187,9 @@ private void checkBoxExtrude_CheckedChanged(object sender, EventArgs e) { - if (m_WaterFeature != null) - { - GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; - if (checkBoxExtrude.Checked) - { - geoWater.ExtrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; - } - else - { - geoWater.ExtrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; - - } - } + if (m_WaterFeature == null) return; + GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; + geoWater.ExtrudeStyle.ExtrudeType = checkBoxExtrude.Checked ? EnumExtrudeType.ExtrudeToValue : EnumExtrudeType.ExtrudeNone; } private void buttonSetPlayParam_Click(object sender, EventArgs e) diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index 692ef01..1a8ceca 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -19,7 +19,7 @@ if (!feature.Dataset.Caption.StartsWith("施工")) { - layer = feature.Dataset.Caption == "供电管线" + layer = feature.Dataset.Caption.Equals("供电管线") ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); @@ -33,7 +33,7 @@ } else { - layer = feature.Dataset.Caption == "施工电力管线" + layer = feature.Dataset.Caption.Equals("施工电力管线") ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); @@ -88,6 +88,7 @@ private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) { GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + if (line == null) return false; GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); if (bufferPolygon == null) return false; diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index c3f8ecc..209373c 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -237,6 +237,7 @@ + Form diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 5a44320..c242b82 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -13,48 +13,23 @@ public static int bufferWidth = 8; public static string strLabel; - public static void CalculateDistance(out double vertical, out double horizon, GSOGeoPolyline3D line1, - GSOGeoPolyline3D line2, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - vertical = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - horizon = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - } public static void clearFeatureHighLight(GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { - ClearHighlight(globeControl1); - ClearHighlight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); } - static void ClearHighlight(GSOGlobeControl ctl) - { - for (int i = 0; i < ctl.Globe.Layers.Count; i++) - { - GSOLayer layer = ctl.Globe.Layers[i]; - if (layer is GSOFeatureLayer) - { - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - } - - /// - /// 单Feature对比方法 - /// - /// - /// - public static DataTable lineFeatureCompare(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + /// + /// 国标检测中根据道路比较实测图层和施工图层是否符合标准 + /// + /// + /// + /// + /// + /// + /// + public static DataTable CompareLayerByRoad(GSOLayer scLayer, GSOLayer sgLayer, string road, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) { DataTable dt = new DataTable(); dt.Columns.Add("实测图层"); @@ -70,24 +45,21 @@ if (scLayer.Caption.Contains("给水") || scLayer.Caption.Contains("雨水") || scLayer.Caption.Contains("污水") || scLayer.Caption.Contains("雨污")) { strLabel = "目标图层包含不符合《给水排水构筑物工程施工及验收规范》(GB50141-2008)要求的管段,具体内容如下:"; -// CreateJiPaiShuiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if(scLayer.Caption.Contains("燃气")) { strLabel = "目标图层包含不符合《聚乙烯燃气管道工程技术规程》(GJJ63-2008)要求的管段,具体内容如下:"; -// CreateRanQiDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } else if (scLayer.Caption.Contains("供电")) { strLabel = "目标图层包含不符合《电力建设施工及验收技术规范》 (DL5031-94)要求的管段,具体内容如下:"; -// CreateGongDianDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); } GBJCDataTable(scLayer, sgLayer, road, dt, globeControl1, globeControl2); return dt; } #region Fan Zhang 重构feature获取 - public static double getLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) + public static double GetLineLength(GSOFeature src,GSOLayer srcLayer,GSOGeoPolygon3D bufferPolygon) { GSOFeatures fullInPolygonFeatures = srcLayer.FindFeaturesInPolygon(bufferPolygon, true); @@ -160,7 +132,7 @@ for (int m = 0; m < sgFeaturesList.Length; m++) { GSOFeature tempFeature = sgFeaturesList[m]; - double tempLength = getLineLength(tempFeature, sgLayer, bufferPolygon); + double tempLength = GetLineLength(tempFeature, sgLayer, bufferPolygon); double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); if (lengthAbs < maxLength) @@ -233,7 +205,7 @@ { GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; double horizonDistance, verticalDistance; - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine, globeControl1, + ClassDoubleScreenCompare.CalculateDistance(scLine, sgLine, out verticalDistance, out horizonDistance, globeControl1, globeControl2); RowValueInsert(scFeature, sgFeature, horizonDistance, verticalDistance,hStandard,vStandard,dt); diff --git a/FeatureTools.cs b/FeatureTools.cs new file mode 100644 index 0000000..cfa1b3d --- /dev/null +++ b/FeatureTools.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using GeoScene.Data; +using GeoScene.Globe; + +namespace Cyberpipe +{ + class FeatureTools + { + /// + /// 清除地球上所有高亮的要素 + /// + /// + public static void ClearAllFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + public static bool DeleteFeature(GSOFeature feature) + { + try + { + string layerName = feature.Dataset.Caption; + + //编号为空,为了限制删除的仅是用户自己添加的feature + string bh = feature.GetFieldAsString("编号"); + if (bh!= null&&!bh.Trim().Equals("")) + { + MessageBox.Show("非自定义创建要素,不可删除"); + return false; + } + feature.Delete();//地球上删除该feature + string sql = "delete from " + layerName + " where 编码 =" + feature.GetFieldAsString("编码") + " and 编号 is null"; + OledbHelper.sqlExecuteNonQuery(sql);//目前无法取到LSSYS_ID,所以这个判断条件不太合适,会导致把该类所有新建的都删除了 + } + catch (Exception) + { + return false; + } + return true; + } + + } +} diff --git a/FrmAccessoryAnalysis.cs b/FrmAccessoryAnalysis.cs index 87727c4..190d82c 100644 --- a/FrmAccessoryAnalysis.cs +++ b/FrmAccessoryAnalysis.cs @@ -135,35 +135,27 @@ } private void Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername)//方法修改,返回类型由int类型修改为GSOFeatures { - GSOFeatures feats = new GSOFeatures(); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + GSOFeatures feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) - { - string featNum = feats[i].GetFieldAsString("编号"); - string featType = feats[i].GetFieldAsString("附属物名称"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["图层名称"].Value = layername; - row.Cells["附属物名称"].Value = featType; - row.Cells["编号"].Value = featNum; + string featNum = feats[i].GetFieldAsString("编号"); + string featType = feats[i].GetFieldAsString("附属物名称"); + if (feats[i].GetFieldDefn("标识器编号") != null) + { + featNum = feats[i].GetFieldAsString("标识器编号"); } + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["图层名称"].Value = layername; + row.Cells["附属物名称"].Value = featType; + row.Cells["编号"].Value = featNum; } } @@ -188,50 +180,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -243,21 +229,17 @@ if (count < 40) { count++; - if (flashflag == "single") + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + if (count % 2 != 0) { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } + m_feature.HighLight = true; + globeControl1.Refresh(); + } + else + { + m_feature.HighLight = false; + globeControl1.Refresh(); } } else @@ -282,26 +264,22 @@ //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) + if (!features[j].Name.Equals(featureName)) continue; + m_feature = features[j]; + if (m_feature.Geometry != null) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null) - { - globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); - } - LightMenu_Click(sender, e); - break; - } + globeControl1.Globe.FlyToGeometry(m_feature.Geometry, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 5); + } + LightMenu_Click(sender, e); + break; } } } @@ -317,25 +295,23 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + pt.X = point3d.X; + pt.Y = point3d.Y; + pt.Z = point3d.Z; + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); + } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmAddInstrument.cs b/FrmAddInstrument.cs index 683c3be..2c0ea07 100644 --- a/FrmAddInstrument.cs +++ b/FrmAddInstrument.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Security.Cryptography.X509Certificates; using System.Windows.Forms; using DevComponents.DotNetBar; using GeoScene.Data; @@ -25,6 +26,7 @@ panel1.Controls.Add(plane3DControl); plane3DControl.Dock = DockStyle.Fill; } + /// /// 添加按钮事件处理 /// @@ -32,37 +34,37 @@ /// private void btnAdd_Click(object sender, EventArgs e) { - if (feature != null) + if (feature == null) { - if (markerFeature != null) - { - markerFeature.Delete(); - } - GSOPoint3d pt = new GSOPoint3d(); - pt.X = point.X; - pt.Y = point.Y; - pt.Z = point.Z; - GSOGeoModel model = new GSOGeoModel(); - model.FilePath = modelPath; - model.Position = pt; - model.AltitudeMode = EnumAltitudeMode.Absolute; - feature = new GSOFeature(); - feature.Geometry = model; - modelLayer.AddFeature(feature); - if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) - { - modelLayer.Save(); - } - globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); - globeControl1.Refresh(); - } - else - { - MessageBox.Show("请选中一个附属物!","提示"); + MessageBox.Show("请选中一个附属物!", "提示"); return; } - Close(); + + if (markerFeature != null) + { + markerFeature.Delete(); + } + GSOPoint3d pt = new GSOPoint3d(); + pt.X = point.X; + pt.Y = point.Y; + pt.Z = point.Z; + GSOGeoModel model = new GSOGeoModel(); + model.FilePath = modelPath; + model.Position = pt; + model.AltitudeMode = EnumAltitudeMode.Absolute; + feature = new GSOFeature(); + feature.Geometry = model; + modelLayer.AddFeature(feature); + if (MessageBox.Show("是否保存到数据库?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + modelLayer.Save(); + } + globeControl1.Globe.FlyToFeature(feature, 0, 45, 3); + globeControl1.Refresh(); + + Close(); } + /// /// 关闭按钮事件处理 /// diff --git a/FrmAddInstrument.designer.cs b/FrmAddInstrument.designer.cs index 2ebab1d..307d2c6 100644 --- a/FrmAddInstrument.designer.cs +++ b/FrmAddInstrument.designer.cs @@ -56,10 +56,9 @@ this.groupPanel1.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel1.Controls.Add(this.listBoxSize); this.groupPanel1.Controls.Add(this.label2); - this.groupPanel1.Location = new System.Drawing.Point(15, 58); - this.groupPanel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel1.Location = new System.Drawing.Point(11, 46); this.groupPanel1.Name = "groupPanel1"; - this.groupPanel1.Size = new System.Drawing.Size(611, 125); + this.groupPanel1.Size = new System.Drawing.Size(458, 100); // // // @@ -96,11 +95,10 @@ // listBoxSize // this.listBoxSize.FormattingEnabled = true; - this.listBoxSize.ItemHeight = 15; - this.listBoxSize.Location = new System.Drawing.Point(115, 11); - this.listBoxSize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.listBoxSize.ItemHeight = 12; + this.listBoxSize.Location = new System.Drawing.Point(86, 9); this.listBoxSize.Name = "listBoxSize"; - this.listBoxSize.Size = new System.Drawing.Size(464, 94); + this.listBoxSize.Size = new System.Drawing.Size(349, 76); this.listBoxSize.TabIndex = 8; this.listBoxSize.SelectedIndexChanged += new System.EventHandler(this.listBoxSize_SelectedIndexChanged); // @@ -109,10 +107,9 @@ this.label2.AutoSize = true; this.label2.BackColor = System.Drawing.Color.Transparent; this.label2.Font = new System.Drawing.Font("宋体", 9F); - this.label2.Location = new System.Drawing.Point(20, 11); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(15, 9); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(67, 15); + this.label2.Size = new System.Drawing.Size(53, 12); this.label2.TabIndex = 1; this.label2.Text = "附属物:"; // @@ -121,10 +118,9 @@ this.groupPanel2.CanvasColor = System.Drawing.SystemColors.Control; this.groupPanel2.ColorSchemeStyle = DevComponents.DotNetBar.eDotNetBarStyle.Office2007; this.groupPanel2.Controls.Add(this.panel1); - this.groupPanel2.Location = new System.Drawing.Point(15, 190); - this.groupPanel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel2.Location = new System.Drawing.Point(11, 152); this.groupPanel2.Name = "groupPanel2"; - this.groupPanel2.Size = new System.Drawing.Size(611, 329); + this.groupPanel2.Size = new System.Drawing.Size(458, 263); // // // @@ -163,19 +159,17 @@ // this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(605, 302); + this.panel1.Size = new System.Drawing.Size(452, 241); this.panel1.TabIndex = 0; // // btnCancel // this.btnCancel.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnCancel.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnCancel.Location = new System.Drawing.Point(527, 528); - this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnCancel.Location = new System.Drawing.Point(395, 422); this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(100, 29); + this.btnCancel.Size = new System.Drawing.Size(75, 23); this.btnCancel.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnCancel.TabIndex = 16; this.btnCancel.Text = "关闭"; @@ -185,10 +179,9 @@ // this.btnAdd.AccessibleRole = System.Windows.Forms.AccessibleRole.PushButton; this.btnAdd.ColorTable = DevComponents.DotNetBar.eButtonColor.OrangeWithBackground; - this.btnAdd.Location = new System.Drawing.Point(415, 528); - this.btnAdd.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.btnAdd.Location = new System.Drawing.Point(311, 422); this.btnAdd.Name = "btnAdd"; - this.btnAdd.Size = new System.Drawing.Size(100, 29); + this.btnAdd.Size = new System.Drawing.Size(75, 23); this.btnAdd.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled; this.btnAdd.TabIndex = 15; this.btnAdd.Text = "添加"; @@ -202,10 +195,9 @@ this.groupPanel3.Controls.Add(this.textBoxXLon); this.groupPanel3.Controls.Add(this.labelLat); this.groupPanel3.Controls.Add(this.labelLon); - this.groupPanel3.Location = new System.Drawing.Point(15, 8); - this.groupPanel3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupPanel3.Location = new System.Drawing.Point(11, 6); this.groupPanel3.Name = "groupPanel3"; - this.groupPanel3.Size = new System.Drawing.Size(611, 40); + this.groupPanel3.Size = new System.Drawing.Size(458, 32); // // // @@ -246,10 +238,9 @@ // this.textBoxXLat.Border.Class = "TextBoxBorder"; this.textBoxXLat.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLat.Location = new System.Drawing.Point(409, 2); - this.textBoxXLat.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLat.Location = new System.Drawing.Point(307, 2); this.textBoxXLat.Name = "textBoxXLat"; - this.textBoxXLat.Size = new System.Drawing.Size(171, 30); + this.textBoxXLat.Size = new System.Drawing.Size(128, 21); this.textBoxXLat.TabIndex = 3; this.textBoxXLat.TextChanged += new System.EventHandler(this.textBoxXLat_TextChanged); // @@ -260,10 +251,9 @@ // this.textBoxXLon.Border.Class = "TextBoxBorder"; this.textBoxXLon.Border.CornerType = DevComponents.DotNetBar.eCornerType.Square; - this.textBoxXLon.Location = new System.Drawing.Point(115, 2); - this.textBoxXLon.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.textBoxXLon.Location = new System.Drawing.Point(86, 2); this.textBoxXLon.Name = "textBoxXLon"; - this.textBoxXLon.Size = new System.Drawing.Size(171, 30); + this.textBoxXLon.Size = new System.Drawing.Size(128, 21); this.textBoxXLon.TabIndex = 2; this.textBoxXLon.TextChanged += new System.EventHandler(this.textBoxXLon_TextChanged); // @@ -272,10 +262,9 @@ this.labelLat.AutoSize = true; this.labelLat.BackColor = System.Drawing.Color.Transparent; this.labelLat.Font = new System.Drawing.Font("宋体", 9F); - this.labelLat.Location = new System.Drawing.Point(329, 11); - this.labelLat.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLat.Location = new System.Drawing.Point(247, 9); this.labelLat.Name = "labelLat"; - this.labelLat.Size = new System.Drawing.Size(52, 15); + this.labelLat.Size = new System.Drawing.Size(41, 12); this.labelLat.TabIndex = 1; this.labelLat.Text = "纬度:"; // @@ -284,18 +273,17 @@ this.labelLon.AutoSize = true; this.labelLon.BackColor = System.Drawing.Color.Transparent; this.labelLon.Font = new System.Drawing.Font("宋体", 9F); - this.labelLon.Location = new System.Drawing.Point(20, 11); - this.labelLon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelLon.Location = new System.Drawing.Point(15, 9); this.labelLon.Name = "labelLon"; - this.labelLon.Size = new System.Drawing.Size(52, 15); + this.labelLon.Size = new System.Drawing.Size(41, 12); this.labelLon.TabIndex = 1; this.labelLon.Text = "经度:"; // // FrmAddInstrument // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(641, 564); + this.ClientSize = new System.Drawing.Size(481, 451); this.Controls.Add(this.groupPanel3); this.Controls.Add(this.btnCancel); this.Controls.Add(this.btnAdd); @@ -304,7 +292,6 @@ this.DoubleBuffered = true; this.EnableGlass = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; - this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; this.Name = "FrmAddInstrument"; this.ShowIcon = false; diff --git a/FrmBufferAnalysis.cs b/FrmBufferAnalysis.cs index ea8a4b7..30bab88 100644 --- a/FrmBufferAnalysis.cs +++ b/FrmBufferAnalysis.cs @@ -30,13 +30,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } } @@ -114,23 +112,17 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i=0;i @@ -145,25 +137,18 @@ { e.Handled = true; } - if (e.KeyChar == 46) //小数点 + if (e.KeyChar != 46) return; + if (text.Text.Length <= 0) + e.Handled = true; //小数点不能在第一位 + else //处理不规则的小数点 { - if (text.Text.Length <= 0) - e.Handled = true; //小数点不能在第一位 - else //处理不规则的小数点 - { - float f; - float oldf; - bool b1 = false, b2 = false; - b1 = float.TryParse(text.Text, out oldf); - b2 = float.TryParse(text.Text + e.KeyChar, out f); - if (b2 == false) - { - if (b1) - e.Handled = true; - else - e.Handled = false; - } - } + float f; + float oldf; + bool b1 = false, b2 = false; + b1 = float.TryParse(text.Text, out oldf); + b2 = float.TryParse(text.Text + e.KeyChar, out f); + if (b2) return; + e.Handled = b1; } } /// @@ -197,51 +182,44 @@ DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } - } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -258,22 +236,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -293,38 +259,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute,0,45,5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -337,23 +297,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmBufferAnalysisBSQ.cs b/FrmBufferAnalysisBSQ.cs index d887d47..e08dba3 100644 --- a/FrmBufferAnalysisBSQ.cs +++ b/FrmBufferAnalysisBSQ.cs @@ -28,13 +28,11 @@ for (int i = globeControl1.Globe.Layers.Count - 1; i >= 0; i--) { GSOLayer layer = globeControl1.Globe.Layers[i]; - if (layer.Dataset != null && layer.Dataset.IsFeatureDataset) + if (layer.Dataset == null || !layer.Dataset.IsFeatureDataset) continue; + string name = layer.Name; + if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) { - string name = layer.Name; - if (layer.Type == EnumLayerType.FeatureLayer && !name.Contains("\\")) - { - clbLayers.Items.Add(layer.Caption); - } + clbLayers.Items.Add(layer.Caption); } } if (txtRadius.Text != "" && pt != null) @@ -127,34 +125,28 @@ GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layername); GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - - if (polygon == null) - feats = flayer.GetAllFeatures(); - else - feats = flayer.FindFeaturesInPolygon(polygon, false); - if (feats.Length > 0) + if (flayer == null) return; + feats = polygon == null ? flayer.GetAllFeatures() : flayer.FindFeaturesInPolygon(polygon, false); + if (feats.Length <= 0) return; + for (int i = 0; i < feats.Length; i++) { - for (int i = 0; i < feats.Length; i++) + string featNum = feats[i].GetFieldAsString("编号"); + if (feats[i].GetFieldDefn("标识器编号") != null) { - string featNum = feats[i].GetFieldAsString("编号"); - if (feats[i].GetFieldDefn("标识器编号") != null) - { - featNum = feats[i].GetFieldAsString("标识器编号"); - } - if (markList.Contains(featNum) == false) - { - DataGridViewRow row = new DataGridViewRow(); - int index = dataGridViewX1.Rows.Add(row); - row = dataGridViewX1.Rows[index]; - row.Cells["编号"].Value = featNum; - row.Cells["图层名称"].Value = layername; - markList.Add(featNum); - } - else - { - return; - } + featNum = feats[i].GetFieldAsString("标识器编号"); + } + if (markList.Contains(featNum) == false) + { + DataGridViewRow row = new DataGridViewRow(); + int index = dataGridViewX1.Rows.Add(row); + row = dataGridViewX1.Rows[index]; + row.Cells["编号"].Value = featNum; + row.Cells["图层名称"].Value = layername; + markList.Add(featNum); + } + else + { + return; } } } @@ -210,48 +202,42 @@ { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); //idx = hittestinfo.RowIndex; - if (hittestinfo.RowIndex > -1) - { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) + { + if (features[j].Name == featureName) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - } - } + m_feature = features[j]; } } } - if (e.Button == MouseButtons.Right) + else if (e.Button == MouseButtons.Right) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); + featureName = featureName.Trim(); + + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) + return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - contextMenuStrip1.Show(dataGridViewX1, e.X, e.Y); - featureName = featureName.Trim(); - - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer == null) - return; - GSOFeatures features = layer.GetFeatureByName(featureName, false); - - for (int j = 0; j < features.Length; j++) + if (features[j].Name == featureName) { - if (features[j].Name == featureName) - { - m_feature = features[j]; - break; - } + m_feature = features[j]; + break; } } } @@ -263,22 +249,10 @@ if (count < 40) { count++; - if (flashflag == "single") - { - if (m_feature != null) - { - if (count % 2 != 0) - { - m_feature.HighLight = true; - globeControl1.Refresh(); - } - else - { - m_feature.HighLight = false; - globeControl1.Refresh(); - } - } - } + if (!flashflag.Equals("single")) return; + if (m_feature == null) return; + m_feature.HighLight = count % 2 != 0; + globeControl1.Refresh(); } else { @@ -295,38 +269,32 @@ if (e.Button == MouseButtons.Left) { DataGridView.HitTestInfo hittestinfo = dataGridViewX1.HitTest(e.X, e.Y); - if (hittestinfo.RowIndex > -1) + if (hittestinfo.RowIndex <= -1) return; + string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); + string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); + + //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); + GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); + if (layer == null) return; + GSOFeatures features = layer.GetFeatureByName(featureName, false); + for (int j = 0; j < features.Length; j++) { - string featureName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["编号"].Value.ToString().Trim(); - string layerName = dataGridViewX1.Rows[hittestinfo.RowIndex].Cells["图层名称"].Value.ToString().Trim(); - - //GSOLayer layer = globeControl1.Globe.Layers.GetLayerByID((int)(Utility.LayerLabel_LayerIDs[layerName])); - GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(layerName); - if (layer != null) + if (features[j].Name != featureName) continue; + m_feature = features[j]; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - GSOFeatures features = layer.GetFeatureByName(featureName, false); - for (int j = 0; j < features.Length; j++) - { - if (features[j].Name == featureName) - { - m_feature = features[j]; - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); - } - } + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } } } @@ -340,23 +308,21 @@ private void FlyToMenu_Click(object sender, EventArgs e) { - if (m_feature != null) + if (m_feature == null) return; + if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) { - if (m_feature.Geometry != null && m_feature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; - double length = line.GetSpaceLength(true, 6378137); - GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); - GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; + GSOGeoPolyline3D line = m_feature.Geometry as GSOGeoPolyline3D; + double length = line.GetSpaceLength(true, 6378137); + GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); + GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; - globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); - } - else - { - globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); - } - LightMenu_Click(sender, e); + globeControl1.Globe.FlyToPosition(point3d, EnumAltitudeMode.Absolute, 0, 45, 5); } + else + { + globeControl1.Globe.FlyToFeature(m_feature, 0, 45, 3); + } + LightMenu_Click(sender, e); } private void LightMenu_Click(object sender, EventArgs e) diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index ac622c4..0a5d0b0 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -43,27 +43,28 @@ globeControl2.MouseClick += globeControl2_MouseClick; } - private void invalParam() + private bool InvalParam() { if (srcFeature == null || dscFeature == null) { MessageBox.Show("请选择要对比的管段!", "提示"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) { MessageBox.Show("请选择同种类型图层!"); - return; + return false; } - else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || - srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) - return; + if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return false; + return true; } private void buttonAnalysis_Click(object sender, EventArgs e) { - invalParam(); - + bool isvalid = InvalParam(); + if (!isvalid) return; dataGridViewX1.DataSource = null; lineFeatureCompare(srcFeature, dscFeature); } @@ -75,11 +76,13 @@ private void lineFeatureCompare(GSOFeature srcFeature, GSOFeature dscFeature) { GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - double srcLineLength = srcLine.GetSpaceLength(false, 6378137); + if (srcLine == null) return; GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; + if (dscLine == null) return; + double srcLineLength = srcLine.GetSpaceLength(false, 6378137); double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - + double horizonDistance, verticalDistance; ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, @@ -136,26 +139,13 @@ globeControl2.Refresh(); } - public static void clearFeatureHighLight(GSOGlobeControl glb) - { - for (int i = 0; i < glb.Globe.Layers.Count; i++) - { - GSOLayer layer = glb.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - feats[j].HighLight = false; - } - } - } void globeControl1_MouseClick(object sender, MouseEventArgs e) { if (globeControl1.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { @@ -181,10 +171,10 @@ void globeControl2_MouseClick(object sender, MouseEventArgs e) { - + if (globeControl2.Globe.SelectedObject == null) return; - clearFeatureHighLight(globeControl1); - clearFeatureHighLight(globeControl2); + FeatureTools.ClearAllFeatureHighLight(globeControl1); + FeatureTools.ClearAllFeatureHighLight(globeControl2); try { diff --git a/FrmGBJC.cs b/FrmGBJC.cs index 6c6447c..a118875 100644 --- a/FrmGBJC.cs +++ b/FrmGBJC.cs @@ -112,7 +112,7 @@ if (scLayer == null || sgLayer == null) return; - DataTable dt = DoublePanelAnalysis.lineFeatureCompare(scLayer, sgLayer, + DataTable dt = DoublePanelAnalysis.CompareLayerByRoad(scLayer, sgLayer, comboBoxRoad.SelectedItem.ToString(), globeControl1, globeControl2); FrmGBJCresult rs = new FrmGBJCresult(globeControl1, globeControl2, dt); diff --git a/MainFrm.cs b/MainFrm.cs index f848026..ac37ae5 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -3365,9 +3365,9 @@ return dismarker.Position; } - #region wxl重构未完成 + #region wxl /// - /// 碰撞分析 + /// wxl重构,碰撞分析 /// /// /// @@ -3423,7 +3423,7 @@ } /// - /// 垂直净距分析,暂时没有在地图上标注 + /// wxl重构,垂直净距分析 /// /// /// @@ -3533,7 +3533,6 @@ featLenth.Clear(); listBox3.Items.Clear(); layerTemp.RemoveAllFeature(); - //polygonJingJuAnalysises.RemoveAll(); clearFeatureHighLight(); dataGridViewX9.Rows.Clear(); Cursor = Cursors.WaitCursor; @@ -3572,6 +3571,7 @@ /// private void HorizontalDistanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, double dis) { + Dictionary featureMap = DoublePanelAnalysis.HorizontalDistanceAnalysis(globeControl1,selectedFeature, _pipelineLayerNames, dis); if (featureMap == null) @@ -4281,10 +4281,9 @@ dataGridViewX4.Rows.Clear(); dataGridViewX5.Rows.Clear(); GSOLayer layer = globeControl1.Globe.Layers.GetLayerByCaption(comboBoxEx2.SelectedItem.ToString()); - if (layer == null) - return; - + GSOFeatureLayer flayer = layer as GSOFeatureLayer; + if (flayer == null) return; GSOFeatures feats = flayer.GetAllFeatures(); for (int i = 0; i < feats.Length; i++) { @@ -7414,13 +7413,17 @@ GSOFeature f; GSOLayer layer; globeControl1.Globe.GetSelectObject(i, out f, out layer); - if (f == null) continue; - f.Delete(); - if (layer != null) - globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); +// if (f == null) continue; +// f.Delete(); +// if (layer != null) +// globeControl1.Globe.AddToEditHistroy(layer, f, EnumEditType.Delete); + FeatureTools.DeleteFeature(f); + globeControl1.Refresh(); + } + MessageBox.Show("删除成功!", "提示"); globeControl1.Globe.Action = EnumAction3D.ActionNull; } diff --git a/NewFunction/FrmFloodAnalysis.cs b/NewFunction/FrmFloodAnalysis.cs index 2031ecf..c599ab0 100644 --- a/NewFunction/FrmFloodAnalysis.cs +++ b/NewFunction/FrmFloodAnalysis.cs @@ -103,14 +103,7 @@ GSOExtrudeStyle extrudeStyle = new GSOExtrudeStyle(); - if (checkBoxExtrude.Checked) - { - extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; - } - else - { - extrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; - } + extrudeStyle.ExtrudeType = checkBoxExtrude.Checked ? EnumExtrudeType.ExtrudeToValue : EnumExtrudeType.ExtrudeNone; extrudeStyle.ExtrudeValue = m_pntMinAlt.Z; extrudeStyle.TailPartVisible = false; @@ -151,32 +144,30 @@ private void timerPlay_Tick(object sender, EventArgs e) { - if (m_WaterFeature != null) + if (m_WaterFeature == null) return; + if (m_dBaseAlt > m_pntMaxAlt.Z) { - if (m_dBaseAlt > m_pntMaxAlt.Z) + if (checkBoxLoopPlay.Checked) { - if (checkBoxLoopPlay.Checked) - { - m_dBaseAlt = m_pntMinAlt.Z; - } - else - { - timerPlay.Stop(); - } + m_dBaseAlt = m_pntMinAlt.Z; } - - m_dBaseAlt += (double)numericUpDownAddPerTime.Value; - - m_globe.Analysis3D.FetchNoSourceFloodAnalyseResult(m_dBaseAlt, out m_dFloodArea, out m_dTotalArea, - out m_pntMaxAlt, out m_pntMinAlt); - - SetText(); - - textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); - trackBarAlt.Value = Math.Min((int)m_dBaseAlt, trackBarAlt.Maximum); - GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; - geoWater.SetAltitude(m_dBaseAlt); + else + { + timerPlay.Stop(); + } } + + m_dBaseAlt += (double)numericUpDownAddPerTime.Value; + + m_globe.Analysis3D.FetchNoSourceFloodAnalyseResult(m_dBaseAlt, out m_dFloodArea, out m_dTotalArea, + out m_pntMaxAlt, out m_pntMinAlt); + + SetText(); + + textBoxWaterAlt.Text = m_dBaseAlt.ToString("f2"); + trackBarAlt.Value = Math.Min((int)m_dBaseAlt, trackBarAlt.Maximum); + GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; + geoWater.SetAltitude(m_dBaseAlt); } private void trackBarAlt_Scroll(object sender, EventArgs e) @@ -196,19 +187,9 @@ private void checkBoxExtrude_CheckedChanged(object sender, EventArgs e) { - if (m_WaterFeature != null) - { - GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; - if (checkBoxExtrude.Checked) - { - geoWater.ExtrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeToValue; - } - else - { - geoWater.ExtrudeStyle.ExtrudeType = EnumExtrudeType.ExtrudeNone; - - } - } + if (m_WaterFeature == null) return; + GSOGeoWater geoWater = (GSOGeoWater)m_WaterFeature.Geometry; + geoWater.ExtrudeStyle.ExtrudeType = checkBoxExtrude.Checked ? EnumExtrudeType.ExtrudeToValue : EnumExtrudeType.ExtrudeNone; } private void buttonSetPlayParam_Click(object sender, EventArgs e) diff --git a/getpipeLineFields.cs b/getpipeLineFields.cs index e8b19b1..0f32478 100644 --- a/getpipeLineFields.cs +++ b/getpipeLineFields.cs @@ -55,7 +55,6 @@ GSOLayer m_layer = m_globeControl.Globe.Layers.GetLayerByCaption(caption);//获取当前选择的layer图层 if (m_layer == null) return ""; - GSOFeatureLayer flayer = m_layer as GSOFeatureLayer; ds = m_layer.Dataset; sourcefDataset = ds as GSOFeatureDataset; sourcefDataset.Open();