waxwink/clustering
Composer 安装命令:
composer require waxwink/clustering
包简介
Clustering map points with K-means or space dividing
README 文档
README
Clustering
This package focuses on clustering map markers in an efficient way by dividing the map in defined square spaces and assign each point to its own space.
instruction
Getting Started
Require the package in your project with the following command with composer:
$ composer require waxwink/clustering
Usage
The usage is pretty straight forward:
require __DIR__.'/vendor/autoload.php'; use Waxwink\Clustering\Clustering; $points = [ [ 'lat' => 35.821006, 'lng' => 51.427388 ], [ 'lat' => 35.716912, 'lng' => 51.439202 ], [ 'lat' => 35.67787, 'lng' => 51.358735 ], [ 'lat' => 35.743621, 'lng' => 51.530846 ], ];
For dividing the space into equal areas and cluster the points by the spaces you can use the following format:
$output = Clustering::getClusters($points, 0.1); //The second parameter is the length of the square spaces by which the points are going to be clusterd. //output : /* array (size=3) 0 => array (size=3) 'lat' => float 35.821006 'lng' => float 51.427388 'total' => int 1 1 => array (size=3) 'lat' => float 35.697391 'lng' => float 51.3989685 'total' => int 2 2 => array (size=3) 'lat' => float 35.743621 'lng' => float 51.530846 'total' => int 1 */
Another option for clustering is the K-means algorithm in which the number of requested clusters is required. This approach is slower in performance but gives accurate clusters.
$output = Clustering::getClusters($points, 2, Clustering::K_MEANS_ALGORITHM, 5); //the second parameter is the number of clusters //the third parameter is the algorithm //the forth parameter is the number of iterations used in the K-means algorithm which is 5 by default //output: /* array (size=2) 0 => array (size=3) 'lat' => float 35.821006 'lng' => float 51.427388 'total' => int 1 1 => array (size=3) 'lat' => float 35.712801 'lng' => float 51.442927666667 'total' => int 3 */
waxwink/clustering 适用场景与选型建议
waxwink/clustering 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 11 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 03 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 waxwink/clustering 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 waxwink/clustering 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 11
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-03-09
