Commit 435da2ca authored by Volker Krause's avatar Volker Krause
Browse files

Exclude the polar regions from the timezone index

This allows us to move about 20% of the available z-order curve length
to more relevant regions, increasing the precision there.

This however further increases the aspect ration to ~2.2, it might
therefore make sense to use an additional bit for an initial split
on the longitude to get this back to around 1. While this doesn't
generally break the approach, the spatial proximity property of the
z-order curve degrades a bit with this, reducing the encoding efficiency
of this.
parent 493ababa
...@@ -23,8 +23,10 @@ zDepth = 11 # minimum tile size is 1/(2^zdepth), amount of bits needed to store ...@@ -23,8 +23,10 @@ zDepth = 11 # minimum tile size is 1/(2^zdepth), amount of bits needed to store
# #
xStart = -180 xStart = -180
xRange = 360 xRange = 360
yStart = -90 # cut out artic regions (starting at 65°S and 80°N), that saves about 20% z-order curve coverage which we
yRange = 180 # can better use to increase precision in more relevant areas
yStart = -65
yRange = 145
xStep = xRange / (1 << zDepth) xStep = xRange / (1 << zDepth)
yStep = yRange / (1 << zDepth) yStep = yRange / (1 << zDepth)
......
...@@ -55,8 +55,13 @@ KnowledgeDb::CountryId KnowledgeDb::countryForTimezone(KnowledgeDb::Tz tz) ...@@ -55,8 +55,13 @@ KnowledgeDb::CountryId KnowledgeDb::countryForTimezone(KnowledgeDb::Tz tz)
#if 0 #if 0
KnowledgeDb::Tz KnowledgeDb::timezoneForCoordinate(float lat, float lon) KnowledgeDb::Tz KnowledgeDb::timezoneForCoordinate(float lat, float lon)
{ {
// see arctic latitude filter in the generator script, we only cover 65°S to 80°N
if (lat < -65.0f || lat > 80.0f) {
return Tz::Undefined;
}
const uint32_t x = ((lon + 180.0) / 360.0) * (1 << timezone_index_zDepth); const uint32_t x = ((lon + 180.0) / 360.0) * (1 << timezone_index_zDepth);
const uint32_t y = ((lat + 90.0) / 180.0) * (1 << timezone_index_zDepth); const uint32_t y = ((lat + 65.0) / 145.0) * (1 << timezone_index_zDepth);
uint32_t z = 0; uint32_t z = 0;
for (int i = timezone_index_zDepth - 1; i >= 0; --i) { for (int i = timezone_index_zDepth - 1; i >= 0; --i) {
z <<= 1; z <<= 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment