Hello all, I have gone through a few tutorials and...
# orm-help
a
Hello all, I have gone through a few tutorials and I am considering GraphQL for my next project. It is essentially based on the Uber model and revolves around e-hailing Taxis. I am researching GraphQL and Prisma and I am currently stuck on working with coordinates. How do I set driver's and rider's coordinates as well as look up drivers within a certain mile radius (or something similar)? Any pointers in the right direction is greatly appreciated.
k
Heyo! Well, certainly updating coordinates for people isn't a difficult thing to accomplish using Prisma's generated update mutations. I can't claim I have some special knowledge about GPS coordinates so I'm just going to offer my arm-chair suggestion. To find people I would figure you'd certainly want to get use Decimal Degrees for your coordinates. https://en.wikipedia.org/wiki/Decimal_degrees That way you can use less-than/greater-than comparisons to find people within a certain square distance from each other. Find out the east/west scale first based on the person's current latitude and from there you could take a rider and search for drivers who are within a certain decimal-point distance from each other. So if a rider is at like, 6.422235, 3.409556, chilling on Victoria Island in Lagos (my girlfriend is from there haha), you'd want to search for drivers whose coordinates are +/- 0.01 in both directions (about 1km at the equator). So something like this I suppose!
Copy code
query nearbyDrivers {
  drivers(
    where: {
      AND: {
        lat_gte: 6.412235,
        lat_lte: 6.432235,
        long_gte: 3.399556,
        long_lte: 3.419556
      }
    }
  ) {
    id
  }
}
👍 1
a
Thanks for the pointers. I have decided to go with plain graphql + express + mongodb