1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al. 3 * This file is part of Overpass_API. 5 * Overpass_API is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU Affero General Public License as 7 * published by the Free Software Foundation, either version 3 of the 8 * License, or (at your option) any later version. 10 * Overpass_API is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 15 * You should have received a copy of the GNU Affero General Public License 16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>. 19#ifndef DE__OSM3S___OVERPASS_API__CORE__INDEX_COMPUTATIONS_H 20#define DE__OSM3S___OVERPASS_API__CORE__INDEX_COMPUTATIONS_H 22#include "../../template_db/ranges.h" 23#include "basic_types.h" 30inline uint32 ll_upper(uint32 ilat, uint32 ilon); 31inline uint32 ll_upper_(uint32 ilat, int32 ilon); 32inline uint32 upper_ilat(uint32 quadtile); 33inline uint32 upper_ilon(uint32 quadtile); 34inline uint32 ilat(uint32 ll_upper, uint32 ll_lower); 35inline int32 ilon(uint32 ll_upper, uint32 ll_lower); 37inline uint32 calc_index(const std::vector< uint32 >& node_idxs); 38inline std::pair< Uint32_Index, Uint32_Index > calc_bbox_bounds(Uint31_Index way_rel_idx); 39inline std::vector< Uint32_Index > calc_node_children(const std::vector< uint32 >& way_rel_idxs); 40inline std::vector< Uint31_Index > calc_children(const std::vector< uint32 >& way_rel_idxs); 41inline std::vector< uint32 > calc_parents(const std::vector< uint32 >& node_idxs); 43inline Ranges< Uint32_Index > calc_ranges(double south, double north, double west, double east); 45inline void recursively_calc_ranges 46 (uint32 south, uint32 north, int32 west, int32 east, 47 uint32 bitlevel, Ranges< Uint32_Index >& ranges); 49/** ------------------------------------------------------------------------ */ 53 bool operator()(uint32 a, uint32 b) const 5512593832108 q return (a & 0x7fffffff) < (b & 0x7fffffff); 59inline uint32 ll_upper(uint32 ilat, uint32 ilon) 6120511671417 q ilat &= 0xffff0000; 6320511671417 q ilat &= 0xff00ff00; 6520511671417 q ilat &= 0xf0f0f0f0; 6720511671417 q ilat &= 0xcccccccc; 6920511671417 q ilat &= 0xaaaaaaaa; 7120511671417 q ilon &= 0xffff0000; 7320511671417 q ilon &= 0xff00ff00; 7520511671417 q ilon &= 0xf0f0f0f0; 7720511671417 q ilon &= 0xcccccccc; 7920511671417 q ilon &= 0xaaaaaaaa; 8120511671417 q return ilat | (ilon>>1); 84inline uint32 ll_upper_(uint32 ilat, int32 ilon) 862063797320 q return (ll_upper(ilat, ilon) ^ 0x40000000); 89inline uint32 upper_ilat(uint32 quadtile) 9114306562418 q uint32 result = (quadtile & 0xaaaaaaaa)>>1; 9214306562418 q result |= (result>>1); 9314306562418 q result &= 0x33333333; 9414306562418 q result |= (result>>2); 9514306562418 q result &= 0x0f0f0f0f; 9614306562418 q result |= (result>>4); 9714306562418 q result &= 0x00ff00ff; 9814306562418 q result |= (result>>8); 10014306562418 q return result & 0xffff; 103inline uint32 upper_ilon(uint32 quadtile) 10514306562418 q uint32 result = (quadtile & 0x55555555); 11414306562418 q return result & 0xffff; 117inline uint32 calc_index(const std::vector< uint32 >& node_idxs) 122 // Calculate the bounding box of the appearing indices. 12422448963216 q std::vector< uint32 >::const_iterator it = node_idxs.begin(); 12522448963216 q uint32 lat_min = *it & 0x2aaaaaaa; 12622448963216 q uint32 lat_max = lat_min; 12722448963216 q uint32 lon_min = *it & 0x55555555; 12822448963216 q uint32 lon_max = lon_min; 1320 if (*it & 0x00000001) 1340 lat_min = *it & 0x2aaaaaa8; 1350 lon_min = *it & 0x55555554; 1360 lat_max = ll_upper((upper_ilat(lat_min) + 3)<<16, 0); 1370 lon_max = ll_upper(0, (upper_ilon(lon_min) + 3)<<16); 1390 else if (*it & 0x00000002) 1410 lat_min = *it & 0x2aaaaa80; 1420 lon_min = *it & 0x55555540; 1430 lat_max = ll_upper((upper_ilat(lat_min) + 0xf)<<16, 0); 1440 lon_max = ll_upper(0, (upper_ilon(lon_min) + 0xf)<<16); 1460 else if (*it & 0x00000004) 1480 lat_min = *it & 0x2aaaa800; 1490 lon_min = *it & 0x55555400; 1500 lat_max = ll_upper((upper_ilat(lat_min) + 0x3f)<<16, 0); 1510 lon_max = ll_upper(0, (upper_ilon(lon_min) + 0x3f)<<16); 1530 else if (*it & 0x00000008) 1550 lat_min = *it & 0x2aaa8000; 1560 lon_min = *it & 0x55554000; 1570 lat_max = ll_upper((upper_ilat(lat_min) + 0xff)<<16, 0); 1580 lon_max = ll_upper(0, (upper_ilon(lon_min) + 0xff)<<16); 1600 else if (*it & 0x00000010) 1620 lat_min = *it & 0x2aa80000; 1630 lon_min = *it & 0x55540000; 1640 lat_max = ll_upper((upper_ilat(lat_min) + 0x3ff)<<16, 0); 1650 lon_max = ll_upper(0, (upper_ilon(lon_min) + 0x3ff)<<16); 1670 else if (*it & 0x00000020) 1690 lat_min = *it & 0x2a800000; 1700 lon_min = *it & 0x55400000; 1710 lat_max = ll_upper((upper_ilat(lat_min) + 0xfff)<<16, 0); 1720 lon_max = ll_upper(0, (upper_ilon(lon_min) + 0xfff)<<16); 1740 else if (*it & 0x00000040) 1760 lat_min = *it & 0x28000000; 1770 lon_min = *it & 0x54000000; 1780 lat_max = ll_upper((upper_ilat(lat_min) + 0x3fff)<<16, 0); 1790 lon_max = ll_upper(0, (upper_ilon(lon_min) + 0x3fff)<<16); 1810 else // *it == 0x80000080 18544897952216 q for (++it; it != node_idxs.end(); ++it) 1940 if (*it & 0x00000001) 1960 lat = *it & 0x2aaaaaa8; 1970 lon = *it & 0x55555554; 1980 lat_u = ll_upper((upper_ilat(lat) + 3)<<16, 0); 1990 lon_u = ll_upper(0, (upper_ilon(lon) + 3)<<16); 2010 else if (*it & 0x00000002) 2030 lat = *it & 0x2aaaaa80; 2040 lon = *it & 0x55555540; 2050 lat_u = ll_upper((upper_ilat(lat) + 0xf)<<16, 0); 2060 lon_u = ll_upper(0, (upper_ilon(lon) + 0xf)<<16); 2080 else if (*it & 0x00000004) 2100 lat = *it & 0x2aaaa800; 2110 lon = *it & 0x55555400; 2120 lat_u = ll_upper((upper_ilat(lat) + 0x3f)<<16, 0); 2130 lon_u = ll_upper(0, (upper_ilon(lon) + 0x3f)<<16); 2150 else if (*it & 0x00000008) 2170 lat = *it & 0x2aaa8000; 2180 lon = *it & 0x55554000; 2190 lat_u = ll_upper((upper_ilat(lat) + 0xff)<<16, 0); 2200 lon_u = ll_upper(0, (upper_ilon(lon) + 0xff)<<16); 2220 else if (*it & 0x00000010) 2240 lat = *it & 0x2aa80000; 2250 lon = *it & 0x55540000; 2260 lat_u = ll_upper((upper_ilat(lat) + 0x3ff)<<16, 0); 2270 lon_u = ll_upper(0, (upper_ilon(lon) + 0x3ff)<<16); 2290 else if (*it & 0x00000020) 2310 lat = *it & 0x2a800000; 2320 lon = *it & 0x55400000; 2330 lat_u = ll_upper((upper_ilat(lat) + 0xfff)<<16, 0); 2340 lon_u = ll_upper(0, (upper_ilon(lon) + 0xfff)<<16); 2360 else if (*it & 0x00000040) 2380 lat = *it & 0x28000000; 2390 lon = *it & 0x54000000; 2400 lat_u = ll_upper((upper_ilat(lat) + 0x3fff)<<16, 0); 2410 lon_u = ll_upper(0, (upper_ilon(lon) + 0x3fff)<<16); 2430 else // *it == 0x80000080 2480 if (lat_u > lat_max) 2520 if (lon_u > lon_max) 25722448989216 q uint32 lat = *it & 0x2aaaaaaa; 25822448989216 q uint32 lon = *it & 0x55555555; 26220612360216 q else if (lat > lat_max) 26620358909216 q else if (lon > lon_max) 272 // Evaluate the bounding box. 27422448963216 q if ((lat_max == lat_min) && (lon_max == lon_min)) 27516940680215 q return node_idxs.front(); 2775508283216 q uint32 ilat_min = upper_ilat(lat_min); 2785508283216 q uint32 ilat_max = upper_ilat(lat_max); 2795508283216 q uint32 ilon_min = upper_ilon(lon_min); 2805508283216 q uint32 ilon_max = upper_ilon(lon_max); 2825508283216 q if (((ilat_max & 0xfffe) - (ilat_min & 0xfffe) < 4) && 2835508283216 q ((ilon_max & 0xfffe) - (ilon_min & 0xfffe) < 4)) 2843090540214 q return (((lon_min | lat_min) & 0xfffffffc) | 0x80000001); 2862417743214 q if (((ilat_max & 0xfff8) - (ilat_min & 0xfff8) < 0x10) && 2872417743214 q ((ilon_max & 0xfff8) - (ilon_min & 0xfff8) < 0x10)) 288155301212 q return (((lon_min | lat_min) & 0xffffffc0) | 0x80000002); 2902262442211 q if (((ilat_max & 0xffe0) - (ilat_min & 0xffe0) < 0x40) && 2912262442211 q ((ilon_max & 0xffe0) - (ilon_min & 0xffe0) < 0x40)) 29233523211 q return (((lon_min | lat_min) & 0xfffffc00) | 0x80000004); 2942228919164 q if (((ilat_max & 0xff80) - (ilat_min & 0xff80) < 0x100) && 2952228919164 q ((ilon_max & 0xff80) - (ilon_min & 0xff80) < 0x100)) 2967536164 q return (((lon_min | lat_min) & 0xffffc000) | 0x80000008); 2982221383148 q if (((ilat_max & 0xfe00) - (ilat_min & 0xfe00) < 0x400) && 2992221383148 q ((ilon_max & 0xfe00) - (ilon_min & 0xfe00) < 0x400)) 30044402148 q return (((lon_min | lat_min) & 0xfffc0000) | 0x80000010); 302217698185 q if (((ilat_max & 0xf800) - (ilat_min & 0xf800) < 0x1000) && 303217698185 q ((ilon_max & 0xf800) - (ilon_min & 0xf800) < 0x1000)) 30425833685 q return (((lon_min | lat_min) & 0xffc00000) | 0x80000020); 306191864585 q if (((ilat_max & 0xe000) - (ilat_min & 0xe000) < 0x4000) && 307191864585 q ((ilon_max & 0xe000) - (ilon_min & 0xe000) < 0x4000)) 30884651985 q return (((lon_min | lat_min) & 0xfc000000) | 0x80000040); 314inline std::pair< Uint32_Index, Uint32_Index > calc_bbox_bounds(Uint31_Index way_rel_idx) 3160 if (way_rel_idx.val() & 0x80000000) 3220 if (way_rel_idx.val() & 0x00000001) 3240 lat = upper_ilat(way_rel_idx.val() & 0x2aaaaaa8); 3250 lon = upper_ilon(way_rel_idx.val() & 0x55555554); 3280 else if (way_rel_idx.val() & 0x00000002) 3300 lat = upper_ilat(way_rel_idx.val() & 0x2aaaaa80); 3310 lon = upper_ilon(way_rel_idx.val() & 0x55555540); 3340 else if (way_rel_idx.val() & 0x00000004) 3360 lat = upper_ilat(way_rel_idx.val() & 0x2aaaa800); 3370 lon = upper_ilon(way_rel_idx.val() & 0x55555400); 3400 else if (way_rel_idx.val() & 0x00000008) 3420 lat = upper_ilat(way_rel_idx.val() & 0x2aaa8000); 3430 lon = upper_ilon(way_rel_idx.val() & 0x55554000); 3460 else if (way_rel_idx.val() & 0x00000010) 3480 lat = upper_ilat(way_rel_idx.val() & 0x2aa80000); 3490 lon = upper_ilon(way_rel_idx.val() & 0x55540000); 3520 else if (way_rel_idx.val() & 0x00000020) 3540 lat = upper_ilat(way_rel_idx.val() & 0x2a800000); 3550 lon = upper_ilon(way_rel_idx.val() & 0x55400000); 3580 else if (way_rel_idx.val() & 0x00000040) 3600 lat = upper_ilat(way_rel_idx.val() & 0x28000000); 3610 lon = upper_ilon(way_rel_idx.val() & 0x54000000); 3640 else // way_rel_idx.val() == 0x80000080 3710 return std::make_pair(ll_upper(lat<<16, lon<<16), 3720 ll_upper((lat+2*offset-1)<<16, (lon+2*offset-1)<<16)+1); 3740 else if (way_rel_idx.val() > 0xff) 3750 return std::make_pair(way_rel_idx.val(), way_rel_idx.val() + 1); 3770 return std::make_pair(0u, 1u); 381inline std::vector< Uint32_Index > calc_node_children(const std::vector< uint32 >& way_rel_idxs) 3830 std::vector< Uint32_Index > result; 3850 std::vector< std::pair< uint32, uint32 > > ranges; 3870 for (std::vector< uint32 >::const_iterator it = way_rel_idxs.begin(); 3880 it != way_rel_idxs.end(); ++it) 3900 if (*it & 0x80000000) 3980 if (*it & 0x00000001) 4000 lat = upper_ilat(*it & 0x2aaaaaa8); 4010 lon = upper_ilon(*it & 0x55555554); 4040 else if (*it & 0x00000002) 4060 lat = upper_ilat(*it & 0x2aaaaa80); 4070 lon = upper_ilon(*it & 0x55555540); 4100 else if (*it & 0x00000004) 4120 lat = upper_ilat(*it & 0x2aaaa800); 4130 lon = upper_ilon(*it & 0x55555400); 4160 else if (*it & 0x00000008) 4180 lat = upper_ilat(*it & 0x2aaa8000); 4190 lon = upper_ilon(*it & 0x55554000); 4220 else if (*it & 0x00000010) 4240 lat = upper_ilat(*it & 0x2aa80000); 4250 lon = upper_ilon(*it & 0x55540000); 4280 else if (*it & 0x00000020) 4300 lat = upper_ilat(*it & 0x2a800000); 4310 lon = upper_ilon(*it & 0x55400000); 4340 else if (*it & 0x00000040) 4360 lat = upper_ilat(*it & 0x28000000); 4370 lon = upper_ilon(*it & 0x54000000); 4400 else // *it == 0x80000080 4470 ranges.push_back(std::make_pair(ll_upper(lat<<16, lon<<16), 4480 ll_upper((lat+offset-1)<<16, (lon+offset-1)<<16)+1)); 4490 ranges.push_back(std::make_pair(ll_upper(lat<<16, (lon+offset)<<16), 4500 ll_upper((lat+offset-1)<<16, (lon+2*offset-1)<<16)+1)); 4510 ranges.push_back(std::make_pair(ll_upper((lat+offset)<<16, lon<<16), 4520 ll_upper((lat+2*offset-1)<<16, (lon+offset-1)<<16)+1)); 4530 ranges.push_back(std::make_pair(ll_upper((lat+offset)<<16, (lon+offset)<<16), 4540 ll_upper((lat+2*offset-1)<<16, (lon+2*offset-1)<<16)+1)); 4550 for (uint32 i = lat; i <= lat_u; ++i) 4570 for (uint32 j = lon; j <= lon_u; ++j) 4580 result.push_back(ll_upper(i<<16, j<<16)); 4620 ranges.push_back(std::make_pair(*it, (*it) + 1)); 4650 sort(ranges.begin(), ranges.end()); 4670 for (std::vector< std::pair< uint32, uint32 > >::const_iterator it = ranges.begin(); 4680 it != ranges.end(); ++it) 4700 if (pos < it->first) 4720 for (; pos < it->second; ++pos) 4730 result.push_back(pos); 481 Idx_Bbox(uint32 ll_upper) 483152972172 q if (ll_upper & 0x80000000) 485120357168 q if (ll_upper & 0x00000001) 48767336136 q lat = upper_ilat(ll_upper & 0x2aaaaaa8); 48867336136 q lon = upper_ilon(ll_upper & 0x55555554); 49253021162 q else if (ll_upper & 0x00000002) 49453021162 q lat = upper_ilat(ll_upper & 0x2aaaaa80); 49553021162 q lon = upper_ilon(ll_upper & 0x55555540); 4990 else if (ll_upper & 0x00000004) 5010 lat = upper_ilat(ll_upper & 0x2aaaa800); 5020 lon = upper_ilon(ll_upper & 0x55555400); 5060 else if (ll_upper & 0x00000008) 5080 lat = upper_ilat(ll_upper & 0x2aaa8000); 5090 lon = upper_ilon(ll_upper & 0x55554000); 5130 else if (ll_upper & 0x00000010) 5150 lat = upper_ilat(ll_upper & 0x2aa80000); 5160 lon = upper_ilon(ll_upper & 0x55540000); 5170 lat_u = lat + 0x3ff; 5180 lon_u = lon + 0x3ff; 5200 else if (ll_upper & 0x00000020) 5220 lat = upper_ilat(ll_upper & 0x2a800000); 5230 lon = upper_ilon(ll_upper & 0x55400000); 5240 lat_u = lat + 0xfff; 5250 lon_u = lon + 0xfff; 5270 else if (ll_upper & 0x00000040) 5290 lat = upper_ilat(ll_upper & 0x28000000); 5300 lon = upper_ilon(ll_upper & 0x54000000); 5310 lat_u = lat + 0x3fff; 5320 lon_u = lon + 0x3fff; 5340 else // ll_upper == 0x80000080 54432615102 q lat = upper_ilat(ll_upper); 54532615102 q lon = upper_ilon(ll_upper); 551 int compare(const Idx_Bbox& rhs) 553117117158 q bool lhs_bigger = (lat < rhs.lat || lon < rhs.lon || lat_u > rhs.lat_u || lon_u > rhs.lon_u); 554117117158 q bool rhs_bigger = (lat > rhs.lat || lon > rhs.lon || lat_u < rhs.lat_u || lon_u < rhs.lon_u); 555117117158 q return (lhs_bigger<<1) | rhs_bigger; 565inline std::vector< Uint31_Index > calc_children(const std::vector< uint32 >& way_rel_idxs) 5670 std::vector< Uint31_Index > result; 5690 for (std::vector< uint32 >::const_iterator it = way_rel_idxs.begin(); 5700 it != way_rel_idxs.end(); ++it) 5720 if (*it & 0x80000000) 5760 if (!(*it & 0x0000007f)) 5770 result.push_back(0x80000080); 5780 for (int32 i = bbox.lat; i <= (bbox.lat_u - 0x3fff); i += 0x2000) 5800 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0x3fff); j += 0x2000) 5810 result.push_back((ll_upper(i<<16, j<<16) & 0xfc000000) | 0x80000040); 5830 for (int32 i = bbox.lat; i <= (bbox.lat_u - 0xfff); i += 0x800) 5850 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0xfff); j += 0x800) 5860 result.push_back((ll_upper(i<<16, j<<16) & 0xffc00000) | 0x80000020); 5880 for (int32 i = bbox.lat; i <= (bbox.lat_u - 0x3ff); i += 0x200) 5900 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0x3ff); j += 0x200) 5910 result.push_back((ll_upper(i<<16, j<<16) & 0xfffc0000) | 0x80000010); 5930 for (int32 i = bbox.lat; i <= (bbox.lat_u - 0xff); i += 0x80) 5950 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0xff); j += 0x80) 5960 result.push_back((ll_upper(i<<16, j<<16) & 0xffffc000) | 0x80000008); 5980 for (int32 i = bbox.lat; i <= (bbox.lat_u - 0x3f); i += 0x20) 6000 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0x3f); j += 0x20) 6010 result.push_back((ll_upper(i<<16, j<<16) & 0xfffffc00) | 0x80000004); 6030 for (int32 i = bbox.lat; i <= (bbox.lat_u - 0xf); i += 8) 6050 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0xf); j += 8) 6060 result.push_back((ll_upper(i<<16, j<<16) & 0xffffffc0) | 0x80000002); 6080 for (int32 i = bbox.lat; i <= (bbox.lat_u - 3); i += 2) 6100 for (int32 j = bbox.lon; j <= (bbox.lon_u - 3); j += 2) 6110 result.push_back((ll_upper(i<<16, j<<16) & 0xfffffffc) | 0x80000001); 6130 for (int32 i = bbox.lat; i <= bbox.lat_u; ++i) 6150 for (int32 j = bbox.lon; j <= bbox.lon_u; ++j) 6160 result.push_back(ll_upper(i<<16, j<<16)); 6200 result.push_back(*it); 6230 sort(result.begin(), result.end()); 6240 result.erase(unique(result.begin(), result.end()), result.end()); 629inline Ranges< Uint31_Index > calc_children(std::vector< Uint31_Index >&& parents) 6314709420 q Ranges< Uint31_Index > result; 6351134172 q std::sort(parents.begin(), parents.end()); 6361134172 q auto i_src = parents.begin()+1; 6371134172 q auto i_target = parents.begin(); 6381134172 q Idx_Bbox bbox_target(i_target->val()); 639118251172 q while (i_src != parents.end()) 641117117158 q Idx_Bbox bbox_src(i_src->val()); 642117117158 q uint comp = bbox_target.compare(bbox_src); 645117117158 q if (comp == 1 || comp == 3) 6521134172 q parents.erase(i_target+1, parents.end()); 66034721168 q if (!(i.val() & 0x0000007f)) 6610 result.push_back(0x80000080, 0x81); 66234721168 q for (int32 i = bbox.lat; i <= (bbox.lat_u - 0x3fff); i += 0x2000) 6640 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0x3fff); j += 0x2000) 6660 Uint31_Index idx((ll_upper(i<<16, j<<16) & 0xfc000000) | 0x80000040); 6670 result.push_back(idx, inc(idx)); 67034721168 q for (int32 i = bbox.lat; i <= (bbox.lat_u - 0xfff); i += 0x800) 6720 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0xfff); j += 0x800) 6740 Uint31_Index idx((ll_upper(i<<16, j<<16) & 0xffc00000) | 0x80000020); 6750 result.push_back(idx, inc(idx)); 67834721168 q for (int32 i = bbox.lat; i <= (bbox.lat_u - 0x3ff); i += 0x200) 6800 for (int32 j = bbox.lon; j <= (bbox.lon_u - 0x3ff); j += 0x200) 6820 Uint31_Index idx((ll_upper(i<<16, j<<16) & 0xfffc0000) | 0x80000010); 6830 result.push_back(idx, inc(idx)); 686263199168 q for (int32 i = bbox.lat; i <= bbox.lat_u; i += 2) 6881957722168 q for (int32 j = bbox.lon; j <= bbox.lon_u; j += 2) 6901729244168 q uint32 idx = ll_upper(i<<16, j<<16); 6921729244168 q if (((idx & 0xf) == 0x0 && ((idx & 0x3ffff) == 0x10 || (idx & 0x3fffff) == 0x20 693432311168 q || (idx & 0x3ffffff) == 0x40 || (idx & 0x3fffffff) == 0x80)) 6941729244168 q || ((idx & 0x3ff) == 0x4 && (i > (bbox.lat_u - 0x3f) || j > (bbox.lon_u - 0x3d))) 6951729244168 q || ((idx & 0x3fff) == 0x8 && (i > (bbox.lat_u - 0xfd) || j > (bbox.lon_u - 0xff)))) 6977407121 q result.push_back(Uint31_Index(idx), Uint31_Index(idx | 0x80000000)); 7001729244168 q if (i > (bbox.lat_u - 3) || j > (bbox.lon_u - 3)) 702422235168 q result.push_back(Uint31_Index(lower), Uint31_Index((idx+1) | 0x80000000)); 7051729244168 q if ((idx & 0x3f) == 0x2 && (i > (bbox.lat_u - 0xf) || j > (bbox.lon_u - 0xf))) 7070 result.push_back(Uint31_Index(lower), Uint31_Index((idx+2) | 0x80000000)); 7101729244168 q result.push_back(Uint31_Index(lower), Uint31_Index(idx+4)); 715186345 q result.push_back(i, inc(i)); 723inline Ranges< Uint31_Index > calc_children_(const std::vector< Uint31_Index >& parents) 7264709420 q return calc_children(std::move(copy)); 730inline Ranges< Uint32_Index > calc_children(const Ranges< Uint31_Index >& way_rel_idxs) 73216632 q Ranges< Uint32_Index > ranges; 7348098232 q for (auto it = way_rel_idxs.begin(); it != way_rel_idxs.end(); ++it) 73617049018 q for (Uint31_Index idx = it.lower_bound(); idx < it.upper_bound(); idx = inc(idx)) 7388967418 q if (idx.val() & 0x80000000) 7446639515 q if (idx.val() & 0x00000001) 7464411713 q lat = upper_ilat(idx.val() & 0x2aaaaaa8); 7474411713 q lon = upper_ilon(idx.val() & 0x55555554); 7502227811 q else if (idx.val() & 0x00000002) 752191269 q lat = upper_ilat(idx.val() & 0x2aaaaa80); 753191269 q lon = upper_ilon(idx.val() & 0x55555540); 756315210 q else if (idx.val() & 0x00000004) 75825049 q lat = upper_ilat(idx.val() & 0x2aaaa800); 75925049 q lon = upper_ilon(idx.val() & 0x55555400); 7626487 q else if (idx.val() & 0x00000008) 7643676 q lat = upper_ilat(idx.val() & 0x2aaa8000); 7653676 q lon = upper_ilon(idx.val() & 0x55554000); 7682815 q else if (idx.val() & 0x00000010) 770935 q lat = upper_ilat(idx.val() & 0x2aa80000); 771935 q lon = upper_ilon(idx.val() & 0x55540000); 7741882 q else if (idx.val() & 0x00000020) 776882 q lat = upper_ilat(idx.val() & 0x2a800000); 777882 q lon = upper_ilon(idx.val() & 0x55400000); 7801001 q else if (idx.val() & 0x00000040) 782901 q lat = upper_ilat(idx.val() & 0x28000000); 783901 q lon = upper_ilon(idx.val() & 0x54000000); 786101 q else // idx.val() == 0x80000080 7946639515 q ll_upper(lat<<16, lon<<16), 7956639515 q ll_upper((lat+offset-1)<<16, (lon+offset-1)<<16)+1); 7976639515 q ll_upper(lat<<16, (lon+offset)<<16), 7986639515 q ll_upper((lat+offset-1)<<16, (lon+2*offset-1)<<16)+1); 8006639515 q ll_upper((lat+offset)<<16, lon<<16), 8016639515 q ll_upper((lat+2*offset-1)<<16, (lon+offset-1)<<16)+1); 8036639515 q ll_upper((lat+offset)<<16, (lon+offset)<<16), 8046639515 q ll_upper((lat+2*offset-1)<<16, (lon+2*offset-1)<<16)+1); 8072327911 q ranges.push_back(idx.val(), idx.val() + 1); 816inline std::set< Uint31_Index > calc_parents(const std::set< Uint31_Index >& node_idxs) 8184341 q std::set< Uint31_Index > result; 8194341 q result.insert(0x80000080); 8214341 q for (std::set< Uint31_Index >::const_iterator it = node_idxs.begin(); 822759341 q it != node_idxs.end(); ++it) 826755036 q uint32 lat = upper_ilat(it->val() & 0x2aaaaaa8) & 0xfffe; 827755036 q uint32 lon = upper_ilon(it->val() & 0x55555554) & 0xfffe; 828755036 q result.insert(ll_upper((lat - 2)<<16, (lon - 2)<<16) | 0x80000001); 829755036 q result.insert(ll_upper(lat<<16, (lon - 2)<<16) | 0x80000001); 830755036 q result.insert(ll_upper((lat - 2)<<16, lon<<16) | 0x80000001); 831755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000001); 835755036 q result.insert(ll_upper((lat - 8)<<16, (lon - 8)<<16) | 0x80000002); 836755036 q result.insert(ll_upper(lat<<16, (lon - 8)<<16) | 0x80000002); 837755036 q result.insert(ll_upper((lat - 8)<<16, lon<<16) | 0x80000002); 838755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000002); 842755036 q result.insert(ll_upper((lat - 0x20)<<16, (lon - 0x20)<<16) | 0x80000004); 843755036 q result.insert(ll_upper(lat<<16, (lon - 0x20)<<16) | 0x80000004); 844755036 q result.insert(ll_upper((lat - 0x20)<<16, lon<<16) | 0x80000004); 845755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000004); 849755036 q result.insert(ll_upper((lat - 0x80)<<16, (lon - 0x80)<<16) | 0x80000008); 850755036 q result.insert(ll_upper(lat<<16, (lon - 0x80)<<16) | 0x80000008); 851755036 q result.insert(ll_upper((lat - 0x80)<<16, lon<<16) | 0x80000008); 852755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000008); 856755036 q result.insert(ll_upper((lat - 0x200)<<16, (lon - 0x200)<<16) | 0x80000010); 857755036 q result.insert(ll_upper(lat<<16, (lon - 0x200)<<16) | 0x80000010); 858755036 q result.insert(ll_upper((lat - 0x200)<<16, lon<<16) | 0x80000010); 859755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000010); 863755036 q result.insert(ll_upper((lat - 0x800)<<16, (lon - 0x800)<<16) | 0x80000020); 864755036 q result.insert(ll_upper(lat<<16, (lon - 0x800)<<16) | 0x80000020); 865755036 q result.insert(ll_upper((lat - 0x800)<<16, lon<<16) | 0x80000020); 866755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000020); 870755036 q result.insert(ll_upper((lat - 0x2000)<<16, (lon - 0x2000)<<16) | 0x80000040); 871755036 q result.insert(ll_upper(lat<<16, (lon - 0x2000)<<16) | 0x80000040); 872755036 q result.insert(ll_upper((lat - 0x2000)<<16, lon<<16) | 0x80000040); 873755036 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000040); 880inline std::vector< uint32 > calc_parents(const std::vector< uint32 >& node_idxs) 882550143 q std::vector< uint32 > result; 883550143 q result.push_back(0x80000080); 885550143 q for (std::vector< uint32 >::const_iterator it = node_idxs.begin(); 88629237143 q it != node_idxs.end(); ++it) 89028687108 q uint32 lat = upper_ilat(*it & 0x2aaaaaa8) & 0xfffe; 89128687108 q uint32 lon = upper_ilon(*it & 0x55555554) & 0xfffe; 89228687108 q result.push_back(ll_upper((lat - 2)<<16, (lon - 2)<<16) | 0x80000001); 89328687108 q result.push_back(ll_upper(lat<<16, (lon - 2)<<16) | 0x80000001); 89428687108 q result.push_back(ll_upper((lat - 2)<<16, lon<<16) | 0x80000001); 89528687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000001); 89928687108 q result.push_back(ll_upper((lat - 8)<<16, (lon - 8)<<16) | 0x80000002); 90028687108 q result.push_back(ll_upper(lat<<16, (lon - 8)<<16) | 0x80000002); 90128687108 q result.push_back(ll_upper((lat - 8)<<16, lon<<16) | 0x80000002); 90228687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000002); 90628687108 q result.push_back(ll_upper((lat - 0x20)<<16, (lon - 0x20)<<16) | 0x80000004); 90728687108 q result.push_back(ll_upper(lat<<16, (lon - 0x20)<<16) | 0x80000004); 90828687108 q result.push_back(ll_upper((lat - 0x20)<<16, lon<<16) | 0x80000004); 90928687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000004); 91328687108 q result.push_back(ll_upper((lat - 0x80)<<16, (lon - 0x80)<<16) | 0x80000008); 91428687108 q result.push_back(ll_upper(lat<<16, (lon - 0x80)<<16) | 0x80000008); 91528687108 q result.push_back(ll_upper((lat - 0x80)<<16, lon<<16) | 0x80000008); 91628687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000008); 92028687108 q result.push_back(ll_upper((lat - 0x200)<<16, (lon - 0x200)<<16) | 0x80000010); 92128687108 q result.push_back(ll_upper(lat<<16, (lon - 0x200)<<16) | 0x80000010); 92228687108 q result.push_back(ll_upper((lat - 0x200)<<16, lon<<16) | 0x80000010); 92328687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000010); 92728687108 q result.push_back(ll_upper((lat - 0x800)<<16, (lon - 0x800)<<16) | 0x80000020); 92828687108 q result.push_back(ll_upper(lat<<16, (lon - 0x800)<<16) | 0x80000020); 92928687108 q result.push_back(ll_upper((lat - 0x800)<<16, lon<<16) | 0x80000020); 93028687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000020); 93428687108 q result.push_back(ll_upper((lat - 0x2000)<<16, (lon - 0x2000)<<16) | 0x80000040); 93528687108 q result.push_back(ll_upper(lat<<16, (lon - 0x2000)<<16) | 0x80000040); 93628687108 q result.push_back(ll_upper((lat - 0x2000)<<16, lon<<16) | 0x80000040); 93728687108 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000040); 940550143 q sort(result.begin(), result.end(), Uint31_Compare()); 941550143 q result.erase(unique(result.begin(), result.end()), result.end()); 947inline void push_back_interval(Ranges< Uint31_Index >& ranges, uint32 idx) 9496941530346 q ranges.push_back(Uint31_Index(idx), Uint31_Index((idx + 1) & 0x7fffffff)); 953inline void blur_index( 954 uint32 distance, uint32 bitmask, uint32 lower_idx, uint32 upper_idx, Ranges< Uint31_Index >& result) 9561349782346 q uint32 source_bitmask = 0x10000 - distance; 9571349782346 q uint32 min_lat = upper_ilat(lower_idx) & source_bitmask; 9581349782346 q uint32 min_lon = upper_ilon(lower_idx) & source_bitmask; 9591349782346 q uint32 max_lat = upper_ilat(upper_idx) & source_bitmask; 9601349782346 q uint32 max_lon = upper_ilon(upper_idx) & source_bitmask; 9614754931346 q for (uint32 lat = min_lat - distance; lat <= max_lat; lat += distance) 9623405149346 q push_back_interval(result, ll_upper(lat<<16, (min_lon - distance)<<16) | bitmask); 9633536381346 q for (uint32 lon = min_lon; lon <= max_lon; lon += distance) 9642186599346 q push_back_interval(result, ll_upper((min_lat - distance)<<16, lon<<16) | bitmask); 9651349782346 q push_back_interval(result, ll_upper(max_lat<<16, max_lon<<16) | bitmask); 969inline void add_decomp_range(const std::pair< Uint32_Index, Uint32_Index >& range, 970 std::vector< std::pair< Uint32_Index, Uint32_Index > >& node_decomp) 972137040346 q uint32 lower = range.first.val(); 973329866346 q while (lower < range.second.val()) 976192826346 q if ((lower & 0x3) != 0 || lower + 4 > range.second.val()) 97840786327 q else if ((lower & 0xf) != 0 || lower + 0x10 > range.second.val()) 98022754208 q else if ((lower & 0x3f) != 0 || lower + 0x40 > range.second.val()) 98220061152 q else if ((lower & 0xff) != 0 || lower + 0x100 > range.second.val()) 98418521129 q else if ((lower & 0x3ff) != 0 || lower + 0x400 > range.second.val()) 986620132 q else if ((lower & 0xfff) != 0 || lower + 0x1000 > range.second.val()) 988200027 q else if ((lower & 0x3fff) != 0 || lower + 0x4000 > range.second.val()) 989136219 q upper = lower + 0x1000; 99063824 q else if ((lower & 0xffff) != 0 || lower + 0x10000 > range.second.val()) 9921969 q else if ((lower & 0x3ffff) != 0 || lower + 0x40000 > range.second.val()) 993302 q upper = lower + 0x10000; 9941667 q else if ((lower & 0xfffff) != 0 || lower + 0x100000 > range.second.val()) 995565 q upper = lower + 0x40000; 9961102 q else if ((lower & 0x3fffff) != 0 || lower + 0x400000 > range.second.val()) 9970 upper = lower + 0x100000; 9981102 q else if ((lower & 0xffffff) != 0 || lower + 0x1000000 > range.second.val()) 999141 q upper = lower + 0x400000; 1000961 q else if ((lower & 0x3ffffff) != 0 || lower + 0x4000000 > range.second.val()) 10010 upper = lower + 0x1000000; 1002961 q else if ((lower & 0xfffffff) != 0 || lower + 0x10000000 > range.second.val()) 1003961 q upper = lower + 0x4000000; 10040 else if ((lower & 0x3fffffff) != 0 || lower + 0x40000000 > range.second.val()) 10050 upper = lower + 0x10000000; 10070 upper = lower + 0x40000000; 1008192826346 q node_decomp.push_back(std::make_pair(lower, upper)); 1014inline void add_decomp_range(const Ranges< Uint32_Index >::Iterator& range, 1015 std::vector< std::pair< Uint32_Index, Uint32_Index > >& node_decomp) 10170 add_decomp_range(std::pair< Uint32_Index, Uint32_Index >{ range.lower_bound(), range.upper_bound() }, node_decomp); 1021template< typename Container > 1022Ranges< Uint31_Index > calc_parents(const Container& node_idxs) 1024890353 q std::vector< std::pair< Uint32_Index, Uint32_Index > > node_decomp; 1025137930353 q for (auto it = node_idxs.begin(); it != node_idxs.end(); ++it) 1026137040346 q add_decomp_range(*it, node_decomp); 1029890353 q result.push_back(0x80000080, 0x80000081); 1031890353 q for (std::vector< std::pair< Uint32_Index, Uint32_Index > >::const_iterator 1032193716353 q it = node_decomp.begin(); it != node_decomp.end(); ++it) 1034192826346 q result.push_back(it->first.val(), it->second.val()); 1036192826346 q uint32 lower_idx = it->first.val() & 0x7ffffffc; 1037192826346 q uint32 upper_idx = (it->second.val() - 1) & 0x7ffffffc; 1038192826346 q blur_index(2, 0x80000001, lower_idx, upper_idx, result); 1040192826346 q lower_idx = it->first.val() & 0x7fffffc0; 1041192826346 q upper_idx = (it->second.val() - 1) & 0x7fffffc0; 1042192826346 q blur_index(8, 0x80000002, lower_idx, upper_idx, result); 1044192826346 q lower_idx = it->first.val() & 0x7ffffc00; 1045192826346 q upper_idx = (it->second.val() - 1) & 0x7ffffc00; 1046192826346 q blur_index(0x20, 0x80000004, lower_idx, upper_idx, result); 1048192826346 q lower_idx = it->first.val() & 0x7fffc000; 1049192826346 q upper_idx = (it->second.val() - 1) & 0x7fffc000; 1050192826346 q blur_index(0x80, 0x80000008, lower_idx, upper_idx, result); 1052192826346 q lower_idx = it->first.val() & 0x7ffc0000; 1053192826346 q upper_idx = (it->second.val() - 1) & 0x7ffc0000; 1054192826346 q blur_index(0x200, 0x80000010, lower_idx, upper_idx, result); 1056192826346 q lower_idx = it->first.val() & 0x7fc00000; 1057192826346 q upper_idx = (it->second.val() - 1) & 0x7fc00000; 1058192826346 q blur_index(0x800, 0x80000020, lower_idx, upper_idx, result); 1060192826346 q lower_idx = it->first.val() & 0x7c000000; 1061192826346 q upper_idx = (it->second.val() - 1) & 0x7c000000; 1062192826346 q blur_index(0x2000, 0x80000040, lower_idx, upper_idx, result); 1070/**--------------------------------------------------------------------------*/ 1072// Calculates the ranges touched by the given bbox. 1073// This function implicitly depends on the chosen coordinate encoding. 1074inline Ranges< Uint32_Index > calc_ranges(double south, double north, double west, double east) 1076337008268 q Ranges< Uint32_Index > ranges; 1078337008268 q uint32 isouth((south + 91.0)*10000000+0.5); 1079337008268 q uint32 inorth((north + 91.0)*10000000+0.5); 1080337008268 q int32 iwest(west*10000000 + (west > 0 ? 0.5 : -0.5)); 1081337008268 q int32 ieast(east*10000000 + (east > 0 ? 0.5 : -0.5)); 1085337008268 q if ((west < 0) && (east >= 0)) 108811 q (isouth & 0xffff0000, inorth & 0xffff0000, 108911 q 0, ieast & 0xffff0000, 1, ranges); 109111 q (isouth & 0xffff0000, inorth & 0xffff0000, 109211 q iwest & 0xffff0000, 0xffff0000, 1, ranges); 1096337007267 q (isouth & 0xffff0000, inorth & 0xffff0000, 1097337007267 q iwest & 0xffff0000, ieast & 0xffff0000, 1, ranges); 11030 recursively_calc_ranges 11040 (isouth & 0xffff0000, inorth & 0xffff0000, 11050 iwest & 0xffff0000, 0xffff0000, 1, ranges); 11060 recursively_calc_ranges 11070 (isouth & 0xffff0000, inorth & 0xffff0000, 11080 0, int32(180.0*10000000 + 0.5) & 0xffff0000, 1, ranges); 11110 recursively_calc_ranges 11120 (isouth & 0xffff0000, inorth & 0xffff0000, 11130 iwest & 0xffff0000, int32(180.0*10000000 + 0.5) & 0xffff0000, 1, ranges); 11170 recursively_calc_ranges 11180 (isouth & 0xffff0000, inorth & 0xffff0000, 11190 int32(-180.0*10000000 - 0.5) & 0xffff0000, 0xffff0000, 1, ranges); 11200 recursively_calc_ranges 11210 (isouth & 0xffff0000, inorth & 0xffff0000, 11220 0, ieast & 0xffff0000, 1, ranges); 11250 recursively_calc_ranges 11260 (isouth & 0xffff0000, inorth & 0xffff0000, 11270 int32(-180.0*10000000 - 0.5) & 0xffff0000, ieast & 0xffff0000, 1, ranges); 1135inline Ranges< Uint32_Index > get_ranges_32(double south, double north, double west, double east) 1137222193 q return ::calc_ranges(south, north, west, east); 1141// Adds recursively the ranges based on the given products of 1143// The expected assertion for the recursion is that the indices are equal 1144// on the first bitlevel bits. Also, indexes must have the last 16 bit set to zero. 1145inline void recursively_calc_ranges 1146 (uint32 south, uint32 north, int32 west, int32 east, 1147 uint32 bitlevel, Ranges< Uint32_Index >& ranges) 11496181741268 q int32 dist = ((0xffff0000u>>bitlevel)&0xffff0000); 1151 // If the difference is exactly dist, the indices fill the whole square 1152 // and we can add this square to the ranges. 11536181741268 q if ((south + dist == north) && (west + dist == east)) 1155740746268 q ranges.push_back(ll_upper_(south, west), ll_upper_(north, east) + 1); 1159 // Shift dist to obtain a proper recursion. 11605440995268 q dist = ((dist>>1)&0xffff0000); 11625440995268 q if ((north | dist) != (south | dist)) 1164 // We need to split between northern and southern part. 1165187192252 q if ((east | dist) != (west | dist)) 1167 // We also need to split between western and eastern part. 11696413173 q (south, south | dist, west, west | dist, 11726413173 q (south, south | dist, (west | dist) + 0x10000, east, 11756413173 q ((south | dist) + 0x10000, north, west, west | dist, 11786413173 q ((south | dist) + 0x10000, north, (west | dist) + 0x10000, east, 1183 // We don't need to split because east and west lie in the 1184 // same half of the current square. 1186180779251 q (south, south | dist, west, east, 1189180779251 q ((south | dist) + 0x10000, north, west, east, 1195 // We don't need to split because north and south lie in the 1196 // same half of the current square. 11975253803268 q if ((east | dist) != (west | dist)) 1199 // We only need to split between western and eastern part. 1201203719254 q (south, north, west, west | dist, 1204203719254 q (south, north, (west | dist) + 0x10000, east, 1208 // We need no split at all. 12105050084268 q (south, north, west, east, bitlevel + 1, ranges); 1215/*---------------------------------------------------------------------------*/ 1218inline uint32 ilat_(double lat) 12205045085372 q return ((lat + 91.0)*10000000+0.5); 1224inline int32 ilon_(double lon) 12265045085372 q return (lon*10000000 + (lon > 0 ? 0.5 : -0.5)); 1230inline uint32 ll_upper_(double lat, double lon) 12325037400119 q uint32 temp = ll_upper(ilat_(lat), ilon_(lon)); 1237inline uint32 ll_lower(uint32 ilat, int32 ilon) 12418768991102 q for (uint32 i(0); i < 16; ++i) 12438253168102 q result |= ((0x1<<i)&ilat)<<(i+1); 12448253168102 q result |= ((0x1<<i)&(uint32)ilon)<<i; 1251inline uint32 ll_lower(double lat, double lon) 125339126 q return ll_lower(ilat_(lat), ilon_(lon)); 1257inline uint32 ilat(double lat) 1259880038118 q return (lat + 91.0)*10000000+0.5; 1263inline int32 ilon(double lon) 126563614163 q return lon*10000000 + (lon > 0 ? 0.5 : -0.5); 1269// convert interleaved coordinates to plain integers 1270inline uint32 ilat(uint32 ll_upper, uint32 ll_lower) 12721778986911449 q uint32 upper = ll_upper & 0xaaaaaaaa; 12731778986911449 q upper = (upper | (upper<<1)) & 0xcccccccc; 12741778986911449 q upper = (upper | (upper<<2)) & 0xf0f0f0f0; 12751778986911449 q upper = (upper | (upper<<4)) & 0xff00ff00; 12761778986911449 q upper = (upper | (upper<<8)) & 0xffff0000; 12781778986911449 q uint32 lower = ll_lower & 0xaaaaaaaa; 12791778986911449 q lower = (lower | (lower>>1)) & 0x99999999; 12801778986911449 q lower = (lower | (lower>>2)) & 0x87878787; 12811778986911449 q lower = (lower | (lower>>4)) & 0x807f807f; 12821778986911449 q lower = (lower | (lower>>8)) & 0x80007fff; 12831778986911449 q lower = (lower | (lower>>16)) & 0x0000ffff; 1289inline double lat(uint32 ll_upper, uint32 ll_lower) 129139983442432 q return ((double)ilat(ll_upper, ll_lower))/10000000 - 91.0; 1294inline double lat(uint32 ilat) 12966535911 q return ((double)ilat)/10000000 - 91.0; 1300// convert interleaved coordinates to plain integers 1301inline int32 ilon(uint32 ll_upper, uint32 ll_lower) 13031781881462450 q uint32 upper = (ll_upper ^ 0x40000000) & 0x55555555; 13041781881462450 q upper = (upper | (upper<<1)) & 0x99999999; 13051781881462450 q upper = (upper | (upper<<2)) & 0xe1e1e1e1; 13061781881462450 q upper = (upper | (upper<<4)) & 0xfe01fe01; 13071781881462450 q upper = (upper | (upper<<8)) & 0xfffe0001; 13081781881462450 q upper = (upper | (upper<<16)) & 0xffff0000; 13101781881462450 q uint32 lower = ll_lower & 0x55555555; 13111781881462450 q lower = (lower | (lower>>1)) & 0x33333333; 13121781881462450 q lower = (lower | (lower>>2)) & 0x0f0f0f0f; 13131781881462450 q lower = (lower | (lower>>4)) & 0x00ff00ff; 13141781881462450 q lower = (lower | (lower>>8)) & 0x0000ffff; 1320inline double lon(uint32 ll_upper, uint32 ll_lower) 132242884825432 q return ((double)ilon(ll_upper, ll_lower))/10000000; 1325inline double lon(int32 ilon) 132729883767 q return ((double)ilon)/10000000; 1331inline bool is_compound_idx(Uint31_Index idx) 13336223960 q return idx.val() & 0x80000000u;