/** * Return the BoundingBox of a rectangle of tiles defined by upper left and lower right tile. * * @param upperLeft tile in upper left corner. * @param lowerRight tile in lower right corner. * @return BoundingBox defined by the area around upperLeft and lowerRight Tile. */ public static BoundingBox getBoundingBox(Tile upperLeft, Tile lowerRight) { BoundingBox ul = upperLeft.getBoundingBox(); BoundingBox lr = lowerRight.getBoundingBox(); return ul.extendBoundingBox(lr); }
/** * @return a new Point at the horizontal and vertical center of this Rectangle. */ public Point getCenter() { return new Point(getCenterX(), getCenterY()); }
/** * @return the current center position of the map. */ @Override public synchronized LatLong getCenter() { return new LatLong(this.latitude, this.longitude); }
/** * @return the parent tile of this tile or null, if the zoom level of this tile is 0. */ public Tile getParent() { if (this.zoomLevel == 0) { return null; } return new Tile(this.tileX / 2, this.tileY / 2, (byte) (this.zoomLevel - 1), this.tileSize); }
/** * @param latLong the LatLong whose coordinates should be checked. * @return true if this BoundingBox contains the given LatLong, false otherwise. */ public boolean contains(LatLong latLong) { return contains(latLong.latitude, latLong.longitude); }
public Rectangle shift(Point origin) { if (origin.x == 0 && origin.y == 0) { return this; } return new Rectangle(this.left + origin.x, this.top + origin.y, this.right + origin.x, this.bottom + origin.y); }
/** * Ctor with given start point, a point that defines the direction of the line and a length * * @param start start point * @param direction point that defines the direction (a line from start to direction point) * @param distance how long to move along the line between start and direction */ public LineSegment(Point start, Point direction, double distance) { this.start = start; this.end = new LineSegment(start, direction).pointAlongLineSegment(distance); }
/** * New line segment with start and end reversed. * * @return new LineSegment with start and end reversed */ public LineSegment reverse() { return new LineSegment(this.end, this.start); }
/** * Creates a BoundingBox extended up to <code>LatLong</code> (but does not cross date line/poles). * * @param latLong coordinates up to the extension * @return an extended BoundingBox or this (if contains coordinates) */ public BoundingBox extendCoordinates(LatLong latLong) { return extendCoordinates(latLong.latitude, latLong.longitude); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + this.latLong.hashCode(); result = prime * result + this.zoomLevel; return result; }
@Override public int hashCode() { int result = 7; result = 31 * result + xy.hashCode(); result = 31 * result + priority; return result; }
@Override public int hashCode() { return this.tile.hashCode(); } }
public Point offset(double dx, double dy) { if (0 == dx && 0 == dy) { return this; } return new Point(this.x + dx, this.y + dy); }
/** * Extend of the area defined by the two tiles in absolute coordinates. * * @param upperLeft tile in upper left corner of area. * @param lowerRight tile in lower right corner of area. * @return rectangle with the absolute coordinates. */ public static Rectangle getBoundaryAbsolute(Tile upperLeft, Tile lowerRight) { return new Rectangle(upperLeft.getOrigin().x, upperLeft.getOrigin().y, lowerRight.getOrigin().x + upperLeft.tileSize, lowerRight.getOrigin().y + upperLeft.tileSize); }
/** * Extend of this tile in relative (tile) coordinates. * * @return rectangle with the relative coordinates. */ public Rectangle getBoundaryRelative() { return new Rectangle(0, 0, tileSize, tileSize); }
/** * Gets the center point of the dimension. * * @return the center point */ public Point getCenter() { return new Point((float) this.width / 2, (float) this.height / 2); }