-
Notifications
You must be signed in to change notification settings - Fork 33
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
Region from coordinates - extended look #2426
Comments
In 2019, following #1977, I had been researching a more flexible approach for area codes and shapes. That resulted in tables defined as follow:
In short, above tables should allow using shapes and region codes from different sources (iso3166-2, NUTS, FIPS etc) with uniformed iso3166-1 alpha-2 country codes, where config should set a priority of codes in case of multiple matches. In addition I had written example scripts for fetching area shapes and codes from OSM overpass and tested effective SQL queries for searching for area codes by location. I had abandoned this work because of lack of interest in introducing the solutions into opencaching code. |
At OCRO, having NUTS data, my primary interest is to associate a different adm_level then the one currently hardcoded.
OCRO has data for adm_level 0, 1, 2, 3 |
I'm not sure how geometries are stored in the other formats and/or if conversions would be required (looking at your table design). I wouldn't simplify geometries because it could lead to all sorts of interesting (and potentially frustrating) results near boundaries. Besides, OC focuses on one country, there is no point in mapping the entire workd in the database. min_lon, max_lon, etc, were designed to be some sort of bounding box optimization? AFAIK opencaching-pl code at some point (in the past - 2014-2017 at least) did a separate PHP implementation to check "inside shape proper" as if there was no (or properly working) Also, since I got the NUTS data from one of the OCPL developers, I believe it would be interesting and useful to put together some procedures to obtain/update such data. |
P.S. I'm also trying to dust off my SQL and basic PHP knowledge ... :-) |
Geometries are geometries, ie. simply shapes regardless of source of origin, there is no conversion. max_ and min_ were added because in time of testing with database filled up with thousands of shape a query This could have changed because in newer mysql/mariadb version spatial searching could be much better optimized. I cannot do comparisons by now because I would have to recreate database and fill up area_shapes table with correct data. I didn't tested As for adm_levels - the table is open for any level you can provide, its usage in code is still open: f.ex. use a maximal adm_level from matching codes/shapes but not greater than configured one. |
I've looked nito the code again. Some has changed since my last forray into this. src/Models/Coordinates/NutsLocation.php This uses ST_WITHIN in the SQL query. I've done some tests manually, this query returns (on my database and coordinates from Romania) levels 0,1,2,3.
Note: returning Not sure why
Is
At least in the data I have (for most countries of Europe) appears to have data at all levels for most countries. OCUS however has data for levels 0 and 2 only. Does this also favour level 2 ?
|
…ic sorting in NutsLocation Introduce new static property `regionLevelPreferenceByCountry` to enable country-specific NUTS region sorting preferences. Refactor `getRegionName` and `getRegionsListByCountryCode` to use `regionLevelPreferenceByCountry` for improved sorting based on regional levels. Changes: - Added `regionLevelPreferenceByCountry` with custom region priority for specific countries (e.g., Romania). - Updated `getRegionName` to dynamically adjust sorting based on `regionLevelPreferenceByCountry`. - Modified `getRegionsListByCountryCode` to prioritize regions by level if set for country.
Given the recent hickup described in issue #2423 I'd like to open a discussion and maybe make some improvements based on OC NODE specific circumstances.
On OCRO I have NUTS data. Editing a cache automatically (via JS and AJAX) sets the "Region" field. I assume it's done via NUTS.
Currently pressing "Region from coordinates" yields an informative box with the following sources:
There are several possible sources for this info, some requiring API key and possibly payment. Although this is a volunteer and community supported project (ie each OC national site), it might be concievable that OC site X might prefer evena subscription based service.
As a general concept, I would suggest the following strategy:
smth like:
This concept would make handling per site much more straightforward.
On the other hand, OCRO is still affected by #103 as our "judeţ" zoning is the appropriate one, but we can't configure NUTS, it's hardcoded and changing anything would break other nodes.
Also see #1838
right now NUTS answer and Nominatim answer differ:
In the least, configurable NUTS layer would be of great help.
The text was updated successfully, but these errors were encountered: