clumpy 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c9b3590d403a8d17022234a9c010d77afb868ba
4
- data.tar.gz: 2c6c5d30ecaab4b5e7b9860da3503a26cd7e4376
3
+ metadata.gz: ba05344e6017c1ab80f749529bb6b1c3264b1e9f
4
+ data.tar.gz: f56e44bb1c4a19e0beb59afb8ab74476e0e7bec9
5
5
  SHA512:
6
- metadata.gz: aa62267024945a10872876e7051bc1c7d5323c7fcb0434cb05255366e59e8ba639e5a96845c090106475f90bd576c584728c5641c5d9a6cc479ff15cd13b6d51
7
- data.tar.gz: 86aab5b639351c14244a2ec557e5f387efabbbefeff727131c615035e6290284ce9e9bcaf93c8cc9a7f1b6475807ff37bbcb4b0b1bdc317b29db19209d977de1
6
+ metadata.gz: bf0193a876462ba874e89549716e8b075fa76b0054041ce6d74b943790d54885d47a2de028d585ed7bc400f071269065acf379dfceeb49bc72fbfc1f8d5f160f
7
+ data.tar.gz: cc23d1a5f7cb5455d2d86e3f6649b3b99814858ae81976bce2f0d514b0fe5f182de82fa0f838474ea9d8c464076d0a9fd63f45605ef29e17b6254e0dbefa234b
@@ -8,7 +8,7 @@ module Clumpy
8
8
  def initialize(points, options = {})
9
9
  @points = points
10
10
  @options = options || {}
11
- @distance_modifier = options.fetch(:distance_modifier) { 5 }
11
+ @distance_modifier = options.fetch(:distance_modifier) { 16 }
12
12
  @clusters = []
13
13
  end
14
14
 
@@ -42,20 +42,15 @@ module Clumpy
42
42
  clusters.find { |c| c.contains?(point) }
43
43
  end
44
44
 
45
- def cluster_latitude_distance
46
- latitude_distance / @distance_modifier
47
- end
48
-
49
- def cluster_longitude_distance
50
- longitude_distance / (@distance_modifier * 2)
45
+ def cluster_side_length
46
+ @cluster_size ||= (latitude_distance + longitude_distance) / @distance_modifier
51
47
  end
52
48
 
53
49
  def cluster_options
54
50
  {
55
51
  values_threshold: options[:values_threshold],
56
52
  include_values: options[:include_values],
57
- latitude_distance: cluster_latitude_distance,
58
- longitude_distance: cluster_longitude_distance
53
+ side_length: cluster_side_length
59
54
  }
60
55
  end
61
56
 
@@ -8,11 +8,10 @@ module Clumpy
8
8
  @points = [point]
9
9
  @options = options
10
10
 
11
- lat_dist = options[:latitude_distance] || 10
12
- lng_dist = options[:longitude_distance] || 10
11
+ side_length = options.fetch(:side_length) { 10 }
13
12
  @bounds = OpenStruct.new(
14
- latitude: (latitude - lat_dist)..(latitude + lat_dist),
15
- longitude: (longitude - lng_dist)..(longitude + lng_dist)
13
+ latitude: (latitude - side_length)..(latitude + side_length),
14
+ longitude: (longitude - side_length)..(longitude + side_length)
16
15
  )
17
16
  end
18
17
 
@@ -1,3 +1,3 @@
1
1
  module Clumpy
2
- VERSION = "0.2.4"
2
+ VERSION = '0.2.5'
3
3
  end
data/spec/builder_spec.rb CHANGED
@@ -35,7 +35,7 @@ describe Clumpy::Builder do
35
35
 
36
36
  it "passes the values threshold through to the cluster" do
37
37
  builder = Clumpy::Builder.new([point1], values_threshold: 100, include_values: true)
38
- builder.cluster_options.should eq({ values_threshold: 100, include_values: true, latitude_distance: 34.01023, longitude_distance: 36 })
38
+ builder.cluster_options.should eq({ values_threshold: 100, include_values: true, side_length: 33.128196875 })
39
39
  clusters = builder.cluster
40
40
  clusters.first.instance_variable_get(:@options).should eq builder.cluster_options
41
41
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Clumpy::ClusterBehavior do
4
4
  let(:point) { OpenStruct.new(latitude: 15, longitude: 20) }
5
5
  let(:other_point) { OpenStruct.new(latitude: 40, longitude: 40) }
6
- let(:cluster) { Clumpy::Cluster.new(point, latitude_distance: 10, longitude_distance: 10) }
6
+ let(:cluster) { Clumpy::Cluster.new(point, side_length: 10) }
7
7
 
8
8
  it "has a nicish to_s representation" do
9
9
  cluster.to_s.should include '# size: 1'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clumpy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Opper