Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

GeoJSON bug fix #51

Merged
merged 1 commit into from

2 participants

@maryama
Owner

No description provided.

@holdenk holdenk merged commit 3ee3179 into foursquare:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 31, 2012
  1. Fixed GeoJSON lat/long bug

    Maryam authored
This page is out of date. Refresh to see the latest.
View
7 src/main/scala/com/foursquare/slashem/Schema.scala
@@ -1434,9 +1434,14 @@ class PointField[T <: Record[T]](override val owner: T) extends Field[Pair[Doubl
try {
a match {
case "" => Empty
+ /*
+ * GeoJSON has (long, lat) instead of (lat, long)
+ * Only ES uses GeoJSON spec and returns an ArrayList
+ *
+ */
case ar: Array[Double] => Full(set(Pair(ar.apply(0),ar.apply(1))))
case (lat : Double)::(lng: Double)::Nil => Full(set(Pair(lat,lng)))
- case arl: ArrayList[_] => Full(set(Pair(arl.get(0).asInstanceOf[Double],arl.get(1).asInstanceOf[Double])))
+ case arl: ArrayList[_] => Full(set(Pair(arl.get(1).asInstanceOf[Double],arl.get(0).asInstanceOf[Double])))
case s: String => setFromString(s)
case _ => Empty
}
View
9 src/test/scala/com/foursquare/slashem/ElasticQueryTest.scala
@@ -253,6 +253,13 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
Assert.assertEquals(doc1._1,new ObjectId("4c809f4251ada1cdc3790b14"))
}
@Test
+ def serializationTest {
+ val r = ESimpleGeoPanda where(_.id eqs new ObjectId("4c809f4251ada1cdc3790b16")) fetch()
+ val lr = r.response.results
+ Assert.assertEquals(lr.length, 1)
+ Assert.assertEquals(lr.apply(0).point.value, (-32.0, 74.0))
+ }
+ @Test
def geoOrderDesc {
var r = ESimpleGeoPanda where (_.name contains "ordertest") complexOrderDesc(_.point sqeGeoDistance(74.0,-31.0)) fetch()
Assert.assertEquals(2,r.response.results.length)
@@ -387,7 +394,7 @@ class ElasticQueryTest extends SpecsMatchers with ScalaCheckMatchers {
val geoLong = -31
val r = ESimpleGeoPanda where (_.name contains "lolerskates") scoreBoostField(_.point sqeGeoDistance(geoLat, geoLong)) fetch()
Assert.assertEquals(r.response.results.length,2)
- Assert.assertEquals(r.response.results.apply(0).point.value._1,74.0,0.9)
+ Assert.assertEquals(r.response.results.apply(0).point.value._2,74.0,0.9)
}
@Test
Something went wrong with that request. Please try again.