Skip to content

Commit

Permalink
Merge branch 'master' into hotfix/hdwy_units
Browse files Browse the repository at this point in the history
  • Loading branch information
cherneysp committed Jul 29, 2022
2 parents 42104da + 0745d43 commit a1f8cc7
Show file tree
Hide file tree
Showing 34 changed files with 3,495 additions and 902 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
| CicleCI Build Status |
|------|
[![CircleCI](https://circleci.com/gh/usdot-fhwa-stol/carma-cloud.svg?style=svg)](https://circleci.com/gh/usdot-fhwa-stol/carma-cloud)

# CARMAcloud

## Documentation
Expand Down
2 changes: 2 additions & 0 deletions osmbin/units.csv
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ ft,in,12,1,0
dm/s,mph,3600,16093.44,0
m/s,dm/s,10,1,0
ft,dm,3.048,1,0
veh/hr/lane,veh/s/lane,1,3600,0
veh/mi/lane,veh/m/lane,1609.344,1,0
73 changes: 8 additions & 65 deletions src/cc/ctrl/CtrlGeo.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import cc.geosrv.Mercator;
import cc.util.Arrays;
import cc.util.Geo;
import cc.util.MathUtil;
import java.awt.geom.Area;
import java.awt.geom.Path2D;
import java.io.DataInputStream;
Expand All @@ -22,9 +21,8 @@
*
* @author aaron.cherney
*/
public class CtrlGeo implements Comparable<CtrlGeo>
public class CtrlGeo
{
public byte[] m_yId;
/**
* negative tangent path
*/
Expand All @@ -41,51 +39,16 @@ public class CtrlGeo implements Comparable<CtrlGeo>
public double[] m_dBB = new double[] {Double.MAX_VALUE, Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE};
public ArrayList<int[]> m_oTiles = new ArrayList();
int m_nZoom;
public int m_nCtrlType;
public byte[] m_yCtrlValue;
public double m_dLength;
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)
throws IOException
{
this(oIn, false, nZoom);
}


public CtrlGeo(DataInputStream oIn, boolean bUpdateTiles, int nZoom)
CtrlGeo(DataInputStream oIn, boolean bUpdateTiles, int nZoom)
throws IOException
{
m_nZoom = nZoom;
oIn.readUTF(); // read version, discard it
m_yId = new byte[16];
oIn.read(m_yId);
oIn.skip(8); // skip updated, long

int nCount = oIn.readInt();
oIn.skip(nCount * 4); // skip vehicle types, they are ints
oIn.skip(20); // skip start, end, DoW (long, long ,int)
nCount = oIn.readInt();
oIn.skip(nCount * 8); // skip between which is pairs of ints
oIn.skip(13); // skip offset, period, span, regulatory (int, int, int, bool)

m_nCtrlType = oIn.readInt();
m_yCtrlValue = new byte[oIn.readInt()];
oIn.read(m_yCtrlValue);

oIn.readUTF(); // read proj, discard it
oIn.readUTF(); // read datum, discard it

oIn.skip(28); // skip time, lon, lat, alt, width, heading (long, int, int, int, int, int)
oIn.readUTF(); // read label, discard it

nCount = oIn.readInt();
oIn.skip(nCount * 16); // skip all the points (each are 4 ints)

m_nZoom = nZoom;
for (int nIndex = 0; nIndex < m_dBB.length; nIndex++)
m_dBB[nIndex] = oIn.readInt() / 100.0; // convert mercator cm to mercator meters

Expand All @@ -106,15 +69,10 @@ public CtrlGeo(DataInputStream oIn, boolean bUpdateTiles, int nZoom)
}


public CtrlGeo(TrafCtrl oCtrl, double dMaxStep, int nZoom)
CtrlGeo(TrafCtrl oCtrl, double dMaxStep, int nZoom)
throws Exception
{
m_nZoom = nZoom;
m_yId = new byte[oCtrl.m_yId.length];
m_nCtrlType = oCtrl.m_nControlType;
m_yCtrlValue = new byte[oCtrl.m_yControlValue.length];
System.arraycopy(oCtrl.m_yControlValue, 0, m_yCtrlValue, 0, m_yCtrlValue.length);
System.arraycopy(oCtrl.m_yId, 0, m_yId, 0, m_yId.length);
int nNumPts = oCtrl.size();
double dTotalLength = 0.0;
double[] dPts = Arrays.newDoubleArray(nNumPts * 3);
Expand Down Expand Up @@ -382,8 +340,8 @@ public static void writePts(DataOutputStream oOut, double[] dPts)
throws IOException
{
oOut.writeInt(Arrays.size(dPts) - 1);
int nPrevX = (int)(MathUtil.round(dPts[1] * 100.0, 0)); // convert mercator meters to mercator cms, rounding to nearest cm
int nPrevY = (int)(MathUtil.round(dPts[2] * 100.0, 0));
int nPrevX = (int)(dPts[1] * 100.0 + 0.5); // convert mercator meters to mercator cms, rounding to nearest cm
int nPrevY = (int)(dPts[2] * 100.0 + 0.5);
oOut.writeInt(nPrevX);
oOut.writeInt(nPrevY);
Iterator<double[]> oIt = Arrays.iterator(dPts, new double[2], 3, 2);
Expand All @@ -392,8 +350,8 @@ public static void writePts(DataOutputStream oOut, double[] dPts)
while (oIt.hasNext())
{
double[] dPt = oIt.next();
nCurX = (int)(MathUtil.round(dPt[0] * 100.0, 0)); // convert mercator meters to mercator cms, rounding to nearest cm
nCurY = (int)(MathUtil.round(dPt[1] * 100.0, 0));
nCurX = (int)(dPt[0] * 100.0 + 0.5); // convert mercator meters to mercator cms, rounding to nearest cm
nCurY = (int)(dPt[1] * 100.0 + 0.5);
oOut.writeByte(nCurX - nPrevX); // write the deltas in the file
oOut.writeByte(nCurY - nPrevY);
nPrevX = nCurX;
Expand Down Expand Up @@ -471,21 +429,6 @@ public static int[] readPtsLonLats(DataInputStream oIn, int[] nPts)

return nPts;
}


@Override
public int compareTo(CtrlGeo o)
{
int nRet = 0;
for (int nIndex = 0; nIndex < m_yId.length; nIndex++)
{
nRet = m_yId[nIndex] - o.m_yId[nIndex];
if (nRet != 0)
return nRet;
}

return nRet;
}


public Area createPolygon()
Expand Down
33 changes: 33 additions & 0 deletions src/cc/ctrl/CtrlIndex.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cc.ctrl;

import java.io.DataInputStream;
import java.io.IOException;

/**
*
* @author aaron.cherney
*/
public class CtrlIndex
{
public byte[] m_yId;
public int m_nType;
public long m_lStart;
public long m_lEnd;
public double[] m_dBB;

public CtrlIndex(DataInputStream oIn)
throws IOException
{
m_nType = oIn.readInt();
m_yId = new byte[16];
oIn.read(m_yId);
m_lStart = oIn.readLong();
m_lEnd = oIn.readLong();
m_dBB = new double[]{oIn.readInt() / 100.0, oIn.readInt() / 100.0, oIn.readInt() / 100.0, oIn.readInt() / 100.0};
}
}
9 changes: 2 additions & 7 deletions src/cc/ctrl/RenderCtrl.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ public static void main(String[] sArgs)
TrafCtrl oCtrl = null;
try (DataInputStream oIn = new DataInputStream(new BufferedInputStream(Files.newInputStream(Paths.get(sFile)))))
{
oCtrl = new TrafCtrl(oIn, false);
}

try (DataInputStream oIn = new DataInputStream(new BufferedInputStream(Files.newInputStream(Paths.get(sFile)))))
{
oCtrl.m_oFullGeo = new CtrlGeo(oIn, true, nZoom);
oCtrl = new TrafCtrl(oIn, true, true);
}

ArrayList<int[]> nTiles = new ArrayList();
Expand All @@ -54,7 +49,7 @@ public static void main(String[] sArgs)
for (int[] nTile : nTiles)
{
String sIndex = String.format(sTdFF, nTile[0], nZoom, nTile[0], nTile[1]) + ".ndx";
ProcCtrl.updateIndex(sIndex, oCtrl.m_yId, lNow);
ProcCtrl.updateIndex(sIndex, oCtrl, lNow);
}

oCtrl.m_yId = null;
Expand Down
Loading

0 comments on commit a1f8cc7

Please sign in to comment.