webtoucher/geometeo-libs

dev-master 2017-03-09 22:15 UTC

This package is auto-updated.

Last update: 2024-09-14 21:54:50 UTC


README

为 GeoMeteo 或其他应用程序提供库。

Latest Stable Version Total Downloads Daily Downloads Latest Unstable Version License

安装

安装此库的首选方式是通过 composer

运行以下命令之一

$ php composer.phar require webtoucher/geometeo-libs "*"

"webtoucher/geometeo-libs": "*"

将以下内容添加到您的 composer.json 文件的 require 部分中。

使用方法

    use \webtoucher\geometeo\libs\GeoDataProvider;
    use \webtoucher\geometeo\libs\SunCalculator;
    use \webtoucher\geometeo\libs\Coordinate;

为选定的地理位置创建和配置数据提供者。

    $provider = new GeoDataProvider(55.012207, 83.289468, 'Asia/Novosibirsk');

    $provider = new GeoDataProvider(
        Coordinate::fromDms(55, 0, 43.945199999987, Coordinate::NORTH),
        Coordinate::fromDms(83, 17, 22.084799999998, Coordinate::EAST),
        'Asia/Novosibirsk'
    );

然后您可以使用计算器和时间网格计算所需数据。

    $inputValuesGrid = [
        '2017-03-02 19:00:00' => [],
        '2017-03-02 19:01:00' => [],
        '2017-03-02 19:02:00' => [],
        '2017-03-02 19:03:00' => [],
        '2017-03-02 19:04:00' => [],
    ];
    $calculator = new SunCalculator(SunCalculator::AZIMUTH|SunCalculator::ALTITUDE);
    $outputValuesGrid = $provider->calculate($calculator, $inputValuesGrid);

    // $outputValuesGrid:
    // [
    //     '2017-03-02 19:00:00' => [
    //         SunCalculator::AZIMUTH => 257.89361108248,
    //         SunCalculator::ALTITUDE => -0.36968324076901,
    //     ],
    //     '2017-03-02 19:01:00' => [
    //         SunCalculator::AZIMUTH => 258.09820089334,
    //         SunCalculator::ALTITUDE => -0.50989896273262,
    //     ],
    //     '2017-03-02 19:02:00' => [
    //         SunCalculator::AZIMUTH => 258.30272277877,
    //         SunCalculator::ALTITUDE => -0.65022023277039,
    //     ],
    //     '2017-03-02 19:03:00' => [
    //         SunCalculator::AZIMUTH => 258.50717913747,
    //         SunCalculator::ALTITUDE => -0.7906452287774,
    //     ],
    //     '2017-03-02 19:04:00' => [
    //         SunCalculator::AZIMUTH => 258.71157237265,
    //         SunCalculator::ALTITUDE => -0.93117213026396,
    //     ],
    // ];

支持

如果您认为发现了错误,请使用 GitHub 问题跟踪器 报告。