1 | <?php |
||
15 | class SimplifyBearing implements SimplifyInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var float |
||
19 | */ |
||
20 | private $bearingAngle; |
||
21 | |||
22 | /** |
||
23 | * SimplifyBearing constructor. |
||
24 | * |
||
25 | * @param float $bearingAngle |
||
26 | */ |
||
27 | public function __construct(float $bearingAngle) |
||
31 | |||
32 | /** |
||
33 | * Simplifies the given polyline |
||
34 | * |
||
35 | * 1. calculate the bearing angle between the first two points p1 and p2: b1 |
||
36 | * 2. calculate the bearing angle between the next two points p2 and p3: b2 |
||
37 | * 3. calculate the difference between b1 and b2: deltaB; if deltaB is |
||
38 | * smaller than the threshold angle, remove the middle point p2 |
||
39 | * 4. start again at (1.) as long as the polyline contains more points |
||
40 | * |
||
41 | * @param Polyline $polyline |
||
42 | * |
||
43 | * @return Polyline |
||
44 | */ |
||
45 | public function simplify(Polyline $polyline): Polyline |
||
87 | } |
||
88 |