Skip to content

Commit

Permalink
Merge pull request water-fountains#483 from tegonal/dev/water-fountai…
Browse files Browse the repository at this point in the history
…ns#478-remove-deprecated-lat-lng

water-fountains#478 remove lat/lng query params
  • Loading branch information
robstoll authored Dec 10, 2021
2 parents 0bcdee8 + 9a39783 commit cc55f7a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/app/router/router.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { combineLatest, of } from 'rxjs/index';
import { SubscriptionService } from '../core/subscription.service';
import { CityService } from '../city/city.service';
import { RouteValidatorService } from '../services/route-validator.service';
import { RoutingService } from '../services/routing.service';
import { switchMap } from 'rxjs/operators';

@Component({
Expand All @@ -25,7 +25,7 @@ export class RouterComponent implements OnInit {
private subscriptionService: SubscriptionService,
private route: ActivatedRoute,
private router: Router,
private routeValidator: RouteValidatorService,
private routeValidator: RoutingService,
private cityService: CityService
) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ import { DataService, lookupFountainAlias } from '../data.service';
import { FountainService } from '../fountain/fountain.service';
import { City } from '../locations';
import { CityService, defaultCity } from '../city/city.service';
import { illegalState } from '../shared/illegalState';
import { Database, FountainSelector, isDatabase, LngLat } from '../types';
import { getSingleNumericParam, getSingleStringParam, isNumeric } from './utils';
import { Database, FountainSelector, LngLat } from '../types';
import { getSingleStringParam, isNumeric } from './utils';
import { catchError, filter, first } from 'rxjs/operators';
import { MapConfig } from '../map/map.config';

Expand All @@ -41,7 +40,7 @@ export interface QueryParams {
@Injectable({
providedIn: 'root',
})
export class RouteValidatorService {
export class RoutingService {
// Validates route names

constructor(
Expand Down Expand Up @@ -329,22 +328,18 @@ export class RouteValidatorService {
getShortenedQueryParams(): Observable<QueryParams> {
return this.fountainService.fountainSelector.map(fountainSelector => {
// Get query parameter values from app state. use short query params by default for #159
const queryParams: QueryParams = {
l: this.languageService.currentLang, // use short language by default// mode: state.mode,
};
if (fountainSelector !== undefined) {
if (fountainSelector.queryType === 'byCoords') {
// if selection by coordinates
queryParams.lat = fountainSelector.lat;
queryParams.lng = fountainSelector.lng;
} else if (fountainSelector.queryType === 'byId') {
// if selection by id
queryParams.i = fountainSelector.idval;
}
}
const queryParams: QueryParams = fountainSelector ? this.getQueryParamsForSelector(fountainSelector) : {};
queryParams.l = this.languageService.currentLang;
return queryParams;
});
}

private getQueryParamsForSelector(fountainSelector: FountainSelector): QueryParams {
switch (fountainSelector.queryType) {
case 'byId':
return { l: this.languageService.currentLang };
}
}
}

function isWikidataId(id: string): boolean {
Expand Down
2 changes: 1 addition & 1 deletion src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export function isDatabase(s: string): s is Database {
}

export interface FountainSelector {
queryType: 'byCoords' | 'byId';
queryType: 'byId';
lat?: number;
lng?: number;
radius?: number;
Expand Down

0 comments on commit cc55f7a

Please sign in to comment.