mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-12 23:31:02 +00:00
256f8c08e2
An installation that holds a key for the TREK services and has no NOMINATIM_URL of its own now sends the OpenStreetMap search and the reverse lookups to photon.liketrek.com first. The answers are read into Nominatim's shape, so the place records stay the same, and every miss (refused key, allowance spent, timeout, error, foreign body) falls back to Nominatim, with a one minute pause after four misses in a row. TREK_PHOTON_URL points at another copy, and the default of TREK_SERVICES_HOSTS now lists photon.liketrek.com and valhalla.liketrek.com beside places.liketrek.com.
64 lines
3.2 KiB
TypeScript
64 lines
3.2 KiB
TypeScript
import type { AppSettingsRepository } from '../../src/db/repositories/AppSettings.repository';
|
|
import type { PlaceDetailsCacheRepository } from '../../src/db/repositories/PlaceDetailsCache.repository';
|
|
import type { PlacesRepository } from '../../src/db/repositories/Places.repository';
|
|
import type { UsersRepository } from '../../src/db/repositories/Users.repository';
|
|
import type { GoogleQuotaService } from '../../src/nest/google-quota/google-quota.service';
|
|
import { MapsUrlResolver } from '../../src/nest/maps/maps-url.resolver';
|
|
import { MapsService } from '../../src/nest/maps/maps.service';
|
|
import { PlaceDetailsResolver } from '../../src/nest/maps/place-details.resolver';
|
|
import { PlacePhotoResolver } from '../../src/nest/maps/place-photo.resolver';
|
|
import { PlacesProviderSelector } from '../../src/nest/maps/places-provider.selector';
|
|
import { PoisAlongResolver } from '../../src/nest/maps/pois-along.resolver';
|
|
import { GooglePlacesClient } from '../../src/nest/maps/providers/google-places.provider';
|
|
import { OsmClient } from '../../src/nest/maps/providers/osm.client';
|
|
import { WikimediaClient } from '../../src/nest/maps/providers/wikimedia.client';
|
|
import type { PlacePhotoCacheService } from '../../src/nest/place-photos/place-photo-cache.service';
|
|
import { noGoogleQuota } from './google-quota';
|
|
import { photonOff } from './photon';
|
|
|
|
/** MapsService and the outbound clients it was wired with, for tests that reach a client directly. */
|
|
export interface MapsParts {
|
|
svc: MapsService;
|
|
google: GooglePlacesClient;
|
|
osm: OsmClient;
|
|
wiki: WikimediaClient;
|
|
selector: PlacesProviderSelector;
|
|
}
|
|
|
|
/**
|
|
* MapsService built by hand the way MapsModule wires it: the repositories and
|
|
* caches a test hands in, and real clients over the global fetch the test
|
|
* stubs. The argument order is MapsService's old six-argument constructor, so
|
|
* a hand-built service reads the same as it did before the providers split out.
|
|
*/
|
|
export function buildMapsParts(
|
|
photoCache: PlacePhotoCacheService,
|
|
appSettings: AppSettingsRepository,
|
|
users: UsersRepository,
|
|
placeDetailsCache: PlaceDetailsCacheRepository,
|
|
places: PlacesRepository,
|
|
googleQuota: GoogleQuotaService = noGoogleQuota,
|
|
): MapsParts {
|
|
const google = new GooglePlacesClient(googleQuota);
|
|
const osm = new OsmClient(photonOff());
|
|
const wiki = new WikimediaClient();
|
|
const selector = new PlacesProviderSelector(appSettings, users, googleQuota);
|
|
const photos = new PlacePhotoResolver(photoCache, places, google, wiki, selector);
|
|
const links = new MapsUrlResolver(osm);
|
|
const details = new PlaceDetailsResolver(placeDetailsCache, google, osm, selector);
|
|
const along = new PoisAlongResolver(osm);
|
|
const svc = new MapsService(photoCache, appSettings, google, osm, wiki, selector, photos, links, details, along);
|
|
return { svc, google, osm, wiki, selector };
|
|
}
|
|
|
|
export function buildMapsService(
|
|
photoCache: PlacePhotoCacheService,
|
|
appSettings: AppSettingsRepository,
|
|
users: UsersRepository,
|
|
placeDetailsCache: PlaceDetailsCacheRepository,
|
|
places: PlacesRepository,
|
|
googleQuota: GoogleQuotaService = noGoogleQuota,
|
|
): MapsService {
|
|
return buildMapsParts(photoCache, appSettings, users, placeDetailsCache, places, googleQuota).svc;
|
|
}
|