Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #2 from dburt/refactoring

This is a fix for the same set of warnings on the refactoring branch
  • Loading branch information...
commit 269c948ff27f5003183e8f243a7f435a021b45e7 2 parents ab03906 + 94389dd
Kristian Mandrup authored

Showing 1 changed file with 4 additions and 22 deletions. Show diff stats Hide diff stats

  1. 26  lib/geo_magic/radius/circular.rb
26  lib/geo_magic/radius/circular.rb
@@ -28,37 +28,19 @@ def to_s
28 28
 
29 29
     # Factory
30 30
     def random_point_within
31  
-      max_radius_rad = dist.distance
  31
+      max_radius_rad = distance.distance
32 32
       range = normalize max_radius_rad
33 33
 
34 34
       q = rand(range) * PI_2
35 35
       r = Math.sqrt(rand(range))
36  
-      dlong = denormalize (range * r) * Math.cos(q)
37  
-      dlat = denormalize (range * r) * Math.sin(q)
  36
+      dlong = denormalize range * r * Math.cos(q)
  37
+      dlat = denormalize range * r * Math.sin(q)
38 38
 
39 39
       GeoMagic::Point.new @center.latitude + dlat, @center.longitude + dlong
40 40
     end
41 41
 
42 42
     def random_points_within number
43  
-      conversion = GeoMagic::Distance.radians_ratio(distance.unit)
44  
-
45  
-      max_radius_rad = distance.distance
46  
-      range = normalize max_radius_rad
47  
-
48  
-      max_radius_rad = distance.distance
49  
-      range = normalize max_radius_rad
50  
-
51  
-      number.times.inject([]) do |res, n|
52  
-        q = rand(range) * PI_2
53  
-        r = Math.sqrt(rand(range))
54  
-
55  
-        dlong = denormalize (range * r) * Math.cos(q)
56  
-        dlat  = denormalize (range * r) * Math.sin(q)
57  
-
58  
-        point = GeoMagic::Point.new @center.latitude + dlat, @center.longitude + dlong
59  
-        res << point
60  
-        res
61  
-      end
  43
+      Array.new(number) { random_point_within }
62 44
     end    
63 45
   end
64 46
 end

0 notes on commit 269c948

Please sign in to comment.
Something went wrong with that request. Please try again.