| 1 |
<?php |
| 2 |
/** |
| 3 |
* iCalcreator, the PHP class package managing iCal (rfc2445/rfc5445) calendar information. |
| 4 |
* |
| 5 |
* copyright (c) 2007-2021 Kjell-Inge Gustafsson, kigkonsult, All rights reserved |
| 6 |
* Link https://kigkonsult.se |
| 7 |
* Package iCalcreator |
| 8 |
* Version 2.30 |
| 9 |
* License Subject matter of licence is the software iCalcreator. |
| 10 |
* The above copyright, link, package and version notices, |
| 11 |
* this licence notice and the invariant [rfc5545] PRODID result use |
| 12 |
* as implemented and invoked in iCalcreator shall be included in |
| 13 |
* all copies or substantial portions of the iCalcreator. |
| 14 |
* |
| 15 |
* iCalcreator is free software: you can redistribute it and/or modify |
| 16 |
* it under the terms of the GNU Lesser General Public License as published |
| 17 |
* by the Free Software Foundation, either version 3 of the License, |
| 18 |
* or (at your option) any later version. |
| 19 |
* |
| 20 |
* iCalcreator is distributed in the hope that it will be useful, |
| 21 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 |
* GNU Lesser General Public License for more details. |
| 24 |
* |
| 25 |
* You should have received a copy of the GNU Lesser General Public License |
| 26 |
* along with iCalcreator. If not, see <https://www.gnu.org/licenses/>. |
| 27 |
* |
| 28 |
* This file is a part of iCalcreator. |
| 29 |
*/ |
| 30 |
|
| 31 |
namespace Kigkonsult\Icalcreator\Util; |
| 32 |
|
| 33 |
use function abs; |
| 34 |
use function sprintf; |
| 35 |
use function rtrim; |
| 36 |
|
| 37 |
/** |
| 38 |
* iCalcreator geo support class |
| 39 |
* |
| 40 |
* @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se> |
| 41 |
* @since 2.27.4 - 2019-07-02 |
| 42 |
*/ |
| 43 |
class GeoFactory |
| 44 |
{ |
| 45 |
/** |
| 46 |
* @var string GEO vars: output format for geo latitude and longitude (before rtrim) etc |
| 47 |
* @access public |
| 48 |
*/ |
| 49 |
public static $geoLatFmt = '%09.6f'; |
| 50 |
public static $geoLongFmt = '%8.6f'; |
| 51 |
|
| 52 |
/** |
| 53 |
* Return formatted geo output |
| 54 |
* |
| 55 |
* @param float $ll |
| 56 |
* @param string $format |
| 57 |
* @return string |
| 58 |
* @access public |
| 59 |
*/ |
| 60 |
public static function geo2str2( $ll, $format ) |
| 61 |
{ |
| 62 |
if( 0.0 < $ll ) { |
| 63 |
$sign = Util::$PLUS; |
| 64 |
} |
| 65 |
else { |
| 66 |
$sign = ( 0.0 > $ll ) ? Util::$MINUS : null; |
| 67 |
} |
| 68 |
return |
| 69 |
rtrim( |
| 70 |
rtrim( |
| 71 |
$sign . sprintf( $format, abs( $ll )), |
| 72 |
Util::$ZERO |
| 73 |
), |
| 74 |
Util::$DOT |
| 75 |
); |
| 76 |
} |
| 77 |
} |
| 78 |
|