Skip to content

Add Amazon Location Service V2 (GeoPlaces) Lookup#1

Open
amrocco wants to merge 4 commits intomasterfrom
amazon-location-v2
Open

Add Amazon Location Service V2 (GeoPlaces) Lookup#1
amrocco wants to merge 4 commits intomasterfrom
amazon-location-v2

Conversation

@amrocco
Copy link
Copy Markdown

@amrocco amrocco commented Mar 23, 2026

Add Amazon Location Service V2 (GeoPlaces) Lookup

Adds a new geocoding lookup for the Amazon Location Service Places V2 API (GeoPlaces), the successor to the original Amazon Location Service Places API.

Key differences from v1 (:amazon_location_service)

  • Uses the aws-sdk-geoplaces gem instead of aws-sdk-locationservice
  • Does not require an index_name — the v2 API removed this concept
  • Calls client.geocode / client.reverse_geocode instead of search_place_index_for_text / search_place_index_for_position
  • Returns proper 2-letter ISO country codes via country.code_2
  • Returns separate state (full name) and state_code (abbreviation), improving on v1 which returned the full name for both

What's included

  • Lookup (lib/geocoder/lookups/amazon_location_service_v2.rb): Forward and reverse geocoding via Aws::GeoPlaces::Client, with language configuration support and AWS credential handling (explicit keys or default credential chain)
  • Result (lib/geocoder/results/amazon_location_service_v2.rb): Parses v2 API responses into standard geocoder result attributes (coordinates, address, city, state, state_code, postal_code, country, country_code, neighborhood, route, place_id)
  • Error handling: Maps AWS exceptions to geocoder exception types (RequestDenied, OverQueryLimitError, InvalidRequest, ServiceUnavailable), respects always_raise configuration, returns [] on error
  • Tests: 13 tests covering geocoding, reverse geocoding, coordinates, place_id, no results, and all 4 error types (with and without always_raise)
  • Documentation: README_API_GUIDE.md entry with configuration examples, supported parameters, and credential setup

Files changed

  • lib/geocoder/lookup.rb — Register new lookup in street_services and all_services_with_http_requests
  • lib/geocoder/lookups/amazon_location_service_v2.rb — Lookup implementation
  • lib/geocoder/results/amazon_location_service_v2.rb — Result parser
  • test/fixtures/amazon_location_service_v2_madison_square_garden — Test fixture
  • test/test_helper.rb — Mock client and AWS error classes
  • test/unit/lookup_test.rb — Exclude from query URL test
  • test/unit/lookups/amazon_location_service_v2_test.rb — Unit tests
  • README_API_GUIDE.md — API documentation entry

End-to-end validation

This lookup was tested end-to-end against the live Amazon Location Service V2 API using an AWS Lambda (Ruby 3.3) deployed in a VPC with a com.amazonaws.us-east-1.geo.places VPC endpoint. Both forward geocoding (QueryText) and reverse geocoding (QueryPosition) were validated against real API responses, confirming correct result parsing, coordinate handling, and credential chain behavior (Lambda IAM role, no explicit keys).

@amrocco amrocco self-assigned this Mar 23, 2026
anthrocc added 3 commits March 24, 2026 14:38
…e class

- Use code_2 instead of code_3 for country_code to match geocoder conventions
- Pass result to super(result) so Base#data is properly set
- Update fixture, mock, and tests accordingly
- Map AccessDeniedException to Geocoder::RequestDenied
- Map ThrottlingException to Geocoder::OverQueryLimitError
- Map ValidationException to Geocoder::InvalidRequest
- Map InternalServerException to Geocoder::ServiceUnavailable
- Catch-all ServiceError maps to Geocoder::Error
- Respects always_raise configuration
- Returns empty array on error (gem convention)
- Add tests for all error types with and without always_raise
@amrocco amrocco changed the title Adding lookup service for amazon location v2 API Add Amazon Location Service V2 (GeoPlaces) Lookup Mar 24, 2026
@amrocco amrocco requested a review from a team March 24, 2026 15:18
@amrocco amrocco assigned sujamkatel and unassigned amrocco Mar 26, 2026
Copy link
Copy Markdown

@sujamkatel sujamkatel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, Few recommendations:

  1. Should we also include a codeowner file and assign to speed? Right now anyone can create and merge PRs in this repo.
  2. Can we also add the issue link in the PR description for posterity on what prompted us to create this new repo.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants