From 7d6177ad2402f84c148922663ed21ad96b125296 Mon Sep 17 00:00:00 2001
From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com>
Date: Fri, 30 Oct 2020 22:28:00 +0100
Subject: [PATCH] feat: add address on strucutre details

---
 src/app/home/home.component.ts                             | 1 +
 src/app/map/models/geoJsonProperties.model.ts              | 7 +++++++
 src/app/map/models/geojson.model.ts                        | 3 ++-
 src/app/models/structure.model.ts                          | 1 +
 .../structure-details/structure-details.component.html     | 2 +-
 5 files changed, 12 insertions(+), 2 deletions(-)
 create mode 100644 src/app/map/models/geoJsonProperties.model.ts

diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index 6630be72c..e198b3374 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -52,6 +52,7 @@ export class HomeComponent implements OnInit {
   private getStructurePosition(structure: Structure): Promise<Structure> {
     return new Promise((resolve, reject) => {
       this.getCoord(structure.voie).subscribe((coord: GeoJson) => {
+        structure.address = coord.properties.name + ' - ' + coord.properties.postcode + ' ' + coord.properties.city;
         structure.distance = this.geoJsonService.getDistance(
           coord.geometry.getLon(),
           coord.geometry.getLat(),
diff --git a/src/app/map/models/geoJsonProperties.model.ts b/src/app/map/models/geoJsonProperties.model.ts
new file mode 100644
index 000000000..fc9abed8d
--- /dev/null
+++ b/src/app/map/models/geoJsonProperties.model.ts
@@ -0,0 +1,7 @@
+export class GeoJsonProperties {
+  public city: string;
+  public country: string;
+  public name: string;
+  public postcode: string;
+  public state: string;
+}
diff --git a/src/app/map/models/geojson.model.ts b/src/app/map/models/geojson.model.ts
index 3407c70da..8ca263895 100644
--- a/src/app/map/models/geojson.model.ts
+++ b/src/app/map/models/geojson.model.ts
@@ -1,9 +1,10 @@
 import { AddressGeometry } from './addressGeometry.model';
+import { GeoJsonProperties } from './geoJsonProperties.model';
 
 export class GeoJson {
   public geometry: AddressGeometry;
   public type: string;
-  public properties: object;
+  public properties: GeoJsonProperties;
 
   constructor(obj?: any) {
     Object.assign(this, obj, {
diff --git a/src/app/models/structure.model.ts b/src/app/models/structure.model.ts
index 16f2781e6..6cc2c585f 100644
--- a/src/app/models/structure.model.ts
+++ b/src/app/models/structure.model.ts
@@ -36,6 +36,7 @@ export class Structure {
   public isOpen: boolean;
   public openedOn: OpeningDay;
   public distance?: string;
+  public address?: string;
 
   constructor(obj?: any) {
     Object.assign(this, obj, {
diff --git a/src/app/structure-list/components/structure-details/structure-details.component.html b/src/app/structure-list/components/structure-details/structure-details.component.html
index 03cbfe870..ba303e734 100644
--- a/src/app/structure-list/components/structure-details/structure-details.component.html
+++ b/src/app/structure-list/components/structure-details/structure-details.component.html
@@ -12,7 +12,7 @@
         <div fxLayout="column" fxFlex="60%">
           <div *ngIf="structure.voie" fxLayout="row" fxLayoutAlign="none center">
             <em class="ico-marker-pin-sm absolute"></em>
-            <p>{{ structure.voie }}</p>
+            <p>{{ structure.n }} {{ structure.address }}</p>
           </div>
           <div *ngIf="structure.siteWeb" fxLayout="row" fxLayoutAlign="none center">
             <em class="ic-globe-alt"></em>
-- 
GitLab