stefanzweifel/php-swiss-cantons

Allow search by zip code

wittwerch opened this issue · 6 comments

It would be helpful if a canton could also be found by zip code.

$canton = $cantonManager->getByZipCode(8001);

Great idea, but then the package would have to ship with a complete "Database" containing all Swiss Zipcodes (there are currently 4250 zipcodes).

Or we could try to use this pattern.

I think it's not possible to avoid storing a mapping table in the package, because there is no pattern in it.

Please have a look at that dataset: http://www.bfs.admin.ch/bfs/portal/de/index/infothek/nomenklaturen/blank/blank/gem_liste/04.html

Example from the dataset
image

1290 => GE
1291 => VD
1292 => GE

Thanks for the link. I will see what I can do. If you have already an idea, on how to implement this: PRs are always welcome :)

Just a quick follow-up question: Can you describe in which scenario / context you're going to use this feature?

I want to auto-complete the profile of a user. The user has to do a registration and I want to keep it simple. Canton is something that I can "compute", so I don't want to ask the user for it.

I just merged my PR and tagged a new release.