/
RoadGeometry.java
61 lines (47 loc) · 1.73 KB
/
RoadGeometry.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package org.movsim.roadmappings;
import org.movsim.network.autogen.opendrive.OpenDRIVE.Road.PlanView.Geometry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Preconditions;
/**
* Decorates the openDRIVE {@link Geometry}.
*/
public class RoadGeometry {
// private static final Logger LOG = LoggerFactory.getLogger(RoadGeometry.class);
public enum GeometryType {
LINE, ARC, SPIRAL, POLY3
}
protected final Geometry geometry;
protected final LaneGeometries laneGeometries;
public RoadGeometry(Geometry geometry, LaneGeometries laneGeometries) {
this.geometry = Preconditions.checkNotNull(geometry);
this.laneGeometries = Preconditions.checkNotNull(laneGeometries);
Preconditions.checkArgument(laneGeometries.getRight().getLaneCount() > 0,
"forward link necessary (under development)");
}
public Geometry geometry() {
return geometry;
}
public int totalLaneCount() {
return laneGeometries.getTotalLaneCount();
}
public double laneWidth() {
return laneGeometries.getRight().getLaneWidth(); // ignore laneWidth from peer so far
}
public GeometryType geometryType() {
if (geometry.isSetLine()) {
return GeometryType.LINE;
} else if (geometry.isSetArc()) {
return GeometryType.ARC;
} else if (geometry.isSetPoly3()) {
return GeometryType.POLY3;
} else if (geometry.isSetSpiral()) {
return GeometryType.SPIRAL;
} else {
throw new IllegalArgumentException("Unknown geometry type: " + geometry);
}
}
public LaneGeometries getLaneGeometries() {
return laneGeometries;
}
}