1.0.6 • Published 5 years ago

@whins/geo-cluster v1.0.6

Weekly downloads
13
License
ISC
Repository
github
Last release
5 years ago

geo-cluster

This is modification of geocluster on Typescript

Install

npm install @whins/geo-cluster

API

let clusters: ICluster = new Geocluster(coordinates, zoom).clusters;

coordinates is an Array of ICoordinate { latitude: number; longitude: number; }.

zoom value from 1 to 20.

clusters is an Array of cluster objects ICluster, which have centroid and elements properties.

Sample Code

import { ICoordinate, ICluster, Geocluster } from "geo-cluster";

let zoom = 2;

let coordinates: ICoordinate = [
    {
        latitude: 10,
        longitude: 20
    },
    {
        latitude: 20,
        longitude: 20
    },
    {
        latitude: 10,
        longitude: 30
    },
    {
        latitude: 40,
        longitude: 20
    }
];

let clusters: ICluster = new Geocluster(coordinates, zoom).clusters;

Result

[
  {
    "centroid": {
      "latitude": 10.5,
      "longitude": 20.5
    },
    "elements": [
      {
        "latitude": 10,
        "longitude": 20
      },
      {
        "latitude": 11,
        "longitude": 21
      }
    ]
  },
  {
    "centroid": {
      "latitude": 40,
      "longitude": 34
    },
    "elements": [
      {
        "latitude": 40,
        "longitude": 35
      },
      {
        "latitude": 40,
        "longitude": 33
      }
    ]
  }
]
1.0.6

5 years ago

1.0.5

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago