Exemplo n.º 1
0
        /// <summary>
        /// Загрузить панорамы по дорогам
        /// </summary>
        public void DownloadRoadsStreetViews()
        {
            int pointsCount = roads.Where(road => !road.IsStreetViewsDownloaded).Sum(road => road.PolylineChunks.Where(chunk => !chunk.IsStreetViewsDownloaded)
                                                                                     .Sum(chunk => chunk.OrderedLocationEntities.Count));
            int count = 0;

            foreach (Road road in roads)
            {
                if (!road.IsStreetViewsDownloaded)
                {
                    foreach (PolylineChunk chunk in road.PolylineChunks)
                    {
                        if (!chunk.IsStreetViewsDownloaded)
                        {
                            DownloadChunkStreetViews(chunk);
                            count += chunk.OrderedLocationEntities.Count;
                            Status = count * 100 / pointsCount;
                        }
                        AddDownloadedChunkToList(chunk);
                    }
                    road.IsStreetViewsDownloaded = true;
                    context.SaveChanges();
                }
                AddDownloadedRoadToList(road);
            }
            Status = 100;
        }
        // ==============================================================================================================
        // = Implementation
        // ==============================================================================================================

        private void ProcessSignViewDetection(List <string> roadNames)
        {
            int           count   = 0;
            GeographiData geoData = GeographiData.Instance;

            foreach (string roadName in roadNames)
            {
                Road road = geoData.Roads[roadName];
                if (!road.IsSignDetected)
                {
                    List <PolylineChunk> orderedPolylineChunk = road.PolylineChunks.OrderBy(x => x.Order).ToList();
                    for (int i = 0; i < orderedPolylineChunk.Count; i++)
                    {
                        if (!orderedPolylineChunk[i].IsSignDetected)
                        {
                            DetectSignForChunk(orderedPolylineChunk[i]);
                        }
                    }
                    for (int i = orderedPolylineChunk.Count - 1; i >= 0; i--)
                    {
                        if (!orderedPolylineChunk[i].IsSignDetected)
                        {
                            DetectSignForChunk(orderedPolylineChunk[i]);
                        }
                        orderedPolylineChunk[i].IsSignDetected = true;
                        dbContext.SaveChanges();
                    }
                    road.IsSignDetected = true;
                    dbContext.SaveChanges();
                }
                AddProcessedRoadName(roadName);
                count++;
                Status = count / roadNames.Count;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Получить все пути по области.
        /// </summary>
        /// <param name="lat">Широта точки центра области запроса.</param>
        /// <param name="lng">Долгота точки центра области запроса.</param>
        /// <returns>Список путей (списков списков координат)</returns>
        public List <PolylineChunk> GetAllDirectionsOfArea(double lat, double lng)
        {
            List <PolylineChunk> areaChunks = new List <PolylineChunk>();
            GeoJson        geoJson          = overpassService.GetWaysOfArea(lat, lng, parameters.Radius);
            HashSet <long> chunkIdSet       = new HashSet <long>(dbContext.Chunks.Select(ch => ch.OverpassId));

            areaChunks.AddRange(geoService.GetPolylineChunksFromGeoJson(geoJson));
            areaChunks.RemoveAll(ch => chunkIdSet.Contains(ch.OverpassId));
            dbContext.Chunks.AddRange(areaChunks);
            dbContext.SaveChanges();
            return(areaChunks);
        }