-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92326d7
commit cdb47ee
Showing
8 changed files
with
402 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'geocoder/lookups/base' | ||
require "geocoder/results/pdok_nl" | ||
|
||
module Geocoder::Lookup | ||
class PdokNl < Base | ||
|
||
def name | ||
'pdok NL' | ||
end | ||
|
||
def supported_protocols | ||
[:https] | ||
end | ||
|
||
private # --------------------------------------------------------------- | ||
|
||
def cache_key(query) | ||
base_query_url(query) + hash_to_query(query_url_params(query)) | ||
end | ||
|
||
def base_query_url(query) | ||
"#{protocol}://api.pdok.nl/bzk/locatieserver/search/v3_1/free?" | ||
end | ||
|
||
def valid_response?(response) | ||
json = parse_json(response.body) | ||
super(response) if json | ||
end | ||
|
||
def results(query) | ||
return [] unless doc = fetch_data(query) | ||
return doc['response']['docs'] | ||
end | ||
|
||
def query_url_params(query) | ||
{ | ||
fl: '*', | ||
q: query.text, | ||
wt: 'json' | ||
}.merge(super) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
require 'geocoder/results/base' | ||
|
||
module Geocoder::Result | ||
class PdokNl < Base | ||
|
||
def response_attributes | ||
@data | ||
end | ||
|
||
def coordinates | ||
@data['centroide_ll'][6..-2].split(' ').map(&:to_f).reverse | ||
end | ||
|
||
def formatted_address | ||
@data['weergavenaam'] | ||
end | ||
|
||
alias_method :address, :formatted_address | ||
|
||
def province | ||
@data['provincienaam'] | ||
end | ||
|
||
alias_method :state, :province | ||
|
||
def city | ||
@data['woonplaatsnaam'] | ||
end | ||
|
||
def district | ||
@data['gemeentenaam'] | ||
end | ||
|
||
def street | ||
@data['straatnaam'] | ||
end | ||
|
||
def street_number | ||
@data['huis_nlt'] | ||
end | ||
|
||
def address_components | ||
@data | ||
end | ||
|
||
def state_code | ||
@data['provinciecode'] | ||
end | ||
|
||
def postal_code | ||
@data['postcode'] | ||
end | ||
|
||
def country | ||
"Netherlands" | ||
end | ||
|
||
def country_code | ||
"NL" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,245 @@ | ||
{ | ||
"response": { | ||
"numFound": 601698, | ||
"start": 0, | ||
"maxScore": 21.486404, | ||
"numFoundExact": true, | ||
"docs": [ | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "adres", | ||
"woonplaatsnaam": "Amsterdam", | ||
"wijkcode": "WK0363AD", | ||
"huis_nlt": "147", | ||
"openbareruimtetype": "Weg", | ||
"buurtnaam": "Nieuwe Kerk e.o.", | ||
"gemeentecode": "0363", | ||
"rdf_seealso": "http://bag.basisregistraties.overheid.nl/bag/id/nummeraanduiding/0363200000218908", | ||
"weergavenaam": "Nieuwezijds Voorburgwal 147, 1012RJ Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "adr-563f90756e46d1c554b4ab00ac61b932", | ||
"gekoppeld_perceel": [ | ||
"ASD04-F-2749" | ||
], | ||
"gemeentenaam": "Amsterdam", | ||
"buurtcode": "BU0363AD05", | ||
"wijknaam": "Burgwallen-Nieuwe Zijde", | ||
"identificatie": "0363010000758545-0363200000218908", | ||
"openbareruimte_id": "0363300000004690", | ||
"waterschapsnaam": "Hoogheemraadschap Amstel Gooi en Vecht", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RJ", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89089949 52.37316398)", | ||
"nummeraanduiding_id": "0363200000218908", | ||
"waterschapscode": "11", | ||
"adresseerbaarobject_id": "0363010000758545", | ||
"huisnummer": 147, | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121202 487370)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 21.486404 | ||
}, | ||
{ | ||
"bron": "BAG/NWB", | ||
"woonplaatscode": "3594", | ||
"type": "weg", | ||
"woonplaatsnaam": "Amsterdam", | ||
"nwb_id": "032937", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"rdf_seealso": "http://bag.basisregistraties.overheid.nl/bag/id/openbare-ruimte/0363300000004690", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "weg-11b9db917ce90372930af5e6a9188478", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89091865 52.37381873)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121203.803 487442.84)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 20.103004 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RC Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-5f1195a7f9fe6a99b1571d7c15c64138", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RC_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RC", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89522341 52.37696711)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121499.326 487791.141)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RD Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-89dbb53c07add38657bf17abe6dd49c4", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RD_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RD", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.8938645 52.3761153)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121406.149 487696.995)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RE Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-f303e0cf9b29083a2beb757476ce8948", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RE_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RE", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89252497 52.37521114)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121314.248 487597.017)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RG Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-e6324266fae865a1d66861a5118ff3af", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RG_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RG", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89177932 52.37453055)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121262.955 487521.639)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RH Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-57b324f3b15c70ac7a8641c10b318c6a", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RH_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RH", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89161743 52.37435875)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121251.8 487502.6)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RJ Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-def6647d79cbce522864726af4c2af74", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RJ_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RJ", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89133064 52.3739109)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121231.93 487452.904)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RK Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-1fbacacc892befcdaa4e46f475e5a16a", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RK_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RK", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.89097665 52.37221864)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121206.534 487264.783)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
}, | ||
{ | ||
"bron": "BAG", | ||
"woonplaatscode": "3594", | ||
"type": "postcode", | ||
"woonplaatsnaam": "Amsterdam", | ||
"openbareruimtetype": "Weg", | ||
"gemeentecode": "0363", | ||
"weergavenaam": "Nieuwezijds Voorburgwal, 1012RL Amsterdam", | ||
"straatnaam_verkort": "Nieuwezijds Voorburgwal", | ||
"id": "pcd-540b9459499a7a25fa74d39a80072570", | ||
"gemeentenaam": "Amsterdam", | ||
"identificatie": "0363300000004690_1012RL_3594", | ||
"openbareruimte_id": "0363300000004690", | ||
"provinciecode": "PV27", | ||
"postcode": "1012RL", | ||
"provincienaam": "Noord-Holland", | ||
"centroide_ll": "POINT(4.8911854 52.37137729)", | ||
"provincieafkorting": "NH", | ||
"centroide_rd": "POINT(121220.109 487171.074)", | ||
"straatnaam": "Nieuwezijds Voorburgwal", | ||
"score": 18.053778 | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"response": { | ||
"numFound": 0, | ||
"start": 0, | ||
"maxScore": 21.486404, | ||
"numFoundExact": true, | ||
"docs": [] | ||
} |
Oops, something went wrong.