Repository navigation
Conversation
|
SonarCloud Quality Gate failed.
|
|
SonarCloud Quality Gate failed.
|
The rest of the Mapbox geocoder plumbing (config/geocoder.php, the
geocoder-php/mapbox-provider + toin0u/geocoder-laravel packages, and
MAPBOX_TOKEN in .env/CI/Fly secrets) already landed on develop as part
of other work and is already used for reverse geocoding in
SetPlaceNetworkData. This just switches the remaining forward-geocode
path, App\Helpers\Geocoder::geocode(), from a raw Google Maps HTTP call
to the same app('geocoder') chain (Mapbox, falling back to GeoPlugin),
matching that existing pattern.
country_code now comes straight from the provider's ISO country code
rather than matching the returned country name against our own country
list, and the dead reverseGeocode() method (superseded by the
reverseQuery() call already in SetPlaceNetworkData) is removed.
Public interface, the Geocoder container binding, and the test mocks
(GeocoderMock, GeocoderFailMock) are unchanged, so no other files need
updating for this to work.
This branch is rebuilt on current develop (~1240 commits ahead of
where it last was) so CI can actually run; the frontend part of the
original PR (replacing vue-google-autocomplete with a Mapbox GL
widget) is intentionally not carried over - see PR comment.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
18af27c to
fcfbcc0
Compare
|
Rebuilt this branch on current While rebasing this, it turned out most of the Mapbox plumbing this PR wanted had already landed on So the only remaining piece of this PR's intent was the forward geocode path, Infra/build files (Dockerfile, docker-compose.yml, docker_run.sh, package.json/package-lock.json) are taken as-is from develop - the versions in this branch were three years stale and would only have caused conflicts. Not carried over: the third part of the original PR description - replacing Needs manual verification:
|
|
develop gained #904 (a fetch() seam so GeocoderTest could exercise the parsing without calling Google) while this branch was replacing the whole method with the geocoder package. Same method, incompatible approaches. Taking this branch's: with the provider chain resolved from the container there is nothing to seam - a test binds its own provider instead, which is what the code comment here already promised. That also drops googleKey(), and reverseGeocode(), which was defined and never called anywhere in the codebase. GeocoderTest is rewritten onto that mechanism: it builds real Geocoder\Model\Address objects and binds a provider returning them. Both container keys have to be replaced, not just one. geocoder-laravel binds the string 'geocoder' through to ProviderAndDumperAggregator and registers that as a singleton, so replacing only the string leaves the real Mapbox chain reachable - and a test that passes then is quietly talking to the network. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
AddressCollection::get(0) raises OutOfBounds on an empty collection, so an address Mapbox and GeoPlugin both fail to place crashed the request instead of returning false the way callers expect - and the way the Google implementation did, since it counted results before indexing. Caught by rewriting GeocoderTest onto a bound provider: the nothing-found case throws with the real code. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
|
@edwh I think this is with you - think I recall from catchup we said for this PR you'd check how it compared to what iFixit had done on their fork regarding alternate geocoders, to see if we can minimise drift. |
|
Compared with iFixit's fork, as asked in the 1 October call. What this PR does now. It's one small change. Looking up a place's map position (geocoding) goes through the geocoding library already set up on What iFixit does. Their fork is https://github.com/iFixit/restarters, and the branch they run is
How they compare. Both move geocoding away from Google, and both can use Mapbox. iFixit's experiment builds its own provider layer. This PR uses the standard library we already have. This PR is the smaller change, so it should be easier for iFixit to pick up if they bring their fork up to date with ours. Recommendation. Keep this PR: merge |
|
Mapbox token: what it is and what it's allowed Where it lives.
Documented limits (the library we use,
Our volume. Geocoding happens server-side when a group, event or profile is saved with a changed location, plus two manual artisan commands: The terms are the real question, not the numbers. For Temporary geocoding Mapbox says results "may not be retained", requests "must be triggered by user activity", and responses may only be used "in conjunction with a Mapbox map". We store the coordinates in the database, |
…der errors GeoPlugin geocodes IP addresses, so it could never have placed a street address; the chain only hid that. Without the chain a bad token or an unreachable Mapbox would surface as a 500, so the helper catches and logs it and returns false, as it did when Google was unreachable. CI stubs the geocoder on a missing MAPBOX_TOKEN rather than a missing Google key, and the docs and test comments say Mapbox. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Mapbox token checkI inspected the
Conclusion: the preview token works for server-side geocoding. It is a plain public token with no URL restriction, which is what server-side calls need. Not verified:
|
|














RES-1858. Turning a group, event or profile location into coordinates and a country code (geocoding) now uses Mapbox, through the
geocoder-phplibrary already configured ondevelop. Before, it called the Google Geocoding API directly.Changes
App\Helpers\Geocoder::geocode()asks Mapbox and reads the coordinates and the ISO country code from its answer. It returnsfalsewhen Mapbox can't place the address, can't be reached, rejects the token or the quota is used up, and logs the reason. Callers show the existing "location could not be geocoded" message, as before.MAPBOX_TOKENis the geocoding credential.GOOGLE_API_CONSOLE_KEYis still used, but only by the browser for the maps and the address autocomplete.MAPBOX_TOKENis empty (forked PRs get no secrets), rather than when the Google key is.reverseGeocode()is removed; reverse geocoding goes throughset:networkdata:place.docs/local-development.mdsays which key does what.Mapbox token
pk.), valid, accountneilrestartwj5gChecked from inside the production machine on 2026-10-14: the token geocodes "Hackney, London" through both the v5 and v6 Mapbox geocoding APIs.
Before merging: check the
neilrestartaccount's Statistics page for monthly geocoding usage against the plan's free allowance (100,000 Temporary Geocoding requests). A public token can't read usage or plan, so this needs the account login. Not for release notes until that's checked.Not included
Tests
tests/Unit/GeocoderTest.phpbinds a fake provider, so nothing touches the network. It covers: coordinates and country code are read from the provider's answer; the ISO code is used, not the country name; an empty answer, a missing country, a provider that throws, and theForceGeocodeFailuresentinel each give the right result.Tests\Support\GeocoderMockreplaces the geocoder, so no test calls Mapbox. Two profile tests that forced a failure by invalidating the Google key now use a town the mock doesn't know.