stefanzweifel/php-swiss-cantons

Zip-code 9496 isn't swiss

Closed this issue ยท 11 comments

The zip-code 9496 is part of Liechtenstein and not swiss.
https://en.wikipedia.org/wiki/Balzers
So the $cantonManager->getByZipcode(9496) throws an exception with message Couldn't find Canton for given abbreviation..

Because this package is about the swiss this zip-code shouldn't be part of it at all!?

Hm, I've added the Zipcode Search back in 2016 (#6) and I honestly can't remember why I've kept the LI zipcodes in the dataset.
I guess I was just to lazy to remove them from the data set from the federal website. ๐Ÿ˜…

You would suggest removing the Liechtenstein zipcodes from the package, right?
I think we could do that. However it would require a new major version. The ZipcodeSearch might have been used by consumers directly, and I don't want to break existing usages.

yes, my problem is that the zipcode search gives a "valid" zipcode entry which isn't resolvable to a canton.
This case has even it's own unittest - exactly describing this. Successfull zipcode search but failing canton resolve.

Yeah. That's a weird test to have.
And as you mentioned, the package is called "swiss cantons". Makes sense to remove traces of Liechtenstein from the dataset.

I will work on this over the next few days (with some other little internal improvements: Move to GitHub Actions, types) and will tag a new major version soon.

Will also see if I can update the dataset. Between 2016 and now, the zipcodes for some cities probably have changed too.

possibly you can also refactor the datasets a bit. The zip-code should only be a mapping objects instead of these full blown zip-code/city mappings.
Or do you want to extend to php-swiss?^^

But there isn't any machine readable page you could parse?
We do something similar for https://github.com/spatie/schema-org - generate the src code from a RDFa file.

Don't know how reliable this table and HTML structure is - but for example parse this table: https://en.wikipedia.org/wiki/Cantons_of_Switzerland#Names_in_national_languages

I've written some automated scripts at my day job, to keep our data sets up to date. One of those data sets contains zipcodes, cities and cantons. Have to check what I can reuse in this package.

Wikipedia is not the safest source for that data. The link mentioned in the README points to a 404 page. I guess we will probably use the dataset provided by the Swiss Post Office: https://swisspost.opendatasoft.com/explore/dataset/politische-gemeinden_v2/table/

I've removed the Liechtenstein Zipcodes in #31. I will tag a new minor version shortly.
Will create an issue to find an easy way to keep the data set up to date soon too.

I already started working on a v3:

  • Dropped support for php 7.2 and php 7.3
  • Added Type Hints, Return Hints
  • Cleaned up some internal code

Thanks @stefanzweifel ! We've updated our package to require your latest version and everything works fine. :)
https://github.com/elbgoods/laravel-swiss-canton-rule/releases/tag/0.2.0