List of usage examples for org.apache.lucene.spatial.prefix.tree QuadPrefixTree MAX_LEVELS_POSSIBLE
int MAX_LEVELS_POSSIBLE
To view the source code for org.apache.lucene.spatial.prefix.tree QuadPrefixTree MAX_LEVELS_POSSIBLE.
Click Source Link
From source file:org.codelibs.elasticsearch.common.geo.GeoUtils.java
License:Apache License
/** * Calculate the number of levels needed for a specific precision. Quadtree * cells will not exceed the specified size (diagonal) of the precision. * @param meters Maximum size of cells in meters (must greater than zero) * @return levels need to achieve precision *//*from ww w . j a v a 2 s . com*/ public static int quadTreeLevelsForPrecision(double meters) { assert meters >= 0; if (meters == 0) { return QuadPrefixTree.MAX_LEVELS_POSSIBLE; } else { final double ratio = 1 + (EARTH_POLAR_DISTANCE / EARTH_EQUATOR); // cell ratio final double width = Math.sqrt((meters * meters) / (ratio * ratio)); // convert to cell width final long part = Math.round(Math.ceil(EARTH_EQUATOR / width)); final int level = Long.SIZE - Long.numberOfLeadingZeros(part) - 1; // (log_2) return (part <= (1L << level)) ? level : (level + 1); // adjust level } }
From source file:org.elasticsearch.common.geo.GeoUtils.java
License:Apache License
/** * Calculate the number of levels needed for a specific precision. Quadtree * cells will not exceed the specified size (diagonal) of the precision. * @param meters Maximum size of cells in meters (must greater than zero) * @return levels need to achieve precision *///from w w w . ja v a 2s . com public static int quadTreeLevelsForPrecision(double meters) { assert meters >= 0; if (meters == 0) { return QuadPrefixTree.MAX_LEVELS_POSSIBLE; } else { final double ratio = 1 + (EARTH_POLAR_DISTANCE / EARTH_EQUATOR); // cell ratio final double width = Math.sqrt((meters * meters) / (ratio * ratio)); // convert to cell width final long part = Math.round(Math.ceil(EARTH_EQUATOR / width)); final int level = Long.SIZE - Long.numberOfLeadingZeros(part) - 1; // (log_2) return (part <= (1l << level)) ? level : (level + 1); // adjust level } }