I'm using Play Framework v1.2.5 and the MongoDB Morphia module PlayMorphia v1.2.12 connecting to MongoDB v2.4.5.
I can't figure out how to do a geospatial query using Morphia.
For example, a basic query is fine:
//save a test address
new Address(47.5, -122.3, "123 South Main Street", "Seattle", "WA", "98109").save();
//now find it
List<Address> address = Address.q().filter("city", "Seattle").filter("street", "123 South Main Street").asList();
assertEquals(address.get(0).street,"123 South Main Street");
However, the documentation makes no mention about how to use MongoDB's $geoWithin $geoIntersects $near $nearSphere queries.
I tried using something like this, as hinted at in the documentation, but it didn't work.
List<Address> e = Address.q().filter("latlon near","[47.5, -122.3]").asList();
I found a way to accomplish this, however, it's pretty ugly because the result needs to be casted.
List<Address> addresses = (List<Address>)(List<?>) Address.q().field("latlon").near(47.5, -122.3).asList();