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 5526943652103 q return (a & 0x7fffffff) < (b & 0x7fffffff); 59inline uint32 ll_upper(uint32 ilat, uint32 ilon) 6126850564449 q ilat &= 0xffff0000; 6326850564449 q ilat &= 0xff00ff00; 6526850564449 q ilat &= 0xf0f0f0f0; 6726850564449 q ilat &= 0xcccccccc; 6926850564449 q ilat &= 0xaaaaaaaa; 7126850564449 q ilon &= 0xffff0000; 7326850564449 q ilon &= 0xff00ff00; 7526850564449 q ilon &= 0xf0f0f0f0; 7726850564449 q ilon &= 0xcccccccc; 7926850564449 q ilon &= 0xaaaaaaaa; 8126850564449 q return ilat | (ilon>>1); 84inline uint32 ll_upper_(uint32 ilat, int32 ilon) 869503379366 q return (ll_upper(ilat, ilon) ^ 0x40000000); 89inline uint32 upper_ilat(uint32 quadtile) 9124910461456 q uint32 result = (quadtile & 0xaaaaaaaa)>>1; 9224910461456 q result |= (result>>1); 9324910461456 q result &= 0x33333333; 9424910461456 q result |= (result>>2); 9524910461456 q result &= 0x0f0f0f0f; 9624910461456 q result |= (result>>4); 9724910461456 q result &= 0x00ff00ff; 9824910461456 q result |= (result>>8); 10024910461456 q return result & 0xffff; 103inline uint32 upper_ilon(uint32 quadtile) 10524910461456 q uint32 result = (quadtile & 0x55555555); 11424910461456 q return result & 0xffff; 117inline uint32 calc_index(const std::vector< uint32 >& node_idxs) 122 // Calculate the bounding box of the appearing indices. 12424287653225 q std::vector< uint32 >::const_iterator it = node_idxs.begin(); 12524287653225 q uint32 lat_min = *it & 0x2aaaaaaa; 12624287653225 q uint32 lat_max = lat_min; 12724287653225 q uint32 lon_min = *it & 0x55555555; 12824287653225 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 18548575318225 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) 25724287665225 q uint32 lat = *it & 0x2aaaaaaa; 25824287665225 q uint32 lon = *it & 0x55555555; 26220412073224 q else if (lat > lat_max) 26619843204224 q else if (lon > lon_max) 272 // Evaluate the bounding box. 27424287653225 q if ((lat_max == lat_min) && (lon_max == lon_min)) 27514652586219 q return node_idxs.front(); 2779635067224 q uint32 ilat_min = upper_ilat(lat_min); 2789635067224 q uint32 ilat_max = upper_ilat(lat_max); 2799635067224 q uint32 ilon_min = upper_ilon(lon_min); 2809635067224 q uint32 ilon_max = upper_ilon(lon_max); 2829635067224 q if (((ilat_max & 0xfffe) - (ilat_min & 0xfffe) < 4) && 2839635067224 q ((ilon_max & 0xfffe) - (ilon_min & 0xfffe) < 4)) 2842873519214 q return (((lon_min | lat_min) & 0xfffffffc) | 0x80000001); 2866761548213 q if (((ilat_max & 0xfff8) - (ilat_min & 0xfff8) < 0x10) && 2876761548213 q ((ilon_max & 0xfff8) - (ilon_min & 0xfff8) < 0x10)) 288141711206 q return (((lon_min | lat_min) & 0xffffffc0) | 0x80000002); 2906619837213 q if (((ilat_max & 0xffe0) - (ilat_min & 0xffe0) < 0x40) && 2916619837213 q ((ilon_max & 0xffe0) - (ilon_min & 0xffe0) < 0x40)) 29238633206 q return (((lon_min | lat_min) & 0xfffffc00) | 0x80000004); 294658120497 q if (((ilat_max & 0xff80) - (ilat_min & 0xff80) < 0x100) && 295658120497 q ((ilon_max & 0xff80) - (ilon_min & 0xff80) < 0x100)) 2962210683 q return (((lon_min | lat_min) & 0xffffc000) | 0x80000008); 298655909897 q if (((ilat_max & 0xfe00) - (ilat_min & 0xfe00) < 0x400) && 299655909897 q ((ilon_max & 0xfe00) - (ilon_min & 0xfe00) < 0x400)) 30014372093 q return (((lon_min | lat_min) & 0xfffc0000) | 0x80000010); 302641537895 q if (((ilat_max & 0xf800) - (ilat_min & 0xf800) < 0x1000) && 303641537895 q ((ilon_max & 0xf800) - (ilon_min & 0xf800) < 0x1000)) 30480836891 q return (((lon_min | lat_min) & 0xffc00000) | 0x80000020); 306560701095 q if (((ilat_max & 0xe000) - (ilat_min & 0xe000) < 0x4000) && 307560701095 q ((ilon_max & 0xe000) - (ilon_min & 0xe000) < 0x4000)) 308250321486 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) 48380335163 q if (ll_upper & 0x80000000) 48538310154 q if (ll_upper & 0x00000001) 48726430142 q lat = upper_ilat(ll_upper & 0x2aaaaaa8); 48826430142 q lon = upper_ilon(ll_upper & 0x55555554); 49211880139 q else if (ll_upper & 0x00000002) 49411880139 q lat = upper_ilat(ll_upper & 0x2aaaaa80); 49511880139 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 54442025142 q lat = upper_ilat(ll_upper); 54542025142 q lon = upper_ilon(ll_upper); 551 int compare(const Idx_Bbox& rhs) 55373165150 q bool lhs_bigger = (lat < rhs.lat || lon < rhs.lon || lat_u > rhs.lat_u || lon_u > rhs.lon_u); 55473165150 q bool rhs_bigger = (lat > rhs.lat || lon > rhs.lon || lat_u < rhs.lat_u || lon_u < rhs.lon_u); 55573165150 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) 63128110477 q Ranges< Uint31_Index > result; 635464163 q std::sort(parents.begin(), parents.end()); 636464163 q auto i_src = parents.begin()+1; 637464163 q auto i_target = parents.begin(); 638464163 q Idx_Bbox bbox_target(i_target->val()); 63973629163 q while (i_src != parents.end()) 64173165150 q Idx_Bbox bbox_src(i_src->val()); 64273165150 q uint comp = bbox_target.compare(bbox_src); 64573165150 q if (comp == 1 || comp == 3) 652464163 q parents.erase(i_target+1, parents.end()); 6606706154 q if (!(i.val() & 0x0000007f)) 6610 result.push_back(0x80000080, 0x81); 6626706154 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)); 6706706154 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)); 6786706154 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)); 68655752154 q for (int32 i = bbox.lat; i <= bbox.lat_u; i += 2) 688432210154 q for (int32 j = bbox.lon; j <= bbox.lon_u; j += 2) 690383164154 q uint32 idx = ll_upper(i<<16, j<<16); 692383164154 q if (((idx & 0xf) == 0x0 && ((idx & 0x3ffff) == 0x10 || (idx & 0x3fffff) == 0x20 69395791154 q || (idx & 0x3ffffff) == 0x40 || (idx & 0x3fffffff) == 0x80)) 694383164154 q || ((idx & 0x3ff) == 0x4 && (i > (bbox.lat_u - 0x3f) || j > (bbox.lon_u - 0x3d))) 695383164154 q || ((idx & 0x3fff) == 0x8 && (i > (bbox.lat_u - 0xfd) || j > (bbox.lon_u - 0xff)))) 6971613105 q result.push_back(Uint31_Index(idx), Uint31_Index(idx | 0x80000000)); 700383164154 q if (i > (bbox.lat_u - 3) || j > (bbox.lon_u - 3)) 70291386154 q result.push_back(Uint31_Index(lower), Uint31_Index((idx+1) | 0x80000000)); 705383164154 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)); 710383164154 q result.push_back(Uint31_Index(lower), Uint31_Index(idx+4)); 715133565 q result.push_back(i, inc(i)); 723inline Ranges< Uint31_Index > calc_children_(const std::vector< Uint31_Index >& parents) 72628110477 q return calc_children(std::move(copy)); 730inline Ranges< Uint32_Index > calc_children(const Ranges< Uint31_Index >& way_rel_idxs) 73219836 q Ranges< Uint32_Index > ranges; 73415992336 q for (auto it = way_rel_idxs.begin(); it != way_rel_idxs.end(); ++it) 73636919220 q for (Uint31_Index idx = it.lower_bound(); idx < it.upper_bound(); idx = inc(idx)) 73820946720 q if (idx.val() & 0x80000000) 7448972816 q if (idx.val() & 0x00000001) 7467672715 q lat = upper_ilat(idx.val() & 0x2aaaaaa8); 7477672715 q lon = upper_ilon(idx.val() & 0x55555554); 750130019 q else if (idx.val() & 0x00000002) 752112918 q lat = upper_ilat(idx.val() & 0x2aaaaa80); 753112918 q lon = upper_ilon(idx.val() & 0x55555540); 75617107 q else if (idx.val() & 0x00000004) 75811976 q lat = upper_ilat(idx.val() & 0x2aaaa800); 75911976 q lon = upper_ilon(idx.val() & 0x55555400); 7625134 q else if (idx.val() & 0x00000008) 7641994 q lat = upper_ilat(idx.val() & 0x2aaa8000); 7651994 q lon = upper_ilon(idx.val() & 0x55554000); 7683143 q else if (idx.val() & 0x00000010) 770943 q lat = upper_ilat(idx.val() & 0x2aa80000); 771943 q lon = upper_ilon(idx.val() & 0x55540000); 7742201 q else if (idx.val() & 0x00000020) 7761201 q lat = upper_ilat(idx.val() & 0x2a800000); 7771201 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 7948972816 q ll_upper(lat<<16, lon<<16), 7958972816 q ll_upper((lat+offset-1)<<16, (lon+offset-1)<<16)+1); 7978972816 q ll_upper(lat<<16, (lon+offset)<<16), 7988972816 q ll_upper((lat+offset-1)<<16, (lon+2*offset-1)<<16)+1); 8008972816 q ll_upper((lat+offset)<<16, lon<<16), 8018972816 q ll_upper((lat+2*offset-1)<<16, (lon+offset-1)<<16)+1); 8038972816 q ll_upper((lat+offset)<<16, (lon+offset)<<16), 8048972816 q ll_upper((lat+2*offset-1)<<16, (lon+2*offset-1)<<16)+1); 80711973918 q ranges.push_back(idx.val(), idx.val() + 1); 816inline std::set< Uint31_Index > calc_parents(const std::set< Uint31_Index >& node_idxs) 8185350 q std::set< Uint31_Index > result; 8195350 q result.insert(0x80000080); 8215350 q for (std::set< Uint31_Index >::const_iterator it = node_idxs.begin(); 822185550 q it != node_idxs.end(); ++it) 826180241 q uint32 lat = upper_ilat(it->val() & 0x2aaaaaa8) & 0xfffe; 827180241 q uint32 lon = upper_ilon(it->val() & 0x55555554) & 0xfffe; 828180241 q result.insert(ll_upper((lat - 2)<<16, (lon - 2)<<16) | 0x80000001); 829180241 q result.insert(ll_upper(lat<<16, (lon - 2)<<16) | 0x80000001); 830180241 q result.insert(ll_upper((lat - 2)<<16, lon<<16) | 0x80000001); 831180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000001); 835180241 q result.insert(ll_upper((lat - 8)<<16, (lon - 8)<<16) | 0x80000002); 836180241 q result.insert(ll_upper(lat<<16, (lon - 8)<<16) | 0x80000002); 837180241 q result.insert(ll_upper((lat - 8)<<16, lon<<16) | 0x80000002); 838180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000002); 842180241 q result.insert(ll_upper((lat - 0x20)<<16, (lon - 0x20)<<16) | 0x80000004); 843180241 q result.insert(ll_upper(lat<<16, (lon - 0x20)<<16) | 0x80000004); 844180241 q result.insert(ll_upper((lat - 0x20)<<16, lon<<16) | 0x80000004); 845180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000004); 849180241 q result.insert(ll_upper((lat - 0x80)<<16, (lon - 0x80)<<16) | 0x80000008); 850180241 q result.insert(ll_upper(lat<<16, (lon - 0x80)<<16) | 0x80000008); 851180241 q result.insert(ll_upper((lat - 0x80)<<16, lon<<16) | 0x80000008); 852180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000008); 856180241 q result.insert(ll_upper((lat - 0x200)<<16, (lon - 0x200)<<16) | 0x80000010); 857180241 q result.insert(ll_upper(lat<<16, (lon - 0x200)<<16) | 0x80000010); 858180241 q result.insert(ll_upper((lat - 0x200)<<16, lon<<16) | 0x80000010); 859180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000010); 863180241 q result.insert(ll_upper((lat - 0x800)<<16, (lon - 0x800)<<16) | 0x80000020); 864180241 q result.insert(ll_upper(lat<<16, (lon - 0x800)<<16) | 0x80000020); 865180241 q result.insert(ll_upper((lat - 0x800)<<16, lon<<16) | 0x80000020); 866180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000020); 870180241 q result.insert(ll_upper((lat - 0x2000)<<16, (lon - 0x2000)<<16) | 0x80000040); 871180241 q result.insert(ll_upper(lat<<16, (lon - 0x2000)<<16) | 0x80000040); 872180241 q result.insert(ll_upper((lat - 0x2000)<<16, lon<<16) | 0x80000040); 873180241 q result.insert(ll_upper(lat<<16, lon<<16) | 0x80000040); 880inline std::vector< uint32 > calc_parents(const std::vector< uint32 >& node_idxs) 882573144 q std::vector< uint32 > result; 883573144 q result.push_back(0x80000080); 885573144 q for (std::vector< uint32 >::const_iterator it = node_idxs.begin(); 88657798144 q it != node_idxs.end(); ++it) 89057225103 q uint32 lat = upper_ilat(*it & 0x2aaaaaa8) & 0xfffe; 89157225103 q uint32 lon = upper_ilon(*it & 0x55555554) & 0xfffe; 89257225103 q result.push_back(ll_upper((lat - 2)<<16, (lon - 2)<<16) | 0x80000001); 89357225103 q result.push_back(ll_upper(lat<<16, (lon - 2)<<16) | 0x80000001); 89457225103 q result.push_back(ll_upper((lat - 2)<<16, lon<<16) | 0x80000001); 89557225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000001); 89957225103 q result.push_back(ll_upper((lat - 8)<<16, (lon - 8)<<16) | 0x80000002); 90057225103 q result.push_back(ll_upper(lat<<16, (lon - 8)<<16) | 0x80000002); 90157225103 q result.push_back(ll_upper((lat - 8)<<16, lon<<16) | 0x80000002); 90257225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000002); 90657225103 q result.push_back(ll_upper((lat - 0x20)<<16, (lon - 0x20)<<16) | 0x80000004); 90757225103 q result.push_back(ll_upper(lat<<16, (lon - 0x20)<<16) | 0x80000004); 90857225103 q result.push_back(ll_upper((lat - 0x20)<<16, lon<<16) | 0x80000004); 90957225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000004); 91357225103 q result.push_back(ll_upper((lat - 0x80)<<16, (lon - 0x80)<<16) | 0x80000008); 91457225103 q result.push_back(ll_upper(lat<<16, (lon - 0x80)<<16) | 0x80000008); 91557225103 q result.push_back(ll_upper((lat - 0x80)<<16, lon<<16) | 0x80000008); 91657225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000008); 92057225103 q result.push_back(ll_upper((lat - 0x200)<<16, (lon - 0x200)<<16) | 0x80000010); 92157225103 q result.push_back(ll_upper(lat<<16, (lon - 0x200)<<16) | 0x80000010); 92257225103 q result.push_back(ll_upper((lat - 0x200)<<16, lon<<16) | 0x80000010); 92357225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000010); 92757225103 q result.push_back(ll_upper((lat - 0x800)<<16, (lon - 0x800)<<16) | 0x80000020); 92857225103 q result.push_back(ll_upper(lat<<16, (lon - 0x800)<<16) | 0x80000020); 92957225103 q result.push_back(ll_upper((lat - 0x800)<<16, lon<<16) | 0x80000020); 93057225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000020); 93457225103 q result.push_back(ll_upper((lat - 0x2000)<<16, (lon - 0x2000)<<16) | 0x80000040); 93557225103 q result.push_back(ll_upper(lat<<16, (lon - 0x2000)<<16) | 0x80000040); 93657225103 q result.push_back(ll_upper((lat - 0x2000)<<16, lon<<16) | 0x80000040); 93757225103 q result.push_back(ll_upper(lat<<16, lon<<16) | 0x80000040); 940573144 q sort(result.begin(), result.end(), Uint31_Compare()); 941573144 q result.erase(unique(result.begin(), result.end()), result.end()); 947inline void push_back_interval(Ranges< Uint31_Index >& ranges, uint32 idx) 9498892990385 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) 9562639140385 q uint32 source_bitmask = 0x10000 - distance; 9572639140385 q uint32 min_lat = upper_ilat(lower_idx) & source_bitmask; 9582639140385 q uint32 min_lon = upper_ilon(lower_idx) & source_bitmask; 9592639140385 q uint32 max_lat = upper_ilat(upper_idx) & source_bitmask; 9602639140385 q uint32 max_lon = upper_ilon(upper_idx) & source_bitmask; 9615545744385 q for (uint32 lat = min_lat - distance; lat <= max_lat; lat += distance) 9622906604385 q push_back_interval(result, ll_upper(lat<<16, (min_lon - distance)<<16) | bitmask); 9635986386385 q for (uint32 lon = min_lon; lon <= max_lon; lon += distance) 9643347246385 q push_back_interval(result, ll_upper((min_lat - distance)<<16, lon<<16) | bitmask); 9652639140385 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) 972199582385 q uint32 lower = range.first.val(); 973576602385 q while (lower < range.second.val()) 976377020385 q if ((lower & 0x3) != 0 || lower + 4 > range.second.val()) 978124620361 q else if ((lower & 0xf) != 0 || lower + 0x10 > range.second.val()) 98016855234 q else if ((lower & 0x3f) != 0 || lower + 0x40 > range.second.val()) 98213944163 q else if ((lower & 0xff) != 0 || lower + 0x100 > range.second.val()) 98412225122 q else if ((lower & 0x3ff) != 0 || lower + 0x400 > range.second.val()) 986197232 q else if ((lower & 0xfff) != 0 || lower + 0x1000 > range.second.val()) 98874124 q else if ((lower & 0x3fff) != 0 || lower + 0x4000 > range.second.val()) 99032417 q else if ((lower & 0xffff) != 0 || lower + 0x10000 > range.second.val()) 9911258 q upper = lower + 0x4000; 99219912 q else if ((lower & 0x3ffff) != 0 || lower + 0x40000 > range.second.val()) 993323 q upper = lower + 0x10000; 9941679 q else if ((lower & 0xfffff) != 0 || lower + 0x100000 > range.second.val()) 995645 q upper = lower + 0x40000; 9961034 q else if ((lower & 0x3fffff) != 0 || lower + 0x400000 > range.second.val()) 9970 upper = lower + 0x100000; 9981034 q else if ((lower & 0xffffff) != 0 || lower + 0x1000000 > range.second.val()) 9990 upper = lower + 0x400000; 10001034 q else if ((lower & 0x3ffffff) != 0 || lower + 0x4000000 > range.second.val()) 100173 q 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; 1008377020385 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) 10241006399 q std::vector< std::pair< Uint32_Index, Uint32_Index > > node_decomp; 1025200588399 q for (auto it = node_idxs.begin(); it != node_idxs.end(); ++it) 1026199582385 q add_decomp_range(*it, node_decomp); 10291006399 q result.push_back(0x80000080, 0x80000081); 10311006399 q for (std::vector< std::pair< Uint32_Index, Uint32_Index > >::const_iterator 1032378026399 q it = node_decomp.begin(); it != node_decomp.end(); ++it) 1034377020385 q result.push_back(it->first.val(), it->second.val()); 1036377020385 q uint32 lower_idx = it->first.val() & 0x7ffffffc; 1037377020385 q uint32 upper_idx = (it->second.val() - 1) & 0x7ffffffc; 1038377020385 q blur_index(2, 0x80000001, lower_idx, upper_idx, result); 1040377020385 q lower_idx = it->first.val() & 0x7fffffc0; 1041377020385 q upper_idx = (it->second.val() - 1) & 0x7fffffc0; 1042377020385 q blur_index(8, 0x80000002, lower_idx, upper_idx, result); 1044377020385 q lower_idx = it->first.val() & 0x7ffffc00; 1045377020385 q upper_idx = (it->second.val() - 1) & 0x7ffffc00; 1046377020385 q blur_index(0x20, 0x80000004, lower_idx, upper_idx, result); 1048377020385 q lower_idx = it->first.val() & 0x7fffc000; 1049377020385 q upper_idx = (it->second.val() - 1) & 0x7fffc000; 1050377020385 q blur_index(0x80, 0x80000008, lower_idx, upper_idx, result); 1052377020385 q lower_idx = it->first.val() & 0x7ffc0000; 1053377020385 q upper_idx = (it->second.val() - 1) & 0x7ffc0000; 1054377020385 q blur_index(0x200, 0x80000010, lower_idx, upper_idx, result); 1056377020385 q lower_idx = it->first.val() & 0x7fc00000; 1057377020385 q upper_idx = (it->second.val() - 1) & 0x7fc00000; 1058377020385 q blur_index(0x800, 0x80000020, lower_idx, upper_idx, result); 1060377020385 q lower_idx = it->first.val() & 0x7c000000; 1061377020385 q upper_idx = (it->second.val() - 1) & 0x7c000000; 1062377020385 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) 1076274676317 q Ranges< Uint32_Index > ranges; 1078274676317 q uint32 isouth((south + 91.0)*10000000+0.5); 1079274676317 q uint32 inorth((north + 91.0)*10000000+0.5); 1080274676317 q int32 iwest(west*10000000 + (west > 0 ? 0.5 : -0.5)); 1081274676317 q int32 ieast(east*10000000 + (east > 0 ? 0.5 : -0.5)); 1085274671317 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); 1096274670316 q (isouth & 0xffff0000, inorth & 0xffff0000, 1097274670316 q iwest & 0xffff0000, ieast & 0xffff0000, 1, ranges); 110451 q (isouth & 0xffff0000, inorth & 0xffff0000, 110551 q iwest & 0xffff0000, 0xffff0000, 1, ranges); 110751 q (isouth & 0xffff0000, inorth & 0xffff0000, 110851 q 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); 112651 q (isouth & 0xffff0000, inorth & 0xffff0000, 112751 q 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) 1137254222 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) 11497474051317 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. 11537474051317 q if ((south + dist == north) && (west + dist == east)) 11551814365317 q ranges.push_back(ll_upper_(south, west), ll_upper_(north, east) + 1); 1159 // Shift dist to obtain a proper recursion. 11605659686317 q dist = ((dist>>1)&0xffff0000); 11625659686317 q if ((north | dist) != (south | dist)) 1164 // We need to split between northern and southern part. 1165106541305 q if ((east | dist) != (west | dist)) 1167 // We also need to split between western and eastern part. 116924203239 q (south, south | dist, west, west | dist, 117224203239 q (south, south | dist, (west | dist) + 0x10000, east, 117524203239 q ((south | dist) + 0x10000, north, west, west | dist, 117824203239 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. 118682338302 q (south, south | dist, west, east, 118982338302 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. 11975553145317 q if ((east | dist) != (west | dist)) 1199 // We only need to split between western and eastern part. 12011384731304 q (south, north, west, west | dist, 12041384731304 q (south, north, (west | dist) + 0x10000, east, 1208 // We need no split at all. 12104168414317 q (south, north, west, east, bitlevel + 1, ranges); 1215/*---------------------------------------------------------------------------*/ 1218inline uint32 ilat_(double lat) 12204344716419 q return ((lat + 91.0)*10000000+0.5); 1224inline int32 ilon_(double lon) 12264344716419 q return (lon*10000000 + (lon > 0 ? 0.5 : -0.5)); 1230inline uint32 ll_upper_(double lat, double lon) 12324273505140 q uint32 temp = ll_upper(ilat_(lat), ilon_(lon)); 1237inline uint32 ll_lower(uint32 ilat, int32 ilon) 1241725282995 q for (uint32 i(0); i < 16; ++i) 1243682619295 q result |= ((0x1<<i)&ilat)<<(i+1); 1244682619295 q result |= ((0x1<<i)&(uint32)ilon)<<i; 1251inline uint32 ll_lower(double lat, double lon) 12536318730 q return ll_lower(ilat_(lat), ilon_(lon)); 1257inline uint32 ilat(double lat) 12591573175109 q return (lat + 91.0)*10000000+0.5; 1263inline int32 ilon(double lon) 126599531050 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) 12724180144546487 q uint32 upper = ll_upper & 0xaaaaaaaa; 12734180144546487 q upper = (upper | (upper<<1)) & 0xcccccccc; 12744180144546487 q upper = (upper | (upper<<2)) & 0xf0f0f0f0; 12754180144546487 q upper = (upper | (upper<<4)) & 0xff00ff00; 12764180144546487 q upper = (upper | (upper<<8)) & 0xffff0000; 12784180144546487 q uint32 lower = ll_lower & 0xaaaaaaaa; 12794180144546487 q lower = (lower | (lower>>1)) & 0x99999999; 12804180144546487 q lower = (lower | (lower>>2)) & 0x87878787; 12814180144546487 q lower = (lower | (lower>>4)) & 0x807f807f; 12824180144546487 q lower = (lower | (lower>>8)) & 0x80007fff; 12834180144546487 q lower = (lower | (lower>>16)) & 0x0000ffff; 1289inline double lat(uint32 ll_upper, uint32 ll_lower) 129154528135465 q return ((double)ilat(ll_upper, ll_lower))/10000000 - 91.0; 1294inline double lat(uint32 ilat) 12961221567 q return ((double)ilat)/10000000 - 91.0; 1300// convert interleaved coordinates to plain integers 1301inline int32 ilon(uint32 ll_upper, uint32 ll_lower) 13034189002595489 q uint32 upper = (ll_upper ^ 0x40000000) & 0x55555555; 13044189002595489 q upper = (upper | (upper<<1)) & 0x99999999; 13054189002595489 q upper = (upper | (upper<<2)) & 0xe1e1e1e1; 13064189002595489 q upper = (upper | (upper<<4)) & 0xfe01fe01; 13074189002595489 q upper = (upper | (upper<<8)) & 0xfffe0001; 13084189002595489 q upper = (upper | (upper<<16)) & 0xffff0000; 13104189002595489 q uint32 lower = ll_lower & 0x55555555; 13114189002595489 q lower = (lower | (lower>>1)) & 0x33333333; 13124189002595489 q lower = (lower | (lower>>2)) & 0x0f0f0f0f; 13134189002595489 q lower = (lower | (lower>>4)) & 0x00ff00ff; 13144189002595489 q lower = (lower | (lower>>8)) & 0x0000ffff; 1320inline double lon(uint32 ll_upper, uint32 ll_lower) 132263374509465 q return ((double)ilon(ll_upper, ll_lower))/10000000; 1325inline double lon(int32 ilon) 132775922369 q return ((double)ilon)/10000000; 1331inline bool is_compound_idx(Uint31_Index idx) 13334724870 q return idx.val() & 0x80000000u;