Skip to content

Commit

Permalink
Updated code for RSM translator
Browse files Browse the repository at this point in the history
  • Loading branch information
cherneysp committed Jul 6, 2021
1 parent 1603cae commit f3971e1
Show file tree
Hide file tree
Showing 26 changed files with 1,127 additions and 68 deletions.
4 changes: 2 additions & 2 deletions src/cc/ctrl/CreateCtrls.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ public static void createCtrl(Path oFile)
dCenter = Arrays.add(dCenter, dW);
}
CtrlLineArcs oCla = new CtrlLineArcs(-1, -1, nOrder, -1, XodrUtil.getLaneType("driving"), dCenter, 0.1);
TrafCtrl oCtrl = new TrafCtrl(sControlType, nControlValue, lTime, oCla.m_dLineArcs, "", bReg);
TrafCtrl oCtrl = new TrafCtrl(sControlType, nControlValue, lTime, oCla.m_dLineArcs, "", bReg, ProcCtrl.CC);
ArrayList<int[]> nTiles = new ArrayList();
oCtrl.write(ProcCtrl.g_sTrafCtrlDir, ProcCtrl.g_dExplodeStep, ProcCtrl.g_nDefaultZoom);
oCtrl.write(ProcCtrl.g_sTrafCtrlDir, ProcCtrl.g_dExplodeStep, ProcCtrl.g_nDefaultZoom, ProcCtrl.CC);
// oCtrl.m_oFullGeo = new CtrlGeo(oCtrl, ProcCtrl.g_dExplodeStep, ProcCtrl.g_nDefaultZoom);
ProcCtrl.updateTiles(nTiles, oCtrl.m_oFullGeo.m_oTiles);
ArrayList<TrafCtrl> oCtrls = new ArrayList();
Expand Down
1 change: 1 addition & 0 deletions src/cc/ctrl/CtrlGeo.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class CtrlGeo implements Comparable<CtrlGeo>
public double m_dAverageWidth = 0.0;
public double[] m_dDebugNT;
public double[] m_dDebugPT;
public boolean[] m_bDow = new boolean[7];


public CtrlGeo(DataInputStream oIn, int nZoom)
Expand Down
2 changes: 1 addition & 1 deletion src/cc/ctrl/CtrlLineArcs.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class CtrlLineArcs implements Comparable<CtrlLineArcs>
public int m_nLaneId;
public long m_lLaneSectionId;
public int m_nLaneType;
public double[] m_dLineArcs; // point are in decimal degree geo coords
public double[] m_dLineArcs;
public static Comparator<CtrlLineArcs> CMPBYLANE = (CtrlLineArcs o1, CtrlLineArcs o2) -> Integer.compare(o1.m_nLaneId, o2.m_nLaneId);
public static Comparator<CtrlLineArcs> CMPBYLANESECTION = (CtrlLineArcs o1, CtrlLineArcs o2) -> Long.compare(o1.m_lLaneSectionId, o2.m_lLaneSectionId);
public static final int CON_TEND_OSTART = 1;
Expand Down
39 changes: 21 additions & 18 deletions src/cc/ctrl/TrafCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@ public TrafCtrl()
}


public TrafCtrl(String sControlType, int nControlValue, long lTime, TrafCtrl oCtrl, String sLabel, boolean bReg)
public TrafCtrl(String sControlType, int nControlValue, long lTime, TrafCtrl oCtrl, String sLabel, boolean bReg, byte ySrc)
{
this(sControlType, nControlValue, lTime, 0, oCtrl, sLabel, bReg);
this(sControlType, nControlValue, lTime, 0, oCtrl, sLabel, bReg, ySrc);
}


public TrafCtrl(String sControlType, int nControlValue, long lTime, long lStart, TrafCtrl oCtrl, String sLabel, boolean bReg)
public TrafCtrl(String sControlType, int nControlValue, long lTime, long lStart, TrafCtrl oCtrl, String sLabel, boolean bReg, byte ySrc)
{
this();
m_nControlType = TrafCtrlEnums.getCtrl(sControlType);
Expand All @@ -100,16 +100,16 @@ public TrafCtrl(String sControlType, int nControlValue, long lTime, long lStart,
for (TrafCtrlPt oPt : oCtrl)
add(new TrafCtrlPt(oPt.m_nX, oPt.m_nY, oPt.m_nZ, oPt.m_nW));

generateId();
generateId(ySrc);
}


public TrafCtrl(String sControlType, String sControlValue, long lTime, TrafCtrl oCtrl, String sLabel, boolean bReg)
public TrafCtrl(String sControlType, String sControlValue, long lTime, TrafCtrl oCtrl, String sLabel, boolean bReg, byte ySrc)
{
this(sControlType, TrafCtrlEnums.getCtrlVal(sControlType, sControlValue), lTime, oCtrl, sLabel, bReg);
this(sControlType, TrafCtrlEnums.getCtrlVal(sControlType, sControlValue), lTime, oCtrl, sLabel, bReg, ySrc);
}

public TrafCtrl(String sControlType, int nControlValue, long lTime, long lStart, double[] dLineArcs, String sLabel, boolean bReg)
public TrafCtrl(String sControlType, int nControlValue, long lTime, long lStart, double[] dLineArcs, String sLabel, boolean bReg, byte ySrc)
{
this(sControlType, lTime, dLineArcs);
m_sLabel = sLabel;
Expand All @@ -120,22 +120,22 @@ public TrafCtrl(String sControlType, int nControlValue, long lTime, long lStart,
else
m_yControlValue = MathUtil.intToBytes(nControlValue, new byte[4]);

generateId();
generateId(ySrc);
}

public TrafCtrl(String sControlType, int nControlValue, long lTime, double[] dLineArcs, String sLabel, boolean bReg)
public TrafCtrl(String sControlType, int nControlValue, long lTime, double[] dLineArcs, String sLabel, boolean bReg, byte ySrc)
{
this(sControlType, nControlValue, lTime, 0, dLineArcs, sLabel, bReg);
this(sControlType, nControlValue, lTime, 0, dLineArcs, sLabel, bReg, ySrc);
}


public TrafCtrl(String sControlType, byte[] yControlValue, long lTime, double[] dLineArcs)
public TrafCtrl(String sControlType, byte[] yControlValue, long lTime, double[] dLineArcs, byte ySrc)
{
this(sControlType, lTime, dLineArcs);
m_yControlValue = new byte[yControlValue.length];
System.arraycopy(yControlValue, 0, m_yControlValue, 0, m_yControlValue.length);

generateId();
generateId(ySrc);
}


Expand Down Expand Up @@ -170,9 +170,9 @@ public TrafCtrl(String sControlType, long lTime, double[] dLineArcs)
}


public TrafCtrl(String sControlType, String sControlValue, long lTime, double[] dLineArcs, String sLabel, boolean bReg)
public TrafCtrl(String sControlType, String sControlValue, long lTime, double[] dLineArcs, String sLabel, boolean bReg, byte ySrc)
{
this(sControlType, TrafCtrlEnums.getCtrlVal(sControlType, sControlValue), lTime, dLineArcs, sLabel, bReg);
this(sControlType, TrafCtrlEnums.getCtrlVal(sControlType, sControlValue), lTime, dLineArcs, sLabel, bReg, ySrc);
}


Expand Down Expand Up @@ -236,7 +236,7 @@ public TrafCtrl(DataInputStream oIn, boolean bConcat)
}


private void generateId()
private void generateId(byte ySrc)
{
if (m_yId != null)
return;
Expand Down Expand Up @@ -292,19 +292,22 @@ private void generateId()
oAbsorb.writeInt(oPt.m_nZ);
}

byte[] yId = new byte[15];
oSqueeze.read(yId);
m_yId = new byte[16];
oSqueeze.read(m_yId);
m_yId[0] = ySrc;
System.arraycopy(yId, 0, m_yId, 1, yId.length);
}
catch (Exception oEx)
{
}
}


public void write(String sPath, double dExplodeStep, int nZoom)
public void write(String sPath, double dExplodeStep, int nZoom, byte ySrc)
throws Exception
{
generateId(); // need id to build file path
generateId(ySrc); // need id to build file path
StringBuilder sBuf = new StringBuilder(sPath);
if (sPath.endsWith("/"))
sBuf.setLength(sBuf.length() - 1); // remove trailing path separator
Expand Down
8 changes: 4 additions & 4 deletions src/cc/ctrl/proc/ProcClosed.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,21 +65,21 @@ protected void proc(String sLineArcsFile, double dTol) throws Exception
TrafCtrl oCtrl = null;
if (sType.compareTo("roadWorks") == 0)
{
oCtrl = new TrafCtrl("closed", "notopen", 0, oCLA.m_dLineArcs, "", true);
oCtrl = new TrafCtrl("closed", "notopen", 0, oCLA.m_dLineArcs, "", true, CC);
}
else if (sType.contains("special1"))
{
oCtrl = new TrafCtrl("closed", sType.contains("1") ? "taperright" : "taperleft", 0, oCLA.m_dLineArcs, "", true);
oCtrl = new TrafCtrl("closed", sType.contains("1") ? "taperright" : "taperleft", 0, oCLA.m_dLineArcs, "", true, CC);
}
else if (sType.contains("special2"))
{
oCtrl = new TrafCtrl("closed", sType.contains("2") ? "openright" : "openleft", 0, oCLA.m_dLineArcs, "", true);
oCtrl = new TrafCtrl("closed", sType.contains("2") ? "openright" : "openleft", 0, oCLA.m_dLineArcs, "", true, CC);
}

if (oCtrl == null)
continue;
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(nTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, nTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcClosing.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ protected void proc(String sLineArcsFile, double dTol) throws Exception
if (!sType.contains("special1"))
continue;

TrafCtrl oCtrl = new TrafCtrl("closing", sType.contains("1") ? "right" : "left", 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("closing", sType.contains("1") ? "right" : "left", 0, oCLA.m_dLineArcs, "", true, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
2 changes: 2 additions & 0 deletions src/cc/ctrl/proc/ProcCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public abstract class ProcCtrl
public static String g_sTdFileFormat;
public static String g_sGeolanesDir;
public static int g_nDefaultZoom = Integer.MIN_VALUE;
public static final byte CC = 0;
public static final byte RSM = 1;
protected static final double WIDTHTH = 1.5;
protected static final double LENLOWTH = 75.0;
protected static final double STOPLINEENDOFFSET = 0.6;
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcDebug.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public void proc(String sLineArcsFile, double dTol)
ArrayList<int[]> oTiles = new ArrayList();
for (CtrlLineArcs oCLA : oLineArcs)
{
TrafCtrl oCtrl = new TrafCtrl("debug", "", 0, oCLA.m_dLineArcs, "", false);
TrafCtrl oCtrl = new TrafCtrl("debug", "", 0, oCLA.m_dLineArcs, "", false, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcDebugOutlines.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public void proc(String sLineArcsFile, double dTol)
ArrayList<int[]> oTiles = new ArrayList();
for (CtrlLineArcs oCLA : oLineArcs)
{
TrafCtrl oCtrl = new TrafCtrl("debug", "", 0, oCLA.m_dLineArcs, "", false);
TrafCtrl oCtrl = new TrafCtrl("debug", "", 0, oCLA.m_dLineArcs, "", false, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcDirection.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ public void proc(String sLineArcsFile, double dTol)
int nShoulder = XodrUtil.getLaneType("shoulder");
for (CtrlLineArcs oCLA : oLineArcs)
{
TrafCtrl oCtrl = new TrafCtrl("direction", "forward", 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("direction", "forward", 0, oCLA.m_dLineArcs, "", true, CC);
if (oCLA.m_nLaneType != nShoulder)
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(nTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, nTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcLatPerm.java
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,13 @@ protected void proc(String sLineArcsFile, double dTol) throws Exception
sRoadMark = RoadMark.getType(nOuterMarkType);
sLaneType = XodrUtil.getLaneType(nOuterRoadType);
nCtrlVal |= (getOuterLatPerm(sRoadMark, sLaneType, bSameOuterDir) & 0xff);
TrafCtrl oCtrl = new TrafCtrl("latperm", nCtrlVal, 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("latperm", nCtrlVal, 0, oCLA.m_dLineArcs, "", true, CC);
if (oCLA.m_nLaneType != nShoulder)
{
oCtrls.add(oCtrl);
m_nColors = Arrays.add(m_nColors, nInnerColor, nOuterColor);
}
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles, m_nColors);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcMaxSpeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@ protected void proc(String sLineArcsFile, double dTol) throws Exception
oSearch.m_nId = oCLA.m_nLaneId;
int nIndex = Collections.binarySearch(m_oSpds, oSearch);
int nSpeed = nIndex >= 0 ? m_oSpds.get(nIndex).m_nSpd : DEFAULTSPD;
TrafCtrl oCtrl = new TrafCtrl("maxspeed", nSpeed, 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("maxspeed", nSpeed, 0, oCLA.m_dLineArcs, "", true, CC);
String sRoadId = Integer.toString(XodrUtil.getRoadId(oCLA.m_nLaneId));
if (oCLA.m_nLaneType != nShoulder && !m_oJunctions.containsKey(sRoadId))
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcOpening.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ protected void proc(String sLineArcsFile, double dTol) throws Exception
if (!sType.contains("special2"))
continue;

TrafCtrl oCtrl = new TrafCtrl("opening", sType.contains("2") ? "right" : "left", 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("opening", sType.contains("2") ? "right" : "left", 0, oCLA.m_dLineArcs, "", true, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcPavement.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ protected void proc(String sLineArcsFile, double dTol) throws Exception
ArrayList<int[]> oTiles = new ArrayList();
for (CtrlLineArcs oCLA : oLineArcs)
{
TrafCtrl oCtrl = new TrafCtrl("pavement", oCLA.m_nLaneType, 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("pavement", oCLA.m_nLaneType, 0, oCLA.m_dLineArcs, "", true, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcSignal.java
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ public void proc(String sLineArcsFile, double dTol)
for (CtrlLineArcs oCLA : oLineArcs)
{
oRng.nextBytes(yBytes);
TrafCtrl oCtrl = new TrafCtrl("signal", yBytes, 0, oCLA.m_dLineArcs);
TrafCtrl oCtrl = new TrafCtrl("signal", yBytes, 0, oCLA.m_dLineArcs, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcStop.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ public void proc(String sLineArcsFile, double dTol)
int nShoulder = XodrUtil.getLaneType("shoulder");
for (CtrlLineArcs oCLA : oLineArcs)
{
TrafCtrl oCtrl = new TrafCtrl("stop", "", 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("stop", "", 0, oCLA.m_dLineArcs, "", true, CC);
if (oCLA.m_nLaneType != nShoulder)
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
4 changes: 2 additions & 2 deletions src/cc/ctrl/proc/ProcYield.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ public void proc(String sLineArcsFile, double dTol)
ArrayList<int[]> oTiles = new ArrayList();
for (CtrlLineArcs oCLA : oLineArcs)
{
TrafCtrl oCtrl = new TrafCtrl("yield", "", 0, oCLA.m_dLineArcs, "", true);
TrafCtrl oCtrl = new TrafCtrl("yield", "", 0, oCLA.m_dLineArcs, "", true, CC);
oCtrls.add(oCtrl);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom);
oCtrl.write(g_sTrafCtrlDir, g_dExplodeStep, g_nDefaultZoom, CC);
updateTiles(oTiles, oCtrl.m_oFullGeo.m_oTiles);
}
renderTiledData(oCtrls, oTiles);
Expand Down
Loading

0 comments on commit f3971e1

Please sign in to comment.