Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Document(collection = "zones")
- public class Zone implements Identifiable<String> {
- ... (other fields)
- private GeoJsonPoint location;
- ... (getters/setters)
- }
- @Repository
- public interface ZoneRepository extends CrudRepository<Zone, String> {
- List<Zone> findByLocationNear(Point p, Distance d);
- }
- ...
- Point p = new GeoJsonPoint(Double.valueOf(longitude), Double.valueOf(latitude));
- Distance d = new Distance(distance, Metrics.KILOMETERS);
- return zoneRepository.findByLocationNear(p, d);
- db.zones.find( { "location" :
- { $near :
- { $geometry : { type : "Point" , coordinates : [-82.706480, 28.038458]},
- $maxDistance : 50
- } } } )
- {
- "_id" : ObjectId("12341983471693746"),
- "name" : "Some location",
- "location" : {
- "type" : "Point",
- "coordinates" : [
- -82.706480,
- 28.038458
- ]
- },
- }
Add Comment
Please, Sign In to add comment