Open romain-sen opened 10 months ago
Seeing the states data here : https://github.com/dr5hn/countries-states-cities-database/blob/master/csv/states.csv
The cities match with the states of type : "metropolitan region", but all the other states (state in these region) have no cities matching.
A quick fix would have been to filter the state to only get the "metropolitan region" ones with their matching cities, but we don't have access to the type in the code...
The complete fix : make the cities match with the region and with the other state.
+1 here
@dosubot Please help me fix this and raise a PR.
I understand the issue you're facing with the mismatch of state codes for cities in France. This seems to be a known issue as there's an open issue titled France No link between city and state databases which was last updated on December 17, 2023.
To resolve this, you would need to update the state codes in your database to match the actual regions or departments. Here's a general approach to update the state codes for France, specifically for Paris to match 'IDF' for 'Ile-de-France':
Identify the Correct Structure for France: Ensure your XML structure accommodates country, state (or region), and city levels. France uses regions and departments, where 'Ile-de-France' is a region and 'Paris' is both a city and a department within this region.
Update or Add the Correct Entries: Look for or add an entry for 'Ile-de-France' and ensure Paris is correctly listed under it with the right state code. If '75C' is an incorrect code and you want to use 'IDF' for 'Ile-de-France', you would update the state code accordingly.
Sample XML Update for Paris in Ile-de-France: Assuming your XML structure supports regions and cities, you might add or update entries similar to the following:
<state>
<id>XXXX</id>
<name>Ile-de-France</name>
<country_id>FR</country_id> <!-- Assuming 'FR' is the country code for France -->
<country_code>FR</country_code>
<country_name>France</country_name>
<state_code>IDF</state_code>
<type>Region</type>
<!-- Add latitude and longitude if needed -->
</state>
<city>
<id>YYYY</id>
<name>Paris</name>
<state_id>XXXX</state_id> <!-- Match the ID of Ile-de-France -->
<state_code>IDF</state_code>
<country_id>FR</country_id>
<country_code>FR</country_code>
<country_name>France</country_name>
<!-- Add latitude and longitude if needed -->
</city>
Adjust According to Your Schema: The above is a simplified example. Your actual implementation may require adjustments based on your schema, especially if you have separate elements or attributes for regions, departments, and cities.
Automate the Update Process: If you have many entries to update, consider writing a script to automate the process. This script would parse your XML, find entries that need updating (e.g., cities in France with incorrect state codes), and update them accordingly.
Remember, the key steps are identifying the correct structure for your data, ensuring the entries for France's regions and cities are accurate, and then updating the state codes to reflect the actual administrative divisions.
As for the structure of the database, the countries
table includes fields for various attributes of countries such as id
, name
, iso3
, iso2
, phonecode
, capital
, currency
, and more. The countries are linked to regions and subregions through the region_id
and subregion_id
fields, respectively. These fields are foreign keys that reference the id
field in the regions
and subregions
tables. This setup allows for a hierarchical structure where countries are associated with their respective regions and subregions.
I hope this helps! If you need further assistance, feel free to ask.
You cannot find the cities of Paris for instance because when you select Paris, you get the state code of '75C' but the cities have the state code 'IDF' for 'Ile-de-France'.