Skip to content

Commit

Permalink
Use TimeSource to handle simulation and real world time, remove extra…
Browse files Browse the repository at this point in the history
…neous commented code
  • Loading branch information
kruegersp authored May 15, 2024
1 parent 60633c8 commit de2170a
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/cc/ws/CtrlTiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class CtrlTiles extends HttpServlet
18, //{"maxaxles"},
18, //{"minvehocc"},
17, //{"pavement"},
17, //{"debug"}
17, //{"debug"}
18, // maxplatoonsize
18 // minplatoonhdwy
};
Expand Down Expand Up @@ -158,7 +158,7 @@ public void init(ServletConfig oConfig)
protected void doGet(HttpServletRequest oRequest, HttpServletResponse oResponse)
throws ServletException, IOException
{
long lNow = System.currentTimeMillis();
long lNow = TimeSource.getInstance().currentTimeMillis();
String[] sUriParts = oRequest.getRequestURI().split("/");
int nZ = Integer.parseInt(sUriParts[sUriParts.length - 3]);
int nX = Integer.parseInt(sUriParts[sUriParts.length - 2]);
Expand Down Expand Up @@ -191,7 +191,6 @@ protected void doGet(HttpServletRequest oRequest, HttpServletResponse oResponse)
double[] dClipBounds = TileUtil.getClippingBounds(nZ, nX, nY, dBounds);

int nExtent = 4096;
// int nExtent = Mercator.getExtent(nZ);
VectorTile.Tile.Layer.Builder oLayerBuilder = VectorTile.Tile.Layer.newBuilder();
oLayerBuilder.setVersion(2);
oLayerBuilder.setExtent(nExtent);
Expand Down Expand Up @@ -449,7 +448,7 @@ private void addControl(HttpServletRequest oReq, HttpServletResponse oRes)
{
try
{
long lNow = System.currentTimeMillis() - 10;
long lNow = TimeSource.getInstance().currentTimeMillis() - 10;
int nType = Integer.parseInt(oReq.getParameter("type"));
String[] sVtypes = oReq.getParameterValues("vtypes[]");
ArrayList<Integer> nVtypes = new ArrayList(sVtypes.length);
Expand Down Expand Up @@ -518,17 +517,11 @@ private void addControl(HttpServletRequest oReq, HttpServletResponse oRes)
dCenter = Arrays.add(dCenter, dW);
}
CtrlLineArcs oCla = new CtrlLineArcs(-1, -1, -1, -1, XodrUtil.getLaneType("driving"), dCenter, 0.1);
TrafCtrl oCtrl = new TrafCtrl(TrafCtrlEnums.CTRLS[nType][0], nControlValue, nVtypes, 0L, 0L, oCla.m_dLineArcs, sLabel, bReg, ProcCtrl.CC);
TrafCtrl oCtrl = new TrafCtrl(TrafCtrlEnums.CTRLS[nType][0], nControlValue, nVtypes, lNow, lNow, oCla.m_dLineArcs, sLabel, bReg, ProcCtrl.CC);
oCtrl.write(ProcCtrl.g_sTrafCtrlDir, ProcCtrl.g_dExplodeStep, ProcCtrl.g_nDefaultZoom, ProcCtrl.CC);
ArrayList<TrafCtrl> oCtrls = new ArrayList();
oCtrls.add(oCtrl);
ProcCtrl.renderCtrls(sType, oCtrls, oCtrl.m_oFullGeo.m_oTiles);
// StringBuilder sBuf = new StringBuilder();
// try (BufferedWriter oOut = Files.newBufferedWriter(Paths.get("/opt/tomcat/work/carmacloud/sample_tcm.xml")))
// {
// oCtrl.getXml(sBuf, "cb9353e606e5aafa", 1, 1, 1, "1.0", true, 0);
// oOut.append(sBuf);
// }
}
catch (Exception oEx)
{
Expand Down Expand Up @@ -561,7 +554,7 @@ private void saveEdit(HttpServletRequest oReq, HttpServletResponse oRes)
{
try
{
long lNow = System.currentTimeMillis();
long lNow = TimeSource.getInstance().currentTimeMillis();
int nType = Integer.parseInt(oReq.getParameter("type"));
String[] sVtypes = oReq.getParameterValues("vtypes[]");
ArrayList<Integer> nVtypes = new ArrayList(sVtypes.length);
Expand Down Expand Up @@ -624,7 +617,7 @@ private void saveEdit(HttpServletRequest oReq, HttpServletResponse oRes)
}
else
{
TrafCtrl oNewCtrl = new TrafCtrl(sType, nControlValue, nVtypes, 0L, 0L, oOriginalCtrl, sLabel, bReg, ProcCtrl.CC);
TrafCtrl oNewCtrl = new TrafCtrl(sType, nControlValue, nVtypes, lNow, lNow, oOriginalCtrl, sLabel, bReg, ProcCtrl.CC);
oCtrlToWrite = oNewCtrl;
oNewCtrl.write(ProcCtrl.g_sTrafCtrlDir, ProcCtrl.g_dExplodeStep, ProcCtrl.g_nDefaultZoom, ProcCtrl.CC);
ArrayList<TrafCtrl> oCtrls = new ArrayList(1);
Expand All @@ -635,7 +628,6 @@ private void saveEdit(HttpServletRequest oReq, HttpServletResponse oRes)
{
for (int[] nTile : oOriginalCtrl.m_oFullGeo.m_oTiles)
{
// ProcCtrl.writeIndexFile(oCtrls, nTile[0], nTile[1]);
String sIndex = String.format(g_sTdFileFormat, nTile[0], g_nZoom, nTile[0], nTile[1]) + ".ndx";
ProcCtrl.updateIndex(sIndex, oOriginalCtrl, oNewCtrl.m_lStart);
}
Expand Down

0 comments on commit de2170a

Please sign in to comment.