I have done it! Geospatial search works! If you can not tell, I am pretty happy about it. I am so close to having the MVP done. I just need to integrate Stripe and a mail sending API. Then after that, it's basically all polishing.
A friend that I made through my blogs actually sent a link to all the math required to actually calculate distance based on latitude and longitude. So once I had that I figured all I needed to do was find an easy way to convert addresses into latitude and longitude. So even though I said that I would not use it, I ended up using the Google Geo-Coding API. As it turns out, as long as you do not need like million API requests a month, the pricing is very budget-friendly. If I actually end up spending money on API requests, it means the website is doing very well, so that would be a problem that I would be more than happy to have.
One thing I learned while creating the Geospatial search functionality is middleware. I already knew how middleware worked and have used some out-of-the-box middleware before. However, this was my first time actually writing my own non-trivial middleware. I am excited that I am still learning on this project even though I intentionally picked technologies that I was already fairly familiar with.
Because I am proud of it, here is the code that I am using for the geospatial search:
It is probably not perfect, but it is mine, and it works. So I love it as is.
Glory to Ukraine!
Top comments (0)