From 1ad81263386c6cf5b1c368c4ad75776dafca8f8f Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Fri, 20 Nov 2020 16:56:06 +0100
Subject: [PATCH] fix(map): add addr number for better location

---
 src/app/home/home.component.ts          | 6 +++---
 src/app/map/components/map.component.ts | 6 +++---
 src/app/services/geojson.service.ts     | 4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index 4cf5aa5b4..873be218a 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -95,7 +95,7 @@ export class HomeComponent implements OnInit {
    */
   private getStructurePosition(structure: Structure): Promise<Structure> {
     return new Promise((resolve, reject) => {
-      this.getCoord(structure.voie, structure.commune).subscribe((coord: GeoJson) => {
+      this.getCoord(structure.n, structure.voie, structure.commune).subscribe((coord: GeoJson) => {
         structure.address = coord.properties.name + ' - ' + coord.properties.postcode + ' ' + coord.properties.city;
         structure.distance = parseInt(
           this.geoJsonService.getDistance(
@@ -116,8 +116,8 @@ export class HomeComponent implements OnInit {
    * Get coord with a street reference
    * @param idVoie Street reference
    */
-  public getCoord(voie: string, zipcode: string): Observable<GeoJson> {
-    return this.geoJsonService.getCoord(voie, zipcode);
+  public getCoord(numero: string, voie: string, zipcode: string): Observable<GeoJson> {
+    return this.geoJsonService.getCoord(numero, voie, zipcode);
   }
 
   public getLocation(): void {
diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts
index f41fb5da9..01a17f2f9 100644
--- a/src/app/map/components/map.component.ts
+++ b/src/app/map/components/map.component.ts
@@ -107,7 +107,7 @@ export class MapComponent implements OnChanges {
 
   private getStructuresPositions(structureListe: Structure[]): void {
     structureListe.forEach((element: Structure) => {
-      this.getCoord(element.voie, element.commune).subscribe((coord: GeoJson) => {
+      this.getCoord(element.n, element.voie, element.commune).subscribe((coord: GeoJson) => {
         this.mapService
           .createMarker(coord.geometry.getLon(), coord.geometry.getLat(), element.id, this.buildToolTip(element))
           .addTo(this.map)
@@ -151,8 +151,8 @@ export class MapComponent implements OnChanges {
    * Get coord with a street reference
    * @param idVoie Street reference
    */
-  public getCoord(voie: string, zipcode: string): Observable<GeoJson> {
-    return this.geoJsonService.getCoord(voie, zipcode);
+  public getCoord(numero: string, voie: string, zipcode: string): Observable<GeoJson> {
+    return this.geoJsonService.getCoord(numero, voie, zipcode);
   }
 
   /**
diff --git a/src/app/services/geojson.service.ts b/src/app/services/geojson.service.ts
index ef92bb87a..5f15ae6d8 100644
--- a/src/app/services/geojson.service.ts
+++ b/src/app/services/geojson.service.ts
@@ -47,9 +47,9 @@ export class GeojsonService {
    * Get GeoLocation with an address
    * @param address Address
    */
-  public getCoord(address: string, zipcode: string): Observable<GeoJson> {
+  public getCoord(numero: string, address: string, zipcode: string): Observable<GeoJson> {
     return this.http
-      .get('/geocoding/photon/api' + '?q=' + address + ' ' + zipcode)
+      .get('/geocoding/photon/api' + '?q=' + numero + ' ' + address + ' ' + zipcode)
       .pipe(map((data: { features: any[]; type: string }) => new GeoJson(data.features[0])));
   }
 
-- 
GitLab