Custom Geo-Query Function

How I created a custom geo-query function to find posts under a specified range from the current location.

July, 2021

fodome promo video

fodome is an Android app that connects food donors with people in need. Each food post captures location details during upload.

How it works

  • When a user first enters the home feed page, all posts are shown (location access not yet enabled)
  • After enabling location, the user confirms their current position
  • Posts are then filtered by proximity with a default range of 20km
  • Users can customize the range from 1km to 1000km
  • For easier access, frequently used ranges (10km, 20km, 50km) are displayed as chip filters
  • A "custom range" option reveals a slider for precise distance selection (1-1000km)

Technical Implementation

The app implements a custom geo-query function that:

  • Compares the user's current location (latitude/longitude) with each post's location
  • Calculates the distance between these points
  • Filters out posts beyond the specified range
  • Re-runs this calculation whenever the range is updated

The function has a time complexity of O(n) where n is the number of posts. For performance optimization with large datasets, we could implement pagination - computing only the first 50-100 posts initially and loading more as the user scrolls. This approach would significantly improve performance once the app reaches a million+ posts.