Closed milan-fabian closed 1 year ago
Looks good. I am just a bit worried that the count
parameter is getting more and more inaccurate. But to fix this a larger rewrite is required.
Can you add a check, that the searched area actually is an area or country:
areaIds = database.search(areaName, languageId: Int32(languageId), maxCount: 10).compactMap({
guard ["ADM1","ADM2","ADM3","ADM4","PCLI"].contains(database.geonames.geonames[$0.0]?.featureCode) else {
return nil
}
return $0.0
})
@patrick-zippenfenig
Looks good. I am just a bit worried that the count parameter is getting more and more inaccurate. But to fix this a larger rewrite is required.
I was trying to come up with a better way, for example I tried adding new entries into the index in format cityName, countryName
, but the index was getting too big. I think the ultimate solution would be to use something more advanced than just an index map.
Can you add a check, that the searched area actually is an area or country:
Good idea, I just pushed a commit with this change.
Thanks! Merged. I will also deploy it in the next moments
The input string "name" is split by comma character (","), first part is used for the original search, seconds part is used for separate search for administration areas and countries.
This can be used for example to search for city Queenstown in New Zealand with query "/v1/search?name=Queenstown,New Zealand".
If the input string doesn't contain comma, it works as previously.
Partially solves https://github.com/open-meteo/open-meteo/issues/125.