From 8b2d614676098561bf50ca61fc42f9c7bdf4aa26 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Wed, 12 Jan 2022 15:27:15 +0100 Subject: [PATCH 1/3] feat: update photon-bal to photon --- karma.conf.js | 2 +- nginx/dev.conf | 4 ++-- proxy.conf.json | 2 +- src/app/services/geojson.service.ts | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/karma.conf.js b/karma.conf.js index 5cee0fd8e..e0feaefc7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -30,7 +30,7 @@ module.exports = function (config) { target: 'https://passerelle.formulaireextranet.grandlyon.com', changeOrigin: true, }, - '/geocoding/photon-bal/api': { + '/geocoding/photon/api': { target: 'https://download.data.grandlyon.com', changeOrigin: true, }, diff --git a/nginx/dev.conf b/nginx/dev.conf index 38db77c59..7609f90b7 100644 --- a/nginx/dev.conf +++ b/nginx/dev.conf @@ -52,8 +52,8 @@ server { proxy_pass https://passerelle.formulaireextranet.grandlyon.com/base-adresse/base-adresse-nationale/streets; } - location /geocoding/photon-bal/api { - proxy_pass https://download.data.grandlyon.com/geocoding/photon-bal/api; + location /geocoding/photon/api { + proxy_pass https://download.data.grandlyon.com/geocoding/photon/api; } location /reverse { diff --git a/proxy.conf.json b/proxy.conf.json index 09812b4a5..f5d918024 100644 --- a/proxy.conf.json +++ b/proxy.conf.json @@ -26,7 +26,7 @@ "changeOrigin": true, "logLevel": "info" }, - "/geocoding/photon-bal/api": { + "/geocoding/photon/api": { "target": "https://download.data.grandlyon.com", "secure": false, "changeOrigin": true, diff --git a/src/app/services/geojson.service.ts b/src/app/services/geojson.service.ts index 5b4670c86..b598e926a 100644 --- a/src/app/services/geojson.service.ts +++ b/src/app/services/geojson.service.ts @@ -49,7 +49,7 @@ export class GeojsonService { */ public getCoord(numero: string, address: string, zipcode: string): Observable<GeoJson> { return this.http - .get('/geocoding/photon-bal/api' + '?q=' + numero + ' ' + address + ' ' + zipcode, { headers: { skip: 'true' } }) + .get('/geocoding/photon/api' + '?q=' + numero + ' ' + address + ' ' + zipcode, { headers: { skip: 'true' } }) .pipe(map((data: { features: any[]; type: string }) => new GeoJson(data.features[0]))); } -- GitLab From af423a733fdf75d3d66a57d00bc6adc89778ba19 Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Tue, 18 Jan 2022 15:29:30 +0100 Subject: [PATCH 2/3] feat: remove brignais from map layers --- src/app/map/components/map.component.ts | 14 -- src/assets/geojson/brignais.json | 256 ------------------------ 2 files changed, 270 deletions(-) delete mode 100644 src/assets/geojson/brignais.json diff --git a/src/app/map/components/map.component.ts b/src/app/map/components/map.component.ts index 13335af94..de1990809 100644 --- a/src/app/map/components/map.component.ts +++ b/src/app/map/components/map.component.ts @@ -7,7 +7,6 @@ import * as _ from 'lodash'; import { GeoJsonProperties } from '../models/geoJsonProperties.model'; import { MarkerType } from './markerType.enum'; import metropole from '../../../assets/geojson/metropole.json'; -import brignais from '../../../assets/geojson/brignais.json'; import L from 'leaflet'; import 'leaflet.locatecontrol'; @@ -295,7 +294,6 @@ export class MapComponent implements OnChanges { ) .addTo(this.map); }); - this.initBrignaisLayer(); this.initMetropoleLayer(); }); } @@ -308,18 +306,6 @@ export class MapComponent implements OnChanges { this.map.fitBounds(markerBounds, { paddingTopLeft: [300, 0] }); } - private initBrignaisLayer(): void { - this.map.addLayer( - geoJSON( - { - type: brignais.features[0].geometry.type, - coordinates: brignais.features[0].geometry.coordinates, - } as any, - { style: () => ({ color: '#a00000', fillOpacity: 0, weight: 1 }) } - ) - ); - } - private initMetropoleLayer(): void { this.map.addLayer( geoJSON( diff --git a/src/assets/geojson/brignais.json b/src/assets/geojson/brignais.json deleted file mode 100644 index 1ee59c4ca..000000000 --- a/src/assets/geojson/brignais.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "type": "FeatureCollection", - "features": [ - { - "type": "Feature", - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [4.725423572838992, 45.67523492540029], - [4.725556205086396, 45.67536799809434], - [4.72593053033344, 45.67665926826292], - [4.725897408725562, 45.67724523002701], - [4.724498364095213, 45.67894195987662], - [4.724136912235676, 45.67971308733658], - [4.724174998822853, 45.680523132991055], - [4.724394519781781, 45.680970121651505], - [4.7253742587434235, 45.684368766945326], - [4.726012834038375, 45.68589017252987], - [4.728784560500518, 45.687405878667384], - [4.72848312066644, 45.68804099459657], - [4.728627880181792, 45.68979513877095], - [4.728809686695279, 45.691089357368675], - [4.7291322400729285, 45.69112944192117], - [4.729902992424156, 45.69111760886067], - [4.730600785997002, 45.690827674081646], - [4.730837815634237, 45.69059885727743], - [4.731204878749306, 45.69000776130103], - [4.73139897139636, 45.69004981338818], - [4.731662645758953, 45.690261928769566], - [4.732023405137734, 45.69111204879683], - [4.732488514263196, 45.69160028260697], - [4.732940942926815, 45.691683394012664], - [4.734099621090595, 45.691746627435876], - [4.73434948614329, 45.69151760548787], - [4.734075638062059, 45.69098140009308], - [4.7343768828349795, 45.69075158713616], - [4.734521008493132, 45.690839438290624], - [4.734719058126453, 45.6910075220864], - [4.73505121379295, 45.691353680573016], - [4.735606549566667, 45.691029880343955], - [4.736235995079525, 45.69102018090333], - [4.737120505040019, 45.690538179796015], - [4.738317135484041, 45.69058277024951], - [4.739604079560944, 45.69022964404202], - [4.740797406330327, 45.689760858170914], - [4.741113249907205, 45.6904044834425], - [4.74169253500404, 45.691251197126086], - [4.743756539358913, 45.69067884477155], - [4.745787361237172, 45.69027810209865], - [4.74597720467782, 45.69018508940489], - [4.7459672618832425, 45.689869996869504], - [4.746732024821265, 45.68966899316945], - [4.7468675851401905, 45.68989206732954], - [4.747075902224951, 45.6903842244931], - [4.748746972517031, 45.690394324128704], - [4.748913884913081, 45.69120236785876], - [4.749881307355184, 45.691313443446006], - [4.750266682621687, 45.69130745660553], - [4.75034087972368, 45.69162155085391], - [4.750980041352062, 45.69151254047945], - [4.750833350277468, 45.6909383685811], - [4.750960383323937, 45.690891358869365], - [4.752247522979393, 45.69095240896389], - [4.7520834134073064, 45.69023439647343], - [4.753175002560322, 45.6902084063704], - [4.75319928549635, 45.68935235728534], - [4.754283721018561, 45.689101290815316], - [4.754480682609426, 45.68923332935833], - [4.75465195760291, 45.6901764038525], - [4.755291379643046, 45.690076371654506], - [4.755418406923607, 45.69002935691955], - [4.755388424697647, 45.68948939989777], - [4.756477139743565, 45.689373351606974], - [4.756255937661885, 45.690097366294154], - [4.755758685048976, 45.690627527691774], - [4.7568813848931875, 45.690366832941145], - [4.757649546809886, 45.690273786526994], - [4.757752907713235, 45.69069550639201], - [4.758773120845915, 45.690445398852184], - [4.758964374007231, 45.690397377334136], - [4.759429714788022, 45.69088549987699], - [4.759622400423712, 45.69088249029222], - [4.760566922030581, 45.69027326534666], - [4.760890926169576, 45.69035827201069], - [4.761283457897996, 45.69057731264884], - [4.7620467414810825, 45.690331191963], - [4.762730363945926, 45.690005248751916], - [4.764257182723493, 45.68952198522801], - [4.765205780326249, 45.688237124358565], - [4.768167149814534, 45.68881216982346], - [4.770277909252294, 45.68931043794418], - [4.770730713369078, 45.688600766684736], - [4.771480342785376, 45.68873309432069], - [4.77193136502855, 45.68877103624345], - [4.772205568931809, 45.68930714947986], - [4.772463628393492, 45.6893391178], - [4.772913213953938, 45.6893320429134], - [4.773703568347919, 45.688328818358265], - [4.7746336027736085, 45.68767466501034], - [4.774950393746933, 45.687534566990124], - [4.774193555047427, 45.68637556484896], - [4.774691747769191, 45.68588133254685], - [4.7748034452827195, 45.68535715987414], - [4.773808079621646, 45.685174682308215], - [4.773805051924615, 45.68467933870828], - [4.773956010522631, 45.683776249949695], - [4.774792025710137, 45.683799108658405], - [4.774636306084858, 45.68335120641176], - [4.775605376060246, 45.68351607645404], - [4.775926185622656, 45.683502011630814], - [4.776104397271003, 45.6830488457035], - [4.776486822059296, 45.682952743560215], - [4.7778351319935375, 45.68292246280935], - [4.778737091105642, 45.68299829393771], - [4.778906775391038, 45.68268036475559], - [4.779160466215576, 45.6825772793951], - [4.779351674493231, 45.68252922330023], - [4.780010484689922, 45.68143795840417], - [4.779189696950867, 45.68028900776877], - [4.779048241725939, 45.67988592162209], - [4.779862670961972, 45.679638868976355], - [4.779908065588893, 45.67905268841031], - [4.780027807598072, 45.67878058222422], - [4.779218635843911, 45.677991733987284], - [4.779207058904248, 45.6776316319511], - [4.779750128780947, 45.676938509964614], - [4.779832415604619, 45.67590139035096], - [4.779538415080308, 45.675149437991905], - [4.779854832445264, 45.67500032376799], - [4.781560873442728, 45.674513984782806], - [4.781547833073028, 45.67410887037405], - [4.781236435009352, 45.672816770058226], - [4.779990236096869, 45.67281846013053], - [4.779668356221317, 45.671598578939054], - [4.779206942552515, 45.67163289129457], - [4.778745750915616, 45.67087457192298], - [4.7782528164999505, 45.669927602756324], - [4.777540551502218, 45.67055133186952], - [4.775529743361716, 45.6715468149248], - [4.775274363821313, 45.671595876680605], - [4.7751808286750155, 45.66948068088587], - [4.775048091273325, 45.669347666713165], - [4.774662871571942, 45.66935373830436], - [4.773637349458038, 45.66942393812807], - [4.773185041670769, 45.66934099029003], - [4.772406241968541, 45.66909204510558], - [4.772337715040516, 45.66895801718882], - [4.771868249713578, 45.668740227731874], - [4.771349154747806, 45.66857725966596], - [4.771175149240492, 45.66876013863497], - [4.770519195438096, 45.669941376444186], - [4.770328022971875, 45.66998941749999], - [4.76966047647199, 45.66960359791103], - [4.76842076011509, 45.66900158424274], - [4.76777441727613, 45.668876626441644], - [4.766430753412082, 45.669041825409025], - [4.765847181522396, 45.66887083651429], - [4.76512544693445, 45.66839576972117], - [4.764905647005159, 45.66794886093501], - [4.765083898794231, 45.667495712998836], - [4.765885284015383, 45.66684364558067], - [4.7662974300263965, 45.666071579427125], - [4.766158977366456, 45.66575850330744], - [4.766337211845127, 45.66530535346818], - [4.765471412252013, 45.66474247875827], - [4.765278817909219, 45.66474549833979], - [4.763831164052034, 45.66527258093708], - [4.762811437637273, 45.6655227337891], - [4.761523158650894, 45.665407788976516], - [4.761145215259903, 45.66402661250905], - [4.760952623171668, 45.66402962469188], - [4.758959929173959, 45.66397970796059], - [4.75916954801526, 45.66289558578311], - [4.759136683116868, 45.66226560499678], - [4.7586861715644595, 45.66223661452678], - [4.758677591471066, 45.661966536766236], - [4.758773121288069, 45.66133455043102], - [4.759075212500354, 45.66073536520345], - [4.7593575921304385, 45.659920317686144], - [4.7585847066096605, 45.659851328893375], - [4.756455211153323, 45.659533295372896], - [4.7563068481391095, 45.65931043355558], - [4.754567101508066, 45.65913039705785], - [4.75154780564835, 45.659105352958626], - [4.751469373071419, 45.65865622119097], - [4.750488825819278, 45.65851835130557], - [4.748934830133477, 45.658524487946195], - [4.747950264726445, 45.65866587642288], - [4.747970682982501, 45.659719381930906], - [4.747696712339127, 45.66039916230322], - [4.747920607095225, 45.66098114366396], - [4.747825806721737, 45.66164012862579], - [4.747259471385523, 45.66160388350693], - [4.746623999017551, 45.66222622116816], - [4.746056967942222, 45.66298259915003], - [4.745567023045599, 45.66333246283877], - [4.745690682366697, 45.66440238199589], - [4.745562286214036, 45.66440437253454], - [4.744977692531974, 45.66419726506753], - [4.744525470411494, 45.66411420217368], - [4.743614191503186, 45.66536227946326], - [4.744227592544672, 45.665668025185646], - [4.743622256781896, 45.66643399042955], - [4.743856781825376, 45.66653844292826], - [4.743574140240937, 45.66735345200182], - [4.743134085012219, 45.667657496767916], - [4.742725855794389, 45.668564517774435], - [4.742391735935124, 45.669785636321016], - [4.742054767883991, 45.67091672759077], - [4.741343123760939, 45.670756600745676], - [4.741032007343306, 45.67107665693612], - [4.740987721924457, 45.67130251712942], - [4.741841950343499, 45.67191079217109], - [4.741977447470289, 45.672133871909935], - [4.741549337153295, 45.672410704036544], - [4.740783378089855, 45.67256665906743], - [4.739619434613251, 45.67232344151881], - [4.738656323818675, 45.672338315084986], - [4.737700561249222, 45.672587249382026], - [4.736867273381311, 45.6726451393355], - [4.736286861425061, 45.67257302643793], - [4.734556355669604, 45.672698770900475], - [4.7342339057562945, 45.67265870193287], - [4.7331398347676, 45.6725944818514], - [4.732757406343585, 45.67269043675427], - [4.731731769421744, 45.672760255017], - [4.731233762765472, 45.67285798191712], - [4.729887079598486, 45.672932718252156], - [4.729247809710637, 45.67303260613895], - [4.727912361852489, 45.67346742583567], - [4.726629868391131, 45.673541138039994], - [4.726138864959061, 45.67386390944757], - [4.725602171277048, 45.67478183974645], - [4.725423572838992, 45.67523492540029] - ] - ] - }, - "properties": { - "code_epci": "246900757", - "insee_reg": 84, - "insee_arr": "1", - "nom_epci": "CC de la Vall\u00e9e du Garon (Ccvg)", - "statut": "Commune simple", - "nom_reg": "AUVERGNE-RHONE-ALPES", - "geo_point_2d": [45.6778041264, 4.75264949198], - "insee_com": "69027", - "nom_com": "Brignais", - "id": "BDCSURCO0000000009605506", - "nom_dep": "RHONE", - "insee_dep": "69", - "population": 11381 - } - } - ] -} -- GitLab From b54d8917fa20ee35aa1ab40e55dba3e7f6c851ba Mon Sep 17 00:00:00 2001 From: Hugo SUBTIL <ext.sopra.husubtil@grandlyon.com> Date: Wed, 19 Jan 2022 12:32:29 +0100 Subject: [PATCH 3/3] clean: refactor duplicated code and add duplication filtering --- .../address-autocomplete.component.html | 2 +- .../address-autocomplete.component.ts | 34 ++++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/app/shared/components/address-autocomplete/address-autocomplete.component.html b/src/app/shared/components/address-autocomplete/address-autocomplete.component.html index 82ccf794d..c107fc916 100644 --- a/src/app/shared/components/address-autocomplete/address-autocomplete.component.html +++ b/src/app/shared/components/address-autocomplete/address-autocomplete.component.html @@ -12,7 +12,7 @@ </div> <div class="autocomplete-items" *ngIf="!isAlreadySearching"> <p *ngFor="let hit of data" (click)="selectedResult(hit)" class="autocomplete-item"> - {{ parseHitToAddress(hit) }} + {{ hit.displayedName }} </p> </div> </div> diff --git a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts index 8670ecc1f..10f2efed1 100644 --- a/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts +++ b/src/app/shared/components/address-autocomplete/address-autocomplete.component.ts @@ -19,18 +19,14 @@ export class AddressAutocompleteComponent implements OnInit { constructor(private addressService: AddressService) {} ngOnInit(): void { - if (this.address) { - let address_str = null; - if (this.address.numero) { - address_str = this.address.numero + ' ' + this.address.street + ' ' + this.address.commune; - } else { - address_str = this.address.street + ' ' + this.address.commune; - } - this.searchAddress.nativeElement.value = address_str; - } + this.lauchSearch(); } ngOnChanges(): void { + this.lauchSearch(); + } + + public lauchSearch(): void { if (this.address) { let address_str = null; if (this.address.numero) { @@ -46,7 +42,12 @@ export class AddressAutocompleteComponent implements OnInit { if (!this.isAlreadySearching) { this.isAlreadySearching = true; this.addressService.searchAddress(searchString).subscribe((data) => { - this.data = data.features; + data.features = data.features.map((el) => { + el.displayedName = this.parseHitToAddress(el); + return el; + }); + // Filtering duplicate displayed string. This duplication is caused by the API used for gathering addresse info. + this.data = [...new Map(data.features.map((item) => [item['displayedName'], item])).values()]; this.isAlreadySearching = false; }); } @@ -67,10 +68,17 @@ export class AddressAutocompleteComponent implements OnInit { this.selectedAddress.emit(address); } - public parseHitToAddress(hit: any): string { + private parseHitToAddress(hit: any): string { + let parsedAddress = ''; if (hit.properties.housenumber) { - return `${hit.properties.housenumber} ${hit.properties.street} ${hit.properties.city}`; + parsedAddress += `${hit.properties.housenumber} `; + } + if (hit.properties.street) { + parsedAddress += `${hit.properties.street}, `; + } else { + parsedAddress += `${hit.properties.name}, `; } - return `${hit.properties.street} ${hit.properties.city}`; + parsedAddress += `${hit.properties.city}`; + return parsedAddress; } } -- GitLab