-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix cities.json generation - Remove canton from cities' names #51
base: main
Are you sure you want to change the base?
Conversation
d4b5aff
to
e43a658
Compare
Thanks for the PR. For example, there are 4 cities called "Buchs" in Switzerland. One in AG, one in LU, one in SG and one in ZH. Could you maybe provide a code example where you run into an issue? |
Oh ! I found that Biel-Benken real canton is Bâle... So event this record is wrong :-/ |
Yeah, just wanted to mention that. :) In this specific example with "Biel-Benken" the dataset by geo.admin.ch seems wrong. Maybe we can somehow get to a dataset by the Swiss Post. That's ususally very up to date; but the Swiss Post seems to have taken down the public site. As you can see, not all data set are equal. For example here are results for cities that are used when calculating insurance premiums. This is the city where I live in. I don't know why the datasource has "Rümlang" in here, as this is a neighbouring city that has nothing to do with my city. {
"data":
[
{
"name": "Glattbrugg",
"zipcode": 8152,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Bülach",
"admin_area_level_3": "Opfikon",
"federal_statistical_office_number": 66,
"alternate_names":
[]
},
{
"name": "Glattbrugg",
"zipcode": 8152,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Zürich",
"admin_area_level_3": "Zürich",
"federal_statistical_office_number": 261,
"alternate_names":
[]
},
{
"name": "Glattbrugg",
"zipcode": 8152,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Dielsdorf",
"admin_area_level_3": "Rümlang",
"federal_statistical_office_number": 97,
"alternate_names":
[]
},
{
"name": "Glattpark (Opfikon)",
"zipcode": 8152,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Bülach",
"admin_area_level_3": "Opfikon",
"federal_statistical_office_number": 66,
"alternate_names":
[]
},
{
"name": "Opfikon",
"zipcode": 8152,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Bülach",
"admin_area_level_3": "Opfikon",
"federal_statistical_office_number": 66,
"alternate_names":
[]
}
]
} Or here are the results for "Buchs". {
"data":
[
{
"name": "Buchs AG",
"zipcode": 5033,
"admin_area_level_1": "AG",
"admin_area_level_2": "Aarau",
"admin_area_level_3": "Buchs (AG)",
"federal_statistical_office_number": 4003,
"alternate_names":
[]
},
{
"name": "Buchs LU",
"zipcode": 6211,
"admin_area_level_1": "LU",
"admin_area_level_2": "Willisau",
"admin_area_level_3": "Dagmersellen",
"federal_statistical_office_number": 1125,
"alternate_names":
[]
},
{
"name": "Buchs SG",
"zipcode": 9470,
"admin_area_level_1": "SG",
"admin_area_level_2": "Werdenberg",
"admin_area_level_3": "Buchs (SG)",
"federal_statistical_office_number": 3271,
"alternate_names":
[
{
"name": "Burgerau",
"name_short": "Burgerau",
"zipcode": 9470
},
{
"name": "Räfis",
"name_short": "Räfis",
"zipcode": 9470
}
]
},
{
"name": "Buchs SG",
"zipcode": 9470,
"admin_area_level_1": "SG",
"admin_area_level_2": "Werdenberg",
"admin_area_level_3": "Sevelen",
"federal_statistical_office_number": 3275,
"alternate_names":
[
{
"name": "Burgerau",
"name_short": "Burgerau",
"zipcode": 9470
},
{
"name": "Räfis",
"name_short": "Räfis",
"zipcode": 9470
}
]
},
{
"name": "Buchs ZH",
"zipcode": 8107,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Dielsdorf",
"admin_area_level_3": "Buchs (ZH)",
"federal_statistical_office_number": 83,
"alternate_names":
[]
},
{
"name": "Buchs ZH",
"zipcode": 8107,
"admin_area_level_1": "ZH",
"admin_area_level_2": "Dielsdorf",
"admin_area_level_3": "Otelfingen",
"federal_statistical_office_number": 94,
"alternate_names":
[]
},
{
"name": "Büchslen",
"zipcode": 3215,
"admin_area_level_1": "FR",
"admin_area_level_2": "See",
"admin_area_level_3": "Murten",
"federal_statistical_office_number": 2275,
"alternate_names":
[
{
"name": "Buchillon",
"name_short": "Buchillon",
"zipcode": 3215
}
]
}
]
} I'm currently torn, if we should go a step further and introduce the "admin area levels" and/or ISO 3166 and ISO 3166-2 to this project as well. Maybe we can include also the data from other projects like |
Is it acceptable for you if, in that case the city name ends with a canton, we keep only the records where the canton found in the cit name matches with the canton in the record ? |
@kira0269 Yeah I think that could work. We would remove cases like "Biel-Benken" from the dataset. On the other hand, I'm not the biggest fan of manipulating source files in that way. But you seem to be the only one using the library or this specific class; so feel free to submit a PR / update this PR. Is there any way you could share / describe how you use this package in your project? Hearing how other use the package would help immensely when making decisions or shaping features. |
Sure. In my application, we generate documents for customers. I need to find the customer's canton, so I use this library in order to match a canton with the customer's data, like the zipcode or the city name if it failed with the zipcode. I really need to find the canton as good as possible, and i want to avoid false positive. I choose by myself what to do if I don't find a specific canton. |
A quick update on this. I just sent an email to the Open-Data team of the Swiss post to check-in, if there is a way to get access to the zipcode data. I think switching back to their data set would solve a couple of problems which popped up, after we've switched to the Swisstopo dataset. I hope we get an answer soon. |
The email bounced / I've got the following automated message back:
It looks like their public APIs do not reflect what we need. Will forward my mail to another department. |
Many of cities from the
cities.json
end with a canton abbreviation, which is not always the same as the indicated city's canton.Also, it improves the search by zipcode and city name.
This fix removes all potential canton abbreviation from cities names.