Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zipcode and Canton is not a One-to-One relationship #46

Closed
kira0269 opened this issue May 17, 2024 · 4 comments
Closed

Zipcode and Canton is not a One-to-One relationship #46

kira0269 opened this issue May 17, 2024 · 4 comments

Comments

@kira0269
Copy link
Contributor

kira0269 commented May 17, 2024

Hi,

I'm using this library since a few months, thank you for your work !

But unfortunately, some cases don't work when guessing the canton from the zipcode.
In fact, in Switzerland, a zipcode (NPA) does not contain the information of a specific canton. It's based on geographical and physical information, like train endpoint. For some zipcode, you can have different cities, which are in different cantons.

Example: 1290 is assigned to Chavanne-les-bois in the canton of Vaud, and Versoix in the canton of Geneva.

It's the same issue with zipcode and cities: a city can have several zipcode...
Example: Kefikon has a zipcode for its part in Thurgovie canton et a zipcode for its part in Zurich canton..

Conclusion
Is it possible to have a system covering all cases ? If not, it would be necessary to add this information as a warning in the library documentation.

@stefanzweifel stefanzweifel changed the title NPA and Canton is not a One-to-One relationship Zipcode and Canton is not a One-to-One relationship May 17, 2024
@stefanzweifel
Copy link
Owner

Yeah, this library is not perfect. :)
And as you mention, the whole system is not perfect. I myself live in a city which has 3 different names and the zipcode – depending on the government data source – belongs to up to 4 different cities.

Is it possible to have a system covering all cases?

Zipcode search was an aftertought for this package and has been added in #6 many years ago. As you mention, the code currently assumes that a zipcode has a one-to-one relationship with a canton.

What we could do, is rewrite the package so that certain methods return an array/collection of Cantons/Zipcodes.
I currently work on other projects, but could implement this in the near future.

The consumer of the package then still have to figure out, which canton to choose.
I don't know how you use the package, but in your example with 1290, you would somehow have to decide which canton to use: Vaud or Geneva.

That's not something the package can solve based on a single data point (zipcode).

@kira0269
Copy link
Contributor Author

kira0269 commented May 17, 2024

That's not something the package can solve based on a single data point (zipcode).

I totally agree. To determine the canton, we'd need at least the zipcode and the city name. But is there any city identifier other than the name ? Or at least a reference liste ?
Otherwise, it will be hard to search with an not-standardized name..

@stefanzweifel
Copy link
Owner

As you mentioned in #33, the link in the README/issue points to a 404 now. I haven't figured out yet, where the Swiss Post now publishes these values.

I found this asset on opendata.swiss, but didn't have the time yet to review the data.
https://opendata.swiss/de/dataset/amtliches-ortschaftenverzeichnis-mit-postleitzahl-und-perimeter

@stefanzweifel
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants