| 1 | <?php |
||
| 13 | class KmlFormatter { |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Builds and returns KML representing the set geographical objects. |
||
| 17 | */ |
||
| 18 | 3 | public function formatLocationsAsKml( Location ...$locations ): string { |
|
| 31 | |||
| 32 | 3 | private function getKmlForLocations( array $locations ): string { |
|
| 33 | 3 | return implode( |
|
| 34 | 3 | "\n", |
|
| 35 | 3 | array_map( |
|
| 36 | 3 | function( Location $location ) { |
|
| 37 | 2 | return $this->locationToKmlPlacemark( $location ); |
|
| 38 | 3 | }, |
|
| 39 | $locations |
||
| 40 | ) |
||
| 41 | ); |
||
| 42 | } |
||
| 43 | |||
| 44 | |||
| 45 | 2 | private function locationToKmlPlacemark( Location $location ): string { |
|
| 66 | |||
| 67 | 2 | private function getCoordinateString( Location $location ): string { |
|
| 73 | |||
| 74 | 2 | private function escapeValue( string $value ): string { |
|
| 77 | |||
| 78 | } |
||
| 79 |