Ejemplo n.º 1
0
    public void showNearPersonnelCamInfo(NearbyDev devList, int total, int i)
    {
        cameraDev = devList;
        num       = total;
        m         = i + 1;
        if (devList.TypeName == null)
        {
            cameraName.text = "";
        }
        else
        {
            cameraName.text = devList.Name.ToString();
        }

        cameraId.text = devList.id.ToString();

        Distance.text = "距离人员" + string.Format("{0:F}", devList.Distance);
    }
Ejemplo n.º 2
0
    public void GetNearPersonnelCamInfo(NearbyDev devList, int total, int i)
    {
        camName = devList.Name.ToString();

        this.transform.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(devList.X, devList.Z, devList.Y);
        devId = devList.id;
        RoomFactory.Instance.GetDevByid(devId, (devNodeT) =>
        {
            GameObject Obj = devNodeT.gameObject;
            EnterObj.transform.GetComponent <RectTransform>().localEulerAngles  = new Vector3(0, 0, Obj.transform.eulerAngles.y + 180);
            selectCam.transform.GetComponent <RectTransform>().localEulerAngles = new Vector3(0, 0, Obj.transform.eulerAngles.y + 180f);


            if (devNodeT == null)
            {
                return;
            }
        });
    }
Ejemplo n.º 3
0
        public List <NearbyDev> GetNearbyCamera_Alarm(int id, float fDis)
        {
            List <NearbyDev> lst  = new List <NearbyDev>();
            List <NearbyDev> lst2 = new List <NearbyDev>();

            DbModel.Location.AreaAndDev.DevInfo dev = db.DevInfos.DbSet.Where(p => p.Id == id).FirstOrDefault();
            if (dev == null || dev.ParentId == null)
            {
                return(lst);
            }

            int?  AreadId = dev.ParentId;
            float PosX    = dev.PosX;
            float PosY    = dev.PosY;
            float PosZ    = dev.PosZ;

            float PosX2 = 0;
            float PosY2 = 0;
            float PosZ2 = 0;

            float sqrtDistance = 0;
            float Distance     = 0;

            var query = from t1 in db.DevAlarms.DbSet
                        join t2 in db.DevInfos.DbSet on t1.DevInfoId equals t2.Id
                        join t3 in db.DevTypes.DbSet on t2.Local_TypeCode equals t3.TypeCode
                        join t4 in db.Areas.DbSet on t2.ParentId equals t4.Id
                        where t2.ParentId == AreadId && (t2.Local_TypeCode == 3000201 || t2.Local_TypeCode == 14 || t2.Local_TypeCode == 3000610 || t2.Local_TypeCode == 1000102)
                        select new NearbyDev {
                id = t2.Id, Name = t2.Name, TypeCode = t2.Local_TypeCode, TypeName = t3.TypeName, Area = t4.Name, X = t2.PosX, Y = t2.PosY, Z = t2.PosZ
            };

            if (query != null)
            {
                lst2 = query.ToList();
            }

            foreach (NearbyDev item in lst2)
            {
                PosX2 = item.X - PosX;
                PosY2 = item.Y - PosY;
                PosZ2 = item.Z - PosZ;

                sqrtDistance  = PosX2 * PosX2 + PosY2 * PosY2 + PosZ2 * PosZ2;
                Distance      = (float)System.Math.Sqrt(sqrtDistance);
                item.Distance = Distance;
                if (Distance <= fDis)
                {
                    NearbyDev item2 = item.Clone();
                    if (item2 != null)
                    {
                        lst.Add(item2);
                    }
                }


                PosX2        = 0;
                PosY2        = 0;
                PosZ2        = 0;
                sqrtDistance = 0;
                Distance     = 0;
            }

            lst.Sort(new DevDistanceCompare());

            return(lst);
        }
Ejemplo n.º 4
0
        public List <NearbyDev> GetNearbyDev_Currency(int id, float fDis, int nFlag)
        {
            List <NearbyDev> lst  = new List <NearbyDev>();
            List <NearbyDev> lst2 = new List <NearbyDev>();

            DbModel.Location.Data.LocationCardPosition lcp = db.LocationCardPositions.DbSet.Where(p => p.PersonId == id).FirstOrDefault();
            if (lcp == null || lcp.AreaId == null)
            {
                return(lst);
            }

            int?AreadId = lcp.AreaId;

            float PosX = lcp.X;
            float PosY = lcp.Y;
            float PosZ = lcp.Z;

            float PosX2 = 0;
            float PosY2 = 0;
            float PosZ2 = 0;

            float sqrtDistance = 0;
            float Distance     = 0;

            var query = from t1 in db.DevInfos.DbSet
                        join t2 in db.DevTypes.DbSet on t1.Local_TypeCode equals t2.TypeCode
                        join t3 in db.Areas.DbSet on t1.ParentId equals t3.Id
                        where t1.ParentId == AreadId && (nFlag == 0 ? true : (t1.Local_TypeCode == 3000201 || t1.Local_TypeCode == 14 || t1.Local_TypeCode == 3000610 || t1.Local_TypeCode == 1000102))
                        select new NearbyDev {
                id = t1.Id, Name = t1.Name, TypeCode = t1.Local_TypeCode, TypeName = t2.TypeName, Area = t3.Name, X = t1.PosX, Y = t1.PosY, Z = t1.PosZ
            };

            if (query != null)
            {
                lst2 = query.ToList();
            }

            foreach (NearbyDev item in lst2)
            {
                PosX2 = item.X - PosX;
                PosY2 = item.Y - PosY;
                PosZ2 = item.Z - PosZ;

                sqrtDistance  = PosX2 * PosX2 + PosY2 * PosY2 + PosZ2 * PosZ2;
                Distance      = (float)System.Math.Sqrt(sqrtDistance);
                item.Distance = Distance;
                if (Distance <= fDis)
                {
                    NearbyDev item2 = item.Clone();
                    if (item2 != null)
                    {
                        item2.X = PosX2;
                        item2.Y = PosY2;
                        item2.Z = PosZ2;
                        lst.Add(item2);
                    }
                }

                PosX2        = 0;
                PosY2        = 0;
                PosZ2        = 0;
                sqrtDistance = 0;
                Distance     = 0;
            }

            lst.Sort(new DevDistanceCompare());

            if (lst.Count == 0)
            {
                lst = null;
            }

            return(lst);
        }
Ejemplo n.º 5
0
        public List <NearbyDev> GetNearbyDev_Currency(int id, float fDis, int nFlag)
        {
            List <NearbyDev> lst  = new List <NearbyDev>();
            List <NearbyDev> lst2 = new List <NearbyDev>();

            DbModel.Location.Data.LocationCardPosition lcp = db.LocationCardPositions.DbSet.Where(p => p.PersonId == id).FirstOrDefault();
            if (lcp == null || lcp.AreaId == null)
            {
                return(lst);
            }

            int?AreadId = lcp.AreaId;

            float PosX = lcp.X;
            float PosY = lcp.Y;
            float PosZ = lcp.Z;

            float PosX2 = 0;
            float PosY2 = 0;
            float PosZ2 = 0;

            float sqrtDistance = 0;
            float Distance     = 0;

            //根据区域ID和标志位获取摄像头
            GetCameraDevByAreaId(AreadId, nFlag, lst2);
            if (lst2.Count <= 0)
            {
                DbModel.Location.AreaAndDev.Area area = db.Areas.Find(p => p.Id == AreadId);
                GetCameraDevByAreaId(area.ParentId, nFlag, lst2);
            }

            //var query = from t1 in db.DevInfos.DbSet
            //            join t2 in db.DevTypes.DbSet on t1.Local_TypeCode equals t2.TypeCode
            //            join t3 in db.Areas.DbSet on t1.ParentId equals t3.Id
            //            where t1.ParentId == AreadId && (nFlag == 0 ? true : (t1.Local_TypeCode == 3000201 || t1.Local_TypeCode == 14 || t1.Local_TypeCode == 3000610 || t1.Local_TypeCode == 1000102))
            //            select new NearbyDev { id = t1.Id, Name = t1.Name, TypeCode = t1.Local_TypeCode, TypeName = t2.TypeName, Area = t3.Name, X = t1.PosX, Y = t1.PosY, Z = t1.PosZ };

            //if (query != null)
            //{
            //    lst2 = query.ToList();
            //}

            var areas  = db.Areas.ToDictionary();
            var bounds = db.Bounds.ToDictionary();

            foreach (var item in areas)
            {
                var area = item.Value;
                if (area.InitBoundId != null)
                {
                    area.InitBound = bounds[(int)area.InitBoundId];
                }
            }

            foreach (NearbyDev item in lst2)
            {
                float x = item.X;
                float y = item.Y;
                float z = item.Z;

                if (areas.ContainsKey(item.AreaId))
                {
                    var area = areas[item.AreaId];//所在区域


                    if (area.Type == AreaTypes.机房)
                    {
                        var floor    = areas[(int)area.ParentId];
                        var building = areas[(int)floor.ParentId];//
                        var minX     = area.InitBound.GetZeroX() + floor.InitBound.GetZeroX() + building.InitBound.GetZeroX();
                        var minY     = area.InitBound.GetZeroY() + floor.InitBound.GetZeroY() + building.InitBound.GetZeroY();
                        x += minX;
                        z += minY;
                    }
                    else if (area.Type == AreaTypes.楼层)
                    {
                        var floor    = area;
                        var building = areas[(int)floor.ParentId];//
                        var minX     = floor.InitBound.GetZeroX() + building.InitBound.GetZeroX();
                        var minY     = floor.InitBound.GetZeroY() + building.InitBound.GetZeroY();
                        x += minX;
                        z += minY;
                    }
                }

                PosX2 = x - PosX;
                PosY2 = y - PosY;
                PosZ2 = z - PosZ;

                sqrtDistance  = PosX2 * PosX2 + PosY2 * PosY2 + PosZ2 * PosZ2;
                Distance      = (float)System.Math.Sqrt(sqrtDistance);
                item.Distance = Distance;
                if (Distance <= fDis)
                {
                    NearbyDev item2 = item.Clone();
                    if (item2 != null)
                    {
                        item2.X = PosX2;
                        item2.Y = PosY2;
                        item2.Z = PosZ2;
                        lst.Add(item2);
                    }
                }

                PosX2        = 0;
                PosY2        = 0;
                PosZ2        = 0;
                sqrtDistance = 0;
                Distance     = 0;
            }

            lst.Sort(new DevDistanceCompare());

            if (lst.Count == 0)
            {
                lst = null;
            }

            return(lst);
        }