README.md in clumpy-0.2.3 vs README.md in clumpy-0.2.4
- old
+ new
@@ -1,30 +1,49 @@
# Clumpy
-Little gem to cluster markers, points or anything that responds to `lat` and `lng`.
+Cluster markers, geocoordinates or anything that responds to `latitude` and `longitude`.
-## Installation
+## Why serverside clustering
-Add this line to your application's Gemfile:
+Of cause there are lots of libs to cluster large amounts of markers in the frontend, but the expensive part is to
+transfer all those markers to the client. In my case it was the difference between sending 10_000 markers - or 20.
- gem 'clumpy'
+## Installation
-And then execute:
+As part of the Gemfile or by hand, nothing unusual here.
- $ bundle
+## Usage
-Or install it yourself as:
+Clumpy takes points, typically geocoordinates, and puts them together into clusters.
- $ gem install clumpy
+It requires the given points to be ruby objects, responding to `latitude` and `longitude` methods.
-## Usage
+```ruby
+require 'ostruct'
-It's dead easy:
+Point = Struct.new(:latitude, :longitude)
+points = [
+ Point.new(latitude: 101, longitude: 11),
+ Point.new(latitude: 102, longitude: 12),
+ Point.new(latitude: 201, longitude: 21)
+]
+```
+Now those points may be clustered easily:
+
```ruby
builder = Clumpy::Builder.new(points)
clusters = builder.cluster
+
+cluster = clusters.first
+cluster.size # => 2
+cluster.latitude # => 101.5
+cluster.longitude # => 11.5
+cluster.points # => points 1 and 2 from above
+cluster.bounds # => represents the area this cluster covers
+cluster.to_json # => well, json representation of that.
```
+
Optionally you could add a `precision: :high` option to the builder initialization to move the cluster a little bit after all points were assigned.
## Contributing