# NOT RUN {
# }
# NOT RUN {
library(GeoMongo)
init = geomongo$new()
getter_client = init$getClient()
init_db = getter_client$get_database("example_db")
init_col = init_db$get_collection("example_collection")
#--------------------------
# geonear using 'aggregate'
#--------------------------
query_geonear = list('$geoNear' = list(near = list(type = "Point", coordinates = c(-122.5, 37.1)),
distanceField = "distance", maxDistance = 900 * 1609.34,
distanceMultiplier = 1 / 1609.34, spherical = TRUE))
init$geoQuery(QUERY = query_geonear, METHOD = "aggregate", COLLECTION = init_col,
DATABASE = init_db, GEOMETRY_NAME = "location", TO_LIST = FALSE)
# }
Run the code above in your browser using DataLab