/** * Instantiates a new FirstRingRegion object from the given geohash value. * * @param geohash * the center */ public FirstRingRegion(final String geohash) { this.center = geohash; this.east = GeoHashExtensions.getAdjacent(geohash, Adjacent.RIGHT); this.west = GeoHashExtensions.getAdjacent(geohash, Adjacent.LEFT); this.north = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP); this.south = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM); this.southEast = GeoHashExtensions.getAdjacent(this.south, Adjacent.RIGHT); this.northEast = GeoHashExtensions.getAdjacent(this.north, Adjacent.RIGHT); this.northWest = GeoHashExtensions.getAdjacent(this.north, Adjacent.LEFT); this.southWest = GeoHashExtensions.getAdjacent(this.south, Adjacent.LEFT); }
/** * Gets the adjacent from the given directions. For instance if directions is 'top' and 'feft' * then the topleft adjacent geohash code will be returned. * * @param geohash * the geohash * @param directions * the directions * @return the geohash code for the adjacent from the given directions. */ public static String getAdjacent(final String geohash, final String... directions) { String geohashresult = geohash; for (final String direction : directions) { geohashresult = getAdjacent(geohashresult, direction); } return geohashresult; }
northNorth = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.TOP); northNorthWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.LEFT, Adjacent.TOP); northWestNorthWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.LEFT, Adjacent.TOP, Adjacent.LEFT); westNorthWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.LEFT, Adjacent.LEFT); northNorthEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.RIGHT, Adjacent.TOP); northEastNorthEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.RIGHT, Adjacent.TOP, Adjacent.RIGHT); eastNorthEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP, Adjacent.RIGHT, Adjacent.RIGHT); eastEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.RIGHT, Adjacent.RIGHT); eastSouthEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.RIGHT, Adjacent.RIGHT); southSouthEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.RIGHT, Adjacent.BOTTOM); southEastSouthEast = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.RIGHT, Adjacent.BOTTOM, Adjacent.RIGHT); southSouth = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.BOTTOM); southSouthWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.LEFT, Adjacent.BOTTOM); southWestSouthWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.LEFT, Adjacent.BOTTOM, Adjacent.LEFT); westSouthWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM, Adjacent.LEFT, Adjacent.LEFT); westWest = GeoHashExtensions.getAdjacent(geohash, Adjacent.LEFT, Adjacent.LEFT);
final String top = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP); final String bottom = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM); final String right = GeoHashExtensions.getAdjacent(geohash, Adjacent.RIGHT); final String left = GeoHashExtensions.getAdjacent(geohash, Adjacent.LEFT); final String topleft = GeoHashExtensions.getAdjacent(left, Adjacent.TOP); final String topright = GeoHashExtensions.getAdjacent(right, Adjacent.TOP); final String bottomright = GeoHashExtensions.getAdjacent(right, Adjacent.BOTTOM); final String bottomleft = GeoHashExtensions.getAdjacent(left, Adjacent.BOTTOM); adjacentAreas.add(geohash); adjacentAreas.add(top);
final String top = GeoHashExtensions.getAdjacent(geohash, Adjacent.TOP); final String bottom = GeoHashExtensions.getAdjacent(geohash, Adjacent.BOTTOM); final String right = GeoHashExtensions.getAdjacent(geohash, Adjacent.RIGHT); final String left = GeoHashExtensions.getAdjacent(geohash, Adjacent.LEFT); final String topleft = GeoHashExtensions.getAdjacent(left, Adjacent.TOP); final String topright = GeoHashExtensions.getAdjacent(right, Adjacent.TOP); final String bottomright = GeoHashExtensions.getAdjacent(right, Adjacent.BOTTOM); final String bottomleft = GeoHashExtensions.getAdjacent(left, Adjacent.BOTTOM);
final String topTop = GeoHashExtensions.getAdjacent(adjacentAreas.get(Adjacent.TOP), Adjacent.TOP); final String topLeftTop = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_LEFT), Adjacent.TOP); final String topLeftTopLeft = GeoHashExtensions.getAdjacent(topLeftTop, Adjacent.LEFT); final String topLeftLeft = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_LEFT), Adjacent.LEFT); final String topRightTop = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_RIGHT), Adjacent.TOP); final String topRightTopRight = GeoHashExtensions.getAdjacent(topRightTop, Adjacent.RIGHT); final String topRightRight = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.TOP_RIGHT), Adjacent.RIGHT); final String rightRight = GeoHashExtensions.getAdjacent(adjacentAreas.get(Adjacent.RIGHT), Adjacent.RIGHT); final String bottomRightRight = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_RIGHT), Adjacent.RIGHT); final String bottomRightBottom = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_RIGHT), Adjacent.BOTTOM); final String bottomRightBottomRight = GeoHashExtensions.getAdjacent(bottomRightBottom, Adjacent.RIGHT); final String bottomBottom = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM), Adjacent.BOTTOM); final String bottomLeftBottom = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_LEFT), Adjacent.BOTTOM); final String bottomLeftBottomLeft = GeoHashExtensions.getAdjacent(bottomLeftBottom, Adjacent.LEFT); final String bottomLeftLeft = GeoHashExtensions .getAdjacent(adjacentAreas.get(Adjacent.BOTTOM_LEFT), Adjacent.LEFT); final String leftLeft = GeoHashExtensions.getAdjacent(adjacentAreas.get(Adjacent.LEFT),
if ((indexOfLastChar != -1) && !base.isEmpty()) base = getAdjacent(base, direction);