Coder Social home page Coder Social logo

iworker / clusterize Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 0.0 349 KB

PHP extension for points clusterization on the map

License: Other

CMake 2.68% C 53.99% M4 2.88% PHP 17.44% Batchfile 22.47% Makefile 0.54%
geo map clusterize php-extension clusterization clustering clusters points baloon

clusterize's Introduction

Build Status Windows Build status Coverage Status

clusterize

PHP extension for clustering points on GEO map

Installation

  1. Compile extension:
git clone [email protected]:iworker/clusterize.git
cd clusterize
phpize
./configure --enable-clusterize
make
sudo make install
  1. Add to php.ini:
extension=clusterize.so

kmeans

K-Means algorithm based on https://github.com/pramsey/kmeans/ library

usage

simple example

$points = [ [ 10, 10], [ 12, 12 ], [ 30, 30 ], [ 32, 32 ] ];
$count_of_clusters = 2;
 
list ($clusters, $points_by_clusters) = clusterize($points, $count_of_clusters);

$clusters:

[ [ 11, 11, 2 ], [ 31, 31, 2 ]];

$points_by_clusters:

[ 0, 0, 1, 1 ]

real life example

Let's imagine there are 3 clusters of points on map in Seattle:

3 clusters in Seattle

Our goal is to detect these 3 clusters using clusterize function:

$points = [
  [ 47.57675, -122.30993 ], // 3rd cluster / 3rd point
  [ 47.62490, -122.30684 ], // 2nd cluster / 1st point
  [ 47.61680, -122.34426 ], // 1th cluster / 5th point
  [ 47.62502, -122.34632 ], // 1th cluster / 4th point
  [ 47.57698, -122.32091 ], // 3rd cluster / 2nd point
  [ 47.62757, -122.30186 ], // 2nd cluster / 2nd point
  [ 47.62548, -122.34289 ], // 1st cluster / 3rd point
  [ 47.62872, -122.29053 ], // 2nd cluster / 3rd point
  [ 47.62201, -122.33551 ], // 1st cluster / 2nd point
  [ 47.58139, -122.31525 ], // 3rd cluster / 1st point
  [ 47.61947, -122.34735 ], // 1st cluster / 1st point
];
 
$count_of_clusters = 3;
 
list ($clusters, $points_by_clusters) = clusterize($points, $count_of_clusters);

$clusters:

[
  [ 47.578373, -122.315363, 3 ],
  [ 47.621756, -122.343266, 5 ],
  [ 47.627063, -122.299743, 3 ],
]

$points_by_clusters:

[0, 2, 1, 1, 0, 2, 1, 2, 1, 0, 1]

So, points divided into 3 clusters:

  • cluster with index 0 which corresponds 3rd cluster on map
  • cluster with index 1 which corresponds 1st cluster on map
  • cluster with index 2 which corresponds 2nd cluster on map

clusterize's People

Contributors

iworker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.