1 | <?php |
||
16 | class Line implements GeometryInterface |
||
17 | { |
||
18 | use GetBoundsTrait; |
||
19 | |||
20 | /** |
||
21 | * @var Coordinate |
||
22 | */ |
||
23 | protected $point1; |
||
24 | |||
25 | /** |
||
26 | * @var Coordinate |
||
27 | */ |
||
28 | protected $point2; |
||
29 | |||
30 | /** |
||
31 | * @param Coordinate $point1 |
||
32 | * @param Coordinate $point2 |
||
33 | */ |
||
34 | public function __construct(Coordinate $point1, Coordinate $point2) |
||
39 | |||
40 | /** |
||
41 | * @param Coordinate $point1 |
||
42 | * |
||
43 | * @return void |
||
44 | */ |
||
45 | public function setPoint1(Coordinate $point1) |
||
49 | |||
50 | /** |
||
51 | * @return Coordinate |
||
52 | */ |
||
53 | public function getPoint1(): Coordinate |
||
57 | |||
58 | /** |
||
59 | * @param Coordinate $point2 |
||
60 | * |
||
61 | * @return void |
||
62 | */ |
||
63 | public function setPoint2(Coordinate $point2) |
||
67 | |||
68 | /** |
||
69 | * @return Coordinate |
||
70 | */ |
||
71 | public function getPoint2(): Coordinate |
||
75 | |||
76 | /** |
||
77 | * Returns an array containing the two points. |
||
78 | * |
||
79 | * @return Coordinate[] |
||
80 | */ |
||
81 | public function getPoints(): array |
||
85 | |||
86 | /** |
||
87 | * Calculates the length of the line (distance between the two |
||
88 | * coordinates). |
||
89 | * |
||
90 | * @param DistanceInterface $calculator instance of distance calculation class |
||
91 | * |
||
92 | * @return float |
||
93 | */ |
||
94 | public function getLength(DistanceInterface $calculator): float |
||
98 | |||
99 | /** |
||
100 | * @param BearingInterface $bearingCalculator |
||
101 | * |
||
102 | * @return float |
||
103 | */ |
||
104 | public function getBearing(BearingInterface $bearingCalculator): float |
||
108 | |||
109 | /** |
||
110 | * @param BearingInterface $bearingCalculator |
||
111 | * |
||
112 | * @return float |
||
113 | */ |
||
114 | public function getFinalBearing(BearingInterface $bearingCalculator): float |
||
118 | |||
119 | /** |
||
120 | * Create a new instance with reversed point order, i. e. reversed direction. |
||
121 | * |
||
122 | * @return Line |
||
123 | */ |
||
124 | public function getReverse(): Line |
||
128 | |||
129 | /** |
||
130 | * Get the midpoint of a Line segment |
||
131 | * |
||
132 | * @see http://www.movable-type.co.uk/scripts/latlong.html#midpoint |
||
133 | * |
||
134 | * @return Coordinate |
||
135 | */ |
||
136 | public function getMidpoint() : Coordinate |
||
153 | } |
||
154 |