public class CellIdUtils extends Object
Modifier and Type | Method and Description |
---|---|
static LatLngBoundingBox |
getBoundingBoxForCells(List<Integer> cellIds)
Creates a bounding box for the list of unordered cell ids.
|
static int |
getCellIdFor(double latitude)
Get cell id.
|
static Set<Integer> |
getCellsEnclosedBy(double minLat,
double maxLat,
double minLong,
double maxLong)
Gets the list of cells that are enclosed within the bounding box.
|
static Integer[] |
getCentiCellIdForBoundingBox(double minLongitude,
double minLatitude,
double maxLongitude,
double maxLatitude)
Returns the cell id and centi cell id for the supplied bounding box, Returning null if the supplied bounding box
doesnt enclose a single cell.
|
static int[] |
getMinMaxCellIdsForBoundingBox(double minLongitude,
double minLatitude,
double maxLongitude,
double maxLatitude)
Return a min cell id and a max cell id for this bounding box.
|
static int |
getMod360CellIdFor(double longitude)
Get mod 360 cell id.
|
static boolean |
isCellIdInBoundingBox(int cellId,
int minCellId,
int maxCellId)
Returns true if the supplied cell id lies in the bounding box demarcated by the min and max cell ids supplied.
|
static void |
main(String[] args)
For ease of conversion
|
static LatLngBoundingBox |
toBoundingBox(int cellId)
Returns the box of the given cell This may require some more work to avoid divide rounding errors
|
static LatLngBoundingBox |
toBoundingBox(int cellId,
int centiCellId)
Returns the box of the given cell and centi cell An attempt has been made to avoid rounding errors with doubles,
but may need revisited
|
static int |
toCellId(Double latitude,
Double longitude)
Determines the cell id for the Lat / Long provided.
|
static int |
toCentiCellId(Double latitude,
Double longitude)
Determines the centi cell id for the given values
|
public static int toCellId(Double latitude, Double longitude) throws UnableToGenerateCellIdException
latitude
- Which may be nulllongitude
- Which may be nullUnableToGenerateCellIdException
- Should the lat long be null or invalidpublic static int getMod360CellIdFor(double longitude)
public static int getCellIdFor(double latitude)
public static boolean isCellIdInBoundingBox(int cellId, int minCellId, int maxCellId) throws Exception
Exception
public static int toCentiCellId(Double latitude, Double longitude) throws UnableToGenerateCellIdException
latitude
- Which may be nulllongitude
- Which may be nullUnableToGenerateCellIdException
- Shoudl the lat long be null or invalidpublic static LatLngBoundingBox toBoundingBox(int cellId)
cellId
- To return the lat long box ofpublic static LatLngBoundingBox toBoundingBox(int cellId, int centiCellId)
cellId
- To return the lat long box ofcentiCellId
- within the boxpublic static Set<Integer> getCellsEnclosedBy(double minLat, double maxLat, double minLong, double maxLong) throws UnableToGenerateCellIdException
UnableToGenerateCellIdException
- if the lat longs are invalidpublic static int[] getMinMaxCellIdsForBoundingBox(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude) throws UnableToGenerateCellIdException
UnableToGenerateCellIdException
public static LatLngBoundingBox getBoundingBoxForCells(List<Integer> cellIds)
public static Integer[] getCentiCellIdForBoundingBox(double minLongitude, double minLatitude, double maxLongitude, double maxLatitude) throws UnableToGenerateCellIdException
UnableToGenerateCellIdException
Copyright © 2024 Global Biodiversity Information Facility (GBIF). All rights reserved.