本文整理汇总了Java中com.spatial4j.core.shape.Rectangle.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getHeight方法的具体用法?Java Rectangle.getHeight怎么用?Java Rectangle.getHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.spatial4j.core.shape.Rectangle
的用法示例。
在下文中一共展示了Rectangle.getHeight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDistanceForLevel
import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
/**
* Given a cell having the specified level, returns the distance from opposite
* corners. Since this might very depending on where the cell is, this method
* may over-estimate.
*
* @param level [1 to maxLevels]
* @return > 0
*/
public double getDistanceForLevel(int level) {
if (level < 1 || level > getMaxLevels())
throw new IllegalArgumentException("Level must be in 1 to maxLevels range");
//TODO cache for each level
Cell cell = getCell(ctx.getWorldBounds().getCenter(), level);
Rectangle bbox = cell.getShape().getBoundingBox();
double width = bbox.getWidth();
double height = bbox.getHeight();
//Use standard cartesian hypotenuse. For geospatial, this answer is larger
// than the correct one but it's okay to over-estimate.
return Math.sqrt(width * width + height * height);
}