by fryingdan · 1y ago · 0 comments
* If coordinates of commute locations are not cached in s3, reaches out to Google Geocode API to get them.
* Based on commute inputs, calculates the intersectional commute area for all housemates. If this is 0, then the program can return 0 properties to the user early as there are no houses there...
* The intersectional commute area is often a multipolygon (multiple shapes), and many APIs do not accept multiple shapes as a query input. Many APIs also do not like complex geometries (often only accepting x max points).
* To get around this, each polygon within the multipolygon is simplified with the Douglas-Peucker algorithm iteratively until the points in the resulting polygons within the multipolygon sum to a total of (x - 2(n-1)) where x is the maximum allowed shape points on an API and n is the number of individual polygons.
The remaining simplified multipolygon is then connected with nearly-infinitely-small bridges [which adds 2 points between each shape, hence x - 2(n-1)]. Once this geometry is calculated, valid properties can be found and returned to the user based on bedroom, bathroom, budget etc preferences.Vanilla JS frontend - uses leaflet.js for the map functionality.
No comments yet.