Urgent.News

What's breaking now, across thousands of outlets.

Tech

Matching Blood Donors by GPS: The Geospatial Query Design Behind GeoBlood

The naive version, and exactly how it fails Every geospatial feature starts life like this: ` js // do not ship this const donors = await Donor.find({ bloodType: 'B-', isAvailable: true }); const nearby = donors .map(d => ({ d, km: haversine(request.coords, d.coords) })) .filter(x => x.km <= 15) .sort((a, b) => a.km - b.km) .slice(0, 20); ` It works. It works on your laptop with 300 seeded…

The naive approach to matching blood donors by GPS fails in several ways. First, it scans the entire collection, resulting in poor performance as the registry grows. Second, it only considers a single blood type, disregarding other valuable donors. Finally, it sorts donors by proximity and stops, potentially missing the most suitable donor. MongoDB's 2dsphere index resolves these issues by modeling the Earth as a sphere and using a Hilbert curve to efficiently locate nearby donors within a specified radius.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Friday Squid Blogging: Rotting Squid on a Beached California Boat

Smells awful : But an estimated 30 to 50 tons of dead squid remain inside the boat’s catch tank, where they have been decomposing for days. “That is nasty.

  • 30 to 50 tons of dead squid decomposing on beached California boat
  • Foul odor from decomposing squid keeps beach closed to public
  • Commercial fisherman compares decomposed squid to gooey, concrete-like mass

The Code Casino

Watching some people use AI for software development right now feels uncomfortably close to watching people gamble. The behavioural patterns seem similar to me.

  • Developers chase rush of feel-good hormones with successful AI prompts
  • Addiction parallels drawn between AI use and gambling behavior
  • Concerns about work-life balance and overuse of AI tools

More from Friday 11 September →