// ============================================================================================================== // = 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; } }
/// <summary> /// Загрузить все геоданные из базы /// </summary> /// <returns>Географические данные</returns> public GeographiData LoadGeoData() { GeographiData geoData = GeographiData.Instance; geoData.Locations = dbContext.LocationEntities.ToDictionary(l => l.OverpassId); geoData.Chunks = dbContext.Chunks.ToDictionary(ch => ch.OverpassId); geoData.Roads = dbContext.Roads.ToDictionary(r => r.Name); return(geoData); }
private void LoadMainAndMiniMapData() { gMapForm = new GMapForm(gMap, gMapMini); controller.LoadGeoData(); GeographiData geoData = GeographiData.Instance; foreach (Road road in geoData.Roads.Values) { LoadMainMapRoad(road); LoadMiniMapRoad(road); } }
/// <summary> /// Получить словарь улиц из Geo Json /// </summary> /// <param name="geoJson">Geo Json</param> /// <returns>Словарь улиц</returns> public Dictionary <string, Road> GetRoadsDictionaryFromGeoJson(GeoJson geoJson) { Dictionary <string, Road> roads = new Dictionary <string, Road>(); GeographiData geoData = GeographiData.Instance; List <Element> ways = new List <Element>(); foreach (Element elem in geoJson.Elements) { if (elem.Type == "way" && !string.IsNullOrEmpty(elem.Tags.Name) && !geoData.Chunks.Keys.Contains(elem.Id)) { ways.Add(elem); } else if (elem.Type == "node" && !geoData.Locations.Keys.Contains(elem.Id)) { geoData.Locations.Add(elem.Id, new LocationEntity(elem)); } } foreach (Element elem in ways) { PolylineChunk chunk = CreateChunk(elem); geoData.Chunks.Add(chunk.OverpassId, chunk); if (geoData.Roads.Keys.Contains(elem.Tags.Name)) { Road road = geoData.Roads[elem.Tags.Name]; AddElementToWay(road.PolylineChunks, chunk); road.IsStreetViewsDownloaded = false; if (!roads.Keys.Contains(road.Name)) { roads.Add(road.Name, road); } } else { Road road = new Road(elem.Tags.Name); AddElementToWay(road.PolylineChunks, chunk); roads.Add(road.Name, road); geoData.Roads.Add(road.Name, road); } } foreach (Road road in roads.Values) { int chunkCount = road.PolylineChunks.Count; for (int i = 0; i < chunkCount; i++) { road.PolylineChunks[i].Order = i; } } return(roads); }
// ============================================================================================================== // = Implementation // ============================================================================================================== private PolylineChunk CreateChunk(Element way) { GeographiData geoData = GeographiData.Instance; PolylineChunk chunk = new PolylineChunk(); chunk.OverpassId = way.Id; chunk.OrderedLocationEntities = new List <OrderedLocationEntity>(); for (int i = 0; i < way.Nodes.Count(); i++) { LocationEntity location = geoData.Locations[way.Nodes[i]]; chunk.OrderedLocationEntities.Add(new OrderedLocationEntity(i, location)); } return(chunk); }
internal void HighlightRoadBySignDetectedStatus(string name) { GeographiData geoData = GeographiData.Instance; foreach (long id in roadDictionary[name]) { if (geoData.Chunks[id].IsSignDetected) { chunkDictionary[id].Stroke.Color = Color.DarkRed; } else { chunkDictionary[id].Stroke.Color = Color.Red; } } }
internal override void Process() { List <string> streets = new List <string>(); foreach (DataGridViewRow row in mainForm.StreetsBypassView.Rows) { bool rowSelected = (bool)row.Cells[2].Value; if (rowSelected) { streets.Add((string)row.Cells[0].Value); } } if (streets.Count > 0) { ConcurrencyUtils.SetAvailability(mainForm.DetectSignsInViewsButton, false); GeographiData geoData = GeographiData.Instance; foreach (string roadName in streets) { Road road = geoData.Roads[roadName]; foreach (PolylineChunk chunk in road.PolylineChunks) { if (chunk.IsSignDetected) { mainForm.GMapForm.MiniMapRoute.DeHighlightPolylineChunk(chunk.OverpassId, true); } } List <string> selectedDetectorsNames = mainForm.GetCheckedDetectorsNamesList(); if (selectedDetectorsNames.Count > 0) { processor = controller.StartDetection(streets, selectedDetectorsNames); Thread byPassStatusThread = new Thread(UpdateStatus); byPassStatusThread.Start(); } else { ConcurrencyUtils.SetAvailability(mainForm.DetectSignsInViewsButton, true); } } } }
internal override void Process() { List <string> streets = new List <string>(); foreach (DataGridViewRow row in mainForm.StreetsGridView.Rows) { bool rowSelected = (bool)row.Cells[2].Value; if (rowSelected) { streets.Add((string)row.Cells[0].Value); } } if (streets.Count > 0) { ConcurrencyUtils.SetAvailability(mainForm.AllDirectionButton, false); ConcurrencyUtils.SetAvailability(mainForm.ClearButton, false); ConcurrencyUtils.SetAvailability(mainForm.StreetViewsRequestButton, false); GeographiData geoData = GeographiData.Instance; foreach (string roadName in streets) { Road road = geoData.Roads[roadName]; foreach (PolylineChunk chunk in road.PolylineChunks) { if (chunk.IsStreetViewsDownloaded) { mainForm.GMapForm.MainMapRoute.DeHighlightPolylineChunk(chunk.OverpassId, true); } } } downloader = controller.GetStreetViews(streets, "Data\\Chunks"); Thread roadLoadStatusThread = new Thread(UpdateStatus); roadLoadStatusThread.Start(); } else { ConcurrencyUtils.SetText(mainForm.ResultLabel, "Не выбрано ни одной улицы. Для загрузки панорам выберете хотябы одну улицу."); } }