/** * Determines the storage directory for a file, using its spatial properties run through the * Geohash algorithm. * * <p>The resulting format is xx/xxx, which is specific to the NOAA NAM dataset, because this will * place each unique grid point in its own directory. */ private static String getStorageDir(String outputDir, Metadata meta) { Coordinates coords = meta.getSpatialProperties().getCoordinates(); String location = GeoHash.encode(coords.getLatitude(), coords.getLongitude(), 10); String subDir = location.substring(0, 2) + "/" + location.substring(2, 5); return outputDir + "/" + subDir; }
/** Creates a block/metadata pair subset for indexing. */ public static Block createBlock(String name, Metadata meta) throws IOException { Metadata m = new Metadata(name); addIndexField("visibility", meta, m); addIndexField("pressure", meta, m); addIndexField("total_precipitation", meta, m); addIndexField("precipitable_water", meta, m); addIndexField("temperature_surface", meta, m); addIndexField("total_cloud_cover", meta, m); addIndexField("snow_depth", meta, m); m.setTemporalProperties(meta.getTemporalProperties()); m.setSpatialProperties(meta.getSpatialProperties()); Block block = new Block("samples", m, Serializer.serialize(meta)); return block; }