Issue #1356 create subgrid for grib files with extra columns
Former-commit-id:c3e1005dc8
[formerly c9c82e37fa21a01a7357c2e065aea435b325587f] Former-commit-id:a7a13d27cd
This commit is contained in:
parent
5b1ca237b2
commit
64922c17c5
1 changed files with 63 additions and 24 deletions
|
@ -41,6 +41,7 @@ import com.raytheon.edex.plugin.grib.util.GridModel;
|
||||||
import com.raytheon.edex.site.SiteUtil;
|
import com.raytheon.edex.site.SiteUtil;
|
||||||
import com.raytheon.uf.common.awipstools.GetWfoCenterPoint;
|
import com.raytheon.uf.common.awipstools.GetWfoCenterPoint;
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
|
import com.raytheon.uf.common.geospatial.util.GridGeometryWrapChecker;
|
||||||
import com.raytheon.uf.common.gridcoverage.Corner;
|
import com.raytheon.uf.common.gridcoverage.Corner;
|
||||||
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
import com.raytheon.uf.common.gridcoverage.GridCoverage;
|
||||||
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
|
import com.raytheon.uf.common.gridcoverage.exception.GridCoverageException;
|
||||||
|
@ -121,6 +122,12 @@ public class GribSpatialCache {
|
||||||
*/
|
*/
|
||||||
private Map<String, SubGridDef> subGridDefMap;
|
private Map<String, SubGridDef> subGridDefMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of coverage id to the number of columns in world wrap or -1 for no
|
||||||
|
* wrapping.
|
||||||
|
*/
|
||||||
|
private Map<Integer, Integer> worldWrapMap;
|
||||||
|
|
||||||
private FileDataList fileDataList;
|
private FileDataList fileDataList;
|
||||||
|
|
||||||
private long fileScanTime = 0;
|
private long fileScanTime = 0;
|
||||||
|
@ -146,6 +153,7 @@ public class GribSpatialCache {
|
||||||
definedSubGridMap = new HashMap<String, SubGrid>();
|
definedSubGridMap = new HashMap<String, SubGrid>();
|
||||||
subGridCoverageMap = new HashMap<String, GridCoverage>();
|
subGridCoverageMap = new HashMap<String, GridCoverage>();
|
||||||
subGridDefMap = new HashMap<String, SubGridDef>();
|
subGridDefMap = new HashMap<String, SubGridDef>();
|
||||||
|
worldWrapMap = new HashMap<Integer, Integer>();
|
||||||
scanFiles();
|
scanFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,17 +356,51 @@ public class GribSpatialCache {
|
||||||
upperRightPosition, PixelOrientation.CENTER,
|
upperRightPosition, PixelOrientation.CENTER,
|
||||||
referenceCoverage);
|
referenceCoverage);
|
||||||
|
|
||||||
|
return trim(modelName, coverage, lowerLeftPosition, upperRightPosition);
|
||||||
|
} else {
|
||||||
|
Integer wrapCount = worldWrapMap.get(coverage.getId());
|
||||||
|
if (wrapCount == null) {
|
||||||
|
wrapCount = GridGeometryWrapChecker.checkForWrapping(coverage
|
||||||
|
.getGridGeometry());
|
||||||
|
worldWrapMap.put(coverage.getId(), wrapCount);
|
||||||
|
}
|
||||||
|
if(wrapCount > 0 && wrapCount < coverage.getNx()){
|
||||||
|
// make sure that there is data going around the world only
|
||||||
|
// once, if the data starts another iteration around the world,
|
||||||
|
// subgrid it to cut off the extra data. This mostly hits to
|
||||||
|
// remove one redundant column.
|
||||||
|
Coordinate upperRightPosition = new Coordinate(wrapCount - 1, 0);
|
||||||
|
upperRightPosition = MapUtil.gridCoordinateToLatLon(upperRightPosition,
|
||||||
|
PixelOrientation.CENTER, coverage);
|
||||||
|
try {
|
||||||
|
Coordinate lowerLeftPosition = new Coordinate(
|
||||||
|
coverage.getLowerLeftLon(),
|
||||||
|
coverage.getLowerLeftLat());
|
||||||
|
return trim(modelName, coverage, lowerLeftPosition,
|
||||||
|
upperRightPosition);
|
||||||
|
} catch (GridCoverageException e) {
|
||||||
|
logger.error(
|
||||||
|
"Failed to generate sub grid for world wide grid: "
|
||||||
|
+ modelName, e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean trim(String modelName, GridCoverage coverage,
|
||||||
|
Coordinate lowerLeft, Coordinate upperRight) {
|
||||||
SubGrid subGrid = new SubGrid();
|
SubGrid subGrid = new SubGrid();
|
||||||
subGrid.setLowerLeftLon(lowerLeftPosition.x);
|
subGrid.setLowerLeftLon(lowerLeft.x);
|
||||||
subGrid.setLowerLeftLat(lowerLeftPosition.y);
|
subGrid.setLowerLeftLat(lowerLeft.y);
|
||||||
subGrid.setUpperRightLon(upperRightPosition.x);
|
subGrid.setUpperRightLon(upperRight.x);
|
||||||
subGrid.setUpperRightLat(upperRightPosition.y);
|
subGrid.setUpperRightLat(upperRight.y);
|
||||||
|
|
||||||
// verify numbers in -180 -> 180 range
|
// verify numbers in -180 -> 180 range
|
||||||
subGrid.setLowerLeftLon(MapUtil.correctLon(subGrid
|
subGrid.setLowerLeftLon(MapUtil.correctLon(subGrid.getLowerLeftLon()));
|
||||||
.getLowerLeftLon()));
|
subGrid.setUpperRightLon(MapUtil.correctLon(subGrid.getUpperRightLon()));
|
||||||
subGrid.setUpperRightLon(MapUtil.correctLon(subGrid
|
|
||||||
.getUpperRightLon()));
|
|
||||||
|
|
||||||
GridCoverage subGridCoverage = coverage.trim(subGrid);
|
GridCoverage subGridCoverage = coverage.trim(subGrid);
|
||||||
|
|
||||||
|
@ -374,9 +416,6 @@ public class GribSpatialCache {
|
||||||
definedSubGridMap.put(subGridKey(modelName, coverage), subGrid);
|
definedSubGridMap.put(subGridKey(modelName, coverage), subGrid);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue