Skip to content

Commit

Permalink
Merge pull request #160 from tegonal/#148-load-by-bound
Browse files Browse the repository at this point in the history
#148 load by bound
  • Loading branch information
robstoll authored Dec 22, 2021
2 parents 11e097b + 3ff2fdb commit d55010b
Show file tree
Hide file tree
Showing 26 changed files with 1,233 additions and 973 deletions.
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

0 comments on commit d55010b

Please sign in to comment.