private List <Geometry> direct(Layer buildings, Layer sources, Geometry receivePoint, double distance) { sources.ResetReading(); double length = 0; Geometry receiveBuffer = receivePoint.Buffer(distance, 30); sources.SetSpatialFilter(receiveBuffer); Feature sFeature = null; Geometry sourcePoint = null; Geometry line = null; Queue <Feature> diffbuildings = new Queue <Feature>(); List <Geometry> geos = new List <Geometry>(); while ((sFeature = sources.GetNextFeature()) != null) { sourcePoint = sFeature.GetGeometryRef(); line = GeometryCreate.createLineString3D(sourcePoint.GetX(0), sourcePoint.GetY(0), sourcePoint.GetZ(0), receivePoint.GetX(0), receivePoint.GetY(0), receivePoint.GetZ(0)); buildings.SetSpatialFilter(line); // List<Geometry> a = getWidth(buildings, sourcePoint, receivePoint, line); List <Geometry> a = diffractionLine2(buildings, sourcePoint, receivePoint, line); if (a != null) // if (buildings.GetFeaturesRead()>0) { // geos.AddRange(getWidth(buildings, sourcePoint, receivePoint, line)); geos.AddRange(a); } else { //计算绕射 // geos.Add(line); // length += line.Length(); // break; } } //Console.WriteLine(length); return(geos); // return length; }
/// <summary> /// 寻找一组声线 /// </summary> /// <param name="buildings">建筑物图层</param> /// <param name="sourcesPoint">声源点</param> /// <param name="receivePoint">接收点</param> /// <param name="range">影响范围</param> /// <returns>一组声线</returns> public Geometry[] getPath(Layer buildings, Geometry sourcesPoint, Geometry receivePoint, float range) { //构建传播路程的数组,分别为两点直射、上绕射、左绕射、右绕射、反射 Geometry[] pathLength = new Geometry[5]; //构建直达声线 Geometry line = GeometryCreate.createLineString3D(sourcesPoint.GetX(0), sourcesPoint.GetY(0), sourcesPoint.GetZ(0), receivePoint.GetX(0), receivePoint.GetY(0), receivePoint.GetZ(0)); //直达声线长度 // double distance = Distance3D.getPointDistance(sourcesPoint, receivePoint); //直达声线 pathLength[0] = line; buildings.SetSpatialFilter(line);//直达声线上受影响的建筑物 //判断是否有直射路径,如果没有,求绕射路径 if (buildings.GetFeatureCount(0) <= 0) { //存在直射则不存在绕射 pathLength[1] = null; pathLength[2] = null; pathLength[3] = null; //计算反射 pathLength[4] = line; } else { Geometry[] diffLine = diffractionLine(buildings, sourcesPoint, receivePoint, line); pathLength[1] = diffLine[0]; pathLength[2] = diffLine[0]; pathLength[3] = diffLine[0]; //忽略反射 pathLength[4] = null; } //计算反射路径 return(pathLength); }