1 package org.opentrafficsim.editor.extensions.map;
2
3 import org.djunits.value.vdouble.scalar.Length;
4 import org.djutils.draw.line.PolyLine2d;
5 import org.djutils.draw.line.Polygon2d;
6 import org.djutils.draw.point.DirectedPoint2d;
7 import org.opentrafficsim.draw.road.CrossSectionElementAnimation.CrossSectionElementData;
8 import org.opentrafficsim.editor.XsdTreeNode;
9 import org.opentrafficsim.road.network.lane.CrossSectionGeometry;
10
11
12
13
14
15
16
17
18
19 public class MapCrossSectionData implements CrossSectionElementData
20 {
21
22
23 private final XsdTreeNode linkNode;
24
25
26 private final CrossSectionGeometry geometry;
27
28
29
30
31
32
33 public MapCrossSectionData(final XsdTreeNode linkNode, final CrossSectionGeometry geometry)
34 {
35 this.linkNode = linkNode;
36 this.geometry = geometry;
37 }
38
39 @Override
40 public DirectedPoint2d getLocation()
41 {
42 return this.geometry.getLocation();
43 }
44
45 @Override
46 public Polygon2d getAbsoluteContour()
47 {
48 return this.geometry.absoluteContour();
49 }
50
51 @Override
52 public Polygon2d getRelativeContour()
53 {
54 return this.geometry.getRelativeContour();
55 }
56
57 @Override
58 public PolyLine2d getCenterLine()
59 {
60 return this.geometry.centerLine();
61 }
62
63
64
65
66
67 @Override
68 public String getLinkId()
69 {
70 return this.linkNode.getId();
71 }
72
73
74
75
76
77
78 public Length getWidth(final Length position)
79 {
80 return Length.ofSI(this.geometry.width().get(position.si / getCenterLine().getLength()));
81 }
82
83 @Override
84 public String toString()
85 {
86 return "Cross section element of " + getLinkId();
87 }
88
89 }