Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/weplay/geokit-gem into wepl…
Browse files Browse the repository at this point in the history
…ay/master
  • Loading branch information
Andre Lewis committed Apr 6, 2009
2 parents d14ed04 + 91fb215 commit 6997c98
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/geokit/mappable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ def ==(other)
other.is_a?(LatLng) ? self.lat == other.lat && self.lng == other.lng : false
end

def hash
lat.hash + lng.hash
end

def eql?(other)
self == other
end

# A *class* method to take anything which can be inferred as a point and generate
# a LatLng from it. You should use this anything you're not sure what the input is,
# and want to deal with it as a LatLng if at all possible. Can take:
Expand Down
18 changes: 17 additions & 1 deletion test/test_latlng.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,21 @@ def test_normalize
res=Geokit::LatLng.normalize([lat,lng])
assert_equal res,Geokit::LatLng.new(lat,lng)
end


def test_hash
lat=37.7690
lng=-122.443
first = Geokit::LatLng.new(lat,lng)
second = Geokit::LatLng.new(lat,lng)
assert_equal first.hash, second.hash
end

def test_eql?
lat=37.7690
lng=-122.443
first = Geokit::LatLng.new(lat,lng)
second = Geokit::LatLng.new(lat,lng)
assert first.eql?(second)
assert second.eql?(first)
end
end

0 comments on commit 6997c98

Please sign in to comment.