/// <summary> /// 获取建筑物相对原点可见的点坐标 /// </summary> /// <param name="p"></param> /// <param name="buildingid"></param> /// <returns></returns> private static List <Point> getBuildingVPlanePoints(Point p, int buildingid, double pMargin) { double bheight = BuildingGrid3D.getBuildingHeight(buildingid); double bAltidue = BuildingGrid3D.getBuildingAltitude(buildingid); // 地形 List <Point> bpoints = BuildingGrid3D.getBuildingVertex(buildingid); int vnum = (int)Math.Ceiling(bheight / vplanegridlength); int vnumBase = (int)Math.Ceiling(bAltidue / vplanegridlength); // 地形 List <Point> ret = new List <Point>(); for (int j = 0, k = bpoints.Count - 1, cnt = bpoints.Count; j < cnt; k = j++) { List <Point> pts = GetCenterPoints(bpoints[k], bpoints[j], pMargin); for (int m = 0; m < pts.Count; m++) { //如果是凸多边形,则可以判断边的中点即可,如果是凹多边形,则需要都判断 //可以在数据库级别存储建筑物定点是计算出建筑物的凹凸性,那么此处就可以进行优化 if (isCover(p, pts[m], bpoints, k)) { continue; } // 地形 for (int i = vnumBase; i < vnum; i++) { ret.Add(new Point(pts[m].X, pts[m].Y, (i + 0.5) * vplanegridlength)); } } } return(ret); }
public static List <Point> GetAllTopGrid(Point source, List <int> buildingIDs) { List <Point> ret = new List <Point>(); for (int k = 0; k < buildingIDs.Count; k++) { int bid = buildingIDs[k]; double z = BuildingGrid3D.getBuildingHeight(bid); if (z < source.Z) // 当建筑物高度小于小区时,才会向该建筑物顶面引一条射线 { List <Point> l = BuildingGrid3D.getBuildingTopVertex(bid); ret.AddRange(l); } } return(ret); }
private static bool isInBuilding(Point p, ref List <TriangleBound> DisAngle) { if (DisAngle == null) { return(false); } int cnt = DisAngle.Count; bool isEdge; int startIndex = 0; for (int i = 0; i < cnt; i++) { List <Point> vertex = BuildingGrid3D.getBuildingVertex(DisAngle[i].buildingid); if (GeometricUtilities.PointInPolygon(vertex.ToArray(), p, out isEdge, ref startIndex)) { return(true); } } return(false); }