Skip to content

Commit

Permalink
refactor: 🔀 Merge branch 'main' of https://github.com/wjtje/wjtje.dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wjtje committed Aug 7, 2023
2 parents 0a6603e + 5d8905b commit 31ee14a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/lib/@types/osm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,23 +74,31 @@ export interface Changeset {

/**
* Minimum latitude of the changeset
*
* Can be empty if the changeset is empty or only edits relations
*/
min_lat: number;
min_lat?: number;

/**
* Minimum longitude of the changeset
*
* Can be empty if the changeset is empty or only edits relations
*/
min_lon: number;
min_lon?: number;

/**
* Maximum latitude of the changeset
*
* Can be empty if the changeset is empty or only edits relations
*/
max_lat: number;
max_lat?: number;

/**
* Maximum longitude of the changeset
*
* Can be empty if the changeset is empty or only edits relations
*/
max_lon: number;
max_lon?: number;

/**
* UID of the user who created this changeset
Expand Down
7 changes: 7 additions & 0 deletions src/lib/api/osm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ export const fetchOsmData = async (): Promise<Changeset[]> => {

const geocodeChangeset = async (changeset: Changeset): Promise<string> => {
console.log(`[osm.ts] Determining location for ${changeset.id}`);

// Check if we actually have a bounding box
if (!changeset.max_lat || !changeset.max_lon || !changeset.min_lat || !changeset.min_lon) {
console.log(`[osm.ts] No bounding box for ${changeset.id}`);
return 'World';
}

const avgLon = (changeset.max_lon + changeset.min_lon) / 2;
const avgLat = (changeset.max_lat + changeset.min_lat) / 2;

Expand Down

0 comments on commit 31ee14a

Please sign in to comment.