Skip to content

Commit

Permalink
Merge pull request usdot-jpo-ode#192 from usdot-jpo-ode/feature/ode-6…
Browse files Browse the repository at this point in the history
…51-hm

Feature/ode 651 hm
  • Loading branch information
tonychen091 committed Nov 8, 2017
2 parents 7ce92eb + ad9a2c8 commit 685119f
Show file tree
Hide file tree
Showing 23 changed files with 149 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ public class OdeDriverAlertMetadata extends OdeLogMetadata{

private static final long serialVersionUID = -8601265839394150140L;

private ReceivedMessageDetails receivedMessageDetails;

public ReceivedMessageDetails getReceivedMessageDetails() {
return receivedMessageDetails;
}

public void setReceivedMessageDetails(ReceivedMessageDetails receivedMessageDetails) {
this.receivedMessageDetails = receivedMessageDetails;
}

public OdeDriverAlertMetadata() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,32 @@ private ElevationBuilder() {
throw new UnsupportedOperationException();
}

public static long j2735Elevation(BigDecimal elevation) {
return elevation.scaleByPowerOfTen(1).intValue();
}

public static long j2735Elevation(JsonNode elevation) {
return j2735Elevation(elevation.decimalValue());
}

public static BigDecimal genericElevation(JsonNode elevation) {
return genericElevation(elevation.asInt());
}

public static BigDecimal genericElevation(long elevation) {
BigDecimal returnValue = null;

if ((elevation.asLong() != -4096) && (elevation.asLong() < 61439) && (elevation.asLong() > -4095)) {
returnValue = BigDecimal.valueOf(elevation.asLong(), 1);
if ((elevation != -4096) && (elevation < 61439) && (elevation > -4095)) {
returnValue = BigDecimal.valueOf(elevation, 1);
}
else if (elevation.asLong() >= 61439) {
else if (elevation >= 61439) {
returnValue = BigDecimal.valueOf((long)61439, 1);
}
else if ((elevation.asLong() <= -4095) && (elevation.asLong() != -4096)) {
else if ((elevation <= -4095) && (elevation != -4096)) {
returnValue = BigDecimal.valueOf((long)-4095, 1);
}




return returnValue;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,28 @@
import com.fasterxml.jackson.databind.JsonNode;

public class HeadingBuilder {

public static BigDecimal genericHeading(JsonNode heading) {
return AngleBuilder.longToDecimal(heading.asLong());
}

public static BigDecimal genericCoarseHeading(JsonNode coarseHeading) {
public static BigDecimal genericHeading(JsonNode heading) {
return genericHeading(heading.asLong());
}

if (coarseHeading.asInt() < 0 || coarseHeading.asInt() > 240) {
throw new IllegalArgumentException("Coarse heading value out of bounds");
}
public static BigDecimal genericHeading(long heading) {
return AngleBuilder.longToDecimal(heading);
}

BigDecimal result = null;
public static BigDecimal genericCoarseHeading(JsonNode coarseHeading) {

if (coarseHeading.asInt() != 240) {
result = BigDecimal.valueOf(coarseHeading.asLong() * 15, 1);
}
if (coarseHeading.asInt() < 0 || coarseHeading.asInt() > 240) {
throw new IllegalArgumentException("Coarse heading value out of bounds");
}

return result;
}
BigDecimal result = null;

if (coarseHeading.asInt() != 240) {
result = BigDecimal.valueOf(coarseHeading.asLong() * 15, 1);
}

return result;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,23 @@ private LatitudeBuilder() {
throw new UnsupportedOperationException();
}

public static int latitude(BigDecimal lat) {
return lat.scaleByPowerOfTen(7).intValue();
public static long j2735Latitude(BigDecimal latitude) {
return latitude.scaleByPowerOfTen(7).intValue();
}

public static long j2735Latitude(JsonNode latitude) {
return j2735Latitude(latitude.decimalValue());
}

public static BigDecimal genericLatitude(JsonNode latitude) {
return genericLatitude(latitude.asInt());
}

public static BigDecimal genericLatitude(long latitude) {
BigDecimal returnValue = null;

if ((latitude != null) && (latitude.asLong() != 900000001)) {
returnValue = BigDecimal.valueOf(latitude.asLong(), 7);

if (latitude != 900000001) {
returnValue = BigDecimal.valueOf(latitude, 7);
}
return returnValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ private LongitudeBuilder() {
throw new UnsupportedOperationException();
}

public static int longitude(BigDecimal lon) {
return lon.scaleByPowerOfTen(7).intValue();
public static long j2735Longitude(BigDecimal longitude) {
return longitude.scaleByPowerOfTen(7).intValue();
}

public static long j2735Longitude(JsonNode longitude) {
return j2735Longitude(longitude.decimalValue());
}

public static BigDecimal genericLongitude(JsonNode longitude) {
return genericLongitude(longitude.asInt());
}

public static BigDecimal genericLongitude(long longitude) {
BigDecimal returnValue = null;

if ((longitude != null) && (longitude.asLong() != 1800000001)) {
returnValue = BigDecimal.valueOf(longitude.asLong(), 7);
if (longitude != 1800000001) {
returnValue = BigDecimal.valueOf(longitude, 7);

}
return returnValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetB10Builder() {
throw new UnsupportedOperationException();
}

public static int offsetB10(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).intValue();
public static Long offsetB10(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetB11Builder() {
throw new UnsupportedOperationException();
}

public static int offsetB11(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).intValue();
public static Long offsetB11(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetB12Builder() {
throw new UnsupportedOperationException();
}

public static int offsetB12(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).intValue();
public static Long offsetB12(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetB13Builder() {
throw new UnsupportedOperationException();
}

public static int offsetB13(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).intValue();
public static Long offsetB13(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetB14Builder() {
throw new UnsupportedOperationException();
}

public static int offsetB14(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).intValue();
public static Long offsetB14(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetB16Builder() {
throw new UnsupportedOperationException();
}

public static int offsetB16(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).intValue();
public static Long offsetB16(BigDecimal offset) {
return offset.scaleByPowerOfTen(2).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetLLB12Builder() {
throw new UnsupportedOperationException();
}

public static int offsetLLB12(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).intValue();
public static Long offsetLLB12(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetLLB14Builder() {
throw new UnsupportedOperationException();
}

public static int offsetLLB14(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).intValue();
public static Long offsetLLB14(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetLLB16Builder() {
throw new UnsupportedOperationException();
}

public static int offsetLLB16(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).intValue();
public static Long offsetLLB16(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetLLB18Builder() {
throw new UnsupportedOperationException();
}

public static int offsetLLB18(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).intValue();
public static Long offsetLLB18(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetLLB22Builder() {
throw new UnsupportedOperationException();
}

public static int offsetLLB22(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).intValue();
public static Long offsetLLB22(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ private OffsetLLB24Builder() {
throw new UnsupportedOperationException();
}

public static int offsetLLB24(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).intValue();
public static Long offsetLLB24(BigDecimal offset) {
return offset.scaleByPowerOfTen(7).longValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,15 @@ private static OdePosition3D odePosition3D(Long latitude, Long longitude, Long e
OdePosition3D jpos = new OdePosition3D();

if (latitude != null) {
if (latitude == 900000001) {
jpos.setLatitude(null);
} else {
jpos.setLatitude(BigDecimal.valueOf(latitude, 7));
}
jpos.setLatitude(LatitudeBuilder.genericLatitude(latitude));
}

if (longitude != null) {
if (longitude == 1800000001) {
jpos.setLongitude(null);
} else {
jpos.setLongitude(BigDecimal.valueOf(longitude, 7));
}
jpos.setLongitude(LongitudeBuilder.genericLongitude(longitude));
}

if (elevation != null) {
if (elevation == -4096) {
jpos.setElevation(null);
} else {
jpos.setElevation(BigDecimal.valueOf(elevation, 1));
}
jpos.setElevation(ElevationBuilder.genericElevation(elevation));
}

return jpos;
Expand All @@ -66,19 +54,19 @@ public static OdePosition3D odePosition3D(JsonNode jpos) {
return dPos;
}

public static DsrcPosition3D dsrcPosition3D(BigDecimal latitude, BigDecimal longitude, BigDecimal elevation) {
private static DsrcPosition3D dsrcPosition3D(BigDecimal latitude, BigDecimal longitude, BigDecimal elevation) {
DsrcPosition3D dPos = new DsrcPosition3D();

if (latitude != null) {
dPos.setLatitude(latitude.scaleByPowerOfTen(7).longValue());
dPos.setLatitude(LatitudeBuilder.j2735Latitude(latitude));
}

if (longitude != null) {
dPos.setLongitude(longitude.scaleByPowerOfTen(7).longValue());
dPos.setLongitude(LongitudeBuilder.j2735Longitude(longitude));
}

if (elevation != null) {
dPos.setElevation(elevation.scaleByPowerOfTen(1).longValue());
dPos.setElevation(ElevationBuilder.j2735Elevation(elevation));
}

return dPos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static BigDecimal genericVelocity(JsonNode velocity) {
return genericSpeedOrVelocity(velocity.asInt());
}

private static BigDecimal genericSpeedOrVelocity(int speedOrVelocity) {
public static BigDecimal genericSpeedOrVelocity(int speedOrVelocity) {

if (speedOrVelocity < 0 || speedOrVelocity > 8191) {
throw new IllegalArgumentException("Speed or velocity out of bounds");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ private static ObjectNode replaceNodeLL(JsonNode oldNode) {
BigDecimal latOffset = oldNode.get("nodeLat").decimalValue();
BigDecimal longOffset = oldNode.get("nodeLong").decimalValue();
JsonNode delta = oldNode.get("delta");
Integer transformedLat = null;
Integer transformedLong = null;
Long transformedLat = null;
Long transformedLong = null;

if ("node-LL1".equals(delta.asText())) {
transformedLat = OffsetLLB12Builder.offsetLLB12(latOffset);
Expand All @@ -641,8 +641,8 @@ private static ObjectNode replaceNodeLL(JsonNode oldNode) {
transformedLat = OffsetLLB24Builder.offsetLLB24(latOffset);
transformedLong = OffsetLLB24Builder.offsetLLB24(longOffset);
} else if ("node-LatLon".equals(delta.asText())) {
transformedLat = LatitudeBuilder.latitude(latOffset);
transformedLong = LongitudeBuilder.longitude(longOffset);
transformedLat = LatitudeBuilder.j2735Latitude(latOffset);
transformedLong = LongitudeBuilder.j2735Longitude(longOffset);
}

ObjectNode latLong = JsonUtils.newNode().put("lat", transformedLat).put("lon", transformedLong);
Expand Down Expand Up @@ -1057,8 +1057,8 @@ public static ObjectNode replaceNodeOffsetPointXY(JsonNode oldNode) {
BigDecimal latOffset = oldNode.get("nodeLat").decimalValue();
BigDecimal longOffset = oldNode.get("nodeLong").decimalValue();
JsonNode delta = oldNode.get("delta");
Integer transformedLat = null;
Integer transformedLong = null;
Long transformedLat = null;
Long transformedLong = null;

if ("node-XY1".equals(delta.asText())) {
transformedLat = OffsetB10Builder.offsetB10(latOffset);
Expand All @@ -1079,8 +1079,8 @@ public static ObjectNode replaceNodeOffsetPointXY(JsonNode oldNode) {
transformedLat = OffsetB16Builder.offsetB16(latOffset);
transformedLong = OffsetB16Builder.offsetB16(longOffset);
} else if ("node-LatLon".equals(delta.asText())) {
transformedLat = LatitudeBuilder.latitude(latOffset);
transformedLong = LongitudeBuilder.longitude(longOffset);
transformedLat = LatitudeBuilder.j2735Latitude(latOffset);
transformedLong = LongitudeBuilder.j2735Longitude(longOffset);
}

ObjectNode latLong = JsonUtils.newNode().put("lat", transformedLat).put("lon", transformedLong);
Expand Down Expand Up @@ -1202,8 +1202,8 @@ private static ObjectNode replaceNode_LatLon(JsonNode jsonNode) {

ObjectNode updatedNode = (ObjectNode) jsonNode;

updatedNode.put("lon", LongitudeBuilder.longitude(updatedNode.get("nodeLong").decimalValue()));
updatedNode.put("lat", LatitudeBuilder.latitude(updatedNode.get("nodeLat").decimalValue()));
updatedNode.put("lon", LongitudeBuilder.j2735Longitude(updatedNode.get("nodeLong").decimalValue()));
updatedNode.put("lat", LatitudeBuilder.j2735Latitude(updatedNode.get("nodeLat").decimalValue()));
updatedNode.remove("nodeLong");
updatedNode.remove("nodeLat");

Expand Down
Loading

0 comments on commit 685119f

Please sign in to comment.