markbaker/quadtrees

PHP 中的 QuadTree 实现

2.2.2 2018-11-10 23:51 UTC

This package is auto-updated.

Last update: 2024-08-29 04:53:35 UTC


README

QuadTree 数据结构的 PHP 实现

主分支: 构建状态

开发分支: 构建状态

需求

  • PHP 版本 7.0.0 或更高

安装

我们建议使用 Composer 安装此包。

通过 composer

在您的项目根目录下,执行以下命令:

composer require markbaker/quadtrees:dev-master

现在您应该已经在项目目录中拥有 composer.jsoncomposer.lock 文件以及 vendor 目录。

然后您可以从代码中引入 Composer 的自动加载器

require 'vendor/autoload.php';

或者,如果您已经有一个 composer.json 文件,那么在该文件中引入此包,并更新 composer。

"require": {
    "markbaker/quadtrees": "dev-master"
}

composer update

从 Phar

尽管我们强烈建议使用 Composer,但我们还提供了一种 Phar 归档 构建器,该构建器将创建包含所有库代码的 Phar 文件。

Phar 构建器脚本位于存储库根目录中,可以使用以下命令运行:

php buildPhar.php

要使用该归档,只需从您的脚本中引入它即可

require 'QuadTrees.phar';

标准自动加载器

如果您想在无需使用 composer 的自动加载器的情况下运行代码,并且不想构建 Phar,那么请在您的代码中从存储库中引入 bootstrap.php 文件,这将启用库的自动加载器。

require 'bootstrap.php';

想要贡献吗?

将该库进行分支!

许可证

QuadTrees 根据 MIT 许可证 许可

示例

/examples 目录包含了一些示例,以展示其使用方法

  • citySearch.php

    允许在定义的边界框内进行搜索,并将显示该边界框内的城市列表

    用法

     php citySearch.php <latitude> <longitude> <width> <height>
    
     latitude   Latitude of the centre point of the bounding box
                  (as a floating-point value in degrees, positive values
                  for East, negative for West)
     longitude  Longitude of the centre point of the bounding box
                  (as a floating-point value in degrees, positive values
                  for North, negative for South)
     width      Width of the bounding box 
                  (as a floating-point value in degrees)
     height     Height of the bounding box
                  (as a floating-point value in degrees)
    

城市列表的数据来自 geonames.org,许可协议为 Creative Commons Attribution 3.0 License,并且“按原样”提供,不提供任何保证或关于准确性、及时性或完整性的表述。

  • lunarLandingSearch.php

    允许在定义的边界框内进行搜索,并将显示该边界框内的月球着陆点列表

    用法

     php lunarLandingSearch.php <latitude> <longitude> <width> <height>
    
     latitude   Latitude of the centre point of the bounding box
                  (as a floating-point value in degrees, positive values
                  for East, negative for West)
     longitude  Longitude of the centre point of the bounding box
                  (as a floating-point value in degrees, positive values
                  for North, negative for South)
     width      Width of the bounding box 
                  (as a floating-point value in degrees)
     height     Height of the bounding box
                  (as a floating-point value in degrees)