By Devisetty Charmi, Katta Lasya, Veeramaneni Sruthi, Yasa Sowmya
During the creation of GiveBridge, a platform for local donations whereby donors list particular items for receivers to get, we ran into a fundamental question: how can a receiver find donations nearby?
City name search is effective but not enough. Someone in a big city can see an item listed in his “city” which is located 30 km from him. Therefore, we positioned ourselves to create a location-based search functionality. The following is our approach to create it using MERN stack.
Step 1: Storing the geographical position in the GeoJSON format.
In this case, we've created a property in the Mongoose schema that represents the geographical position of the donation. However, the usual blunder here is mixing up the order of coordinates; in GeoJSON, the latitude must be indicated after the longitude.
Step 2: Create a 2d sphere index
Simply storing coordinates is insufficient.…