Music Record Browser / Location service
heardDownloads ↓7.103.0
HEARD KNOWLEDGE BASE

Location service

Design, API usage, geographic data, and operations.

01 / PREPAREImport source features

Places, buildings, and addresses for the intended coverage.

02 / PUBLISHBuild versioned S3 cells

Upload every cell and manifest; activate current.json last.

03 / QUERYResolve nearby candidates

Read intersecting cells, test geometry, rank and deduplicate.

Purpose and ownership#

NewDatelinePlaceLookupStack 2.0 turns coordinates into nearby businesses, building footprints, residential buildings and address points. It serves lookup candidates; heard decides which label to save, associates it with a song, and stores account/device corrections. The service does not identify residents or invent missing business names.

Design: two lookup deployments#

The standalone service is a Python Lambda plus private S3 index and REST API. Heard also packages an embedded S3 lookup Lambda inside NewDatelineMusicStack. These are separate indexes and deployments. Deploying or loading one does not automatically populate the other.

In the 7.77 manual-options path, PlacesFn invokes configured external and embedded Lambdas in parallel, then adds OpenStreetMap and reverse-address candidates, deduplicates by normalized name/address and sorts by containment/distance. The final merged list can contain up to 40 options. This is broader than calling the standalone service alone.

ComponentResponsibility
S3 PlaceIndexBucketPrivate encrypted cells, immutable dataset versions, manifest and active current.json pointer. Retained on stack deletion.
LookupFunctionPython 3.12, 512 MB, 20-second timeout; validates queries, reads intersecting cells, applies geometry and ranks candidates.
PlacesApiREST /v1/places/nearby and /v1/health; optional existing Cognito pool. Stage throttle: 25 requests/second, burst 50.
Import toolsDownload Overture, stream/build spatial cells locally, upload a complete version and activate it last.

App overview and functionality

Location service: design, usage and artifacts

Project architecture

Microphone settings and tuning

Design: data and spatial matching#

Publication model#

  • Download raw place, building and address records for the desired regions. Preserve unnamed building features and footprint geometry.
  • Build a versioned local index. Features spanning cell boundaries are replicated into intersecting cells; records retain stable IDs.
  • Upload datasets/VERSION/cells/*.json.gz and that version’s manifest. Only after all cells upload does the publisher update current.json.
  • Each publication replaces active coverage. Combine all desired regional inputs into one version; a Seattle-only publication does not add to an earlier Spokane-only publication.

Query execution#

Each request reads current.json, computes the radius bounding box and intersecting cell keys, and reads cells with up to eight S3 workers. Queries exceeding 256 cells or crossing unsupported polar/antimeridian geometry fail explicitly. GPS accuracy lowers confidence; it does not enlarge the requested radius.

Eligible small nonempty cells can be cached in a warm Lambda process for 60 seconds, with a 96-entry limit. Missing cells are not negatively cached. Cells exceeding 8 MB compressed or 32 MB expanded are rejected. A failed cell read produces service failure rather than a misleading partial success.

Distance, ranking and confidence#

  • Points use haversine distance. Buildings use polygon rings and holes: containing footprints rank first; outside queries use distance to the boundary, not only the displayed center.
  • Footprint distances use a local metric projection appropriate for the supported short search radius. This is not a long-range geodesic engine.
  • Replicated rows deduplicate by stable feature ID; distinct businesses at one address remain separate.
  • Standalone order: containing features first, shortest distance next, businesses on ties, then name and ID. The result limit is applied after ranking.
  • Confidence is a distance/containment/accuracy heuristic in the 0–1 range. It is not a calibrated probability of the user occupying a building.

Coverage and cost boundaries#

Deployment ships code, not geographic data. Missing names require corrected/new source data or a heard-side manual preference. National publication can require substantial download, disk, replicated storage and upload work; Alaska and Hawaii require deliberate coverage. Runtime costs are S3, Lambda, API Gateway and logs; no always-on database is needed for a fresh standalone stack.

Usage: lookup API and heard integration#

InputContract
latitude / latRequired finite number, −90 to 90. Empty values and booleans are rejected.
longitude / lon / lngRequired finite number, −180 to 180.
radiusMetersDefault 60.96 m (200 ft); 1–1,000 m. Alternatively radiusFeet or distanceFeet; never mix feet and meters fields.
accuracyMetersDefault 0; accepted 0–5,000 m. Used for confidence.
limitInteger 1–50; default 30. Heard requests 30 from each Lambda provider.

HTTP example#

Use the deployed LookupApiUrl output rather than a hard-coded account endpoint. If protected, send the existing pool’s raw ID token in Authorization. CORS permits configured origins but is not authentication.

GET {LookupApiUrl}?latitude=47.6588&longitude=-117.4260
    &radiusFeet=200&accuracyMeters=15&limit=30

IAM direct invocation#

Heard’s backend receives authorized browser/native requests and invokes the service with its IAM role. No AWS credentials belong in a browser. For direct invocation, check FunctionError, parse the proxy envelope, verify statusCode, then JSON-decode body.

{"latitude":47.6588,"longitude":-117.4260,
 "radiusMeters":60.96,"accuracyMeters":15,"limit":30}

Successful body: bestMatch, matches, alternatives, options and results aliases; count; indexReady; datasetVersion; source; cellsQueried; query. Candidates include ID, name, category, featureType, address, coordinates, distanceMeters, distanceFeet, containsPoint, matchType and confidence when available.

StatusMeaning / handling
200, matches presentReady index; show candidates and preserve captured GPS.
200, empty arraysReady index but no indexed feature within radius; preserve address/coordinate fallback.
400 invalid-queryInvalid input or unsupported/oversized geometry; correct the query.
503 place-index-not-loadedNo active dataset; publish the index.
503 place-index-unavailableStorage/read/format failure; inspect CloudWatch and retry appropriately.

heard integration#

Deploy the service, publish data, then redeploy heard’s web-aws-source. Its deployment discovers LookupFunctionArn; PLACE_LOOKUP_FUNCTION_ARN is the explicit override. Deploying heard grants invocation permissions. Keep the supplied deployment in the intended account/region and verify actual outputs. Automatic naming and manual correction must both be tested.

Usage: publication and troubleshooting#

Representative WSL2 workflow#

Run from a fresh extracted standalone-service folder after configuring AWS credentials and the target account/region. Full prerequisite steps are in INSTALL-WSL2.md inside the linked source archive.

./scripts/setup-wsl.sh
source .venv/bin/activate
npm test
./scripts/deploy.sh
python tools/download_overture.py \
  --bbox=-122.459,47.481,-122.224,47.734 \
  --types=place,building,address --output-dir=data/raw/seattle-01
python tools/build_place_index.py data/raw/seattle-01/*.geojson \
  --dataset-version seattle-01 --output-dir data/place-index/seattle-01
python tools/upload_place_index.py data/place-index/seattle-01 \
  --region us-east-1

Verification and rollback#

Use scripts/verify.sh with coordinates inside imported coverage and inspect actual returned names. /health confirms publication, not coverage at a particular address. Rebuild under a unique version if publication is interrupted. For rollback, point current.json to a complete older version’s manifest; keep old cells until verification finishes.

SymptomCheck
A building/business is missingImport bounds, all three feature types, exact GPS, radius and source names. A footprint alone cannot supply an absent business name.
Standalone works; heard does notExact discovered Lambda ARN, invocation permission, deployed client/backend configuration, and which index supplied the result.
HTTP 401 / CORS errorCorrect existing-pool ID token / exact allowed website origin. Direct IAM invocation is independent of browser CORS.
New upload loses old coverageEach version is a complete active coverage replacement; rebuild all intended regions together.
Aurora charges continueMigration intentionally retains legacy resources. Verify S3 results, preserve required data/snapshots and follow MIGRATION.md for deliberate retirement.

Implementation references

The application integration source is in web-aws-source/infra/lambda/places.ts, place-index.ts and identify/index.py. See WSL deployment instructions and architecture. A separate historical location-service ZIP is no longer embedded in this project package.

CONTINUE READINGArchitecture
heard · Project 7.103.0Guide source baseline 7.77 · October 15, 2026

Search documentation

Search across all guides.

Screenshot