/// <summary> /// load all loadlists /// </summary> public void Load(bool isUtmDest) { Helper.AsyncRun(delegate { foreach (LoadList loadList in loadLists) { try { FormMain.ShowMessage("----- Load: Start to load " + loadList.header.outputPath + " -----"); FormMain.ShowMessage("Load: Start time " + DateTime.Now.ToString()); // restore config to default before each loading MUtilities.ResetConfig(); MUtilities.InitConfig(File.ReadAllText(Config.LOADER_CONFIG_PATH)); loadList.LoadStart(isUtmDest); FormMain.ShowMessage("Load: End time " + DateTime.Now.ToString()); FormMain.ShowMessage("----- Load: Finish " + loadList.header.outputPath + " -----"); } catch (Exception ex) { FormMain.ShowMessage(ex); } } }); }
/// <summary> /// get utm info from source file and return a guessed date of the image file /// </summary> /// <param name="filePath"></param> /// <param name="fileType"></param> /// <returns></returns> public void InitByUtmSourceFile(string filePath, MESourceFileType fileType, string srcProjection, string dstProjection) { this.filePath = filePath.ToLower(); switch (fileType) { case MESourceFileType.doqq: MUtilities.ReadUtmMetaFromDoqq(filePath, ref metaInfo, ref guessedDate); metaInfo.fileType = MESourceFileType.doqq; break; case MESourceFileType.doqqc: MUtilities.ReadUtmMetaFromDoqq(filePath, ref metaInfo, ref guessedDate); metaInfo.fileType = MESourceFileType.doqqc; break; case MESourceFileType.tif: metaInfo = MUtilities.ReadUtmMetaFromTiff(filePath); metaInfo.fileType = MESourceFileType.tif; break; default: throw new Exception("Can only get utm info from doqq, doqqc and tif files"); } // convert projection if (srcProjection != "") { MUtilities.TransformProjection(srcProjection, dstProjection, ref metaInfo.x, ref metaInfo.y); } guessedDate = guessedDate.Replace(" ", ""); guessedDate = guessedDate.Substring(0, Math.Min(guessedDate.Length, 12)); }
public Point[] GetUtmCorrectedRelativePolygon(TileXY tilexy, int zone) { double[] input = new double[4]; double[] result = new double[8]; input[0] = box.top; input[1] = box.right; input[2] = box.bottom; input[3] = box.left; for (int i = 0; i < 4; i++) { input[i] = input[i] * Math.PI / 180; } MUtilities.LatLonRectangleExpandByUtm(zone, input, result); for (int i = 0; i < 8; i++) { result[i] = result[i] * 180 / Math.PI; } Point[] points = new Point[4]; points[0] = BingProjection.LatLongToPixelXY(result[0], result[1], tilexy.level); points[1] = BingProjection.LatLongToPixelXY(result[2], result[3], tilexy.level); points[2] = BingProjection.LatLongToPixelXY(result[4], result[5], tilexy.level); points[3] = BingProjection.LatLongToPixelXY(result[6], result[7], tilexy.level); for (int i = 0; i < 4; i++) { points[i].X -= tilexy.x * 256; points[i].Y -= tilexy.y * 256; } return(points); }
protected void Application_Start(object sender, EventArgs e) { MUtilities.InitConfig("LOG_PATH = " + Config.LOG_PATH_CPP); HttpRuntime.Cache["memorycache_blacktile_256"] = File.ReadAllBytes(Config.BLACK_256_TILE_PATH); HttpRuntime.Cache["memorycache_blacktile_400"] = File.ReadAllBytes(Config.BLACK_400_TILE_PATH); HttpRuntime.Cache["memorycache_blacktile_512"] = File.ReadAllBytes(Config.BLACK_512_TILE_PATH); }
private void btnBuildIndexStart_Click(object sender, EventArgs e) { Helper.AsyncRun(delegate { int recordTotal = 0; foreach (string path in Helper.GetLines(tbBuildIndexDirs.Text)) { FormMain.ShowMessage("BuildIndex: Start " + path); recordTotal += MUtilities.BuildIndex(path, tbConnectionString.Text); FormMain.ShowMessage("BuildIndex: End " + path); } FormMain.ShowMessage("Total records inserted: " + recordTotal + ", check the database to verify the number"); }); }
private void FormMain_Load(object sender, EventArgs e) { SafeRun(delegate { if (File.Exists(Config.LOADER_CONFIG_PATH)) { MUtilities.InitConfig(File.ReadAllText(Config.LOADER_CONFIG_PATH)); MUtilities.InitConfig("LOG_PATH = " + Config.LOG_CPP_PATH); } else { ShowMessage("Warning: Config file is not found. Default config is used."); } cbSourceProjection.SelectedIndex = cbDestProjection.SelectedIndex = 0; }); }
private void SetLoadProjection() { SafeRun(delegate { if (cbSourceProjection.Text == "" || cbDestProjection.Text == "") { return; } if (cbDestProjection.Text == "UTM" && cbSourceProjection.Text != "UTM") { ShowMessage("Error: when dest is UTM, source MUST also be UTM!"); } MUtilities.InitConfig("SOURCE_PROJECTION = " + cbSourceProjection.Text + "\nDEST_PROJECTION = " + cbDestProjection.Text); ShowMessage("Load: " + cbSourceProjection.Text + " -> " + cbDestProjection.Text); }); }
/// <summary> /// start loading this list /// </summary> /// <param name="isUtmDest">if dest projection is UTM, zones are loaded seperately into different outputDirs</param> public void LoadStart(bool isUtmDest) { // load config if (configString.Length != 0) { MUtilities.InitConfig(configString); } if (isUtmDest) { // get a list of zones List <int> zones = new List <int>(); foreach (LoadListRecord rec in records) { if (!zones.Contains(rec.metaInfo.zone)) { zones.Add(rec.metaInfo.zone); } } FormMain.ShowMessage("Load: number of zones: " + zones.Count); // load each zone foreach (int zone in zones) { FormMain.ShowMessage("Load: start to load zone " + zone); string path = Path.GetFullPath(header.outputPath) + "\\zone " + zone; header.ssmi.outputZone = (byte)zone; List <LoadListRecord> recordsToLoad = new List <LoadListRecord>(); foreach (LoadListRecord rec in records) { if (rec.metaInfo.zone == zone) { recordsToLoad.Add(rec); } } LoadStart(path, recordsToLoad); } } else { FormMain.ShowMessage("Load: start to load"); header.ssmi.outputZone = 0; // the zone is ignored in this loading mode LoadStart(Path.GetFullPath(header.outputPath), records); } }
public static void LatLon_to_bing_ext(ref double lonDegree, ref double latDegree) { double lonClipped = Clip(ref lonDegree, 180); double latClipped = Clip(ref latDegree, 85.0511); lonDegree = Helper.DegreeToRadian(lonDegree); latDegree = Helper.DegreeToRadian(latDegree); int result = MUtilities.TransformProjection("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs ", "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +units=m +k=1.0 +nadgrids=@null +no_defs", ref lonDegree, ref latDegree); if (result != 0) { throw new Exception("projection transformation failed with error code " + result + " for lat/lon = " + latDegree + "," + lonDegree); } //// extend result //if (lonClipped != 0) // lonDegree += lonClipped * 20037500; //if (latClipped != 0) // latDegree += latClipped * 20037500; }