By sending latitude longitude of current Location, I would like to find the nearest airport in my collection.
I've used geodist for finding the distance between two latitute/longitude coordinates.
Question: Is it possible to make a query after getting all collection of airport to check whether the current location is available within a specific distance?
E.g. When minimum current distance to an item of the collections is within 100km, then I would like to show this item as result.
This My Query...
return Airport
.find(_.pick(params, _.keys(Airport.schema.paths)))
.populate(_.keys(_.groupBy(_.reject(
strapi.models.airport.associations, {autoPopulate: false}), 'alias')).join(' '));
This My Route...
{
"method": "GET",
"path": "/airport/:latitude/:longitude/",
"handler": "Airport.findOne",
"config": {
"policies": []
}
},
This my Controller...
findOne: async (ctx) => {
return strapi.services.airport.fetch(ctx.params);
},