diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/Program.cs b/Program.cs index bd3fa95..ece4a85 100644 --- a/Program.cs +++ b/Program.cs @@ -39,8 +39,6 @@ string programUrl = getProgramUrl(localConfigPath, "programurl"); if (programUrl != "") { - - //FrmDownloadProgress frmdownload = FrmDownloadProgress.getForm(programUrl); Process.Start(ent + "/UpDateProgress.exe").WaitForExit(); return; } diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/Program.cs b/Program.cs index bd3fa95..ece4a85 100644 --- a/Program.cs +++ b/Program.cs @@ -39,8 +39,6 @@ string programUrl = getProgramUrl(localConfigPath, "programurl"); if (programUrl != "") { - - //FrmDownloadProgress frmdownload = FrmDownloadProgress.getForm(programUrl); Process.Start(ent + "/UpDateProgress.exe").WaitForExit(); return; } diff --git a/ShResult.cs b/ShResult.cs index 433c3de..79081c4 100644 --- a/ShResult.cs +++ b/ShResult.cs @@ -7,7 +7,6 @@ public ShResult() { } - public ShResult(string _layerid, string _question) { layerid = _layerid; diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/Program.cs b/Program.cs index bd3fa95..ece4a85 100644 --- a/Program.cs +++ b/Program.cs @@ -39,8 +39,6 @@ string programUrl = getProgramUrl(localConfigPath, "programurl"); if (programUrl != "") { - - //FrmDownloadProgress frmdownload = FrmDownloadProgress.getForm(programUrl); Process.Start(ent + "/UpDateProgress.exe").WaitForExit(); return; } diff --git a/ShResult.cs b/ShResult.cs index 433c3de..79081c4 100644 --- a/ShResult.cs +++ b/ShResult.cs @@ -7,7 +7,6 @@ public ShResult() { } - public ShResult(string _layerid, string _question) { layerid = _layerid; diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe index 89a05f3..65db2ee 100644 --- a/bin/x86/Debug/Cyberpipe.exe +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/Program.cs b/Program.cs index bd3fa95..ece4a85 100644 --- a/Program.cs +++ b/Program.cs @@ -39,8 +39,6 @@ string programUrl = getProgramUrl(localConfigPath, "programurl"); if (programUrl != "") { - - //FrmDownloadProgress frmdownload = FrmDownloadProgress.getForm(programUrl); Process.Start(ent + "/UpDateProgress.exe").WaitForExit(); return; } diff --git a/ShResult.cs b/ShResult.cs index 433c3de..79081c4 100644 --- a/ShResult.cs +++ b/ShResult.cs @@ -7,7 +7,6 @@ public ShResult() { } - public ShResult(string _layerid, string _question) { layerid = _layerid; diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe index 89a05f3..65db2ee 100644 --- a/bin/x86/Debug/Cyberpipe.exe +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb index ff80739..6491630 100644 --- a/bin/x86/Debug/Cyberpipe.pdb +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/Program.cs b/Program.cs index bd3fa95..ece4a85 100644 --- a/Program.cs +++ b/Program.cs @@ -39,8 +39,6 @@ string programUrl = getProgramUrl(localConfigPath, "programurl"); if (programUrl != "") { - - //FrmDownloadProgress frmdownload = FrmDownloadProgress.getForm(programUrl); Process.Start(ent + "/UpDateProgress.exe").WaitForExit(); return; } diff --git a/ShResult.cs b/ShResult.cs index 433c3de..79081c4 100644 --- a/ShResult.cs +++ b/ShResult.cs @@ -7,7 +7,6 @@ public ShResult() { } - public ShResult(string _layerid, string _question) { layerid = _layerid; diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe index 89a05f3..65db2ee 100644 --- a/bin/x86/Debug/Cyberpipe.exe +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb index ff80739..6491630 100644 --- a/bin/x86/Debug/Cyberpipe.pdb +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/bin/x86/Debug/MyPlace.kml b/bin/x86/Debug/MyPlace.kml index bad2179..6036f64 100644 --- a/bin/x86/Debug/MyPlace.kml +++ b/bin/x86/Debug/MyPlace.kml @@ -1,101 +1,3 @@ - - - - 1 - - relativeToGround - - - - 120.611131732338,31.187759658792,0 - 120.611174179651,31.1877622151576,0 - 120.611198294644,31.1874824180543,0 - 120.611155847473,31.1874798616962,0 - 120.611131732338,31.187759658792,0 - - - - - - - 1 - - - absolute - - 120.611155826595,31.1877276306654,-1.88476951327175 - 120.611155826633,31.1877276302315,-1.84700015000999 - - - - - 垂直0.04米 - 1 - - - absolute - - 120.611155826595,31.1877276306654,-1.86588483164087 - - - - - 1 - - - absolute - - 120.611176765514,31.187484684993,-1.91999998688698 - 120.611163381257,31.1874838407729,-1.91999985929579 - - - - - 水平1.28米 - 1 - - - absolute - - 120.611176765514,31.187484684993,-1.91999992309138 - - - - - + diff --git a/ClassAddMakerToGlobel.cs b/ClassAddMakerToGlobel.cs new file mode 100644 index 0000000..1e0455e --- /dev/null +++ b/ClassAddMakerToGlobel.cs @@ -0,0 +1,108 @@ +using GeoScene.Globe; +using GeoScene.Data; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassAddMakerToGlobel + { + public static void LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, + double distance, bool markerVisible, string label, GSOGlobeControl globeControl1, + GSOGlobeControl globeControl2) + { + if (pntIntersect1 == null || pntIntersect2 == null) + return; + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOGeoMarker dismarker = new GSOGeoMarker(); + GSOFeature marker = null; + GSOFeature line = null; + createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, + distance, label, dismarker); + + line.Visible = marker.Visible = markerVisible; + globeControl1.Globe.MemoryLayer.AddFeature(line); + globeControl1.Globe.MemoryLayer.AddFeature(marker); + + globeControl2.Globe.MemoryLayer.AddFeature(line); + globeControl2.Globe.MemoryLayer.AddFeature(marker); + } + + public static void LabelDistance(GSOPoint3d pntIntersect1,GSOPoint3d pntIntersect2, + double distance, bool markerVisible, GSOGlobeControl globeControl, string label) + { + if (pntIntersect1 == null || pntIntersect2 == null) return; + + GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); + GSOPoint3ds point3ds = new GSOPoint3ds(); + point3ds.Add(pntIntersect1); + point3ds.Add(pntIntersect2); + disline.AddPart(point3ds); + + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); + style.LineColor = Color.GreenYellow; + style.LineWidth = 3; + style.VertexVisible = true; + disline.Style = style; + disline.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOFeature line = new GSOFeature(); + line.Geometry = disline; + GSOGeoMarker dismarker = new GSOGeoMarker(); + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.White; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + GSOFeature marker = new GSOFeature(); + marker.Geometry = dismarker; + + line.Visible = marker.Visible = markerVisible; + globeControl.Globe.MemoryLayer.AddFeature(line); + globeControl.Globe.MemoryLayer.AddFeature(marker); + } + + public static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, + GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) + { + GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 + style.LineColor = Color.Red; + style.LineWidth = 5; //设置线的宽度为5 + style.VertexVisible = true; //显示线的节点 + disline.Style = style; //把风格添加到线上 + disline.AltitudeMode = EnumAltitudeMode.Absolute; + line = new GSOFeature(); + line.Geometry = disline; + + dismarker.X = pntIntersect1.X; + dismarker.Y = pntIntersect1.Y; + dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; + dismarker.Text = label + distance.ToString("0.00") + "米"; + dismarker.AltitudeMode = EnumAltitudeMode.Absolute; + + GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); + GSOTextStyle styleText = new GSOTextStyle(); + styleText.IsSizeFixed = true; + styleText.ForeColor = Color.Red; + styleText.FontSize = 20; + styleMarker.TextStyle = styleText; + dismarker.Style = styleMarker; + + marker = new GSOFeature(); + marker.Geometry = dismarker; + } + + } +} diff --git a/ClassDataTableParam.cs b/ClassDataTableParam.cs new file mode 100644 index 0000000..537934e --- /dev/null +++ b/ClassDataTableParam.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace Cyberpipe +{ + public class ClassDataTableParam + { + public string selectedFeatureCaption; + public string selectedFeatureName; + public string targetFeatureCaption; + public string targetFeatureName; + public string resultDis; + public string dis; + } + + + +} diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs index f2935da..692ef01 100644 --- a/ClassDoubleScreenCompare.cs +++ b/ClassDoubleScreenCompare.cs @@ -45,12 +45,9 @@ features.Add(fs[i]); } } - return getMostSimilarFeatureFromFeatures(feature, features); - } - private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) { double maxLength = 0; @@ -133,69 +130,13 @@ verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, verticalDistance, true, "垂直", globeControl1, globeControl2); horizonDistance = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, horizonDistance, true, "水平", globeControl1, globeControl2); } - private static GSOPoint3d LabelDistance(GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, - double distance, bool markerVisible, string label,GSOGlobeControl globeControl1,GSOGlobeControl globeControl2) - { - if (pntIntersect1 == null || pntIntersect2 == null) - return new GSOPoint3d(); - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - - GSOGeoMarker dismarker = new GSOGeoMarker(); - GSOFeature marker = null; - GSOFeature line = null; - createLineStyle(out marker, out line, disline, pntIntersect1, pntIntersect2, distance, label, dismarker); - - line.Visible = marker.Visible = markerVisible; - globeControl1.Globe.MemoryLayer.AddFeature(line); - globeControl1.Globe.MemoryLayer.AddFeature(marker); - - globeControl2.Globe.MemoryLayer.AddFeature(line); - globeControl2.Globe.MemoryLayer.AddFeature(marker); - - return dismarker.Position; - } - - private static void createLineStyle(out GSOFeature marker, out GSOFeature line, GSOGeoPolyline3D disline, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, string label, GSOGeoMarker dismarker) - { - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - style.LineColor = Color.Red; - style.LineWidth = 5; //设置线的宽度为5 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - line = new GSOFeature(); - line.Geometry = disline; - - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = label + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.Red; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - marker = new GSOFeature(); - marker.Geometry = dismarker; - } - } } diff --git a/ClassYJSHAlgorithm.cs b/ClassYJSHAlgorithm.cs new file mode 100644 index 0000000..3305ce9 --- /dev/null +++ b/ClassYJSHAlgorithm.cs @@ -0,0 +1,82 @@ +using System; +using System.Collections.Generic; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; + +namespace Cyberpipe +{ + class ClassYJSHAlgorithm + { + public static void distanceAnalysis(GSOFeature selectedFeature, List _pipelineLayerNames, + GSOGlobeControl globeControl, out List shV, out List shH) + { + shV = new List(); + shH = new List(); + ClassDataTableParam vSh, hSh; + + GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; + string selectFeatureCaption = selectedFeature.Dataset.Caption; + + for (int i = 0; i < _pipelineLayerNames.Count; i++) + { + GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); + if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; + + //获取净距标准 + double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); + GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); + GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); + if (targetFeats.Length == 0) continue; + + for (int j = 0; j < targetFeats.Length; j++) + { + GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; + + vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, true); + if (vSh != null) shV.Add(vSh); + ; + hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], + selectFeatureCaption, false); + if (hSh!= null) shH.Add(hSh); + } + } + } + + private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, + GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, + string selectedFeatureCaption,bool isVer) + { + + ClassDataTableParam shDataTable=new ClassDataTableParam(); + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + double dis = isVer + ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) + : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + + feature.HighLight = true; + string type = isVer ? "垂直" : "水平"; + + if (Math.Abs(dis) > 0) + ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); + + if (!(dis > -1) || !(dis < distance)) return null; + shDataTable.selectedFeatureCaption = selectedFeatureCaption; + shDataTable.selectedFeatureName = selectFeatureLine.Name; + shDataTable.targetFeatureCaption = feature.Dataset.Caption; + shDataTable.targetFeatureName = targetLine.Name; + shDataTable.resultDis = dis.ToString("0.00"); + shDataTable.dis = distance.ToString("0.00"); + + return shDataTable; + } + + } +} diff --git a/ClassYJSHModel.cs b/ClassYJSHModel.cs index e0aa9b1..d81c7e2 100644 --- a/ClassYJSHModel.cs +++ b/ClassYJSHModel.cs @@ -4,176 +4,114 @@ { class ClassYJSHModel { - public static GSOLayer shLayer = null; + //public static GSOLayer shLayer = null; - public static double CalculateDistance(string shLayerName,string pipeLineName) + public static double GetDistance(string shLayerName, string pipeLineName) { - double distance = 1; - if (shLayerName.Contains("给水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("燃气")||pipeLineName.Contains("天然气")) - { - distance = 00.15; - } - else if (pipeLineName.Contains("电信")||pipeLineName.Contains("电通")||pipeLineName.Contains("联通")||pipeLineName.Contains("移动")||pipeLineName.Contains("网通")||pipeLineName.Contains("共通")||pipeLineName.Contains("电视")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电")||pipeLineName.Contains("路灯")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; + else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) + return 0.15; } else if (shLayerName.Contains("污水") || shLayerName.Contains("雨水")) { if (pipeLineName.Contains("给水")) - { - distance = 0.4; - } + return 0.4; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("热力")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.15; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("燃气") || pipeLineName.Contains("天然气")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } - else if(pipeLineName.Contains("污水")||pipeLineName.Contains("雨水")) - { - distance = 0.15; - } + return 0.15; + else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) + return 0.15; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.15; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.15; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) { if (pipeLineName.Contains("给水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.25; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.25; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } else if (shLayerName.Contains("电力") || shLayerName.Contains("供电")) { if (pipeLineName.Contains("给水")) - { - distance = 0.15; - } + return 0.15; else if (pipeLineName.Contains("污水") || pipeLineName.Contains("雨水")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("热力")) - { - distance = 0.5; - } + return 0.5; else if (pipeLineName.Contains("燃气") || pipeLineName.Contains("天然气")) - { - distance = 0.5; - } - else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || pipeLineName.Contains("电视")) - { - distance = 0.5; - } + return 0.5; + else if (pipeLineName.Contains("电信") || pipeLineName.Contains("电通") || pipeLineName.Contains("联通") || + pipeLineName.Contains("移动") || pipeLineName.Contains("网通") || pipeLineName.Contains("共通") || + pipeLineName.Contains("电视")) + return 0.5; else if (pipeLineName.Contains("电力") || pipeLineName.Contains("供电") || pipeLineName.Contains("路灯")) - { - distance = 0.5; - } + return 0.5; } - return distance; + return 1; } } diff --git a/Cyberpipe.csproj b/Cyberpipe.csproj index ab084e9..bd1b2b0 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,10 +203,13 @@ + + + diff --git a/Cyberpipe.suo b/Cyberpipe.suo index ecb1339..2970e47 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 2c45db6..19511cc 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -11,8 +11,6 @@ { public static GSOGlobeControl globeControl1 = null; public static GSOGlobeControl globeControl2 = null; -// public static GSOLayer layerTemp = null; -// public static GSOLayer layerTemp2 = null; public static int bufferWidth = 8; public static string strLabel; diff --git a/Forms/FrmMnModify.cs b/Forms/FrmMnModify.cs index 93fcbec..726954d 100644 --- a/Forms/FrmMnModify.cs +++ b/Forms/FrmMnModify.cs @@ -15,7 +15,6 @@ private GSOGlobeControl globecontrol; private string shlayername; MainFrm mainfrm; - private double movex; private double movey; private double movez; @@ -60,15 +59,6 @@ questionGrid.Rows[idx].Cells[1].Value = sr.question; } } - /// 选中对象 - /// - /// - /// - /// - private void buttonX1_Click(object sender, EventArgs e) - { - globecontrol.Globe.Action = EnumAction3D.SelectObject; - } /// /// 选中某一行 /// @@ -101,7 +91,6 @@ GSOGeoPolyline3D lineLine = line.GetSegment(0, length / 2); GSOPoint3d point3d = lineLine[lineLine.PartCount - 1][lineLine[lineLine.PartCount - 1].Count - 1]; globecontrol.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - //globecontrol.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); hlfeature = rowFeature; highlight(); @@ -130,91 +119,86 @@ /// private void button1_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveXTxt.Text.Trim()) && isNumber(moveYTxt.Text.Trim())) + MessageBox.Show("请选择要修改的管线"); + return; + } + + if (!isNumber(moveXTxt.Text.Trim()) || !isNumber(moveYTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + + double disx = double.Parse(moveXTxt.Text.Trim()); //jingdu + double disy = double.Parse(moveYTxt.Text.Trim()); //weidu + + + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) { + GSOFeature monifeat = monifeats[i]; + GSOGeometry monifeatline = monifeat.Geometry; + GSOPoint3d pts = monifeatline.GeoCenterPoint; + double pl = pts.X; + double pa = pts.Y; - double disx = double.Parse(moveXTxt.Text.Trim());//jingdu - double disy = double.Parse(moveYTxt.Text.Trim());//weidu + double movealtitude = disy/110/1000; + double movelongitude = disx/110/1000/Math.Cos(pa); - - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) + if (monifeat != null) { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - GSOGeometry monifeatline = monifeat.Geometry; - GSOPoint3d pts = monifeatline.GeoCenterPoint; - double pl = pts.X; - double pa = pts.Y; - - double movealtitude = disy / 110 / 1000; - double movelongitude = disx / 110 / 1000 / Math.Cos(pa); - - if (monifeat != null) - { - monifeat.Geometry.MoveXY(movelongitude, movealtitude); - } - } - moniLayer.Save(); - + monifeat.Geometry.MoveXY(movelongitude, movealtitude); } + } + moniLayer.Save(); + } - movex += disx; - movey += disy; - moveXLbl.Text = movex.ToString(); - moveYLbl.Text = movey.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { - MessageBox.Show("请选择要修改的管线"); - } + movex += disx; + movey += disy; + moveXLbl.Text = movex.ToString(); + moveYLbl.Text = movey.ToString(); + globecontrol.Refresh(); } - /// - /// 升降对象 - /// - /// - /// - private void button2_Click(object sender, EventArgs e) + + void button2_Click(object sender, EventArgs e) { - if (selectLbl.Text != "") + if (selectLbl.Text == "") { - if (isNumber(moveZTxt.Text.Trim())) - { - double dis = double.Parse(moveZTxt.Text.Trim()); - GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); - if (moniLayer != null) - { - GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); - for (int i = 0; i < monifeats.Length; i++) - { - GSOFeature monifeat = monifeats[i]; - if (monifeat != null) - { - monifeat.Geometry.MoveZ(dis); - } - } - moniLayer.Save(); - } - moniLayer.Dataset.Save(); - - movez += dis; - moveUpLbl.Text = movez.ToString(); - } - else { - MessageBox.Show("请输入数字"); - } - } - else { MessageBox.Show("请选择要修改的管线"); + return; } + if (!isNumber(moveZTxt.Text.Trim())) + { + MessageBox.Show("请输入数字"); + return; + } + double dis = double.Parse(moveZTxt.Text.Trim()); + GSOLayer moniLayer = globecontrol.Globe.Layers.GetLayerByCaption(shlayername); + if (moniLayer != null) + { + GSOFeatures monifeats = moniLayer.GetFeatureByFieldValue("编号", selectLbl.Text, true); + for (int i = 0; i < monifeats.Length; i++) + { + GSOFeature monifeat = monifeats[i]; + if (monifeat != null) + { + monifeat.Geometry.MoveZ(dis); + } + } + moniLayer.Save(); + } + moniLayer.Dataset.Save(); + + movez += dis; + moveUpLbl.Text = movez.ToString(); + globecontrol.Refresh(); } + /// /// 判断是否为数字 /// diff --git a/FrmShResult.Designer.cs b/FrmShResult.Designer.cs index b76899d..4872752 100644 --- a/FrmShResult.Designer.cs +++ b/FrmShResult.Designer.cs @@ -323,7 +323,7 @@ this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "审核结果"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FrmShResult_FormClosed); - this.Load += new System.EventHandler(this.FrmShResult_Load); + //this.Load += new System.EventHandler(this.FrmShResult_Load); ((System.ComponentModel.ISupportInitialize)(this.dgridShHResult)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dgridShVResult)).EndInit(); this.tableLayoutPanel1.ResumeLayout(false); diff --git a/FrmShResult.cs b/FrmShResult.cs index 91c0ef7..aa96875 100644 --- a/FrmShResult.cs +++ b/FrmShResult.cs @@ -12,37 +12,16 @@ { public partial class FrmShResult : Office2007Form { - public double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; public string layername; - public GSOGlobeControl globleControl1; - int selectState; - //定位和闪烁初始化定义 - int count; - private string flashflag = "single"; + private GSOGlobeControl globleControl1; + int count=0; GSOFeature hlfeature = null; - - GSOLayer layerTemp; - List m_PipelineLayerNames = new List();//线图层名称 - GSOFeatures polygonJingJuAnalysises = new GSOFeatures(); - - List m_vqLayer = new List(); - List m_hqLayer = new List(); - + List m_PipelineLayerNames = new List(); MainFrm mainfrm; - ArrayList shresultLists = new ArrayList(); - /// - /// - /// - /// - /// - /// - /// - /// - public FrmShResult(double _vbz, double _hbz, string _layername, GSOGlobeControl _globleControl1, + + public FrmShResult(string _layername, GSOGlobeControl _globleControl1, List _PipelineLayerNames) { - dVerticalJingJuBiaoZhun = _vbz; - dHorizontalJingJuBiaoZhun = _hbz; layername = _layername; globleControl1 = _globleControl1; m_PipelineLayerNames = _PipelineLayerNames; @@ -50,433 +29,91 @@ InitializeComponent(); } - public FrmShResult() + void addDataToDataGridView(List dt, DataGridView dataGridVeiw) { - // TODO: Complete member initialization + for (int i = 0; i < dt.Count; i++) + { + int id = dataGridVeiw.Rows.Add(); + dataGridVeiw.Rows[id].Cells[0].Value = dt[i].selectedFeatureCaption; + dataGridVeiw.Rows[id].Cells[1].Value = dt[i].selectedFeatureName; + dataGridVeiw.Rows[id].Cells[2].Value = dt[i].targetFeatureCaption; + dataGridVeiw.Rows[id].Cells[3].Value = dt[i].targetFeatureName; + dataGridVeiw.Rows[id].Cells[4].Value = dt[i].resultDis; + dataGridVeiw.Rows[id].Cells[5].Value = dt[i].dis; + } } public void analysis() { mainfrm = (MainFrm)Owner; - layerTemp = globleControl1.Globe.Layers.Add(Application.StartupPath + "\\tempLgdData.lgd"); + List dtV = new List(); + List dtH = new List(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - return; - - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - GSOFeatures feats = flayer.GetAllFeatures(); - if (feats == null) - { - return; - } + GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername);//审核图层 + if (layer == null) return; + GSOFeatures feats = layer.GetAllFeatures(); + if (feats == null) return; for (int i = 0; i < feats.Length; i++) { - selectState = 1; - VerticalDistanceAnalysis("垂直净距分析", feats[i], m_PipelineLayerNames); - HorizontalDistanceAnalysis("水平净距分析", feats[i], m_PipelineLayerNames); + ClassYJSHAlgorithm.distanceAnalysis(feats[i], m_PipelineLayerNames, globleControl1,out dtV, out dtH); + addDataToDataGridView(dtH, dgridShHResult); + addDataToDataGridView(dtV, dgridShVResult); } - //////////////////////得到问题图层列表//////////////////////// + mainfrm.shresultLists = initMainfrmShList(); + + recordHistory(dgridShVResult,"V"); + recordHistory(dgridShHResult,"H"); + } + + private ArrayList initMainfrmShList() + { + List m_vqLayer = new List(); + List m_hqLayer = new List(); + ArrayList shresultLists = new ArrayList(); + for (int i = 0; i < dgridShVResult.RowCount; i++) { - m_vqLayer.Add(dgridShVResult.Rows[i].Cells["审核编号"].Value.ToString()); + if (m_vqLayer.Contains(dgridShVResult.Rows[i].Cells[1].Value.ToString())) continue; + + m_vqLayer.Add(dgridShVResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShVResult.Rows[i].Cells[1].Value.ToString(), "垂直净距不符合要求")); } for (int i = 0; i < dgridShHResult.RowCount; i++) { - m_hqLayer.Add(dgridShHResult.Rows[i].Cells["审核编号1"].Value.ToString()); - } + if (m_hqLayer.Contains(dgridShHResult.Rows[i].Cells[1].Value.ToString())) continue; - ShResult sr = null; - - shresultLists.Clear(); - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_vqLayer.Count; j++) - { - if (m_vqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "垂直净距不符合要求"); - shresultLists.Add(sr); - break; - } - } + m_hqLayer.Add(dgridShHResult.Rows[i].Cells[1].Value.ToString()); + shresultLists.Add(new ShResult(dgridShHResult.Rows[i].Cells[1].Value.ToString(), "水平净距不符合要求")); } - for (int i = 0; i < feats.Length; i++) - { - GSOFeature feat = feats[i]; - string featname = feat.Name; - for (int j = 0; j < m_hqLayer.Count; j++) - { - if (m_hqLayer.Contains(featname)) - { - sr = new ShResult(feat.Name, "水平净距不符合要求"); - shresultLists.Add(sr); - break; - } - } - } - mainfrm.shresultLists = shresultLists; + return shresultLists; + } - //数据库中录入审核记录 + private void recordHistory(DataGridView datagridview,string type) + { String sql = ""; - string now = DateTime.Now.ToString("yyyy-MM-dd"); - if (dgridShVResult.Rows.Count > 0) + if (datagridview.Rows.Count > 0) { - for (int i = 0; i < dgridShVResult.Rows.Count; i++) + for (int i = 0; i < datagridview.Rows.Count; i++) { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShVResult.Rows[i].Cells[0].Value + "','" - + dgridShVResult.Rows[i].Cells[1].Value + "','" - + dgridShVResult.Rows[i].Cells[2].Value + "','" - + dgridShVResult.Rows[i].Cells[3].Value + "','" - + dgridShVResult.Rows[i].Cells[4].Value + "','V','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - OledbHelper.sqlExecuteNonQuery(sql); - } - } + sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE," + + "KIND,SH_STAFF,SH_TIME) values('" + + datagridview.Rows[i].Cells[0].Value + "','" + + datagridview.Rows[i].Cells[1].Value + "','" + + datagridview.Rows[i].Cells[2].Value + "','" + + datagridview.Rows[i].Cells[3].Value + "','" + + datagridview.Rows[i].Cells[4].Value + "','" + type + "','" + + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; - if (dgridShHResult.Rows.Count > 0) - { - for (int j = 0; j < dgridShHResult.Rows.Count; j++) - { - sql = "insert into casic_audit_result(SH_LAYER,SH_NO,WT_LAYER,WT_NO,DISTANCE,KIND,SH_STAFF,SH_TIME) values('" - + dgridShHResult.Rows[j].Cells[0].Value + "','" - + dgridShHResult.Rows[j].Cells[1].Value + "','" - + dgridShHResult.Rows[j].Cells[2].Value + "','" - + dgridShHResult.Rows[j].Cells[3].Value + "','" - + dgridShHResult.Rows[j].Cells[4].Value + "','H','" - + Utility.userName + "'," + "to_date('" + now + "','yyyy-MM-dd'))"; OledbHelper.sqlExecuteNonQuery(sql); } } } - private void FrmShResult_Load(object sender, EventArgs e) - { - - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的垂直距离 并在表格中记录符合要求的管线 - /// - /// - /// - /// - /// - private void VerticalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double verticalDistance = 1; - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - //GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - verticalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - GSOGeoPolygon3D polygon = line1.CreateBuffer(verticalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) continue; - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < verticalDistance) - { - int idx = -1; - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "垂直净距分析") - { - feat2.HighLight = true; - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - markerPosition = LabelVerticalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - idx = dgridShVResult.Rows.Add(); - dgridShVResult.Rows[idx].Cells[0].Value = caption; - dgridShVResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShVResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShVResult.Rows[idx].Cells[3].Value = feat2.Name; - dgridShVResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShVResult.Rows[idx].Cells[5].Value = verticalDistance.ToString("0.00"); - // } - } - } - } - line2.ReleaseInnerPointer(); - feat2.ReleaseInnerPointer(); - } - feats2.ReleaseInnerPointer(); - } - } - line1.ReleaseInnerPointer(); - selectedFeature.ReleaseInnerPointer(); - } - /// - /// 查找指定图层中在 指定范围内的feature对象集合 - /// - /// - /// - /// - private GSOFeatures Polygon_Contain_PointAnalysis(GSOGeoPolygon3D polygon, string layername) - { - GSOFeatures feats = new GSOFeatures(); - GSOLayer layer = globleControl1.Globe.Layers.GetLayerByCaption(layername); - if (layer == null) - { - return feats; - } - GSOFeatureLayer flayer = layer as GSOFeatureLayer; - if (flayer != null) - { - GSOFeatureDataset fdataset = flayer.Dataset as GSOFeatureDataset; - } - - if (polygon == null) - { - feats = flayer.GetAllFeatures(); - } - else - { - feats = flayer.FindFeaturesInPolygon(polygon, false); - } - return feats; - } - /// - /// 在指定的两点组成的线的中间添加一个marker对象,并将marker对象添加到指定的图层中 - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelVerticalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "垂直"+distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - - private GSOPoint3d LabelHorizontalDistance(GSOLayer markerLayer, GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible) - { - if (pntIntersect1 == null || pntIntersect2 == null) - { - return new GSOPoint3d(); - } - GSOGeoPolyline3D disline = new GSOGeoPolyline3D(); - GSOPoint3ds point3ds = new GSOPoint3ds(); - point3ds.Add(pntIntersect1); - point3ds.Add(pntIntersect2); - disline.AddPart(point3ds); - GSOSimpleLineStyle3D style = new GSOSimpleLineStyle3D(); //创建线的风格 - //设置透明度及颜色,FromArgb()中的四个参数分别为alpha、red、green、blue,取值范围为0到255 - style.LineColor = Color.GreenYellow; - style.LineWidth = 3; //设置线的宽度为3 - style.VertexVisible = true; //显示线的节点 - disline.Style = style; //把风格添加到线上 - disline.AltitudeMode = EnumAltitudeMode.Absolute; - - GSOFeature line = new GSOFeature(); - line.Geometry = disline; - - GSOGeoMarker dismarker = new GSOGeoMarker(); - dismarker.X = pntIntersect1.X; - dismarker.Y = pntIntersect1.Y; - dismarker.Z = (pntIntersect1.Z + pntIntersect2.Z) / 2; - dismarker.Text = "水平" + distance.ToString("0.00") + "米"; - dismarker.AltitudeMode = EnumAltitudeMode.Absolute; - GSOMarkerStyle3D styleMarker = new GSOMarkerStyle3D(); - GSOTextStyle styleText = new GSOTextStyle(); - styleText.IsSizeFixed = true; - styleText.ForeColor = Color.White; - styleText.FontSize = 20; - styleMarker.TextStyle = styleText; - dismarker.Style = styleMarker; - - GSOFeature marker = new GSOFeature(); - marker.Geometry = dismarker; - - line.Visible = marker.Visible = markerVisible; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 计算指定feature对象与除了该feature所在图层之外的 所有管线图层中的所有feature对象 的水平距离 并记录符合要求的管线 功能 - /// - /// - /// - /// - /// - private void HorizontalDistanceAnalysis(string type, GSOFeature selectedFeature, List _pipelineLayerNames) - { - double horizontalDistance = 1; - #region - if (selectedFeature == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - GSOGeoPolyline3D line1 = selectedFeature.Geometry as GSOGeoPolyline3D; - if (line1 == null) - { - selectState = 0; - MessageBox.Show("请选择一条管线!"); - return; - } - - string caption = selectedFeature.Dataset.Caption; - - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - - for (int i = 0; i < _pipelineLayerNames.Count; i++) - { - horizontalDistance = ClassYJSHModel.CalculateDistance(layername, _pipelineLayerNames[i]); - - GSOGeoPolygon3D polygon = line1.CreateBuffer(horizontalDistance, true, 5, true, false); - - if (caption == _pipelineLayerNames[i]) - { - continue; - } - GSOLayer layer2 = globleControl1.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); - if (layer2 != null) - { - GSOFeatureLayer flayer2 = layer2 as GSOFeatureLayer; - GSOFeatureDataset fdataset2 = flayer2.Dataset as GSOFeatureDataset; - GSOFeatures feats2 = Polygon_Contain_PointAnalysis(polygon, _pipelineLayerNames[i]); - for (int j = 0; j < feats2.Length; j++) - { - GSOFeature feat2 = feats2[j]; - GSOGeoPolyline3D line2 = feats2[j].Geometry as GSOGeoPolyline3D; - if (line2 == null) - { - continue; - } - - double dDist = -1; - dDist = globleControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - if (dDist > -1) - { - - if (dDist < horizontalDistance) - { - GSOPoint3d markerPosition = new GSOPoint3d(); - if (type == "水平净距分析") - { - /* - if (dDist.ToString("0.00") != "0.00") - { - * */ - feat2.HighLight = true; - int idx = dgridShHResult.Rows.Add(); - markerPosition = LabelHorizontalDistance(layerTemp, pntProIntersect1, pntProIntersect2, dDist, true); - - dgridShHResult.Rows[idx].Tag = feat2; - dgridShHResult.Rows[idx].Cells[0].Value = caption; - dgridShHResult.Rows[idx].Cells[1].Value = selectedFeature.Name; - dgridShHResult.Rows[idx].Cells[2].Value = layer2.Caption; - dgridShHResult.Rows[idx].Cells[3].Value = feats2[j].Name; - dgridShHResult.Rows[idx].Cells[4].Value = dDist.ToString("0.00"); - dgridShHResult.Rows[idx].Cells[5].Value = horizontalDistance.ToString(); - } - //} - } - - } - - } - } - } - #endregion - } /// /// 双击后围绕问题对象旋转 /// @@ -486,54 +123,15 @@ { if (e.RowIndex != -1) { + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShVResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShVResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - string scLayer = dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString(); - string scFeatureName = dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; - - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShVResult.Rows[e.RowIndex].Cells["审核图层"].Value.ToString()); - string shlayerid = (dgridShVResult.Rows[e.RowIndex].Cells["审核编号"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 50); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - ///高亮 - //LightMenu_Click(sender, e); - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } - } + } /// /// 双击后围绕问题对象旋转 /// @@ -543,69 +141,19 @@ { if (e.RowIndex != -1) { - string scLayer = dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString(); - string scFeatureName = dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString(); - GSOLayer scgsoLayer = globleControl1.Globe.Layers.GetLayerByCaption(scLayer); - GSOFeatures scgsoFeatures = scgsoLayer.GetFeatureByName(scFeatureName, false); - GSOFeature scgsoFeature = scgsoFeatures[0]; + GSOLayer gsoLayer = globleControl1.Globe.Layers.GetLayerByCaption( + dgridShHResult.Rows[e.RowIndex].Cells[0].Value.ToString()); + GSOFeatures gsoFeatures = gsoLayer.GetFeatureByName( + dgridShHResult.Rows[e.RowIndex].Cells[1].Value.ToString(), false); - AddMakerToLayer(globleControl1, scgsoFeature, scFeatureName); - highlight(); - /* - string shlayer = (dgridShHResult.Rows[e.RowIndex].Cells["审核图层1"].Value.ToString()); - string shlayerid = (dgridShHResult.Rows[e.RowIndex].Cells["审核编号1"].Value.ToString()); - - GSOLayer centerlayer = globleControl1.Globe.Layers.GetLayerByCaption(shlayer); - GSOFeatures feats = centerlayer.GetFeatureByName(shlayerid, true); - if (centerlayer != null) - { - for (int j = 0; j < feats.Length; j++) - { - if (feats[j].Name == shlayerid) - { - //m_feature = features[j]; - GSOFeature rowFeature = feats[j]; - if (rowFeature == null) - continue; - if (rowFeature.Geometry != null && rowFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - GSOGeoPolyline3D line = rowFeature.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]; - globleControl1.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 30); - globleControl1.Globe.FlyAroundPosition(point3d, true, 10, EnumFlyRepeatValueType.Degrees); - //高亮显示 - hlfeature = rowFeature; - highlight(); - } - else - { - globleControl1.Globe.JumpToFeature(rowFeature, 300); - } - } - } - } - */ - + ClassSearchAnalysis.AddMakerToLineFeature(globleControl1, gsoFeatures[0]); + highlight(gsoFeatures[0]); } } - /// - /// 清除渲染结果 - /// - public void ClearAnalyseResult() - { - dgridShHResult.Rows.Clear(); - dgridShVResult.Rows.Clear(); - layerTemp.RemoveAllFeature(); - globleControl1.Refresh(); - } - /// - /// 高亮显示 - /// - public void highlight(){ - flashflag = "single"; + public void highlight(GSOFeature feature) + { + hlfeature = feature; timer1.Start(); } /// @@ -615,42 +163,38 @@ /// private void timer1_Tick(object sender, EventArgs e) { - GSOFeature rowFeature = hlfeature;//as GSOFeature; - if (rowFeature == null) - return; + GSOFeature rowFeature = hlfeature; + if (rowFeature == null) return; - if (count < 40) - { - count++; - if (flashflag == "single") - { - if (rowFeature != null) - { - if (count % 2 != 0) - { - rowFeature.HighLight = true; - globleControl1.Refresh(); - } - else - { - rowFeature.HighLight = false; - globleControl1.Refresh(); - } - } - } - } - else + if (count >= 40) { timer1.Stop(); rowFeature.HighLight = false; count = 0; } + else + { + count++; + if (count%2 != 0) + { + rowFeature.HighLight = true; + globleControl1.Refresh(); + } + else + { + rowFeature.HighLight = false; + globleControl1.Refresh(); + } + } } private void FrmShResult_FormClosed(object sender, FormClosedEventArgs e) { mainfrm.boolfrmShResult = false; + globleControl1.Globe.MemoryLayer.RemoveAllFeature(); + timer1.Stop(); } + /// /// 一键审核导出 /// @@ -658,141 +202,23 @@ /// private void buttonExp1_Click(object sender, EventArgs e) { - if (dgridShHResult.Rows.Count > 0 || dgridShVResult.Rows.Count > 0) - { - string strSaveFile = string.Empty; - SaveFileDialog savefiledialog = new SaveFileDialog(); - savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; - savefiledialog.AddExtension = true; - savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + DateTime.Now.Minute + DateTime.Now.Second; - if (savefiledialog.ShowDialog() == DialogResult.OK) - { - strSaveFile = savefiledialog.FileName; - } - else - { - return; - } - - ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); - MessageBox.Show("导出成功!"); - } - else + if (dgridShHResult.Rows.Count <= 0 && dgridShVResult.Rows.Count <= 0) { MessageBox.Show("表格内容为空!", "提示"); + return; } - } + string strSaveFile = string.Empty; + SaveFileDialog savefiledialog = new SaveFileDialog(); + savefiledialog.Filter = "Excel文件|*.xls,*.xlsx"; + savefiledialog.AddExtension = true; + savefiledialog.FileName = "一键审核" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.Hour + + DateTime.Now.Minute + DateTime.Now.Second; + if (savefiledialog.ShowDialog() != DialogResult.OK) return; + else strSaveFile = savefiledialog.FileName; - /// - /// 地球场景中添加lable标注 - /// - /// - /// - /// - private void AddMakerToLayer(GSOGlobeControl glb, GSOFeature gsoFeature, string FeatureName) - { - glb.Globe.MemoryLayer.RemoveAllFeature(); + ExpEXCEL.ExpToExcel(dgridShHResult, dgridShVResult, strSaveFile); + MessageBox.Show("导出成功!"); - GSOFeature radiusMarkerFeature; - if (gsoFeature != null) - { - GSOGeoPolyline3D selLine = gsoFeature.Geometry as GSOGeoPolyline3D; - - if (selLine[0].Count > 1) - { - GSOLayer makerLayer = glb.Globe.MemoryLayer; - - GSOGeoPoint3D pt = new GSOGeoPoint3D(); - GSOPoint3d point3d = selLine.GeoCenterPoint; - pt.X = point3d.X; - pt.Y = point3d.Y; - pt.Z = point3d.Z; - - glb.Globe.JumpToPosition(point3d, EnumAltitudeMode.Absolute, 200); - - string radiusLabelName = FeatureName; - radiusMarkerFeature = new GSOFeature(); - GSOPoint2d point2d = new GSOPoint2d(0, 50); - if (makerLayer != null) - { - if (getLabelName(makerLayer) != -1) - { - radiusMarkerFeature = createLabel(makerLayer, radiusMarkerFeature, pt, radiusLabelName, (getLabelName(makerLayer) + 1).ToString(), point2d); - radiusMarkerFeature.Visible = true; - makerLayer.AddFeature(radiusMarkerFeature); - } - } - - glb.Refresh(); - } - } - } - - /// - /// 获取指定图层中最后一个feature对象的名称对应的整数 - /// - /// - /// - public int getLabelName(GSOLayer layer) - { - int nid = -1; - if (layer.GetAllFeatures().Length > 0) - { - string id = layer.GetAllFeatures()[layer.GetAllFeatures().Length - 1].Name; - int.TryParse(id, out nid); - } - else - { - nid = 0; - } - return nid; - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private GSOFeature createLabel(GSOLayer layer, GSOFeature feature, GSOGeoPoint3D point, string labelName, string featureName, GSOPoint2d point2d) - { - for (int i = layer.GetAllFeatures().Length - 1; i >= 0; i--) - { - GSOFeature gfeat = layer.GetAt(i); - if (gfeat != null && gfeat.Geometry != null && gfeat.Geometry.Type == EnumGeometryType.GeoPoint3D) - { - GSOGeoPoint3D pointItem = gfeat.Geometry as GSOGeoPoint3D; - if (pointItem.X == point.X && pointItem.Y == point.Y && pointItem.Z == point.Z) - { - layer.RemoveAt(i); - break; - } - } - } - point.AltitudeMode = EnumAltitudeMode.Absolute; - feature.Geometry = point; - feature.Name = featureName; - GSOLabel newLabel = new GSOLabel(); - newLabel.Text = labelName; - newLabel.Style = new GSOLabelStyle(); - newLabel.Style.Opaque = 0.8; - newLabel.Style.OutlineColor = Color.Gray; - newLabel.Style.TractionLineEndPos = point2d; - newLabel.Style.OutlineWidth = 1; - newLabel.Style.TracktionLineWidth = 3; - newLabel.Style.TractionLineColor = Color.Green; - - Color color1 = Color.FromArgb(60, 187, 206, 230); - Color color2 = Color.FromArgb(150, 187, 200, 250); - newLabel.Style.BackBeginColor = color1; - newLabel.Style.BackEndColor = color2; - - feature.Label = newLabel; - return feature; } } diff --git a/MainFrm.cs b/MainFrm.cs index b7c7c39..d0bdbb9 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -1112,8 +1112,6 @@ t1.Start(); } - //delegate void LoadDataForGlobalControl(); - private void connectServer() { globeControl1.Globe.ConnectServer(Utility.serverip, Utility.serverport, "", ""); //加载locaServer中的数据 @@ -1808,6 +1806,7 @@ GSOLayer lsLayer = globeControl1.Globe.Layers.GetLayerByCaption(node.Text); double x = lsLayer.LatLonBounds.Center.X; double y = lsLayer.LatLonBounds.Center.Y; + if (x == 0 && y == 0) { x = lsLayer.Bounds.Center.X; @@ -5800,7 +5799,7 @@ } } } - /// + /// /// 一键审核功能 /// /// @@ -5808,8 +5807,8 @@ private void buttonItem128_Click(object sender, EventArgs e) { LogManager.saveLog(Utility.userName, buttonItem128.Text); - frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); + frmSh = new FrmYJSHTC(globeControl1, globeControl2, layerTree); if (frmSh.ShowDialog() == DialogResult.OK) { frmWait = new FrmWait("一键审核……"); @@ -5821,102 +5820,86 @@ thread.Start(); } } - + void doWork() { FrmShResult frmShResult = null; + //double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; - double dVerticalJingJuBiaoZhun = 1, dHorizontalJingJuBiaoZhun = 1; if (frmSh.rukuLayer != null) { - #region - Invoke((EventHandler) delegate + try { - try + this.Invoke((EventHandler) delegate { - List managerLayerList = new List(); - for (int i = 0; i < layerManagerNode.Nodes.Count; i++) - { - managerLayerList.Add(layerManagerNode.Nodes[i].Text); - } - if (!managerLayerList.Contains(frmSh.rukuLayer.Caption)) - { - TreeNode node = new TreeNode(); - node.Tag = frmSh.rukuLayer; - node.Text = frmSh.rukuLayer.Dataset.Caption; - node.ImageIndex = 0; - node.SelectedImageIndex = 0; - node.Checked = frmSh.rukuLayer.Visible; - layerManagerNode.Nodes.Insert(0, node); - layerManagerNode.Expand(); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "提示"); - } - }); - #endregion + addNodeToManagerNode(frmSh.rukuLayer); + }); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "提示"); + } shlayername = frmSh.rukuLayer.Name; globeControl1.Refresh(); } - //#region wxl 下面unreachable - //if (frmShResult != null && !frmShResult.IsDisposed) - //{ - // try - // { - // clearFeatureHighLight(); - // ClearRedlineAnalyseResult(); - // frmShResult.Close(); - // } - // catch (Exception ex) - // { - // MessageBox.Show(ex.Message); - // } - //} - //#endregion wxl - frmShResult = new FrmShResult(dVerticalJingJuBiaoZhun, dHorizontalJingJuBiaoZhun, shlayername, globeControl1, - Utility.m_PipelineLayerNames); + frmShResult = new FrmShResult(shlayername, globeControl1, Utility.m_PipelineLayerNames); if (boolfrmShResult) return; - frmShResult.Location = new Point(Width - frmShResult.Width - 10, Height - frmShResult.Height - 50); frmShResult.Owner = this; - //一键审核实际计算步骤 frmShResult.analysis(); - //MainFrm窗体显示控制,回到一键审核Tab - Invoke((EventHandler) delegate + try { - frmShResult.Show(); - frmWait.Close(); - //将tab页恢复到一键审核 - ribbonTabItem11.Checked = true; - try + this.Invoke((EventHandler)delegate { - globeControl1.Globe.Action = EnumAction3D.ActionNull; - splitContainer1.Panel2Collapsed = true; - - panelOfTable.Visible = false; - legendSC.Visible = false; - legendSG.Visible = false; - - GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); - if (redLayer != null) - { - redLayer.Visible = false; - } - } - catch (Exception ex) - { - MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - }); - + frmShResult.Show(); + returnShTap(); + }); + } + catch (Exception ex) + { + MessageBox.Show("系统运行错误:" + ex, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } boolfrmShResult = true; } + + private void addNodeToManagerNode(GSOLayer layer) + { + List managerLayerList = new List(); + for (int i = 0; i < layerManagerNode.Nodes.Count; i++)//layerManagerNode 临时图层 + { + managerLayerList.Add(layerManagerNode.Nodes[i].Text); + } + if (!managerLayerList.Contains(layer.Dataset.Caption)) + { + TreeNode node = new TreeNode(); + node.Tag = layer; + node.Text = layer.Dataset.Caption; + node.ImageIndex = 0; + node.SelectedImageIndex = 0; + node.Checked = layer.Visible; + layerManagerNode.Nodes.Insert(0, node); + layerManagerNode.Expand(); + } + } + + void returnShTap() + { + frmWait.Close(); + ribbonTabItem11.Checked = true; + globeControl1.Globe.Action = EnumAction3D.ActionNull; + splitContainer1.Panel2Collapsed = true; + + panelOfTable.Visible = false; + legendSC.Visible = false; + legendSG.Visible = false; + + GSOLayer redLayer = globeControl1.Globe.Layers.GetLayerByCaption("红线"); + if (redLayer != null) + redLayer.Visible = false; + } /// /// 清除渲染结果 /// diff --git a/Program.cs b/Program.cs index bd3fa95..ece4a85 100644 --- a/Program.cs +++ b/Program.cs @@ -39,8 +39,6 @@ string programUrl = getProgramUrl(localConfigPath, "programurl"); if (programUrl != "") { - - //FrmDownloadProgress frmdownload = FrmDownloadProgress.getForm(programUrl); Process.Start(ent + "/UpDateProgress.exe").WaitForExit(); return; } diff --git a/ShResult.cs b/ShResult.cs index 433c3de..79081c4 100644 --- a/ShResult.cs +++ b/ShResult.cs @@ -7,7 +7,6 @@ public ShResult() { } - public ShResult(string _layerid, string _question) { layerid = _layerid; diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe index 89a05f3..65db2ee 100644 --- a/bin/x86/Debug/Cyberpipe.exe +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb index ff80739..6491630 100644 --- a/bin/x86/Debug/Cyberpipe.pdb +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/bin/x86/Debug/MyPlace.kml b/bin/x86/Debug/MyPlace.kml index bad2179..6036f64 100644 --- a/bin/x86/Debug/MyPlace.kml +++ b/bin/x86/Debug/MyPlace.kml @@ -1,101 +1,3 @@ - - - - 1 - - relativeToGround - - - - 120.611131732338,31.187759658792,0 - 120.611174179651,31.1877622151576,0 - 120.611198294644,31.1874824180543,0 - 120.611155847473,31.1874798616962,0 - 120.611131732338,31.187759658792,0 - - - - - - - 1 - - - absolute - - 120.611155826595,31.1877276306654,-1.88476951327175 - 120.611155826633,31.1877276302315,-1.84700015000999 - - - - - 垂直0.04米 - 1 - - - absolute - - 120.611155826595,31.1877276306654,-1.86588483164087 - - - - - 1 - - - absolute - - 120.611176765514,31.187484684993,-1.91999998688698 - 120.611163381257,31.1874838407729,-1.91999985929579 - - - - - 水平1.28米 - 1 - - - absolute - - 120.611176765514,31.187484684993,-1.91999992309138 - - - - - + diff --git a/bin/x86/Debug/glVersion.txt b/bin/x86/Debug/glVersion.txt index 1fc46d0..06a7613 100644 --- a/bin/x86/Debug/glVersion.txt +++ b/bin/x86/Debug/glVersion.txt Binary files differ