3 ms·
I looked at a few network requests and you are fetching the country code for some locations, is there some docu on this how/why you are doing so? I soon perhaps
by carstenhag 3y ago
I looked at a few network requests and you are fetching the country code for some locations, is there some docu on this how/why you are doing so? I soon perhaps also have to implement a simple "is this location in country XY" check and it seems both trivial and complex at the same time to solve, without a full map-aware database/system.
https://github.com/pietervdvn/MapComplete-data/tree/main/latlon2country https://github.com/pietervdvn/MapComplete-data/tree/main/lat...
- pietervdvn 3y agoYeah, the country location is a requirement to show the opening hours. The library (https://github.com/opening-hours/opening_hours.js https://github.com/opening-hours/opening_hours.js) is aware of holidays in many countries, but for that it needs to know what country a POI is in. The country awareness source code is here: https://github.com/pietervdvn/latlon2country https://github.com/pietervdvn/latlon2country The idea: I've taken all the country boundaries from OSM (via nominatim); I slice them in four parts. If the resulting geojson is too big, I slice this again until I have small geojsons, suitable to download. If you know the zoomlevel and location, one can use the standard slippy-tile-index to fetch the correct tile. (Alternatively, if the entire tile is within a country, it'll just return the country code) However, the client also needs to know what zoomlevel there is. For that, I built a search tree. It's been a while though, so I've forgotten some of the details ;)