Skip to content

Commit

Permalink
feat(geo): make geoservice more robust
Browse files Browse the repository at this point in the history
If the geoservice does not manage to get the municipality, do not
send the municipality to the backend and let the backend call the
nominatim API. It enables to get the city even if the user
internet connection is not really good
  • Loading branch information
Maxime Vergez committed Dec 15, 2021
1 parent 61238d4 commit ebbb2c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/api/refgeo.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class RefGeoService {
? address.city
: address.municipality
? address.municipality
: 'Non trouvé';
: null;
return city;
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,11 @@ export class ObsFormComponent implements AfterViewInit {
.toISOString()
.match(/\d{4}-\d{2}-\d{2}/)[0];
formData.append('date', normDate);
formData.append('municipality', this.municipality);
if (this.municipality !== undefined && this.municipality != null) {
// If municipality is not present, let the backend find
// the municipality. So only append municipality if defined
formData.append('municipality', this.municipality);
}
for (let item of ['count', 'comment', 'id_program', 'email']) {
formData.append(item, this.obsForm.get(item).value);
}
Expand Down

0 comments on commit ebbb2c5

Please sign in to comment.