@@ -93,19 +93,28 @@ public function geocodeQuery(GeocodeQuery $query): Collection
93
93
$ results = [];
94
94
foreach ($ json ->features as $ feature ) {
95
95
$ coordinates = $ feature ->geometry ->coordinates ;
96
- $ streetName = !empty ($ feature ->properties ->street ) ? $ feature ->properties ->street : null ;
97
- $ number = !empty ($ feature ->properties ->housenumber ) ? $ feature ->properties ->housenumber : null ;
98
- $ municipality = !empty ($ feature ->properties ->city ) ? $ feature ->properties ->city : null ;
99
- $ postCode = !empty ($ feature ->properties ->postCode ) ? $ feature ->properties ->postCode : null ;
96
+
97
+ switch ($ feature ->properties ->type ) {
98
+ case 'housenumber ' :
99
+ $ streetName = !empty ($ feature ->properties ->street ) ? $ feature ->properties ->street : null ;
100
+ $ number = !empty ($ feature ->properties ->housenumber ) ? $ feature ->properties ->housenumber : null ;
101
+ break ;
102
+ case 'street ' :
103
+ $ streetName = !empty ($ feature ->properties ->name ) ? $ feature ->properties ->name : null ;
104
+ $ number = null ;
105
+ break ;
106
+ }
107
+ $ locality = !empty ($ feature ->properties ->city ) ? $ feature ->properties ->city : null ;
108
+ $ postalCode = !empty ($ feature ->properties ->postcode ) ? $ feature ->properties ->postcode : null ;
100
109
101
110
$ results [] = Address::createFromArray ([
102
111
'providedBy ' => $ this ->getName (),
103
112
'latitude ' => $ coordinates [1 ],
104
113
'longitude ' => $ coordinates [0 ],
105
114
'streetNumber ' => $ number ,
106
115
'streetName ' => $ streetName ,
107
- 'locality ' => $ municipality ,
108
- 'postalCode ' => $ postCode ,
116
+ 'locality ' => $ locality ,
117
+ 'postalCode ' => $ postalCode ,
109
118
]);
110
119
}
111
120
0 commit comments