public void SimpleTest() { var sdf = new SimpleDf("sdf"); sdf.preferedType["id"] = SdfColType.dfint; sdf.preferedType["dt"] = SdfColType.dfdatetime; sdf.preferedFormat["dt"] = "yyyy-MM-dd HH:mm:ss"; sdf.preferedSubstitute["dt"] = ("+00", ""); sdf.ReadCsv(sdflines); Assert.True(sdf.Nrow() == 3); Assert.True(sdf.Ncol() == 5); Assert.True(sdf.InfoClassStr() == "Classes:id:dfint,x:dfdouble,y:dfdouble,dt:dfdatetime,n:dfstring"); Assert.True(sdf.GetIntCol("id").Sum() == 6); Assert.True(sdf.GetDoubleCol("x").Sum() == 6); Assert.True(sdf.GetDoubleCol("y").Sum() == 9); Assert.True(sdf.DataErrors() == 0); // Use the Assert class to test conditions }
public IEnumerator PlotStaticTrack() { var sw = new StopWatch(); ResolveFullCsvName(); Debug.Log("Plot " + vehicleTrackName); //if (dozgo != null) //{ // DeleteTrack(); //} vehgo = new GameObject(vehicleTrackName + "_tracks"); vehgo.transform.parent = trackParent.transform; var lngcol = sdf.GetDoubleCol("x"); var latcol = sdf.GetDoubleCol("y"); var skalink = vtm.trackScale * 0.5f; // meters var skawid = vtm.trackWidthScale; var skanode = vtm.trackScale * 0.57f; // meters nnodes = 0; nlinks = 0; var nrow = sdf.Nrow(); if (nrow == 0) { Debug.LogError("Plot Static Track - no rows in track df " + fullcsvname); yield break; } Debug.Log("Plotting " + vehicleTrackName + " consolidationDistance:" + vtm.consolidationDistance + " trackscale:" + vtm.trackScale); var ll0 = new LatLng(latcol[0], lngcol[0]); (var pos0, _, _) = qmesh.GetWcMeshPosFromLatLng(ll0); var dolinks = vtm.vehicleTrackForm == VehicleTrackForm.Links || vtm.vehicleTrackForm == VehicleTrackForm.NodesAndLinks; var donodes = vtm.vehicleTrackForm == VehicleTrackForm.Nodes || vtm.vehicleTrackForm == VehicleTrackForm.NodesAndLinks; for (var i = 0; i < nrow; i++) { var ptname = "pt" + i; var ppname = "pp" + i; if (ptname == "pt21632") { Debug.Log("pt:" + ptname); } var ll = new LatLng(latcol[i], lngcol[i]); (var pos, _, _) = qmesh.GetWcMeshPosFromLatLng(ll); if (Vector3.Distance(pos0, pos) > vtm.consolidationDistance) { if (donodes) { SphInfo.DoInfoSphereSlim(vehgo, ptname, pos, skanode, clr, ll); nnodes++; } if (dolinks) { var cclr = qut.GetColorByName(clr); var frac = i * 1.0f / nrow; var nclr = Color.Lerp(cclr, Color.white, frac); //var pipe = qut.CreatePipe(ppname, pos0, pos, nclr, skalink); //var pipe = GpuInst.CreateCylinderGpu(ppname, pos0, pos, skalink, clr); var pipe = vtm.qmm.qtt.AddFragLine(ppname, pos0, pos, skalink, lclr: clr, widratio: skawid); pipe.transform.parent = vehgo.transform; nlinks++; } pos0 = pos; } if (sw.ElapfOverYieldTime()) { Debug.Log($"Plot Static Track yielding on {i} of {nrow} after {sw.ElapSecs()} secs"); yield return(null); } } sw.Stop(); Debug.Log($"Plot static track plotted {nnodes} nodes and {nlinks} links in {sw.ElapSecs()} secs"); yield return(null); }