using System; using System.Collections.Generic; using GeoScene.Globe; using GeoScene.Data; namespace Cyberpipe { class ClassYJSHAlgorithm { public static void distanceAnalysis(GSOFeature selectedFeature, List<string> _pipelineLayerNames, GSOGlobeControl globeControl, out List<ClassDataTableParam> shV, out List<ClassDataTableParam> shH) { shV = new List<ClassDataTableParam>(); shH = new List<ClassDataTableParam>(); ClassDataTableParam vSh, hSh; GSOGeoPolyline3D selectFeatureLine = selectedFeature.Geometry as GSOGeoPolyline3D; string selectFeatureCaption = selectedFeature.Dataset.Caption; for (int i = 0; i < _pipelineLayerNames.Count; i++) { GSOLayer targetLayer = globeControl.Globe.Layers.GetLayerByCaption(_pipelineLayerNames[i]); if (selectFeatureCaption == _pipelineLayerNames[i]||targetLayer == null) continue; //获取净距标准 double distance = ClassYJSHModel.GetDistance(selectedFeature.Dataset.Caption, _pipelineLayerNames[i]); GSOGeoPolygon3D polygon = selectFeatureLine.CreateBuffer(distance, true, 5, true, false); GSOFeatures targetFeats = targetLayer.FindFeaturesInPolygon(polygon, false); if (targetFeats.Length == 0) continue; for (int j = 0; j < targetFeats.Length; j++) { GSOGeoPolyline3D targetLine = targetFeats[j].Geometry as GSOGeoPolyline3D; vSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], selectFeatureCaption, true); if (vSh != null) shV.Add(vSh); ; hSh = GetDataTableResult(globeControl, distance, selectFeatureLine, targetLine, targetFeats[j], selectFeatureCaption, false); if (hSh!= null) shH.Add(hSh); } } } private static ClassDataTableParam GetDataTableResult(GSOGlobeControl globeControl, double distance, GSOGeoPolyline3D selectFeatureLine, GSOGeoPolyline3D targetLine,GSOFeature feature, string selectedFeatureCaption,bool isVer) { ClassDataTableParam shDataTable=new ClassDataTableParam(); GSOPoint3d pntIntersect1 = new GSOPoint3d(); GSOPoint3d pntIntersect2 = new GSOPoint3d(); GSOPoint3d pntProIntersect1 = new GSOPoint3d(); GSOPoint3d pntProIntersect2 = new GSOPoint3d(); double dis = isVer ? globeControl.Globe.Analysis3D.ComputeVerticalDistance(selectFeatureLine,targetLine, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false) : globeControl.Globe.Analysis3D.ComputeHorizonDistance(selectFeatureLine, targetLine, out pntIntersect1, out pntIntersect2, out pntProIntersect1, out pntProIntersect2, false); feature.HighLight = true; string type = isVer ? "垂直" : "水平"; if (Math.Abs(dis) > 0) ClassAddMakerToGlobel.LabelDistance(pntProIntersect1, pntProIntersect2, dis, true, globeControl, type); if (!(dis > -1) || !(dis < distance)) return null; shDataTable.selectedFeatureCaption = selectedFeatureCaption; shDataTable.selectedFeatureName = selectFeatureLine.Name; shDataTable.targetFeatureCaption = feature.Dataset.Caption; shDataTable.targetFeatureName = targetLine.Name; shDataTable.resultDis = dis.ToString("0.00"); shDataTable.dis = distance.ToString("0.00"); return shDataTable; } } }