Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| Line | |
0.00% |
0 / 21 |
|
0.00% |
0 / 3 |
90 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getElementName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| parseCoordinates | |
0.00% |
0 / 15 |
|
0.00% |
0 / 1 |
56 | |||
| 1 | <?php |
| 2 | namespace MultiMaps; |
| 3 | |
| 4 | /** |
| 5 | * Line class for collection of map elements |
| 6 | * |
| 7 | * @file Line.php |
| 8 | * @ingroup MultiMaps |
| 9 | * @author Pavel Astakhov <pastakhov@yandex.ru> |
| 10 | * @license GPL-2.0-or-later |
| 11 | * @property string $color Color line |
| 12 | * @property string $weight Weight line |
| 13 | * @property string $opacity Opacity line |
| 14 | */ |
| 15 | class Line extends BaseMapElement { |
| 16 | |
| 17 | /** |
| 18 | * Constructor |
| 19 | */ |
| 20 | function __construct() { |
| 21 | parent::__construct(); |
| 22 | |
| 23 | $this->availableProperties = array_merge( |
| 24 | $this->availableProperties, |
| 25 | [ 'color', 'weight', 'opacity' ] |
| 26 | ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Returns element name |
| 31 | * return string Element name |
| 32 | */ |
| 33 | public function getElementName() { |
| 34 | return 'Line'; // TODO i18n? |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Filling property 'coordinates' |
| 39 | * @global string $egMultiMaps_CoordinatesSeparator |
| 40 | * @param string $coordinates |
| 41 | * @param string|null $service Name of map service |
| 42 | * @return bool |
| 43 | */ |
| 44 | protected function parseCoordinates( $coordinates, $service = null ) { |
| 45 | global $egMultiMaps_CoordinatesSeparator; |
| 46 | |
| 47 | $array = explode( $egMultiMaps_CoordinatesSeparator, $coordinates ); |
| 48 | |
| 49 | if ( $service == 'leaflet' && count( $array ) == 1 ) { |
| 50 | $value = $array[0]; |
| 51 | $coord = Geocoders::getCoordinates( $value, $service, [ 'polygon' => true ] ); |
| 52 | if ( $coord !== false && is_array( $coord['polygon'] ) ) { |
| 53 | $this->coordinates = $coord['polygon']; |
| 54 | } else { |
| 55 | $this->errormessages[] = \wfMessage( 'multimaps-unable-parse-coordinates', $value )->escaped(); |
| 56 | return false; |
| 57 | } |
| 58 | } else { |
| 59 | foreach ( $array as $value ) { |
| 60 | $point = new Point(); |
| 61 | if ( $point->parse( $value, $service ) ) { |
| 62 | $this->coordinates[] = $point; |
| 63 | } else { |
| 64 | $this->errormessages[] = \wfMessage( 'multimaps-unable-parse-coordinates', $value )->escaped(); |
| 65 | return false; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | return true; |
| 70 | } |
| 71 | |
| 72 | } |