定制 waxwink/clustering 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

waxwink/clustering

Composer 安装命令:

composer require waxwink/clustering

包简介

Clustering map points with K-means or space dividing

README 文档

README

image_2019-03-10_09-19-21

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
*/

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-03-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固