diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/bin/x86/Debug/Config.xml b/bin/x86/Debug/Config.xml index 508515a..950c0af 100644 --- a/bin/x86/Debug/Config.xml +++ b/bin/x86/Debug/Config.xml @@ -2,10 +2,10 @@ LocaSpace三维地下管线信息系统 release - SZHTDB2 + szhtdb2 192.168.0.203 release - 192.168.0.203 + 127.0.0.1 1500 http://192.168.0.203/images/ http://192.168.0.203/images/default.jpg diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/bin/x86/Debug/Config.xml b/bin/x86/Debug/Config.xml index 508515a..950c0af 100644 --- a/bin/x86/Debug/Config.xml +++ b/bin/x86/Debug/Config.xml @@ -2,10 +2,10 @@ LocaSpace三维地下管线信息系统 release - SZHTDB2 + szhtdb2 192.168.0.203 release - 192.168.0.203 + 127.0.0.1 1500 http://192.168.0.203/images/ http://192.168.0.203/images/default.jpg diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe new file mode 100644 index 0000000..89a05f3 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/bin/x86/Debug/Config.xml b/bin/x86/Debug/Config.xml index 508515a..950c0af 100644 --- a/bin/x86/Debug/Config.xml +++ b/bin/x86/Debug/Config.xml @@ -2,10 +2,10 @@ LocaSpace三维地下管线信息系统 release - SZHTDB2 + szhtdb2 192.168.0.203 release - 192.168.0.203 + 127.0.0.1 1500 http://192.168.0.203/images/ http://192.168.0.203/images/default.jpg diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe new file mode 100644 index 0000000..89a05f3 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb new file mode 100644 index 0000000..ff80739 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/bin/x86/Debug/Config.xml b/bin/x86/Debug/Config.xml index 508515a..950c0af 100644 --- a/bin/x86/Debug/Config.xml +++ b/bin/x86/Debug/Config.xml @@ -2,10 +2,10 @@ LocaSpace三维地下管线信息系统 release - SZHTDB2 + szhtdb2 192.168.0.203 release - 192.168.0.203 + 127.0.0.1 1500 http://192.168.0.203/images/ http://192.168.0.203/images/default.jpg diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe new file mode 100644 index 0000000..89a05f3 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb new file mode 100644 index 0000000..ff80739 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/bin/x86/Debug/MyPlace.kml b/bin/x86/Debug/MyPlace.kml index 6036f64..bad2179 100644 --- a/bin/x86/Debug/MyPlace.kml +++ b/bin/x86/Debug/MyPlace.kml @@ -1,3 +1,101 @@ - + + + + 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/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/bin/x86/Debug/Config.xml b/bin/x86/Debug/Config.xml index 508515a..950c0af 100644 --- a/bin/x86/Debug/Config.xml +++ b/bin/x86/Debug/Config.xml @@ -2,10 +2,10 @@ LocaSpace三维地下管线信息系统 release - SZHTDB2 + szhtdb2 192.168.0.203 release - 192.168.0.203 + 127.0.0.1 1500 http://192.168.0.203/images/ http://192.168.0.203/images/default.jpg diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe new file mode 100644 index 0000000..89a05f3 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb new file mode 100644 index 0000000..ff80739 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/bin/x86/Debug/MyPlace.kml b/bin/x86/Debug/MyPlace.kml index 6036f64..bad2179 100644 --- a/bin/x86/Debug/MyPlace.kml +++ b/bin/x86/Debug/MyPlace.kml @@ -1,3 +1,101 @@ - + + + + 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/databaseConfig.xml b/bin/x86/Debug/databaseConfig.xml index 8d4d3bd..256cb30 100644 --- a/bin/x86/Debug/databaseConfig.xml +++ b/bin/x86/Debug/databaseConfig.xml @@ -7,10 +7,10 @@ release - 192.168.0.203 - scott - szsgdb2 - szsgdb2 + 127.0.0.1 + SZSG + scott + SZSG 127.0.0.1 diff --git a/ClassDoubleScreenCompare.cs b/ClassDoubleScreenCompare.cs new file mode 100644 index 0000000..f2935da --- /dev/null +++ b/ClassDoubleScreenCompare.cs @@ -0,0 +1,201 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using GeoScene.Globe; +using GeoScene.Data; +using GeoScene.Engine; +using System.Drawing; + +namespace Cyberpipe +{ + class ClassDoubleScreenCompare + { + public static GSOFeature getSameFeatureFromOtherGlobe(GSOFeature feature, + GSOGlobeControl globeControl1, GSOGlobeControl globeControl2,double bufferWidth,GSOGeoPolygon3D resPolygon) + { + GSOLayer layer; + GSOFeatures features = new GSOFeatures(); + + if (!feature.Dataset.Caption.StartsWith("施工")) + { + layer = feature.Dataset.Caption == "供电管线" + ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") + : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(feature, fs[i], globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + else + { + layer = feature.Dataset.Caption == "施工电力管线" + ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") + : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); + + GSOFeatures fs = layer.FindFeaturesInPolygon(resPolygon, false); + + for (int i = 0; i < fs.Length; i++) + { + if (isSimilarFeature(fs[i], feature, globeControl1, globeControl2, bufferWidth)) + features.Add(fs[i]); + } + } + + return getMostSimilarFeatureFromFeatures(feature, features); + + } + + + private static GSOFeature getMostSimilarFeatureFromFeatures(GSOFeature feature, GSOFeatures features) + { + double maxLength = 0; + GSOFeature f = new GSOFeature(); + GSOGeoPolyline3D line = feature.Geometry as GSOGeoPolyline3D; + + if (features.Length == 0) return null; + if (features.Length == 1) + { + f = features[0]; + f.HighLight = true; + } + else + { + for (int m = 0; m < features.Length; m++) + { + GSOGeoPolyline3D tempSGLine = features[m].Geometry as GSOGeoPolyline3D; + + double tempLength = tempSGLine.GetSpaceLength(false, 6378137); + double lengthAbs = Math.Abs(tempLength - line.GetSpaceLength(false, 6378137)); + if (m == 0) + { + f = features[0]; + f.HighLight = true; + maxLength = lengthAbs; + } + else if (lengthAbs < maxLength) + { + f = features[m]; + f.HighLight = true; + maxLength = lengthAbs; + } + } + } + return f; + } + + private static bool isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, double bufferWidth) + { + GSOGeoPolyline3D line = feature1.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = line.CreateBuffer(bufferWidth * 2, true, 5, true, false); + + if (bufferPolygon == null) return false; + + GSOFeatures featuresInLayer = layer.FindFeaturesInPolygon(bufferPolygon, true); + + if (featuresInLayer == null || featuresInLayer.Length <= 0) + return false; + + for (int i = 0; i < featuresInLayer.Length; i++) + { + if (featuresInLayer[i].Name == feature2.Name) + { + return true; + break; + } + } + return false; + } + + private static bool isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature, + GSOGlobeControl globeControl1,GSOGlobeControl globeControl2,double bufferWidth) + { + GSOLayer dscLayer = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); + GSOLayer srcLayer = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); + + if (!isSameFeature(srcFeature, dscFeature, dscLayer, bufferWidth) + && !isSameFeature(dscFeature, srcFeature, srcLayer, bufferWidth)) + return false; + return true; + } + + public static void CalculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2, + out double horizonDistance, out double verticalDistance, GSOGlobeControl globeControl1, GSOGlobeControl globeControl2) + { + GSOPoint3d pntIntersect1 = new GSOPoint3d(); + GSOPoint3d pntIntersect2 = new GSOPoint3d(); + GSOPoint3d pntProIntersect1 = new GSOPoint3d(); + GSOPoint3d pntProIntersect2 = new GSOPoint3d(); + + verticalDistance = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, + out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); + 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); + + } + + 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/Cyberpipe.csproj b/Cyberpipe.csproj index ea462be..a0ba3b3 100644 --- a/Cyberpipe.csproj +++ b/Cyberpipe.csproj @@ -203,6 +203,7 @@ + diff --git a/DoublePanelAnalysis.cs b/DoublePanelAnalysis.cs index 123caf1..2c45db6 100644 --- a/DoublePanelAnalysis.cs +++ b/DoublePanelAnalysis.cs @@ -258,42 +258,25 @@ for (int i = 0; i < scLayer.GetAllFeatures().Length; i++) { GSOFeature scFeature = scLayer.GetAt(i); - if (scFeature.GetFieldAsString("所属道路") == road) + if (scFeature.GetFieldAsString("所属道路") != road) continue; + GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; + GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + + GSOFeature sgFeature = null; + GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); + + //**判断同一个Feature + if (sgFeatures.Length >= 1) { - GSOGeoPolyline3D scLine = scFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D bufferPolygon = scLine.CreateBuffer(bufferWidth, true, 5, true, false); + sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); - GSOFeature sgFeature = null; - GSOFeatures sgFeatures = sgLayer.FindFeaturesInPolygon(bufferPolygon, true); - - //**判断同一个Feature - if (sgFeatures.Length >= 1) + if (sgFeature != null) { - sgFeature = GetSameFeature(scFeature, scLayer, sgLayer, bufferWidth); + GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; + double horizonDistance, verticalDistance; - if (sgFeature != null) - { - GSOGeoPolyline3D sgLine = sgFeature.Geometry as GSOGeoPolyline3D; - double horizonDistance, verticalDistance; - - CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); - GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); - } - else - { - scFeature.HighLight = true; - DataRow dr = dt.NewRow(); - dr[0] = scLayer.Caption; - dr[1] = scFeature.GetFieldAsString("编号"); - dr[2] = sgLayer.Caption; - dr[3] = "无"; - dr[4] = "无"; - dr[5] = "0.02"; - dr[6] = "无"; - dr[7] = "0.02"; - dr[8] = "未设计管段"; - dt.Rows.Add(dr); - } + CalculateDistance(out verticalDistance, out horizonDistance, scLine, sgLine); + GongDianAnalysis(scLayer.Caption, sgLayer.Caption, scFeature, sgFeature, horizonDistance, verticalDistance, dt); } else { @@ -311,6 +294,21 @@ dt.Rows.Add(dr); } } + else + { + scFeature.HighLight = true; + DataRow dr = dt.NewRow(); + dr[0] = scLayer.Caption; + dr[1] = scFeature.GetFieldAsString("编号"); + dr[2] = sgLayer.Caption; + dr[3] = "无"; + dr[4] = "无"; + dr[5] = "0.02"; + dr[6] = "无"; + dr[7] = "0.02"; + dr[8] = "未设计管段"; + dt.Rows.Add(dr); + } } } /// diff --git a/FrmCompareFeature.cs b/FrmCompareFeature.cs index a05e8e7..ac622c4 100644 --- a/FrmCompareFeature.cs +++ b/FrmCompareFeature.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.Data; using System.Drawing; using System.Windows.Forms; @@ -11,26 +10,16 @@ { public partial class FrmCompareFeature : Office2007Form { - GSOFeature srcFeature; - GSOFeature dscFeature; - GSOGlobeControl globeControl1; - GSOGlobeControl globeControl2; - bool isSamePolyline; - - GSOLayer layerTemp; - GSOLayer layerTemp2; - GSOFeature new_feat; + private GSOFeature srcFeature, dscFeature; + private GSOGlobeControl globeControl1, globeControl2; GSOGeoPolygon3D resPolygon; - static FrmCompareFeature frm; - public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2, int width) + public static void ShowForm(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, int width) { if (frm == null) { - frm = new FrmCompareFeature(_globeControl1, _globeControl2, _layerTemp, _layerTemp2); - + frm = new FrmCompareFeature(_globeControl1, _globeControl2); frm.Location = new Point((width - frm.Width)/2, 50); frm.Show(_globeControl1.Parent); } @@ -41,8 +30,7 @@ } } - public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2, - GSOLayer _layerTemp, GSOLayer _layerTemp2) + public FrmCompareFeature(GSOGlobeControl _globeControl1, GSOGlobeControl _globeControl2) { globeControl1 = _globeControl1; globeControl2 = _globeControl2; @@ -50,99 +38,35 @@ globeControl1.Globe.Action = EnumAction3D.SelectObject; globeControl2.Globe.Action = EnumAction3D.SelectObject; - layerTemp = _layerTemp; - layerTemp2 = _layerTemp2; globeControl1.MouseClick += globeControl1_MouseClick; globeControl2.MouseClick += globeControl2_MouseClick; } + private void invalParam() + { + if (srcFeature == null || dscFeature == null) + { + MessageBox.Show("请选择要对比的管段!", "提示"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) + { + MessageBox.Show("请选择同种类型图层!"); + return; + } + else if (srcFeature.Geometry.Type != dscFeature.Geometry.Type || + srcFeature.Geometry.Type != EnumGeometryType.GeoPolyline3D) + return; + } + private void buttonAnalysis_Click(object sender, EventArgs e) { + invalParam(); + dataGridViewX1.DataSource = null; - - double bufferWidth = Convert.ToDouble(textBox1.Text); - - if (srcFeature == null || dscFeature == null) - MessageBox.Show("请选择要对比的管段!", "提示"); - else - { - if (srcFeature.Geometry.Type != dscFeature.Geometry.Type) - MessageBox.Show("请选择同种类型图层!"); - else if (srcFeature.Geometry.Type == dscFeature.Geometry.Type && - srcFeature.Geometry.Type == EnumGeometryType.GeoPolyline3D) - { - lineLayerCompare(srcFeature, dscFeature, bufferWidth); - if (!isSamePolyline) - MessageBox.Show("实测管段与施工管段非同一条管段,请选择同一管段进行比较!", "提示"); - else - { - lineFeatureCompare(srcFeature, dscFeature); - globeControl1.Globe.Action = EnumAction3D.ActionNull; - globeControl2.Globe.Action = EnumAction3D.ActionNull; - } - } - else - MessageBox.Show("无法处理该类型图层!"); - } + lineFeatureCompare(srcFeature, dscFeature); } - - /// - /// 在容差范围内判断是否同一根管段 - /// - /// - /// - /// - /// - private bool lineLayerCompare(GSOFeature srcFeature, GSOFeature dscFeature, double bufferWidth) - { - isSamePolyline = false; - - GSOGeoPolyline3D srcLine = srcFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D srcBufferPolygon = srcLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer dsc = globeControl2.Globe.Layers.GetLayerByCaption(dscFeature.Dataset.Caption); - - if (srcBufferPolygon != null) - { - GSOFeatures featuresInSrcLayer = dsc.FindFeaturesInPolygon(srcBufferPolygon, true); - - if (featuresInSrcLayer != null && featuresInSrcLayer.Length > 0) - { - for (int i = 0; i < featuresInSrcLayer.Length; i++) - { - if (featuresInSrcLayer[i].Name == dscFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; - GSOGeoPolygon3D dscBufferPolygon = dscLine.CreateBuffer(bufferWidth * 2, true, 5, true, false); - GSOLayer src = globeControl1.Globe.Layers.GetLayerByCaption(srcFeature.Dataset.Caption); - - if (dscBufferPolygon != null) - { - GSOFeatures featuresInDscLayer = src.FindFeaturesInPolygon(dscBufferPolygon, true); - - if (featuresInDscLayer != null && featuresInDscLayer.Length > 0) - { - for (int i = 0; i < featuresInDscLayer.Length; i++) - { - if (featuresInDscLayer[i].Name == srcFeature.Name) - { - isSamePolyline = true; - break; - } - } - } - } - - return isSamePolyline; - } - /// /// 分析两根管段的具体差异 /// @@ -156,8 +80,10 @@ GSOGeoPolyline3D dscLine = dscFeature.Geometry as GSOGeoPolyline3D; double dscLineLength = dscLine.GetSpaceLength(false, 6378137); - double horizonDistance = calculateDistance(srcLine, dscLine,false); - double verticalDistance = calculateDistance(srcLine, dscLine,true); + double horizonDistance, verticalDistance; + + ClassDoubleScreenCompare.CalculateDistance(srcLine, dscLine, out horizonDistance, + out verticalDistance,globeControl1,globeControl2); DataTable dt = new DataTable(); dt.Columns.Add("数据名称"); @@ -189,6 +115,98 @@ dt.Rows.Add(dscRow); dataGridViewX1.DataSource = dt; + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) + { + globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); + + GSOFeature new_feat = new GSOFeature(); + resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); + resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; + new_feat.Geometry = resPolygon; + + globeControl1.Globe.MemoryLayer.AddFeature(new_feat); + globeControl2.Globe.MemoryLayer.AddFeature(new_feat); + + globeControl1.Refresh(); + globeControl2.Refresh(); + } + + public static void clearFeatureHighLight(GSOGlobeControl glb) + { + for (int i = 0; i < glb.Globe.Layers.Count; i++) + { + GSOLayer layer = glb.Globe.Layers[i]; + if (!(layer is GSOFeatureLayer)) continue; + GSOFeatures feats = layer.GetAllFeatures(); + for (int j = 0; j < feats.Length; j++) + { + feats[j].HighLight = false; + } + } + } + + void globeControl1_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl1.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl1.Globe.Action != EnumAction3D.SelectObject || + globeControl1.Globe.SelectedObject == null) + return; + GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + srcFeature = globeControl1.Globe.SelectedObject; + dscFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(srcFeature, + globeControl1,globeControl2,bufferWidth,resPolygon); + + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } + + void globeControl2_MouseClick(object sender, MouseEventArgs e) + { + + if (globeControl2.Globe.SelectedObject == null) return; + clearFeatureHighLight(globeControl1); + clearFeatureHighLight(globeControl2); + + try + { + double bufferWidth = Convert.ToDouble(textBox1.Text); + resPolygon = null; + + if (globeControl2.Globe.Action != EnumAction3D.SelectObject || + globeControl2.Globe.SelectedObject == null) + return; + + GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; + addPologyToGlobeControl(line, bufferWidth); + + dscFeature = globeControl2.Globe.SelectedObject; + srcFeature = ClassDoubleScreenCompare.getSameFeatureFromOtherGlobe(dscFeature, + globeControl1, globeControl2, bufferWidth, resPolygon); + } + catch (Exception ex) + { + LogError.PublishError(ex); + } + } private void FrmCompareFeature_FormClosing(object sender, FormClosingEventArgs e) @@ -198,322 +216,5 @@ frm = null; } - private void addPologyToGlobeControl(GSOGeoPolyline3D line, double bufferWidth) - { - new_feat = new GSOFeature(); - resPolygon = line.CreateBuffer(bufferWidth*2, true, 0, false, false); - resPolygon.AltitudeMode = EnumAltitudeMode.RelativeToGround; - new_feat.Geometry = resPolygon; - - layerTemp.AddFeature(new_feat); - layerTemp2.AddFeature(new_feat); - globeControl1.Refresh(); - globeControl2.Refresh(); - } - - private GSOLayer getSameLayer(GSOFeature feature) - { - GSOLayer layer = null; - if (!feature.Dataset.Caption.StartsWith("施工")) - { - layer = feature.Dataset.Caption == "供电管线" - ? globeControl2.Globe.Layers.GetLayerByCaption("施工电力管线") - : globeControl2.Globe.Layers.GetLayerByCaption("施工" + feature.Dataset.Caption); - } - else - { - layer = feature.Dataset.Caption == "施工电力管线" - ? globeControl1.Globe.Layers.GetLayerByCaption("供电管线") - : globeControl1.Globe.Layers.GetLayerByCaption(feature.Dataset.Caption.Replace("施工", "")); - } - - return layer; - } - - /// - /// 地球1中点击地球2中同步添加缓冲区 - /// - /// - /// - void globeControl1_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl1.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl1.Globe.Action == EnumAction3D.SelectObject && - globeControl1.Globe.SelectedObject != null) - { - GSOGeoPolyline3D line = globeControl1.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - addPologyToGlobeControl(line, bufferWidth); - } - - srcFeature = globeControl1.Globe.SelectedObject; - GSOLayer layers = getSameLayer(srcFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = srcFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(srcFeature, features[i], Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - listFeatures.Add(features[i]); - } - calculate(out maxLength, out dscFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - /// - /// 地球2中点击地球1中同步添加缓冲区 - /// - /// - /// - void globeControl2_MouseClick(object sender, MouseEventArgs e) - { - layerTemp.Visible = true; - layerTemp2.Visible = true; - GSOFeatures listFeatures = new GSOFeatures(); - double maxLength = 0; - - if (globeControl2.Globe.SelectedObject == null) return; - else - { - clearFeatureHighLight(globeControl1, globeControl2); - try - { - double bufferWidth = Convert.ToDouble(textBox1.Text); - resPolygon = null; - - if (globeControl2.Globe.Action != EnumAction3D.SelectObject || - globeControl2.Globe.SelectedObject == null) - return; - else - { - GSOGeoPolyline3D line = globeControl2.Globe.SelectedObject.Geometry as GSOGeoPolyline3D; - - addPologyToGlobeControl(line, bufferWidth); - } - - dscFeature = globeControl2.Globe.SelectedObject; - //双屏同时选中同一管段 - GSOLayer layers = getSameLayer(dscFeature); - - GSOFeatures features = layers.FindFeaturesInPolygon(resPolygon, false); - GSOGeoPolyline3D scLine = dscFeature.Geometry as GSOGeoPolyline3D; - - for (int i = 0; i < features.Length; i++) - { - lineLayerCompare(features[i], dscFeature, Convert.ToDouble(textBox1.Text)); - if (isSamePolyline) - { - listFeatures.Add(features[i]); - } - } - calculate(out maxLength, out srcFeature, listFeatures, scLine); - - } - catch (Exception ex) - { - LogError.PublishError(ex); - } - } - } - - private void calculate(out double maxLength, out GSOFeature feature, GSOFeatures listFeatures, - GSOGeoPolyline3D scLine) - { - maxLength = 0; - feature=new GSOFeature(); - if (listFeatures.Length == 0) - feature = null; - else - { - if (listFeatures.Length == 1) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - } - else - { - for (int m = 0; m < listFeatures.Length; m++) - { - GSOGeoPolyline3D tempSGLine = listFeatures[m].Geometry as GSOGeoPolyline3D; - - double tempLength = tempSGLine.GetSpaceLength(false, 6378137); - double lengthAbs = Math.Abs(tempLength - scLine.GetSpaceLength(false, 6378137)); - if (m == 0) - { - feature = listFeatures[0]; - listFeatures[0].HighLight = true; - maxLength = lengthAbs; - } - else if (lengthAbs < maxLength) - { - feature = listFeatures[m]; - listFeatures[m].HighLight = true; - maxLength = lengthAbs; - } - } - } - } - } - - /// - /// 计算距离 - /// - /// - /// - /// - double calculateDistance(GSOGeoPolyline3D line1, GSOGeoPolyline3D line2,bool isVertical) - { - GSOPoint3d pntIntersect1 = new GSOPoint3d(); - GSOPoint3d pntIntersect2 = new GSOPoint3d(); - GSOPoint3d pntProIntersect1 = new GSOPoint3d(); - GSOPoint3d pntProIntersect2 = new GSOPoint3d(); - double dDist = 0; - if (isVertical) - { - dDist = globeControl1.Globe.Analysis3D.ComputeVerticalDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "垂直"); - } - else - { - dDist = globeControl1.Globe.Analysis3D.ComputeHorizonDistance(line1, line2, - out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); - - LabelDistance(layerTemp, layerTemp2, pntProIntersect1, pntProIntersect2, dDist, true, "水平"); - } - - return dDist; - } - - /// - /// 清除所有高亮Feature - /// - /// - private void clearFeatureHighLight(GSOGlobeControl glb1,GSOGlobeControl glb2) - { - layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); - //清除gbl1中高亮 - for (int i = 0; i < glb1.Globe.Layers.Count; i++) - { - GSOLayer layer = glb1.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - //清除gbl2中高亮 - for (int i = 0; i < glb2.Globe.Layers.Count; i++) - { - GSOLayer layer = glb2.Globe.Layers[i]; - if (!(layer is GSOFeatureLayer)) continue; - GSOFeatures feats = layer.GetAllFeatures(); - for (int j = 0; j < feats.Length; j++) - { - GSOFeature feat = feats[j]; - feat.HighLight = false; - } - } - } - - /// - /// 添加标注 - /// - /// - /// - /// - /// - /// - /// - private GSOPoint3d LabelDistance(GSOLayer markerLayer, GSOLayer markerLayer2, - GSOPoint3d pntIntersect1, GSOPoint3d pntIntersect2, double distance, bool markerVisible,string label) - { - 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; - markerLayer.AddFeature(line); - markerLayer.AddFeature(marker); - - markerLayer2.AddFeature(line); - markerLayer2.AddFeature(marker); - - return dismarker.Position; - } - /// - /// 控制标注和字体的颜色 - /// - /// - /// - /// - /// - /// - /// - /// - /// - private 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/FrmWait.Designer.cs b/FrmWait.Designer.cs index 99733ea..88f5a29 100644 --- a/FrmWait.Designer.cs +++ b/FrmWait.Designer.cs @@ -55,7 +55,6 @@ this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(0, 24); this.label1.TabIndex = 1; - this.label1.Click += new System.EventHandler(this.label1_Click); // // FrmWait // @@ -71,7 +70,7 @@ this.ShowIcon = false; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.Text = "正在处理,请稍后..."; - this.Load += new System.EventHandler(this.FrmWait_Load); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmWait_FormClosing); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/FrmWait.cs b/FrmWait.cs index d3b7a48..d645ae4 100644 --- a/FrmWait.cs +++ b/FrmWait.cs @@ -32,27 +32,6 @@ frm = null; } - private void FrmWait_Load(object sender, EventArgs e) - { - - - } - - - private void labelX2_Click(object sender, EventArgs e) - { - - } - - private void progressBarX1_Click(object sender, EventArgs e) - { - - } - - private void label1_Click(object sender, EventArgs e) - { - - } } } diff --git a/FrmYJSHTC.cs b/FrmYJSHTC.cs index 3572371..27b7186 100644 --- a/FrmYJSHTC.cs +++ b/FrmYJSHTC.cs @@ -143,9 +143,7 @@ for (int i = ctl1.Globe.Layers.Count - 1; i >= 0; i--) { if (ctl1.Globe.Layers[i].Caption == str) - { ctl1.Globe.Layers.Remove(ctl1.Globe.Layers[i]); - } } foreach (TreeNode n in layerTree.Nodes) @@ -155,20 +153,15 @@ for (int i = 0; i < n.Nodes.Count; i++) { if (n.Nodes[i].Text == str) - { n.Nodes[i].Remove(); - } } } } string sql = "delete from casic_audit_result where SH_LAYER = '" + str + "'"; - OledbHelper.sqlExecuteNonQuery(sql); - } } - } } diff --git a/MainFrm.cs b/MainFrm.cs index ba3bf31..7dd16a4 100644 --- a/MainFrm.cs +++ b/MainFrm.cs @@ -6336,16 +6336,15 @@ globeControl1.Globe.ClearMeasure(); layerTemp.RemoveAllFeature(); - layerTemp2.RemoveAllFeature(); buttonItemLS5.Checked = false; dataGridViewX1.DataSource = null; panelOfTable.Visible = false; globeControl1.Globe.MemoryLayer.RemoveAllFeature(); + globeControl2.Globe.MemoryLayer.RemoveAllFeature(); globeControl1.Globe.ClearAnalysis(); - // 清除净距分析结果 buttonX2_Click(null, null); buttonX8_Click(null, null); @@ -8624,7 +8623,7 @@ LogManager.saveLog(Utility.userName, buttonItem8.Text); int width = Width; - FrmCompareFeature.ShowForm(globeControl1, globeControl2, layerTemp, layerTemp2, width); + FrmCompareFeature.ShowForm(globeControl1, globeControl2, width); } /// /// 红线审核导出图片 @@ -8760,7 +8759,6 @@ private void btn_role_resc_Click(object sender, EventArgs e) { - LogManager.saveLog(Utility.userName, btn_role_resc.Text); if (FrmRoleRescManager.IS_OPEN) return; @@ -8778,7 +8776,8 @@ frm.ShowDialog(); } } -//文档管理 操作 + + //文档管理 操作 private void btn_document_info_Click(object sender, EventArgs e) { diff --git a/bin/x86/Debug/Config.xml b/bin/x86/Debug/Config.xml index 508515a..950c0af 100644 --- a/bin/x86/Debug/Config.xml +++ b/bin/x86/Debug/Config.xml @@ -2,10 +2,10 @@ LocaSpace三维地下管线信息系统 release - SZHTDB2 + szhtdb2 192.168.0.203 release - 192.168.0.203 + 127.0.0.1 1500 http://192.168.0.203/images/ http://192.168.0.203/images/default.jpg diff --git a/bin/x86/Debug/Cyberpipe.exe b/bin/x86/Debug/Cyberpipe.exe new file mode 100644 index 0000000..89a05f3 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.exe Binary files differ diff --git a/bin/x86/Debug/Cyberpipe.pdb b/bin/x86/Debug/Cyberpipe.pdb new file mode 100644 index 0000000..ff80739 --- /dev/null +++ b/bin/x86/Debug/Cyberpipe.pdb Binary files differ diff --git a/bin/x86/Debug/MyPlace.kml b/bin/x86/Debug/MyPlace.kml index 6036f64..bad2179 100644 --- a/bin/x86/Debug/MyPlace.kml +++ b/bin/x86/Debug/MyPlace.kml @@ -1,3 +1,101 @@ - + + + + 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/databaseConfig.xml b/bin/x86/Debug/databaseConfig.xml index 8d4d3bd..256cb30 100644 --- a/bin/x86/Debug/databaseConfig.xml +++ b/bin/x86/Debug/databaseConfig.xml @@ -7,10 +7,10 @@ release - 192.168.0.203 - scott - szsgdb2 - szsgdb2 + 127.0.0.1 + SZSG + scott + SZSG 127.0.0.1 diff --git a/bin/x86/Debug/log.txt b/bin/x86/Debug/log.txt index e134074..f55c13a 100644 --- a/bin/x86/Debug/log.txt +++ b/bin/x86/Debug/log.txt @@ -258,3 +258,831 @@ exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 14:27:52--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Void globeControl1_MouseClick(System.Object, System.Windows.Forms.MouseEventArgs) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 267 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:25:50--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:25:52--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:25:54--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:25:57--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:25:58--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:26:01--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:26:04--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:26:05--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Void addPologyToGlobeControl(GeoScene.Data.GSOGeoPolyline3D, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.addPologyToGlobeControl(GSOGeoPolyline3D line, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 204 + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 258 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/15 15:26:07--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 251 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 13:45:42--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 77 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 287 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 13:49:02--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 77 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 201 + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 286 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:04:27--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSimilarFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 101 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 312 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:04:30--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSimilarFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 101 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 312 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:10:09--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 312 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:11:18--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 312 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:15:59--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:16:13--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:16:47--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:16:57--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:17:17--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:17:21--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:19:56--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 202 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 310 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:25:18--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:29:47--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:32:57--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:33:05--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:33:14--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:33:18--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:33:28--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:34:25--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:34:29--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:37:44--------------------- + + + + e.Message:未将对象引用设置到对象的实例。 + + e.Source:Cyberpipe + + e.TargetSite:Boolean isSameFeature(GeoScene.Data.GSOFeature, GeoScene.Data.GSOFeature, GeoScene.Globe.GSOLayer, Double) + + e.StackTrace: 在 Cyberpipe.FrmCompareFeature.isSameFeature(GSOFeature feature1, GSOFeature feature2, GSOLayer layer, Double bufferWidth) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 82 + 在 Cyberpipe.FrmCompareFeature.isSimilarFeature(GSOFeature srcFeature, GSOFeature dscFeature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 103 + 在 Cyberpipe.FrmCompareFeature.getSameFeatureFromOtherGlobe(GSOFeature feature) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 203 + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 311 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:42:24--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 280 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:58:16--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 284 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:58:17--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 284 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:58:30--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 284 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:58:36--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 284 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 14:58:39--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl1_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 284 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 15:24:35--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 196 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 15:24:35--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 196 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 15:24:36--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 196 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 15:24:37--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 196 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 15:24:39--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 196 + + + + exception over ------------------------------------------------------------ + + exception begin -----------------2016/11/16 15:36:51--------------------- + + + + e.Message:输入字符串的格式不正确。 + + e.Source:mscorlib + + e.TargetSite:Double ParseDouble(System.String, System.Globalization.NumberStyles, System.Globalization.NumberFormatInfo) + + e.StackTrace: 在 System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) + 在 System.Double.Parse(String s, IFormatProvider provider) + 在 Cyberpipe.FrmCompareFeature.globeControl2_MouseClick(Object sender, MouseEventArgs e) 位置 D:\GHFX\GHFX_REFACTOR\FrmCompareFeature.cs:行号 189 + + + + exception over ------------------------------------------------------------