Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#148 load by bound #160

Merged
merged 4 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .envTEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
APP_ID=datablue
PORT=3000
LOG_LEVEL=debug
REQUEST_LIMIT=100kb
REQUEST_LIMIT=10MB
GOOGLE_API_KEY=mykey
SESSION_SECRET=mySecret
NODE_ENV=development
Expand Down
24 changes: 21 additions & 3 deletions config/locations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Translated } from '../server/common/typealias';
import { BoundingBox, Translated, uncheckedBoundingBoxToChecked } from '../server/common/typealias';

/*
* @license
Expand All @@ -19,14 +19,16 @@ export interface Location {
name: string;
description: Translated<string>;
description_more: Translated<string>;
bounding_box: BoundingBox;
bounding_box: UncheckedBoundingBox;
//TODO @ralf.hauser not used as it seems, remove?
operator_fountain_catalog_qid: string;
//TODO @ralf.hauser not used as it seems, remove?
issue_api: IssueApi;
}

// TODO it would make more sense to move common types to an own library which is consumed by both, datablue and proximap
// if you change something here, then you need to change it in proximap as well
export interface BoundingBox {
export interface UncheckedBoundingBox {
latMin: number;
lngMin: number;
latMax: number;
Expand Down Expand Up @@ -521,7 +523,23 @@ export function isCity(s: string): s is City {
return cities.includes(s as City);
}

// TODO it would make more sense to move common types to an own library which is consumed by both, datablue and proximap
// if you change something here, then you need to change it in proximap as well
export function getCityBoundingBox(city: City): BoundingBox {
const uncheckedBoundingBox = locationsCollection[city].bounding_box;
try {
return uncheckedBoundingBoxToChecked(uncheckedBoundingBox);
} catch (e: any) {
const newErr = new Error('Could not get city bounding box for ' + city);
newErr.stack += '\nCaused by: ' + e.stack;
throw newErr;
}
}

// TODO it would make more sense to move common types to an own library which is consumed by both, datablue and proximap
// if you change something here, then you need to change it in proximap as well
export type LocationsCollection = Record<City, Location>;

// we don't expose just the internal structure as we also want to be sure that it follows the spec.
// However, we allow City union to grow dynamically
export const locationsCollection: LocationsCollection = internalLocationsCollection;
Expand Down
Loading