private void DetectSignForImagePack(ImagePack pack)
 {
     foreach (StreetView view in pack.ImageList)
     {
         DetectSignsForStreetView(view);
     }
 }
Exemplo n.º 2
0
        private void DownloadImagePack(LocationEntity start, LocationEntity end)
        {
            List <LocationEntity> locations = new List <LocationEntity>();

            locations.Add(start);
            locations.AddRange(geoService.GetIntermediateLocations(start, end));
            locations.Add(end);
            ImagePack pack = new ImagePack(start.OverpassId, end.OverpassId);

            for (int j = 0; j < locations.Count - 1; j++)
            {
                double angle     = geoService.CalculateAngle(locations[j].Lat - locations[j + 1].Lat, locations[j].Lng - locations[j + 1].Lng);
                string directory = path + "\\" + pack.StartLocation + "-" + pack.EndLocation;
                createDirectory(directory);
                try
                {
                    Stream viewStream = restService.GetStreetViewStream(locations[j].Lat.ToString(), locations[j].Lng.ToString(), angle.ToString());
                    string filePath   = directory + "\\" + j + ".jpeg";
                    using (var fileStream = File.Create(filePath))
                    {
                        viewStream.CopyTo(fileStream);
                    }
                    pack.ImageList.Add(new StreetView(j, filePath, locations[j].Lat, locations[j].Lng));
                }
                catch (WebException ex)
                {
                    j--;
                }
            }
            start.ImagePacks.Add(pack);
            context.ImagePacks.Add(pack);
            context.SaveChanges();
        }
Exemplo n.º 3
0
 private void Pack_TimeOut(ImagePack sender)
 {
     if (Buffers.ContainsKey(sender.Key))
     {
         this.Buffers.Remove(sender.Key);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// 接收图片消息
 /// </summary>
 private void RectivePicMessage()
 {
     try
     {
         byte[]   reBuff   = new byte[51000];
         EndPoint endPoint = new IPEndPoint(IPAddress.Any, 44564);
         while (true)
         {
             this.picSocket.ReceiveFrom(reBuff, ref endPoint);
             IPEndPoint end      = endPoint as IPEndPoint;
             string     senderIP = end.Address.ToString();
             if (senderIP == KeyData.StaticInfo.MyUser.IP)
             {
                 continue;
             }
             bool     isPublic = (end.Port == sendProt_Pub);
             HeadBuff head     = GetHead(reBuff);
             if (!Buffers.ContainsKey(head.packKey) && head.packid == 0)
             {
                 ImagePack pack = new ImagePack(head.packKey, head.len, senderIP, isPublic);
                 pack.DownOver += Pack_DownOver;
                 pack.TimeOut  += Pack_TimeOut;
                 Buffers.Add(head.packKey, pack);
             }
             else
             {
                 byte[] soures = new byte[head.len];
                 Array.Copy(reBuff, 24, soures, 0, head.len);
                 Buffers[head.packKey].AddPack(head.packid, soures);
             }
         }
     }
     catch (Exception)
     { }
 }
        private ImagePack GetImagePack(LocationEntity start, LocationEntity end)
        {
            ImagePack returnPack = null;

            foreach (ImagePack pack in start.ImagePacks)
            {
                if (pack.EndLocation == end.OverpassId)
                {
                    returnPack = pack;
                }
            }
            return(returnPack);
        }
        private void DetectSignForChunkInversed(PolylineChunk chunk)
        {
            for (int i = 0; i < chunk.OrderedLocationEntities.Count - 1; i++)
            {
                LocationEntity start         = chunk.OrderedLocationEntities.Find(x => x.Order == i).LocationEntity;
                LocationEntity end           = chunk.OrderedLocationEntities.Find(x => x.Order == i + 1).LocationEntity;
                ImagePack      packToProcess = GetImagePack(end, start);

                if (packToProcess != null)
                {
                    DetectSignForImagePack(packToProcess);
                }
            }
            AddChunkToProcessedList(chunk);
        }
Exemplo n.º 7
0
 private void Pack_DownOver(ImagePack sender, byte[] overBuff)
 {
     Model.Transmission.LocalPicMessage mes = new Model.Transmission.LocalPicMessage()
     {
         imgBuff  = overBuff,
         isPublic = sender.isPublic,
         senderIP = sender.senderIP,
         sender   = Method.GetUser(sender.senderIP).Name
     };
     if (ReceivePictureMessageEvent != null)
     {
         ReceivePictureMessageEvent.Invoke(mes);
     }
     this.Buffers.Remove(sender.Key);
 }