```const locationCoord = {latitude: 52.516272, lon...
# orm-help
c
Copy code
const locationCoord = {latitude: 52.516272, longitude: 13.377722}; 
const radius = 2000; // 2km, 2000m
const currentlocationCoord = geolib.getBoundsOfDistance(locationCoord, radius);
const {maxLat, maxLng, minLat, minLng} = geolib.getBounds(currentlocationCoord)

query {
    getLocations(where: {
        latitude_gt: minLat,
        latitude_lt: maxLat,
        longitude_gt: minLng,
        longitude_lt: maxLng
    }) {
        id
    }
}
👍 1
k
superpowa, thank you!
a
Cool! Just to be clear, this will match coords within a rectangle based on the radius and not a circle - right? Or am I missing something?
c
I don't get a radius is not a circle :)) Image drawing a circle from a center point with a particular radius 🙂
And yes, the code from above will get all the coordinates which are
inside
the bounds of the specified location + a radius.
@kratam please let me know if this worked 😄
k
It worked, thanks!
Not exactly what I wanted (order by distance), but it's good enough for now.
a
@catalinmiron Right, but it can match coords that are further away then the specified radius since it is using the bounds of the circle defined by the radius..
c
Nope 🙂 It is going to work as rectangle instead of circle but there's something which is working.