/** * * @param rectValueSource mandatory; source of rectangles * @param isGeo True if ctx.isGeo() and thus dateline issues should be attended to * @param queryExtent mandatory; the query rectangle * @param queryTargetProportion see class javadocs. Between 0 and 1. * @param minSideLength see class javadocs. 0.0 will effectively disable. */ public BBoxOverlapRatioValueSource(ShapeValuesSource rectValueSource, boolean isGeo, Rectangle queryExtent, double queryTargetProportion, double minSideLength) { super(rectValueSource); this.isGeo = isGeo; this.minSideLength = minSideLength; this.queryExtent = queryExtent; this.queryArea = calcArea(queryExtent.getWidth(), queryExtent.getHeight()); assert queryArea >= 0; this.queryTargetProportion = queryTargetProportion; if (queryTargetProportion < 0 || queryTargetProportion > 1.0) throw new IllegalArgumentException("queryTargetProportion must be >= 0 and <= 1"); }
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); }
if (queryArea > 0) { queryRatio = intersectionArea / queryArea; } else if (queryExtent.getHeight() > 0) {//vert line queryRatio = height / queryExtent.getHeight(); } else if (queryExtent.getWidth() > 0) {//horiz line queryRatio = width / queryExtent.getWidth(); double targetArea = calcArea(target.getWidth(), target.getHeight()); assert targetArea >= 0; double targetRatio; if (targetArea > 0) { targetRatio = intersectionArea / targetArea; } else if (target.getHeight() > 0) {//vert line targetRatio = height / target.getHeight(); } else if (target.getWidth() > 0) {//horiz line targetRatio = width / target.getWidth();
final int columns = calcRowsOrCols(cellWidth, heatMinX, inputRect.getWidth(), inputRect.getMinX(), worldRect.getWidth()); final double heatMinY = cornerRect.getMinY(); final double cellHeight = cornerRect.getHeight(); final int rows = calcRowsOrCols(cellHeight, heatMinY, inputRect.getHeight(), inputRect.getMinY(), worldRect.getHeight()); assert rows > 0 && columns > 0; if (columns > MAX_ROWS_OR_COLUMNS || rows > MAX_ROWS_OR_COLUMNS || columns * rows > maxCells) {