public static void RemoveSectors(List <int> sectors, Action <string> inform) { inform("Removing Grids" + Environment.NewLine); SystemsDB.RemoveGridSystems(sectors.ToArray(), inform); // MUST do first as relies on system grid for info inform("Vacuum Database for size" + Environment.NewLine); SystemsDB.Vacuum(); }
public static void RemoveSectors(List <int> sectors, Action <string> inform) { inform("Removing Grids" + Environment.NewLine); SystemsDatabase.Instance.RemoveGridSystems(sectors.ToArray(), inform); inform("Vacuum Database for size" + Environment.NewLine); SystemsDB.Vacuum(); }
// in a thread, look up the sector private void FillSectorThread(Object seco) { Sector d = (Sector)seco; //System.Diagnostics.Debug.WriteLine($"Galaxy: Thread start for {d.pos}"); // note d.text/d.positions may be much longer than d.systems if (d.searchsize > 0) // if not a clear.. { if (ShowDistance) { Vector4 pos = new Vector4(d.pos.X + d.searchsize / 2, d.pos.Y + d.searchsize / 2, d.pos.Z + d.searchsize / 2, 0); // from centre of box d.systems = SystemsDB.GetSystemList(d.pos.X, d.pos.Y, d.pos.Z, d.searchsize, ref d.text, ref d.positions, (x, y, z) => { return(new Vector4((float)x / SystemClass.XYZScalar, (float)y / SystemClass.XYZScalar, (float)z / SystemClass.XYZScalar, 0)); }, (v, s) => { var dist = (pos - v).Length; return(s + $" @ {dist:0.#}ly"); }); } else { d.systems = SystemsDB.GetSystemList(d.pos.X, d.pos.Y, d.pos.Z, d.searchsize, ref d.text, ref d.positions, (x, y, z) => { return(new Vector4((float)x / SystemClass.XYZScalar, (float)y / SystemClass.XYZScalar, (float)z / SystemClass.XYZScalar, 0)); }, null); } if (d.systems > 0) // may get nothing, so don't do this if so { // note only draw d.systems using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Center; d.bitmaps = GLOFC.Utils.BitMapHelpers.DrawTextIntoFixedSizeBitmaps(slset.LabelSize, d.text, Font, System.Drawing.Text.TextRenderingHint.ClearTypeGridFit, ForeText, BackText, 0.5f, textformat: fmt, length: d.systems); } d.textpos = GLPLVertexShaderMatrixTriStripTexture.CreateMatrices(d.positions, LabelOffset, //offset LabelSize, //size new Vector3(0, 0, 0), // rot (unused due to below) true, false, // rotate, no elevation length: d.systems // limit length ); } } generatedsectors.Enqueue(d); // d has been filled //System.Diagnostics.Debug.WriteLine($"{Environment.TickCount % 100000} {d.pos} {tno} {d.systems} end"); Interlocked.Add(ref subthreadsrunning, -1); }
public void FillFromDB() // does not affect the display object { GridId.XZ(Id, out float x, out float z); if (array1displayed) { SystemsDB.GetSystemVector(Id, ref array2, ref carray2, Percentage, FromIntXYZScalar); // MAY return array/carray is null array2vertices = array2.Length; // System.Diagnostics.Debug.WriteLine("Grid " + Id + " " + x + "," + z + " into 2 at " + Percentage + " for " + array2vertices); } else { SystemsDB.GetSystemVector(Id, ref array1, ref carray1, Percentage, FromIntXYZScalar); array1vertices = array1.Length; // System.Diagnostics.Debug.WriteLine("Grid " + Id + " " + x + "," + z + " into 1 at " + Percentage + " for " + array1vertices); } }
private void DrawStars() { Cursor.Current = Cursors.WaitCursor; if (starpositions == null) { starpositions = SystemsDB.GetStarPositions(10, (x, y, z) => { return(new Point3D(x, y, z)); }); // limit to 10% } using (Pen pen = new Pen(Color.White, 2)) using (Graphics gfx = Graphics.FromImage(imageViewer.Image)) { foreach (Point3D si in starpositions) { DrawPoint(gfx, pen, si.X, si.Z); } } Cursor.Current = Cursors.Default; }
public long UpdateSync(bool[] grididallow, Func <bool> PendingClose, Action <string> ReportProgress) { DateTime lastrecordtime = SystemsDatabase.Instance.GetLastEDSMRecordTimeUTC(); DateTime maximumupdatetimewindow = DateTime.UtcNow.AddDays(-ForcedFullDownloadDays); // limit download to this amount of days if (lastrecordtime < maximumupdatetimewindow) { lastrecordtime = maximumupdatetimewindow; // this stops crazy situations where somehow we have a very old date but the full sync did not take care of it } long updates = 0; double fetchmult = 1; DateTime minimumfetchspan = DateTime.UtcNow.AddHours(-UpdateFetchHours / 2); // we don't bother fetching if last record time is beyond this point while (lastrecordtime < minimumfetchspan) // stop at X mins before now, so we don't get in a condition { // where we do a set, the time moves to just before now, // and we then do another set with minimum amount of hours if (PendingClose()) { return(updates); } if (updates == 0) { LogLine("Checking for updated EDSM systems (may take a few moments)."); } EDSMClass edsm = new EDSMClass(); double hourstofetch = UpdateFetchHours; //EDSM new server feb 2021, more capable, DateTime enddate = lastrecordtime + TimeSpan.FromHours(hourstofetch * fetchmult); if (enddate > DateTime.UtcNow) { enddate = DateTime.UtcNow; } LogLine($"Downloading systems from UTC {lastrecordtime.ToUniversalTime().ToString()} to {enddate.ToUniversalTime().ToString()}"); System.Diagnostics.Debug.WriteLine($"Downloading systems from UTC {lastrecordtime.ToUniversalTime().ToString()} to {enddate.ToUniversalTime().ToString()} {hourstofetch}"); string json = null; BaseUtils.ResponseData response; try { Stopwatch sw = new Stopwatch(); response = edsm.RequestSystemsData(lastrecordtime, enddate, timeout: 20000); fetchmult = Math.Max(0.1, Math.Min(Math.Min(fetchmult * 1.1, 1.0), 5000.0 / sw.ElapsedMilliseconds)); } catch (WebException ex) { ReportProgress($"EDSM request failed"); if (ex.Status == WebExceptionStatus.ProtocolError && ex.Response != null && ex.Response is HttpWebResponse) { string status = ((HttpWebResponse)ex.Response).StatusDescription; LogLine($"Download of EDSM systems from the server failed ({status}), will try next time program is run"); } else { LogLine($"Download of EDSM systems from the server failed ({ex.Status.ToString()}), will try next time program is run"); } return(updates); } catch (Exception ex) { ReportProgress($"EDSM request failed"); LogLine($"Download of EDSM systems from the server failed ({ex.Message}), will try next time program is run"); return(updates); } if (response.Error) { if ((int)response.StatusCode == 429) { LogLine($"EDSM rate limit hit - waiting 2 minutes"); for (int sec = 0; sec < 120; sec++) { if (!PendingClose()) { System.Threading.Thread.Sleep(1000); } } } else { LogLine($"Download of EDSM systems from the server failed ({response.StatusCode.ToString()}), will try next time program is run"); return(updates); } } json = response.Body; if (json == null) { ReportProgress("EDSM request failed"); LogLine("Download of EDSM systems from the server failed (no data returned), will try next time program is run"); return(updates); } // debug File.WriteAllText(@"c:\code\json.txt", json); DateTime prevrectime = lastrecordtime; System.Diagnostics.Debug.WriteLine("Last record time {0} JSON size {1}", lastrecordtime.ToUniversalTime(), json.Length); long updated = 0; try { ReportProgress($"EDSM star database update from UTC " + lastrecordtime.ToUniversalTime().ToString()); updated = SystemsDB.ParseEDSMJSONString(json, grididallow, ref lastrecordtime, PendingClose, ReportProgress, ""); System.Diagnostics.Debug.WriteLine($".. Updated {updated} to {lastrecordtime.ToUniversalTime().ToString()}"); System.Diagnostics.Debug.WriteLine("Updated to time {0}", lastrecordtime.ToUniversalTime()); // if lastrecordtime did not change (=) or worse still, EDSM somehow moved the time back (unlikely) if (lastrecordtime <= prevrectime) { lastrecordtime += TimeSpan.FromHours(12); // Lets move on manually so we don't get stuck } } catch (Exception e) { System.Diagnostics.Debug.WriteLine("SysClassEDSM.2 Exception " + e.ToString()); ReportProgress("EDSM request failed"); LogLine("Processing EDSM systems download failed, will try next time program is run"); return(updates); } updates += updated; SystemsDatabase.Instance.SetLastEDSMRecordTimeUTC(lastrecordtime); // keep on storing this in case next time we get an exception int delay = 10; // Anthor's normal delay int ratelimitlimit; int ratelimitremain; int ratelimitreset; if (response.Headers != null && response.Headers["X-Rate-Limit-Limit"] != null && response.Headers["X-Rate-Limit-Remaining"] != null && response.Headers["X-Rate-Limit-Reset"] != null && Int32.TryParse(response.Headers["X-Rate-Limit-Limit"], out ratelimitlimit) && Int32.TryParse(response.Headers["X-Rate-Limit-Remaining"], out ratelimitremain) && Int32.TryParse(response.Headers["X-Rate-Limit-Reset"], out ratelimitreset)) { if (ratelimitremain < ratelimitlimit * 3 / 4) // lets keep at least X remaining for other purposes later.. { delay = ratelimitreset / (ratelimitlimit - ratelimitremain); // slow down to its pace now.. example 878/(360-272) = 10 seconds per quota } else { delay = 0; } System.Diagnostics.Debug.WriteLine("EDSM Delay Parameters {0} {1} {2} => {3}s", ratelimitlimit, ratelimitremain, ratelimitreset, delay); } for (int sec = 0; sec < delay; sec++) { if (!PendingClose()) { System.Threading.Thread.Sleep(1000); } } } return(updates); }
private void DoPerformSync() // in Background worker { InvokeAsyncOnUiThread.Invoke(() => OnSyncStarting?.Invoke()); // tell listeners sync is starting resyncEDSMRequestedFlag = 1; // sync is happening, stop any async requests.. // check for 102, if so, upgrade it.. SystemsDatabase.Instance.UpgradeSystemTableFrom102TypeDB(() => PendingClose, ReportSyncProgress, syncstate.perform_edsm_fullsync); if (EDDConfig.Instance.EDSMDownload) // if no system off, and EDSM download on { Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Perform System Data Download from EDSM"); try { bool[] grids = new bool[GridId.MaxGridID]; foreach (int i in GridId.FromString(EDDConfig.Instance.EDSMGridIDs)) { grids[i] = true; } syncstate.ClearCounters(); if (syncstate.perform_edsm_fullsync || syncstate.perform_edsm_alias_sync) { if (syncstate.perform_edsm_fullsync && !PendingClose) { // Download new systems try { string edsmsystems = Path.Combine(EDDOptions.Instance.AppDataDirectory, "edsmsystems.json.gz"); ReportSyncProgress("Performing full download of System Data from EDSM"); Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Full system download using URL " + EDDConfig.Instance.EDSMFullSystemsURL); bool success = BaseUtils.DownloadFile.HTTPDownloadFile(EDDConfig.Instance.EDSMFullSystemsURL, edsmsystems, false, out bool newfile); syncstate.perform_edsm_fullsync = false; if (success) { syncstate.edsm_fullsync_count = SystemsDatabase.Instance.UpgradeSystemTableFromFile(edsmsystems, grids, () => PendingClose, ReportSyncProgress); if (syncstate.edsm_fullsync_count < 0) // this should always update something, the table is replaced. If its not, its been cancelled { return; } BaseUtils.FileHelpers.DeleteFileNoError(edsmsystems); // remove file - don't hold in storage } else { ReportSyncProgress(""); LogLineHighlight("Failed to download full EDSM systems file. Try re-running EDD later"); BaseUtils.FileHelpers.DeleteFileNoError(edsmsystems); // remove file - don't hold in storage return; // new! if we failed to download, fail here, wait for another time } } catch (Exception ex) { LogLineHighlight("GetAllEDSMSystems exception:" + ex.Message); } } if (!PendingClose && syncstate.perform_edsm_alias_sync) { try { EDSMClass edsm = new EDSMClass(); string edsmhiddensystems = Path.Combine(EDDOptions.Instance.AppDataDirectory, "edsmhiddensystems.json"); string jsonhidden = edsm.GetHiddenSystems(edsmhiddensystems); if (jsonhidden != null) { SystemsDB.ParseAliasString(jsonhidden); syncstate.perform_edsm_alias_sync = false; SystemsDatabase.Instance.SetLastEDSMAliasDownloadTime(); } } catch (Exception ex) { LogLineHighlight("GetEDSMAlias exception: " + ex.Message); } } } if (!PendingClose) // perform an update sync to get any new EDSM data { syncstate.edsm_updatesync_count = UpdateSync(grids, () => PendingClose, ReportSyncProgress); } } catch (OperationCanceledException) { // Swallow Operation Cancelled exceptions } catch (Exception ex) { LogLineHighlight("Check Systems exception: " + ex.Message + Environment.NewLine + "Trace: " + ex.StackTrace); } } InvokeAsyncOnUiThread(() => PerformSyncCompletedonUI()); }
public TestSQLForm() { InitializeComponent(); string edsminfile = @"c:\code\edsm\edsmsystems.10e6.json"; bool deletedb = false; bool reloadjson = false; bool printstars = false; bool testdelete = false; bool loadaliases = false; if (deletedb) { BaseUtils.FileHelpers.DeleteFileNoError(EliteDangerousCore.EliteConfigInstance.InstanceOptions.SystemDatabasePath); } SystemsDatabase.Instance.MaxThreads = 8; SystemsDatabase.Instance.MinThreads = 2; SystemsDatabase.Instance.MultiThreaded = true; SystemsDatabase.Instance.Initialize(); // SQLiteConnectionSystem.UpgradeSystemTableFrom102TypeDB(() => { return false; }, (s) => System.Diagnostics.Debug.WriteLine(s),false); if (reloadjson) { SystemsDatabase.Instance.UpgradeSystemTableFromFile(edsminfile, null, () => false, (s) => System.Diagnostics.Debug.WriteLine(s)); } if (printstars) { using (StreamWriter wr = new StreamWriter(@"c:\code\edsm\starlistout.lst")) { SystemsDB.ListStars(orderby: "s.sectorid,s.edsmid", starreport: (s) => { wr.WriteLine(s.Name + " " + s.Xi + "," + s.Yi + "," + s.Zi + ", EDSM:" + s.EDSMID + " Grid:" + s.GridID); }); } } if (testdelete) { SystemsDB.RemoveGridSystems(new int[] { 810, 911 }); using (StreamWriter wr = new StreamWriter(@"c:\code\edsm\starlistout2.lst")) { SystemsDB.ListStars(orderby: "s.sectorid,s.edsmid", starreport: (s) => { wr.WriteLine(s.Name + " " + s.Xi + "," + s.Yi + "," + s.Zi + ", EDSM:" + s.EDSMID + " Grid:" + s.GridID); }); } } if (loadaliases) { string infile = @"c:\code\edsm\hiddensystems.jsonl"; BaseUtils.AppTicks.TickCountLap(); long updated = SystemsDB.ParseAliasFile(infile); System.Diagnostics.Debug.WriteLine("Alias Load: " + BaseUtils.AppTicks.TickCountLap() + " updated " + updated); BaseUtils.AppTicks.TickCountLap(); string infile2 = @"c:\code\edsm\hiddensystems2.jsonl"; updated = SystemsDB.ParseAliasFile(infile2); System.Diagnostics.Debug.WriteLine("Alias Load: " + BaseUtils.AppTicks.TickCountLap() + " updated " + updated); } // ******************************************** // TESTS BASED on the 10e6 json file // ******************************************** { long aliasn; aliasn = SystemsDB.FindAlias(-1, "CM Draco"); System.Diagnostics.Debug.Assert(aliasn == 19700); aliasn = SystemsDB.FindAlias(1, null); System.Diagnostics.Debug.Assert(aliasn == 19700); aliasn = SystemsDB.FindAlias(-1, "CM qwkqkq"); System.Diagnostics.Debug.Assert(aliasn == -1); List <ISystem> aliaslist = SystemsDB.FindAliasWildcard("Horsehead"); System.Diagnostics.Debug.Assert(aliaslist.Count > 10); } { BaseUtils.AppTicks.TickCountLap(); ISystem s; for (int I = 0; I < 50; I++) // 6/4/18 50 @ 38 (76 no index on systems) { s = SystemsDB.FindStar("HIP 112535"); // this one is at the front of the DB System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 112535")); } System.Diagnostics.Debug.WriteLine("FindStar HIP x for X: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; BaseUtils.AppTicks.TickCountLap(); string star = "HIP 101456"; for (int I = 0; I < 50; I++) { s = SystemsDB.FindStar(star); // This one is at the back of the DB System.Diagnostics.Debug.Assert(s != null && s.Name.Equals(star)); // System.Diagnostics.Debug.WriteLine("Lap : " + BaseUtils.AppTicks.TickCountLap()); } System.Diagnostics.Debug.WriteLine("Find Standard for X: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 50; I++) // 6/4/18 50 @ 26ms (No need for system index) { s = SystemsDB.FindStar("kanur"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Kanur") && s.Xi == -2832 && s.Yi == -3188 && s.Zi == 12412); } System.Diagnostics.Debug.WriteLine("Find Kanur for X: " + BaseUtils.AppTicks.TickCountLap()); } { // 16/4/18 100 @ 52ms (48 no system tables) ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 100; I++) { s = SystemsDB.FindStar(2836547); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Tucanae Sector SP-N b7-6") && s.Xi == 10844 && s.Yi == -18100 && s.Zi == 28036 && s.EDSMID == 2836547); } System.Diagnostics.Debug.WriteLine("Find EDSMID for 100: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; s = SystemsDB.FindStar("hip 91507"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 91507")); s = SystemsDB.FindStar("Byua Eurk GL-Y d107"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Byua Eurk GL-Y d107") && s.X == -3555.5625 && s.Y == 119.25 && s.Z == 5478.59375); s = SystemsDB.FindStar("BD+18 711"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("BD+18 711") && s.Xi == 1700 && s.Yi == -68224 && s.Zi == -225284); s = SystemsDB.FindStar("Chamaeleon Sector FG-W b2-3"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Chamaeleon Sector FG-W b2-3") && s.Xi == 71440 && s.Yi == -12288 && s.Zi == 35092); } { // No system indexes = 4179 xz=10 @21, xz=100 @ 176, x= 100 @ 1375, xz 100 @ 92 xz vacummed 76. System.Diagnostics.Debug.WriteLine("Begin Find Pos for 100"); ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 100; I++) { SystemsDatabase.Instance.DBRead(db => { s = SystemsDB.GetSystemByPosition(-100.7, 166.4, -36.8, db); System.Diagnostics.Debug.Assert(s != null && s.Name == "Col 285 Sector IZ-B b15-2"); }); // System.Diagnostics.Debug.WriteLine("Lap : " + BaseUtils.AppTicks.TickCountLap()); } System.Diagnostics.Debug.WriteLine("Find Pos for 100: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; s = SystemCache.FindSystem("hip 91507"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 91507")); s = SystemCache.FindSystem("hip 91507"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 91507")); s = SystemCache.FindSystem("Byua Eurk GL-Y d107"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Byua Eurk GL-Y d107") && s.X == -3555.5625 && s.Y == 119.25 && s.Z == 5478.59375); s = SystemCache.FindSystem("BD+18 711"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("BD+18 711") && s.Xi == 1700 && s.Yi == -68224 && s.Zi == -225284); s = SystemCache.FindSystem("Chamaeleon Sector FG-W b2-3"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Chamaeleon Sector FG-W b2-3") && s.Xi == 71440 && s.Yi == -12288 && s.Zi == 35092); s = SystemCache.FindSystem("kanur"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Kanur") && s.Xi == -2832 && s.Yi == -3188 && s.Zi == 12412); //s = SystemCache.FindSystem(s.EDSMID); //System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Kanur") && s.Xi == -2832 && s.Yi == -3188 && s.Zi == 12412); s = SystemCache.FindSystem("CM DRACO"); // this is an alias system System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("CM Draconis") && s.EDSMID == 19700); } { List <ISystem> slist; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 10; I++) { slist = SystemsDB.FindStarWildcard("Tucanae Sector CQ-Y"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 20); //System.Diagnostics.Debug.WriteLine("Lap : " + BaseUtils.AppTicks.TickCountLap()); } System.Diagnostics.Debug.WriteLine("Find Wildcard Standard trunced: " + BaseUtils.AppTicks.TickCountLap()); } { BaseUtils.AppTicks.TickCountLap(); List <ISystem> slist; for (int I = 0; I < 10; I++) { slist = SystemsDB.FindStarWildcard("HIP 6"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 48); foreach (var e in slist) { System.Diagnostics.Debug.Assert(e.Name.StartsWith("HIP 6")); } } System.Diagnostics.Debug.WriteLine("Find Wildcard HIP 6: " + BaseUtils.AppTicks.TickCountLap()); } { BaseUtils.AppTicks.TickCountLap(); List <ISystem> slist; for (int I = 0; I < 10; I++) { slist = SystemsDB.FindStarWildcard("USNO-A2.0 127"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 185); foreach (var e in slist) { System.Diagnostics.Debug.Assert(e.Name.StartsWith("USNO-A2.0")); } } System.Diagnostics.Debug.WriteLine("Find Wildcard USNo: " + BaseUtils.AppTicks.TickCountLap()); } { List <ISystem> slist; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 1; I++) { slist = SystemsDB.FindStarWildcard("HIP"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 48); } System.Diagnostics.Debug.WriteLine("Find Wildcard HIP: " + BaseUtils.AppTicks.TickCountLap()); } { List <ISystem> slist; slist = SystemsDB.FindStarWildcard("Synuefai MC-H"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 3); slist = SystemsDB.FindStarWildcard("Synuefai MC-H c"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 3); slist = SystemsDB.FindStarWildcard("Synuefai MC-H c12"); System.Diagnostics.Debug.Assert(slist != null && slist.Count == 0); slist = SystemsDB.FindStarWildcard("Synuefai MC-H c12-"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 3); slist = SystemsDB.FindStarWildcard("HIP 6"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 5); slist = SystemsDB.FindStarWildcard("Coalsack Sector"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 4); slist = SystemsDB.FindStarWildcard("Coalsack"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 4); slist = SystemsDB.FindStarWildcard("4 S"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 1); } { // xz index = 70ms BaseUtils.SortedListDoubleDuplicate <ISystem> list = new BaseUtils.SortedListDoubleDuplicate <ISystem>(); BaseUtils.AppTicks.TickCountLap(); double x = 0, y = 0, z = 0; SystemsDatabase.Instance.DBRead(db => { SystemsDB.GetSystemListBySqDistancesFrom(list, x, y, z, 20000, 0.5, 20, true, db); System.Diagnostics.Debug.WriteLine("Stars Near Sol: " + BaseUtils.AppTicks.TickCountLap()); System.Diagnostics.Debug.Assert(list != null && list.Count >= 20); }); //foreach (var k in list) System.Diagnostics.Debug.WriteLine(Math.Sqrt(k.Key).ToString("N1") + " Star " + k.Value.ToStringVerbose()); } { // xz index = 185ms BaseUtils.SortedListDoubleDuplicate <ISystem> list = new BaseUtils.SortedListDoubleDuplicate <ISystem>(); BaseUtils.AppTicks.TickCountLap(); double x = 490, y = 0, z = 0; SystemsDatabase.Instance.DBRead(db => { SystemsDB.GetSystemListBySqDistancesFrom(list, x, y, z, 20000, 0.5, 50, true, db); //should span 2 grids 810/811 System.Diagnostics.Debug.WriteLine("Stars Near x490: " + BaseUtils.AppTicks.TickCountLap()); System.Diagnostics.Debug.Assert(list != null && list.Count >= 20); }); //foreach (var k in list) System.Diagnostics.Debug.WriteLine(Math.Sqrt(k.Key).ToString("N1") + " Star " + k.Value.ToStringVerbose()); } { // 142ms with xz and no sector lookup SystemsDatabase.Instance.DBRead(db => { BaseUtils.AppTicks.TickCountLap(); ISystem s; s = SystemsDB.GetSystemNearestTo(new Point3D(100, 0, 0), new Point3D(1, 0, 0), 110, 20, SystemsDB.SystemsNearestMetric.IterativeWaypointDevHalf, db); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Alpha Centauri")); System.Diagnostics.Debug.WriteLine("Find Nearest Star: " + BaseUtils.AppTicks.TickCountLap()); }); } { SystemCache.AddToAutoCompleteList(new List <string>() { "galone", "galtwo", "sol2" }); List <string> sys; sys = SystemCache.ReturnSystemAutoCompleteList("Sol", null); System.Diagnostics.Debug.Assert(sys != null && sys.Contains("Solati") && sys.Count >= 4); } { uint[] colours = null; Vector3[] vertices = null; uint[] colours2 = null; Vector3[] vertices2 = null; BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(5, ref vertices, ref colours, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.Assert(vertices.Length > 1000); System.Diagnostics.Debug.WriteLine("5 load : " + BaseUtils.AppTicks.TickCountLap()); BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices, ref colours, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.WriteLine("810 load 100 : " + BaseUtils.AppTicks.TickCountLap()); BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices2, ref colours2, 50, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.Assert(vertices.Length >= vertices2.Length * 2); System.Diagnostics.Debug.WriteLine("810 load 50 : " + BaseUtils.AppTicks.TickCountLap()); } { var v = SystemsDB.GetStarPositions(5, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.Assert(v.Count > 450000); // var v2 = SystemClassDB.GetStarPositions(100, (x, y, z) => { return new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f); }); } }
private void DoPerformSync() // in Background worker { InvokeAsyncOnUiThread.Invoke(() => OnSyncStarting?.Invoke()); // tell listeners sync is starting resyncEDSMEDDBRequestedFlag = 1; // sync is happening, stop any async requests.. Debug.WriteLine(BaseUtils.AppTicks.TickCountLap() + " Perform EDSM/EDDB sync"); try { bool[] grids = new bool[GridId.MaxGridID]; foreach (int i in GridId.FromString(EDDConfig.Instance.EDSMGridIDs)) { grids[i] = true; } syncstate.ClearCounters(); if (syncstate.perform_edsm_fullsync || syncstate.perform_eddb_edsmalias_sync) { if (syncstate.perform_edsm_fullsync && !PendingClose) { // Download new systems try { string edsmsystems = Path.Combine(EliteConfigInstance.InstanceOptions.AppDataDirectory, "edsmsystems.json"); ReportSyncProgress("Performing full download of EDSM Database from server"); bool success = BaseUtils.DownloadFile.HTTPDownloadFile(EliteConfigInstance.InstanceConfig.EDSMFullSystemsURL, edsmsystems, false, out bool newfile); syncstate.perform_edsm_fullsync = false; if (success) { syncstate.edsm_fullsync_count = SQLiteConnectionSystem.UpgradeSystemTableFromFile(edsmsystems, grids, () => PendingClose, ReportSyncProgress); if (syncstate.edsm_fullsync_count < 0) // this should always update something, the table is replaced. If its not, its been cancelled { return; } BaseUtils.FileHelpers.DeleteFileNoError(edsmsystems); // remove file - don't hold in storage } } catch (Exception ex) { LogLineHighlight("GetAllEDSMSystems exception:" + ex.Message); } } if (!PendingClose) { try { EDSMClass edsm = new EDSMClass(); string jsonhidden = edsm.GetHiddenSystems(); if (jsonhidden != null) { SystemsDB.ParseAliasString(jsonhidden); string eddbsystems = Path.Combine(EliteConfigInstance.InstanceOptions.AppDataDirectory, "eddbsystems.json"); bool success = BaseUtils.DownloadFile.HTTPDownloadFile(EliteConfigInstance.InstanceConfig.EDDBSystemsURL, eddbsystems, false, out bool newfile); syncstate.perform_eddb_edsmalias_sync = false; if (success) { syncstate.eddb_sync_count = SystemsDB.ParseEDDBJSONFile(eddbsystems, () => PendingClose); if (syncstate.eddb_sync_count < 0) // on a cancel or error { return; } SQLiteConnectionSystem.SetLastEDDBDownloadTime(); BaseUtils.FileHelpers.DeleteFileNoError(eddbsystems); // remove file - don't hold in storage } } } catch (Exception ex) { LogLineHighlight("GetEDDBUpdate exception: " + ex.Message); } } } if (!PendingClose) { syncstate.edsm_updatesync_count = UpdateSync(grids, () => PendingClose, ReportSyncProgress); } } catch (OperationCanceledException) { // Swallow Operation Cancelled exceptions } catch (Exception ex) { LogLineHighlight("Check Systems exception: " + ex.Message + Environment.NewLine + "Trace: " + ex.StackTrace); } InvokeAsyncOnUiThread(() => PerformSyncCompletedonUI()); }
public Form1() { InitializeComponent(); bool deletedb = false; string edsminfile = @"c:\code\edsm\edsmsystems.10e6.json"; bool reloadjson = false; string eddbinfile = @"c:\code\edsm\eddbsystems.json"; bool reloadeddb = false; bool printstars = false; bool printstarseddb = false; bool testdelete = false; bool loadaliases = false; if (deletedb) { BaseUtils.FileHelpers.DeleteFileNoError(EliteDangerousCore.EliteConfigInstance.InstanceOptions.SystemDatabasePath); } SQLiteConnectionSystem.Initialize(); SQLiteConnectionSystem.UpgradeSystemTableFrom102TypeDB(() => { return(false); }, (s) => System.Diagnostics.Debug.WriteLine(s), false); if (reloadjson) { SQLiteConnectionSystem.UpgradeSystemTableFromFile(edsminfile, null, () => false, (s) => System.Diagnostics.Debug.WriteLine(s)); } if (reloadeddb) { BaseUtils.AppTicks.TickCountLap(); long updated = SystemsDB.ParseEDDBJSONFile(eddbinfile, () => false); System.Diagnostics.Debug.WriteLine("EDDB Load : " + BaseUtils.AppTicks.TickCountLap() + " updated " + updated); updated = SystemsDB.ParseEDDBJSONFile(eddbinfile, () => false); System.Diagnostics.Debug.WriteLine("EDDB Load : " + BaseUtils.AppTicks.TickCountLap() + " updated " + updated); } if (printstars) { using (StreamWriter wr = new StreamWriter(@"c:\code\edsm\starlistout.lst")) { SystemsDB.ListStars(orderby: "s.sectorid,s.edsmid", eddbinfo: false, starreport: (s) => { wr.WriteLine(s.Name + " " + s.Xi + "," + s.Yi + "," + s.Zi + ", EDSM:" + s.EDSMID + " Grid:" + s.GridID); }); } } if (testdelete) { SystemsDB.RemoveGridSystems(new int[] { 810, 911 }); using (StreamWriter wr = new StreamWriter(@"c:\code\edsm\starlistout2.lst")) { SystemsDB.ListStars(orderby: "s.sectorid,s.edsmid", eddbinfo: false, starreport: (s) => { wr.WriteLine(s.Name + " " + s.Xi + "," + s.Yi + "," + s.Zi + ", EDSM:" + s.EDSMID + " Grid:" + s.GridID); }); } } if (loadaliases) { string infile = @"c:\code\edsm\hiddensystems.jsonl"; BaseUtils.AppTicks.TickCountLap(); long updated = SystemsDB.ParseAliasFile(infile); System.Diagnostics.Debug.WriteLine("Alias Load: " + BaseUtils.AppTicks.TickCountLap() + " updated " + updated); BaseUtils.AppTicks.TickCountLap(); string infile2 = @"c:\code\edsm\hiddensystems2.jsonl"; updated = SystemsDB.ParseAliasFile(infile2); System.Diagnostics.Debug.WriteLine("Alias Load: " + BaseUtils.AppTicks.TickCountLap() + " updated " + updated); } if (printstarseddb) { List <ISystem> stars = SystemsDB.ListStars(orderby: "s.sectorid,s.edsmid", eddbinfo: true); using (StreamWriter wr = new StreamWriter(@"c:\code\edsm\starlisteddb.lst")) { foreach (var s in stars) { wr.Write(s.Name + " " + s.Xi + "," + s.Yi + "," + s.Zi + ", EDSM:" + s.EDSMID + " Grid:" + s.GridID); if (s.EDDBID != 0) { wr.Write(" EDDBID:" + s.EDDBID + " " + s.Population + " " + s.Faction + " " + s.Government + " " + s.Allegiance + " " + s.State + " " + s.Security + " " + s.PrimaryEconomy + " " + s.Power + " " + s.PowerState + " " + s.NeedsPermit + " " + s.EDDBUpdatedAt); } wr.WriteLine(""); } } } ///////////////////////////////////////////// main tests { //BaseUtils.AppTicks.TickCountLap(); // Repeated run 1420/2.. removed too slow //ISystem s; //for (int I = 0; I < 2; I++) //{ // long total = SystemsDB.GetTotalSystems(); // System.Diagnostics.Debug.Assert(total > 9999); //} //System.Diagnostics.Debug.WriteLine("total systems for X: " + BaseUtils.AppTicks.TickCountLap()); } { long aliasn; aliasn = SystemsDB.FindAlias(-1, "CM Draco"); System.Diagnostics.Debug.Assert(aliasn == 19700); aliasn = SystemsDB.FindAlias(1, null); System.Diagnostics.Debug.Assert(aliasn == 19700); aliasn = SystemsDB.FindAlias(-1, "CM qwkqkq"); System.Diagnostics.Debug.Assert(aliasn == -1); List <ISystem> aliaslist = SystemsDB.FindAliasWildcard("Horsehead"); System.Diagnostics.Debug.Assert(aliaslist.Count > 10); } { BaseUtils.AppTicks.TickCountLap(); ISystem s; for (int I = 0; I < 50; I++) // 6/4/18 50 @ 38 (76 no index on systems) { s = SystemsDB.FindStar("HIP 112535"); // this one is at the front of the DB System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 112535")); } System.Diagnostics.Debug.WriteLine("FindStar HIP x for X: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 50; I++) { s = SystemsDB.FindStar("HIP 14490"); // This one is at the back of the DB System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 14490")); // System.Diagnostics.Debug.WriteLine("Lap : " + BaseUtils.AppTicks.TickCountLap()); } System.Diagnostics.Debug.WriteLine("Find Standard for X: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 50; I++) // 6/4/18 50 @ 26ms (No need for system index) { s = SystemsDB.FindStar("kanur"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Kanur") && s.Xi == -2832 && s.Yi == -3188 && s.Zi == 12412 && s.EDDBID == 10442); } System.Diagnostics.Debug.WriteLine("Find Kanur for X: " + BaseUtils.AppTicks.TickCountLap()); } { // 16/4/18 100 @ 52ms (48 no system tables) ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 100; I++) { s = SystemsDB.FindStar(2836547); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Tucanae Sector SP-N b7-6") && s.Xi == 10844 && s.Yi == -18100 && s.Zi == 28036 && s.EDSMID == 2836547 && s.EDDBID == 0); } System.Diagnostics.Debug.WriteLine("Find EDSMID for 100: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; s = SystemsDB.FindStar("hip 91507"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 91507") && s.EDDBID == 8856); s = SystemsDB.FindStar("Byua Eurk GL-Y d107"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Byua Eurk GL-Y d107") && s.X == -3555.5625 && s.Y == 119.25 && s.Z == 5478.59375); s = SystemsDB.FindStar("BD+18 711"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("BD+18 711") && s.Xi == 1700 && s.Yi == -68224 && s.Zi == -225284); s = SystemsDB.FindStar("Chamaeleon Sector FG-W b2-3"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Chamaeleon Sector FG-W b2-3") && s.Xi == 71440 && s.Yi == -12288 && s.Zi == 35092); } { // No system indexes = 4179 xz=10 @21, xz=100 @ 176, x= 100 @ 1375, xz 100 @ 92 xz vacummed 76. System.Diagnostics.Debug.WriteLine("Begin Find Pos for 100"); ISystem s; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 100; I++) { s = SystemsDB.GetSystemByPosition(-100.7, 166.4, -36.8); System.Diagnostics.Debug.Assert(s != null && s.Name == "Col 285 Sector IZ-B b15-2"); // System.Diagnostics.Debug.WriteLine("Lap : " + BaseUtils.AppTicks.TickCountLap()); } System.Diagnostics.Debug.WriteLine("Find Pos for 100: " + BaseUtils.AppTicks.TickCountLap()); } { ISystem s; s = SystemCache.FindSystem("hip 91507"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 91507") && s.EDDBID == 8856); s = SystemCache.FindSystem("hip 91507"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("HIP 91507") && s.EDDBID == 8856); s = SystemCache.FindSystem("Byua Eurk GL-Y d107"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Byua Eurk GL-Y d107") && s.X == -3555.5625 && s.Y == 119.25 && s.Z == 5478.59375); s = SystemCache.FindSystem("BD+18 711"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("BD+18 711") && s.Xi == 1700 && s.Yi == -68224 && s.Zi == -225284); s = SystemCache.FindSystem("Chamaeleon Sector FG-W b2-3"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Chamaeleon Sector FG-W b2-3") && s.Xi == 71440 && s.Yi == -12288 && s.Zi == 35092); s = SystemCache.FindSystem("kanur"); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Kanur") && s.Xi == -2832 && s.Yi == -3188 && s.Zi == 12412 && s.EDDBID == 10442); s = SystemCache.FindSystem(s.EDSMID); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Kanur") && s.Xi == -2832 && s.Yi == -3188 && s.Zi == 12412 && s.EDDBID == 10442); s = SystemCache.FindSystem("CM DRACO"); // this is an alias system System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("CM Draconis") && s.EDSMID == 19700); } { List <ISystem> slist; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 10; I++) { slist = SystemsDB.FindStarWildcard("Tucanae Sector CQ-Y"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 20); //System.Diagnostics.Debug.WriteLine("Lap : " + BaseUtils.AppTicks.TickCountLap()); } System.Diagnostics.Debug.WriteLine("Find Wildcard Standard trunced: " + BaseUtils.AppTicks.TickCountLap()); } { BaseUtils.AppTicks.TickCountLap(); List <ISystem> slist; for (int I = 0; I < 10; I++) { slist = SystemsDB.FindStarWildcard("HIP 6"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 48); foreach (var e in slist) { System.Diagnostics.Debug.Assert(e.Name.StartsWith("HIP 6")); } } System.Diagnostics.Debug.WriteLine("Find Wildcard HIP 6: " + BaseUtils.AppTicks.TickCountLap()); } { BaseUtils.AppTicks.TickCountLap(); List <ISystem> slist; for (int I = 0; I < 10; I++) { slist = SystemsDB.FindStarWildcard("USNO-A2.0 127"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 185); foreach (var e in slist) { System.Diagnostics.Debug.Assert(e.Name.StartsWith("USNO-A2.0")); } } System.Diagnostics.Debug.WriteLine("Find Wildcard USNo: " + BaseUtils.AppTicks.TickCountLap()); } { List <ISystem> slist; BaseUtils.AppTicks.TickCountLap(); for (int I = 0; I < 1; I++) { slist = SystemsDB.FindStarWildcard("HIP"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 48); } System.Diagnostics.Debug.WriteLine("Find Wildcard HIP: " + BaseUtils.AppTicks.TickCountLap()); } { List <ISystem> slist; slist = SystemsDB.FindStarWildcard("Synuefai MC-H"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 3); slist = SystemsDB.FindStarWildcard("Synuefai MC-H c"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 3); slist = SystemsDB.FindStarWildcard("Synuefai MC-H c12"); System.Diagnostics.Debug.Assert(slist != null && slist.Count == 0); slist = SystemsDB.FindStarWildcard("Synuefai MC-H c12-"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 3); slist = SystemsDB.FindStarWildcard("HIP 6"); System.Diagnostics.Debug.Assert(slist != null && slist.Count > 5); slist = SystemsDB.FindStarWildcard("Coalsack Sector"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 4); slist = SystemsDB.FindStarWildcard("Coalsack"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 4); slist = SystemsDB.FindStarWildcard("4 S"); System.Diagnostics.Debug.Assert(slist != null && slist.Count >= 1); slist = SystemsDB.FindStarWildcard("Beagle Point"); System.Diagnostics.Debug.Assert(slist != null && slist.Count == 1); ISystem bp = slist[0]; slist = SystemsDB.FindAliasWildcard("Ceeckia ZQ-L C24-0"); System.Diagnostics.Debug.Assert(slist != null && slist.Count == 1 && bp.Name == slist[0].Name); } { // xz index = 70ms BaseUtils.SortedListDoubleDuplicate <ISystem> list = new BaseUtils.SortedListDoubleDuplicate <ISystem>(); BaseUtils.AppTicks.TickCountLap(); double x = 0, y = 0, z = 0; SystemsDB.GetSystemListBySqDistancesFrom(list, x, y, z, 20000, 0.5, 20, true); System.Diagnostics.Debug.WriteLine("Stars Near Sol: " + BaseUtils.AppTicks.TickCountLap()); System.Diagnostics.Debug.Assert(list != null && list.Count >= 20); //foreach (var k in list) System.Diagnostics.Debug.WriteLine(Math.Sqrt(k.Key).ToString("N1") + " Star " + k.Value.ToStringVerbose()); } { // xz index = 185ms BaseUtils.SortedListDoubleDuplicate <ISystem> list = new BaseUtils.SortedListDoubleDuplicate <ISystem>(); BaseUtils.AppTicks.TickCountLap(); double x = 490, y = 0, z = 0; SystemsDB.GetSystemListBySqDistancesFrom(list, x, y, z, 20000, 0.5, 50, true); //should span 2 grids 810/811 System.Diagnostics.Debug.WriteLine("Stars Near x490: " + BaseUtils.AppTicks.TickCountLap()); System.Diagnostics.Debug.Assert(list != null && list.Count >= 20); //foreach (var k in list) System.Diagnostics.Debug.WriteLine(Math.Sqrt(k.Key).ToString("N1") + " Star " + k.Value.ToStringVerbose()); } { // 142ms with xz and no sector lookup BaseUtils.AppTicks.TickCountLap(); ISystem s; s = SystemsDB.GetSystemNearestTo(new Point3D(100, 0, 0), new Point3D(1, 0, 0), 110, 20, SystemsDB.metric_waypointdev2); System.Diagnostics.Debug.Assert(s != null && s.Name.Equals("Sol")); System.Diagnostics.Debug.WriteLine("Find Nearest Star: " + BaseUtils.AppTicks.TickCountLap()); } { SystemCache.AddToAutoCompleteList(new List <string>() { "galone", "galtwo", "sol2" }); List <string> sys; sys = SystemCache.ReturnSystemAutoCompleteList("Sol", null); System.Diagnostics.Debug.Assert(sys != null && sys.Contains("Sol") && sys.Count >= 5); } { uint[] colours = null; Vector3[] vertices = null; uint[] colours2 = null; Vector3[] vertices2 = null; BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(5, ref vertices, ref colours, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.Assert(vertices.Length > 10000); System.Diagnostics.Debug.WriteLine("5 load : " + BaseUtils.AppTicks.TickCountLap()); BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices, ref colours, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.WriteLine("810 load 100 : " + BaseUtils.AppTicks.TickCountLap()); BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices2, ref colours2, 50, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.Assert(vertices.Length >= vertices2.Length * 2); System.Diagnostics.Debug.WriteLine("810 load 50 : " + BaseUtils.AppTicks.TickCountLap()); int lengthall = vertices.Length; BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices, ref colours, ref vertices2, ref colours2, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); System.Diagnostics.Debug.Assert(vertices.Length >= 20000); System.Diagnostics.Debug.Assert(vertices2.Length >= 300000); System.Diagnostics.Debug.Assert(vertices.Length + vertices2.Length == lengthall); System.Diagnostics.Debug.WriteLine("810 load dual : " + BaseUtils.AppTicks.TickCountLap()); int pop = vertices.Length; int unpop = vertices2.Length; BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices, ref colours, ref vertices2, ref colours2, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }, SystemsDB.SystemAskType.PopulatedStars); System.Diagnostics.Debug.Assert(vertices.Length == pop); System.Diagnostics.Debug.Assert(vertices2 == null); System.Diagnostics.Debug.WriteLine("810 load pop : " + BaseUtils.AppTicks.TickCountLap()); BaseUtils.AppTicks.TickCountLap(); SystemsDB.GetSystemVector(810, ref vertices, ref colours, ref vertices2, ref colours2, 100, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }, SystemsDB.SystemAskType.UnpopulatedStars); System.Diagnostics.Debug.Assert(vertices.Length == unpop); System.Diagnostics.Debug.Assert(vertices2 == null); System.Diagnostics.Debug.WriteLine("810 load unpop : " + BaseUtils.AppTicks.TickCountLap()); } { var v = SystemsDB.GetStarPositions(5, (x, y, z) => { return(new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f)); }); // var v2 = SystemClassDB.GetStarPositions(100, (x, y, z) => { return new Vector3((float)x / 128.0f, (float)y / 128.0f, (float)z / 128.0f); }); } }