Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added test for Venue.location
  • Loading branch information
tommorris committed Nov 24, 2012
1 parent 4f51920 commit 596b214
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/org/tommorris/osmcheckin/Venue.scala
Expand Up @@ -16,7 +16,7 @@ class Venue(obj: Node, context: Node) {

def hasTag(tag: String) = tags.contains(tag)

def location = (obj.attribute("lat").get.first.text.toDouble, obj.attribute("lon").get.first.text.toDouble)
def location(): (Double, Double) = (obj.attribute("lat").get.first.text.toDouble, obj.attribute("lon").get.first.text.toDouble)

// returns distance in metres
def distanceFrom(lat: Double, long: Double) = {
Expand Down Expand Up @@ -48,4 +48,4 @@ class VenueWay(obj: scala.xml.Node, context:scala.xml.Node) extends Venue(obj, c
val longitude = nodes().foldLeft(0.toDouble)((a, b) => a + b.attribute("lon").get.first.text.toDouble) / nodes.size
(latitude, longitude)
}
}
}
5 changes: 5 additions & 0 deletions src/test/scala/org/tommorris/osmcheckin/VenueTest.scala
Expand Up @@ -15,6 +15,11 @@ class VenueSpec extends Specification {
ven.hasTag("amenity") must beTrue
ven.hasTag("name") must beTrue
}

"it should return locations" should {
val ven = Venue((example \ "node")(0), example)
ven.location() must beEqualTo(Pair(51.5238028.toDouble, -0.1430911.toDouble))
}
}

// vim: set ts=2 sw=2 et:

0 comments on commit 596b214

Please sign in to comment.