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

fix: neither doc or inst has lat, lng #382

Merged
merged 1 commit into from
Sep 22, 2023
Merged
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
fix: neither doc or inst has lat, lng
  • Loading branch information
jalezi committed Sep 22, 2023
commit 177a1e52c0fed8b947281de1917fb3e19da93282
10 changes: 9 additions & 1 deletion src/services/doctors.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ export function createDoctor(doctor, inst) {
const website = trimString(doctor.website || institution.website);
const phone = trimString(doctor.phone || institution.phone);

const geoLocation = {
let geoLocation = {
lat: parseFloat(doctor.lat || institution.lat),
lon: parseFloat(doctor.lon || institution.lon),
};

if (Number.isNaN(geoLocation.lat) || Number.isNaN(geoLocation.lon)) {
// instead if throwing an error, we'll just use the center of Slovenia
// eslint-disable-next-line no-console
console.error(`Invalid geoLocation for ${name} (${doctor.key}),`, { institution, doctor });
const [lat, lon] = GEO_LOCATION.SL_CENTER;
geoLocation = { lat, lon };
}

const addressObject = getAddressObject(doctor, institution);
const isExtra = doctor.type.match(/-x$/);
const isFloating = doctor.type.match(/-f$/);
Expand Down