public void GetHiResMapsFromDbfList(string file, bool deepSearch = true) { List <Feature> features; List <string> noCovered; features = PrepareLists(file, out noCovered, true); Downloader downloader = new Downloader(); Recognizer reco = new Recognizer(); foreach (var f in features) { string redcode = f.Attributes["REDCODE"] as string; RadioInfo r = RadioInfo.ParseRedcode(redcode); if (skipRadios.ContainsKey(r.makeKey()) == false && noCovered.Contains(r.makeKey()) == false) //if (r.Prov == "02" && (r.Dpto != "01" || r.Fraccion != "01")) { FraccionInfo fraccion = new FraccionInfo(r.Prov, r.Dpto, r.Fraccion); if (r.isDone(true) == false && r.isNotRequired(true) == false && downloader.getFraccionInfo(fraccion)) { // le recalcula el extent reco.RecognizeRadio(r, false, deepSearch); // le pone una proporción igual a la de la fracción if (r.Geometry != null && r.GeoExtents.Width < fraccion.ExtentsEnvelope.Width * .75F && r.GeoExtents.Height < fraccion.ExtentsEnvelope.Height * .75F) { string extents = CalculateZoomedExtents(r, fraccion); downloader.getMapaRadio(r, extents, true); } else { File.WriteAllText(r.getNotRequiredName(true), "-"); } } else { Console.Write("."); } } } }
private List <Feature> PrepareLists(string file, out List <string> noCovered, bool hiRes = false) { List <Feature> allFeatures = new List <Feature>(); allFeatures = FileReaders.ReadDbasefile(file); var features = FilterFeatures(allFeatures); Console.WriteLine(""); Console.WriteLine("Calculando radios pendientes..."); int total = 0; int pendientes = 0; noCovered = new List <string>(); string nocoveredFile = Context.ResolveFilename("no_covered.txt"); if (File.Exists(nocoveredFile)) { noCovered.AddRange(File.ReadAllLines(nocoveredFile)); } foreach (var f in features) { string redcode = f.Attributes["REDCODE"] as string; RadioInfo r = RadioInfo.ParseRedcode(redcode); if (skipRadios.ContainsKey(r.makeKey()) == false) { total++; string name = r.makeName(); if (!r.isDone(hiRes) && !r.isNotRequired(hiRes) && noCovered.Contains(r.makeKey()) == false) { pendientes++; } } } Console.WriteLine("Pendientes: " + pendientes + "."); Console.WriteLine("Descubiertos sin cobertura: " + noCovered.Count + "."); Console.WriteLine("Total: " + total + "."); return(features); }
public void getMapaRadio(RadioInfo radio, string extent, bool useHiResNames = false) { mapCount++; if (radio.isDone(useHiResNames)) { if (mapCount % 50 == 0) { Console.Write("."); } return; } Console.WriteLine("Getting MAP " + radio.makeName() + " (" + mapCount.ToString() + ")..."); //return; List <string> radios = new List <string>(); var args = new NameValueCollection() { { "la", "" }, { "qProvincias", radio.Prov }, { "qDepartamentos", radio.Dpto }, { "qFracciones", radio.Fraccion }, { "qRadios", radio.Radio }, { "extent", extent }, { "old_mapa_x", "" }, { "old_mapa_y", "" }, { "mode", "14" }, { "togglecapa", "i_selectores" }, { "zsize", "1" }, { "zoomdir", "pan" }, { "ver_escala", "2" }, { "escala", "26000" } }; //extent:1688948 3601619.5 5996706 7909377.5 // 4026334.96104 6061347.65263 4031832.35085 6066845.04243 retry3: var response = Post(Context.url, args); if (response == null) { Context.Log("timeouts", radio); return; } string htmlRoot = Saver(response, radio, useHiResNames); var notFound = htmlRoot.IndexOf("No encontré cobertura para"); if (notFound > 0) { Context.Log("no_covered", radio.makeKey()); return; } Console.WriteLine("Gotfile!"); int i = htmlRoot.IndexOf("/temp/image"); if (i == -1) { Context.Log("errors", "No map for radio " + radio.makeName()); return; } int iEnd = htmlRoot.IndexOf(".gif", i); string gif = Context.url2 + htmlRoot.Substring(i, iEnd - i + 4); var argument = gif; byte[] response2 = null; using (WebDownload client = new WebDownload()) { int tries = 0; retry2: try { response2 = client.DownloadData(gif); Thread.Sleep(1 * 1000); } catch { tries++; if (tries == 8) { throw; } Thread.Sleep(30 * 1000); goto retry3; } } GifSaver(response2, radio, useHiResNames); //Process.Start("iexplore.exe", argument); //MessageBox.Show("Traje " + radios.Count.ToString() + " radios"); }