Add tileIndex3Deg to accession
Genesys assigns a tileIndex
to accessions with latitude and longitude. The tileIndex
currently in use is based on a 5min grid.
Add new @Column("tileIndex3deg") int tileIndex3deg
to AccessionId
. This new index is based on a 3min grid (0.05 degrees * 60 = 3min) and is incompatible with the 5min grid.
The new index tileIndex3deg
must be updated in @PrePersist/@PreUpdate
method, the same as tileIndex
.
Grid details used by Subsetting rasters:
dimensions : 2600, 7200, 18720000 (nrow, ncol, ncell)
extent : -180, 180, -60, 70 (xmin, xmax, ymin, ymax)
resolution : 0.05, 0.05 (x, y)
The function to calculate this index should be somewhere in utils:
/**
* Gets the 3x3 degree grid cell zero-based index starting in the NW corner (-180,90) with `tile=0` and ending in
* the SW corner (180,-60). A 3 degree grid has `ncol=7200` "columns" and `nrow=3600` "rows".
*
* @param latitude the latitude
* @param longitude the longitude
* @return the cell index for a 3 degree grid
*/
public static final Long get3DegreeCellId(Number longitude, Number latitude) {
if (longitude == null || latitude == null)
return null;
final int columns = 7200;
final int rows = 3600;
if (longitude.doubleValue() < -180 || longitude.doubleValue() > 180)
return null;
if (latitude.doubleValue() < -90 || latitude.doubleValue() > 90)
return null;
// longitude (-180:180) -> (0:columns-1)
long ncol = Math.round((columns - 1) * (longitude.doubleValue() + 180d) / 360d) % columns;
// latitude (-90:90) -> (0:rows-1)
long nrow = Math.round((rows - 1) * (latitude.doubleValue() + 90) / 180d) % rows;
// System.err.println(longitude + "," + latitude + ": ncol=" + ncol + ",nrow=" +
// nrow + " tile=" + (nrow * columns + ncol));
// System.err.flush();
return nrow * columns + ncol;
}
Liquibase adds the new column. We need an admin tool action to generate values for accession.tileIndex3
for records where latitude.between(-90, 90).and(longitude.between(-180, 180))
.
Please extend AccessionGeoFilter
to support filtering by the new tile index: public Set<Long> tileIndex3deg;
.