1 | <?php |
||
18 | class NationaalGeoregister extends AbstractHttpProvider implements Provider |
||
19 | { |
||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | const ENDPOINT_URL_FREE = 'https://geodata.nationaalgeoregister.nl/locatieserver/v3/free?%s'; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | const ENDPOINT_URL_REVERSE = 'https://geodata.nationaalgeoregister.nl/locatieserver/revgeo?%s'; |
||
29 | |||
30 | /** |
||
31 | * @var string[] |
||
32 | */ |
||
33 | const BLACKLISTED_OPTIONS = [ |
||
34 | 'fl', |
||
35 | 'rows', |
||
36 | 'type', |
||
37 | 'wt', |
||
38 | ]; |
||
39 | |||
40 | /** |
||
41 | * @var array |
||
42 | */ |
||
43 | const DEFAULT_OPTIONS = [ |
||
44 | 'bq' => 'type:gemeente^0.5 type:woonplaats^0.5 type:weg^1.0 type:postcode^1.5 type:adres^1.5', |
||
45 | 'fl' => 'centroide_ll,huis_nlt,huisnummer,straatnaam,postcode,woonplaatsnaam,gemeentenaam,gemeentecode,provincienaam,provinciecode', |
||
46 | ]; |
||
47 | |||
48 | /** |
||
49 | * @var array |
||
50 | */ |
||
51 | const REQUIRED_OPTIONS_GEOCODE = []; |
||
52 | |||
53 | /** |
||
54 | * @var array |
||
55 | */ |
||
56 | const REQUIRED_OPTIONS_REVERSE = [ |
||
57 | 'type' => 'adres', |
||
58 | ]; |
||
59 | |||
60 | /** |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $options = []; |
||
64 | |||
65 | /** |
||
66 | * @param \Http\Client\HttpClient $client An HTTP adapter |
||
67 | * @param array $options Extra query parameters (optional) |
||
68 | */ |
||
69 | 51 | public function __construct(HttpClient $client, array $options = []) |
|
75 | |||
76 | /** |
||
77 | * @return array |
||
78 | */ |
||
79 | 6 | public function getOptions(): array |
|
83 | |||
84 | /** |
||
85 | * @param array $options |
||
86 | */ |
||
87 | 51 | public function setOptions(array $options) |
|
91 | |||
92 | /** |
||
93 | * @param \Geocoder\Query\GeocodeQuery $query |
||
94 | * |
||
95 | * @throws \Geocoder\Exception\InvalidServerResponse |
||
96 | * @throws \Geocoder\Exception\UnsupportedOperation |
||
97 | * |
||
98 | * @return \Geocoder\Collection |
||
99 | */ |
||
100 | 39 | public function geocodeQuery(GeocodeQuery $query): Collection |
|
109 | |||
110 | /** |
||
111 | * @param \Geocoder\Query\GeocodeQuery $query |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | 36 | protected function getGeocodeOptions(GeocodeQuery $query): array |
|
127 | |||
128 | /** |
||
129 | * @param \Geocoder\Query\ReverseQuery $query |
||
130 | * |
||
131 | * @throws \Geocoder\Exception\InvalidServerResponse |
||
132 | * |
||
133 | * @return \Geocoder\Collection |
||
134 | */ |
||
135 | 3 | public function reverseQuery(ReverseQuery $query): Collection |
|
139 | |||
140 | /** |
||
141 | * @param \Geocoder\Query\ReverseQuery $query |
||
142 | * |
||
143 | * @return array |
||
144 | */ |
||
145 | 3 | protected function getReverseOptions(ReverseQuery $query): array |
|
158 | |||
159 | /** |
||
160 | * @return string |
||
161 | */ |
||
162 | 21 | public function getName(): string |
|
166 | |||
167 | /** |
||
168 | * @param string $query |
||
169 | * |
||
170 | * @throws \Geocoder\Exception\InvalidServerResponse |
||
171 | * |
||
172 | * @return \Geocoder\Model\AddressCollection |
||
173 | */ |
||
174 | 39 | protected function executeQuery(string $query): AddressCollection |
|
204 | |||
205 | /** |
||
206 | * @param string $query |
||
207 | * |
||
208 | * @throws \Geocoder\Exception\InvalidServerResponse |
||
209 | * |
||
210 | * @return \stdClass |
||
211 | */ |
||
212 | 39 | protected function getResultsForQuery(string $query): \stdClass |
|
228 | } |
||
229 |