Merge "Omaha #2913 Remove ability to create images from uengine." into omaha_14.4.1
Former-commit-id:db3889a955
[formerly74443038fc
] [formerly02108895f0
[formerly feb218207bc20ba7cab026379e2ef0d2c0efb58c]] Former-commit-id:02108895f0
Former-commit-id:86d8f9cabb
This commit is contained in:
commit
aed63519e3
13 changed files with 19 additions and 1254 deletions
|
@ -2,30 +2,27 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Grib Plug-in
|
||||
Bundle-SymbolicName: com.raytheon.edex.plugin.grib
|
||||
Bundle-Version: 1.12.1174.qualifier
|
||||
Eclipse-RegisterBuddy: com.raytheon.edex.common, com.raytheon.uf.common.serialization
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Require-Bundle: com.raytheon.edex.common,
|
||||
com.raytheon.edex.uengine,
|
||||
Require-Bundle: com.raytheon.edex.common;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.awipstools,
|
||||
com.raytheon.uf.common.comm,
|
||||
com.raytheon.uf.common.dataplugin.grid,
|
||||
com.raytheon.uf.common.dataplugin.level,
|
||||
com.raytheon.uf.common.localization,
|
||||
com.raytheon.uf.common.dataplugin.grid;bundle-version="1.13.0",
|
||||
com.raytheon.uf.common.dataplugin.level;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.localization;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.common.parameter,
|
||||
com.raytheon.uf.edex.awipstools,
|
||||
com.raytheon.uf.edex.plugin.grid,
|
||||
com.raytheon.uf.edex.python.decoder,
|
||||
org.apache.camel,
|
||||
org.apache.commons.lang,
|
||||
org.apache.commons.logging,
|
||||
org.apache.camel;bundle-version="2.12.3",
|
||||
org.apache.commons.lang;bundle-version="2.6.0",
|
||||
org.apache.commons.logging;bundle-version="1.0.4",
|
||||
javax.measure,
|
||||
ucar.nc2
|
||||
Export-Package: com.raytheon.edex.plugin.grib,
|
||||
com.raytheon.edex.plugin.grib.exception,
|
||||
com.raytheon.edex.plugin.grib.spatial,
|
||||
com.raytheon.edex.plugin.grib.util,
|
||||
com.raytheon.edex.uengine.tasks.grib,
|
||||
com.raytheon.edex.util.grib
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
|
|
|
@ -1,256 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.uengine.tasks.grib;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.referencing.operation.DefaultMathTransformFactory;
|
||||
import org.opengis.referencing.FactoryException;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
|
||||
import com.raytheon.edex.uengine.exception.MicroEngineException;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.CoordinateSequence;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.GeometryCollection;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.geom.LinearRing;
|
||||
import com.vividsolutions.jts.geom.Polygon;
|
||||
import com.vividsolutions.jts.geom.impl.CoordinateArraySequence;
|
||||
|
||||
/**
|
||||
* GribImpacts task derived from original uEngine GribImpacts task.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Apr 12, 2007 njensen Initial Creation
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class GribImpacts extends ScriptTask {
|
||||
|
||||
private CoordinateReferenceSystem crs;
|
||||
|
||||
private GridGeometry2D geom;
|
||||
|
||||
private float[] gribData;
|
||||
|
||||
private int minValue = -1;
|
||||
|
||||
private List<Integer> keys = new ArrayList<Integer>();
|
||||
|
||||
public GribImpacts(float[] aGribData, GridGeometry2D aGeometry,
|
||||
CoordinateReferenceSystem aCrs) {
|
||||
gribData = aGribData;
|
||||
geom = aGeometry;
|
||||
crs = aCrs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
Coordinate[] coords = null;
|
||||
GeometryFactory factory = new GeometryFactory();
|
||||
Map<Integer, Geometry> polygons = new HashMap<Integer, Geometry>();
|
||||
|
||||
// set up the transform from grid coordinates to lon/lat
|
||||
|
||||
MathTransform fullTransform = null;
|
||||
try {
|
||||
DefaultMathTransformFactory dmtf = new DefaultMathTransformFactory();
|
||||
fullTransform = dmtf.createConcatenatedTransform(
|
||||
geom.getGridToCRS(), MapUtil.getTransformToLatLon(crs));
|
||||
|
||||
} catch (FactoryException e) {
|
||||
logger.error("Unable to create MathTransform instances - "
|
||||
+ "cannot transform from GRID space to Lat/Lon", e);
|
||||
throw new MicroEngineException(
|
||||
"Unable to create MathTransform instances - cannot transform from GRID space to Lat/Lon",
|
||||
e);
|
||||
}
|
||||
|
||||
// determine the grid width and length
|
||||
int nx = geom.getGridRange().getSpan(0);
|
||||
int ny = geom.getGridRange().getSpan(1);
|
||||
|
||||
// verify that the grib data length matches the
|
||||
// grid dimensions
|
||||
if (gribData.length != (nx * ny)) {
|
||||
throw new MicroEngineException("Data is corrupt - dx: " + nx
|
||||
+ ", dy:" + ny + ", size:" + gribData.length);
|
||||
}
|
||||
|
||||
// create an array to hold the max number of verices for a row
|
||||
double[] xyCoord = new double[4 * (nx + 1)];
|
||||
|
||||
int gribIdx = 0; // index of the first cell in the current row
|
||||
int v; // value of the current cell
|
||||
int n; // number of adjacent cells with the same value
|
||||
int x; // x coordinate of the first cell in the current string
|
||||
|
||||
// for each row in the grid
|
||||
for (int y = ny - 1; y >= 0; --y) {
|
||||
// set x to the first cell in the row
|
||||
x = 0;
|
||||
|
||||
// loop over the cells in the row
|
||||
do { // while x < nx
|
||||
|
||||
// skip over cells with vales < the minValue
|
||||
do {
|
||||
v = (int) gribData[gribIdx + x];
|
||||
if (v >= minValue) {
|
||||
break;
|
||||
}
|
||||
x++;
|
||||
} while (x < nx);
|
||||
|
||||
// if we're at the end of the row get out of this loop
|
||||
if (x >= nx) {
|
||||
break;
|
||||
}
|
||||
|
||||
// count up adjacent cells with the same value
|
||||
n = 1;
|
||||
while ((x + n < nx) && (v == (int) gribData[gribIdx + x + n])) {
|
||||
n++;
|
||||
}
|
||||
|
||||
// compute the grid coordinates of the vertices surrounding
|
||||
// this string of adjacent cells
|
||||
for (int j = 0; j <= n; j++) {
|
||||
xyCoord[4 * j] = x + j - .5;
|
||||
xyCoord[4 * j + 1] = y + .5;
|
||||
|
||||
xyCoord[4 * j + 2] = x + j - .5;
|
||||
xyCoord[4 * j + 3] = y - .5;
|
||||
}
|
||||
|
||||
// move x to the next cell after the current string
|
||||
x += n;
|
||||
|
||||
// transform the grid coordinates to lon/lat
|
||||
try {
|
||||
fullTransform
|
||||
.transform(xyCoord, 0, xyCoord, 0, 2 * (n + 1));
|
||||
} catch (TransformException e) {
|
||||
logger.error("Unable to create a polygon", e);
|
||||
throw new MicroEngineException(
|
||||
"Unable to create a polygon", e);
|
||||
}
|
||||
|
||||
// convert the lon/lats to coordinates
|
||||
int m = 2 * (n + 1);
|
||||
coords = new Coordinate[m + 1];
|
||||
for (int j = 0; j <= n; j++) {
|
||||
coords[j] = new Coordinate(xyCoord[4 * j],
|
||||
xyCoord[4 * j + 1]);
|
||||
coords[m - j - 1] = new Coordinate(xyCoord[4 * j + 2],
|
||||
xyCoord[4 * j + 3]);
|
||||
}
|
||||
// duplicate the first point as the last to close the
|
||||
// polygon
|
||||
coords[m] = new Coordinate(coords[0]);
|
||||
|
||||
// create a coordinate sequence
|
||||
CoordinateSequence cs = new CoordinateArraySequence(coords);
|
||||
|
||||
// create a polygon and add it to the list
|
||||
LinearRing linearRing = new LinearRing(cs, factory);
|
||||
Polygon polygon = new Polygon(linearRing, null, factory);
|
||||
|
||||
// see if we already have a polygon for this cell value
|
||||
Geometry g = polygons.get(v);
|
||||
if (g == null) {
|
||||
// if not then add a new polygon
|
||||
polygons.put(v, polygon);
|
||||
} else {
|
||||
// if so then merge this polygon with the existing one
|
||||
g = g.union(polygon);
|
||||
polygons.put(v, g);
|
||||
}
|
||||
} while (x < nx);
|
||||
|
||||
// increment the grib data index to the next row
|
||||
gribIdx += nx;
|
||||
}
|
||||
|
||||
// create a geometry collection from the polygon map
|
||||
// and put it in the chain data
|
||||
GeometryCollection collection = new GeometryCollection(polygons
|
||||
.values().toArray(new Geometry[] {}), factory);
|
||||
|
||||
// create a map of attribute names/values
|
||||
keys = new ArrayList<Integer>(polygons.keySet());
|
||||
return collection;
|
||||
}
|
||||
|
||||
public CoordinateReferenceSystem getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(CoordinateReferenceSystem aCrs) {
|
||||
crs = aCrs;
|
||||
}
|
||||
|
||||
public GridGeometry2D getGeom() {
|
||||
return geom;
|
||||
}
|
||||
|
||||
public void setGeom(GridGeometry2D aGeom) {
|
||||
geom = aGeom;
|
||||
}
|
||||
|
||||
public float[] getGribData() {
|
||||
return gribData;
|
||||
}
|
||||
|
||||
public void setGribData(float[] aGribData) {
|
||||
gribData = aGribData;
|
||||
}
|
||||
|
||||
public int getMinValue() {
|
||||
return minValue;
|
||||
}
|
||||
|
||||
public void setMinValue(int aMinValue) {
|
||||
minValue = aMinValue;
|
||||
}
|
||||
|
||||
public List<Integer> getKeys() {
|
||||
return keys;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,296 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.uengine.tasks.grib;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferFloat;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.SampleModel;
|
||||
|
||||
import javax.media.jai.BorderExtender;
|
||||
import javax.media.jai.Interpolation;
|
||||
import javax.media.jai.JAI;
|
||||
import javax.media.jai.ParameterBlockJAI;
|
||||
import javax.media.jai.PlanarImage;
|
||||
import javax.media.jai.RasterFactory;
|
||||
import javax.media.jai.TiledImage;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.edex.colormap.ColorMapManager;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.datastorage.records.IDataRecord;
|
||||
import com.raytheon.uf.common.util.GridUtil;
|
||||
|
||||
/**
|
||||
* GribMap task derived from original uEngine GribMap task. Maps grid data to an
|
||||
* image.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Mar 29, 2007 njensen Initial Creation
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class GribMap extends ScriptTask {
|
||||
|
||||
private String colorMapName;
|
||||
|
||||
private int scaleFactor = 1;
|
||||
|
||||
private IDataRecord dataRecord;
|
||||
|
||||
private GridGeometry2D gridGeometry;
|
||||
|
||||
private static final float DEF_MINIMUM = Float.POSITIVE_INFINITY;
|
||||
|
||||
private static final float DEF_MAXIMUM = Float.NEGATIVE_INFINITY;
|
||||
|
||||
private float minimum = DEF_MINIMUM;
|
||||
|
||||
private float maximum = DEF_MAXIMUM;
|
||||
|
||||
public GribMap(String aPlugin, String aColorMapName,
|
||||
IDataRecord aDataRecord, GridGeometry2D aGridGeometry) {
|
||||
colorMapName = aColorMapName;
|
||||
dataRecord = aDataRecord;
|
||||
gridGeometry = aGridGeometry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
float max = -9999;
|
||||
float min = 9999;
|
||||
float userMin;
|
||||
float userMax;
|
||||
|
||||
float[] gribData = (float[]) dataRecord.getDataObject();
|
||||
|
||||
// ColorMap colorMap = ColorMap.getColorMap(colorMapName);
|
||||
// if (colorMap == null) {
|
||||
// throw new MicroEngineException(
|
||||
// "Invalid ColorMap name " + Util.printString(colorMapName) +
|
||||
// ", cannot decode image.");
|
||||
// }
|
||||
/*
|
||||
* subtract one since we map the GRIB values to valid pixel (grey scale)
|
||||
* values based on the color map. For example, a 32 color color map
|
||||
* requires pixel values 0 to 31.
|
||||
*/
|
||||
int colors = (int) ColorMapManager.MAX_VALUE;
|
||||
|
||||
int width = gridGeometry.getGridRange().getSpan(0);
|
||||
int height = gridGeometry.getGridRange().getSpan(1);
|
||||
|
||||
if (scaleFactor > 1.0) {
|
||||
|
||||
int len = width * height;
|
||||
Point origin = new Point(0, 0);
|
||||
|
||||
// create a float sample model
|
||||
SampleModel sampleModel = RasterFactory.createBandedSampleModel(
|
||||
DataBuffer.TYPE_FLOAT, width, height, 1);
|
||||
|
||||
// create a TiledImage using the float SampleModel
|
||||
TiledImage tiledImage = new TiledImage(0, 0, width, height, 0, 0,
|
||||
sampleModel, null);
|
||||
|
||||
// create a DataBuffer from the float[][] array
|
||||
DataBufferFloat dataBuffer = new DataBufferFloat(gribData, len);
|
||||
|
||||
// create a Raster
|
||||
Raster raster = RasterFactory.createWritableRaster(sampleModel,
|
||||
dataBuffer, origin);
|
||||
|
||||
// set the TiledImage data to that of the Raster
|
||||
tiledImage.setData(raster);
|
||||
|
||||
PlanarImage scaledImg;
|
||||
|
||||
// Interpolate the image using a scale factor and
|
||||
// the copy border extender
|
||||
ParameterBlockJAI param = new ParameterBlockJAI("Scale");
|
||||
param.addSource(tiledImage);
|
||||
param.setParameter("xScale", (float) scaleFactor);
|
||||
param.setParameter("yScale", (float) scaleFactor);
|
||||
Interpolation interpol = Interpolation
|
||||
.getInstance(Interpolation.INTERP_BILINEAR);
|
||||
param.setParameter("interpolation", interpol);
|
||||
RenderingHints hint = new RenderingHints(JAI.KEY_BORDER_EXTENDER,
|
||||
BorderExtender.createInstance(BorderExtender.BORDER_COPY));
|
||||
scaledImg = JAI.create("Scale", param, hint);
|
||||
|
||||
// Get the floats back out
|
||||
DataBuffer newDb = scaledImg.getData().getDataBuffer();
|
||||
DataBufferFloat dbf = (java.awt.image.DataBufferFloat) newDb;
|
||||
|
||||
// Update the grib data objects for further processing
|
||||
gribData = dbf.getData();
|
||||
width = width * scaleFactor;
|
||||
height = height * scaleFactor;
|
||||
gridGeometry = new GridGeometry2D(new GeneralGridEnvelope(
|
||||
new int[] { 0, 0 }, new int[] { width, height }, false),
|
||||
gridGeometry.getEnvelope());
|
||||
}
|
||||
int pixels = gribData.length;
|
||||
|
||||
for (int i = 0; i < pixels; i++) {
|
||||
if (gribData[i] != GridUtil.GRID_FILL_VALUE) {
|
||||
if (max < gribData[i]) {
|
||||
max = gribData[i];
|
||||
}
|
||||
|
||||
if (min > gribData[i]) {
|
||||
min = gribData[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* validate the user specified minimum
|
||||
*/
|
||||
userMin = minimum;
|
||||
if (minimum != DEF_MINIMUM) {
|
||||
userMin = minimum;
|
||||
// if (userMin > min) {
|
||||
// theLogger.warn("Requested minimum [" + userMin +
|
||||
// "] larger than computed minimum. "+
|
||||
// "Using computed minimum of " + min);
|
||||
// userMin = min;
|
||||
// }
|
||||
} else {
|
||||
userMin = min;
|
||||
}
|
||||
/*
|
||||
* validate user specified maximum
|
||||
*/
|
||||
if (maximum != DEF_MAXIMUM) {
|
||||
userMax = maximum;
|
||||
// if (userMax < max) {
|
||||
// theLogger.warn("Requested maximum [" + userMax +
|
||||
// "] smaller than computed maximum. "+
|
||||
// "Using computed maximum of " + max);
|
||||
// userMax = max;
|
||||
// }
|
||||
} else {
|
||||
userMax = max;
|
||||
}
|
||||
/*
|
||||
* not sure if this can actually happen, but for completeness
|
||||
*/
|
||||
if (userMax < userMin) {
|
||||
logger.warn("Invalid minimum/maximum specified. "
|
||||
+ "Using computed values of " + min + " and " + max);
|
||||
userMin = min;
|
||||
userMax = max;
|
||||
}
|
||||
/**
|
||||
* update the minimum and maximum values
|
||||
*/
|
||||
min = userMin;
|
||||
max = userMax;
|
||||
|
||||
/*
|
||||
* remap the data
|
||||
*/
|
||||
float range = max - min;
|
||||
float diff = 0f;
|
||||
byte[] imageData = new byte[pixels];
|
||||
for (int index = 0; index < pixels; index++) {
|
||||
float pixel = gribData[index];
|
||||
if (pixel < min) {
|
||||
pixel = min;
|
||||
} else if (pixel > max) {
|
||||
pixel = max;
|
||||
}
|
||||
diff = pixel - min;
|
||||
imageData[index] = (byte) Math.abs((Math.round(colors
|
||||
* (diff / range))));
|
||||
}
|
||||
|
||||
return imageData;
|
||||
}
|
||||
|
||||
public String getColorMapName() {
|
||||
return colorMapName;
|
||||
}
|
||||
|
||||
public void setColorMapName(String aColorMapName) {
|
||||
colorMapName = aColorMapName;
|
||||
}
|
||||
|
||||
public IDataRecord getDataRecord() {
|
||||
return dataRecord;
|
||||
}
|
||||
|
||||
public void setDataRecord(IDataRecord aDataRecord) {
|
||||
dataRecord = aDataRecord;
|
||||
}
|
||||
|
||||
public float getMaximum() {
|
||||
return maximum;
|
||||
}
|
||||
|
||||
public void setMaximum(float aMaximum) {
|
||||
maximum = aMaximum;
|
||||
}
|
||||
|
||||
public float getMinimum() {
|
||||
return minimum;
|
||||
}
|
||||
|
||||
public void setMinimum(float aMinimum) {
|
||||
minimum = aMinimum;
|
||||
}
|
||||
|
||||
public int getScaleFactor() {
|
||||
return scaleFactor;
|
||||
}
|
||||
|
||||
public void setScaleFactor(int aScaleFactor) {
|
||||
scaleFactor = aScaleFactor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the gridGeometry
|
||||
*/
|
||||
public GridGeometry2D getGridGeometry() {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gridGeometry
|
||||
* the gridGeometry to set
|
||||
*/
|
||||
public void setGridGeometry(GridGeometry2D gridGeometry) {
|
||||
this.gridGeometry = gridGeometry;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
/**
|
||||
* Contains JavaScript oriented μEngine tasks specific to gribs
|
||||
*/
|
||||
package com.raytheon.edex.uengine.tasks.grib;
|
|
@ -1,151 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.uengine.tasks.process;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferByte;
|
||||
import java.awt.image.IndexColorModel;
|
||||
import java.awt.image.MultiPixelPackedSampleModel;
|
||||
import java.awt.image.Raster;
|
||||
import java.awt.image.WritableRaster;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.edex.colormap.ColorMapManager;
|
||||
import com.raytheon.edex.exception.ColorTableException;
|
||||
import com.raytheon.edex.uengine.exception.MicroEngineException;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
|
||||
/**
|
||||
* ColorMapImage task derived from original uEngine ColorMapImage task. Applies
|
||||
* a color map to an image.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Mar 29, 2007 njensen Initial Creation
|
||||
* Jul 26, 2007 njensen Uses com.raytheon.edex.colormaps.ColorMap
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class ColorMapImage extends ScriptTask {
|
||||
|
||||
private String colorMapName;
|
||||
|
||||
private byte[] image;
|
||||
|
||||
private GridGeometry2D gridGeometry;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param aColorMapName
|
||||
* the name of the color map
|
||||
* @param anImage
|
||||
* the image in bytes
|
||||
* @param aGeometry
|
||||
* the geometry of the image
|
||||
*/
|
||||
public ColorMapImage(String aColorMapName, Object anImage,
|
||||
GridGeometry2D aGeometry) {
|
||||
colorMapName = aColorMapName;
|
||||
image = (byte[]) anImage;
|
||||
gridGeometry = aGeometry;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
// ByteBuffer buffer = ByteBuffer.allocate(image.length);
|
||||
// buffer.put(image);
|
||||
//
|
||||
// // must set buffer position before doing a get, otherwise get
|
||||
// Exception
|
||||
// buffer.position(0);
|
||||
//
|
||||
int width = gridGeometry.getGridRange().getSpan(0);
|
||||
int height = gridGeometry.getGridRange().getSpan(1);
|
||||
//
|
||||
// byte raster[] = new byte[width * height];
|
||||
// byte[] raster = image;
|
||||
|
||||
// logger.debug("Reading raw image file: width=" + width
|
||||
// + ", height=" + height + ", img.len="
|
||||
// + image.length + ", ras.len=" + raster.length);
|
||||
|
||||
// for (int iy = 0; iy < height; iy++) {
|
||||
// buffer.get(raster, iy * width, width);
|
||||
// }
|
||||
|
||||
IndexColorModel cm = null;
|
||||
try {
|
||||
cm = ColorMapManager.buildColorModel(ColorMapManager.getInstance()
|
||||
.getColorMap(colorMapName));
|
||||
} catch (ColorTableException e) {
|
||||
throw new MicroEngineException("Error creating color model", e);
|
||||
}
|
||||
DataBufferByte byteArray = new DataBufferByte(image, width * height);
|
||||
|
||||
MultiPixelPackedSampleModel sample = new MultiPixelPackedSampleModel(
|
||||
DataBuffer.TYPE_BYTE, width, height,
|
||||
ColorMapManager.NUMBER_BITS);
|
||||
WritableRaster writeRaster = Raster.createWritableRaster(sample,
|
||||
byteArray, new Point(0, 0));
|
||||
|
||||
BufferedImage bi = new BufferedImage(width, height,
|
||||
BufferedImage.TYPE_BYTE_INDEXED, cm);
|
||||
bi.setData(writeRaster);
|
||||
|
||||
return bi;
|
||||
}
|
||||
|
||||
public String getColorMapName() {
|
||||
return colorMapName;
|
||||
}
|
||||
|
||||
public void setColorMapName(String aColorMapName) {
|
||||
colorMapName = aColorMapName;
|
||||
}
|
||||
|
||||
public GridGeometry2D getGridGeometry() {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
public void setGridGeometry(GridGeometry2D aGridGeometry) {
|
||||
gridGeometry = aGridGeometry;
|
||||
}
|
||||
|
||||
public byte[] getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(byte[] aImage) {
|
||||
image = aImage;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.uengine.tasks.process;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.coverage.grid.GridCoverageFactory;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.gce.geotiff.GeoTiffWriter;
|
||||
import org.geotools.geometry.Envelope2D;
|
||||
|
||||
import com.raytheon.edex.uengine.exception.MicroEngineException;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
|
||||
/**
|
||||
* ImageOut task derived from original uEngine ImageOut task. Writes an image out
|
||||
* to a byte array in the specified format.
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Mar 29, 2007 njensen Initial Creation
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class ImageOut extends ScriptTask
|
||||
{
|
||||
private BufferedImage image;
|
||||
|
||||
private String format;
|
||||
|
||||
private GridGeometry2D gridGeometry;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param anImage the image to write out
|
||||
* @param aFormat the format to write the image out to
|
||||
* @param aGridGeometry the geometry of the image, only required for geotiffs
|
||||
*/
|
||||
public ImageOut(BufferedImage anImage, String aFormat, GridGeometry2D aGridGeometry)
|
||||
{
|
||||
image = anImage;
|
||||
format = aFormat;
|
||||
gridGeometry = aGridGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param anImage the image to write out
|
||||
* @param aFormat the format to write the image out to
|
||||
*/
|
||||
public ImageOut(BufferedImage anImage, String aFormat)
|
||||
{
|
||||
image = anImage;
|
||||
format = aFormat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object execute()
|
||||
{
|
||||
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
|
||||
try
|
||||
{
|
||||
logger.debug("converting buffered image to file format"
|
||||
+ ", image size="
|
||||
+ (image != null ? (image.getWidth() * image.getHeight())
|
||||
: "N/A"));
|
||||
if ("tiff".equalsIgnoreCase(format)
|
||||
|| "tif".equalsIgnoreCase(format))
|
||||
{
|
||||
|
||||
// Get the envelope (contains the CRS).
|
||||
Envelope2D e = gridGeometry.getEnvelope2D();
|
||||
|
||||
// Create the grid coverage.
|
||||
GridCoverageFactory factory = new GridCoverageFactory();
|
||||
GridCoverage2D coverage = factory.create("SomeName", image, e);
|
||||
|
||||
// Create the geotiff writer and write the geotiff to
|
||||
// the
|
||||
// output stream.
|
||||
GeoTiffWriter tiffWriter = new GeoTiffWriter(byteOut);
|
||||
tiffWriter.write(coverage, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImageIO.write(image, format, byteOut);
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new MicroEngineException("Error writing image out.", e);
|
||||
}
|
||||
|
||||
return byteOut.toByteArray();
|
||||
}
|
||||
|
||||
public String getFormat()
|
||||
{
|
||||
return format;
|
||||
}
|
||||
|
||||
public void setFormat(String aFormat)
|
||||
{
|
||||
format = aFormat;
|
||||
}
|
||||
|
||||
public GridGeometry2D getGridGeometry()
|
||||
{
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
public void setGridGeometry(GridGeometry2D aGridGeometry)
|
||||
{
|
||||
gridGeometry = aGridGeometry;
|
||||
}
|
||||
|
||||
public BufferedImage getImage()
|
||||
{
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(BufferedImage aImage)
|
||||
{
|
||||
image = aImage;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,185 +0,0 @@
|
|||
/**
|
||||
* This software was developed and / or modified by Raytheon Company,
|
||||
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
|
||||
*
|
||||
* U.S. EXPORT CONTROLLED TECHNICAL DATA
|
||||
* This software product contains export-restricted data whose
|
||||
* export/transfer/disclosure is restricted by U.S. law. Dissemination
|
||||
* to non-U.S. persons whether in the United States or abroad requires
|
||||
* an export license or other authorization.
|
||||
*
|
||||
* Contractor Name: Raytheon Company
|
||||
* Contractor Address: 6825 Pine Street, Suite 340
|
||||
* Mail Stop B8
|
||||
* Omaha, NE 68106
|
||||
* 402.291.0100
|
||||
*
|
||||
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
|
||||
* further licensing information.
|
||||
**/
|
||||
|
||||
package com.raytheon.edex.uengine.tasks.process;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.RenderedImage;
|
||||
import java.awt.image.renderable.ParameterBlock;
|
||||
|
||||
import javax.media.jai.JAI;
|
||||
import javax.media.jai.PlanarImage;
|
||||
import javax.media.jai.RenderedOp;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoverage2D;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.geometry.Envelope2D;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.edex.uengine.exception.MicroEngineException;
|
||||
import com.raytheon.edex.uengine.tasks.ScriptTask;
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date PR# Engineer Description
|
||||
* ----------- ---------- ------------ --------------------------
|
||||
* Apr 10, 2007 njensen Initial Creation
|
||||
*
|
||||
* </PRE>
|
||||
*
|
||||
*/
|
||||
public class ReprojectImage extends ScriptTask {
|
||||
private BufferedImage image;
|
||||
|
||||
private CoordinateReferenceSystem crs;
|
||||
|
||||
private GridGeometry2D gridGeometry;
|
||||
|
||||
public ReprojectImage(BufferedImage anImage, GridGeometry2D aGridGeometry,
|
||||
CoordinateReferenceSystem aCrs) {
|
||||
image = anImage;
|
||||
gridGeometry = aGridGeometry;
|
||||
crs = aCrs;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.edex.uengine.js.tasks.ScriptTask#execute()
|
||||
*/
|
||||
@Override
|
||||
public Object execute() {
|
||||
BufferedImage reprojectedImage = null;
|
||||
logger.info("execute() reprojecting image" + ", image size="
|
||||
+ (image.getHeight() * image.getWidth()));
|
||||
Envelope2D e = gridGeometry.getEnvelope2D();
|
||||
// crs
|
||||
|
||||
GeometryFactory gf = new GeometryFactory();
|
||||
try {
|
||||
MathTransform toLatLon = MapUtil.getTransformToLatLon(gridGeometry
|
||||
.getCoordinateReferenceSystem());
|
||||
|
||||
double[] p1 = { e.getMinX(), e.getMinY() };
|
||||
double[] p2 = { e.getMaxX(), e.getMaxY() };
|
||||
|
||||
toLatLon.transform(p1, 0, p1, 0, 1);
|
||||
toLatLon.transform(p2, 0, p2, 0, 1);
|
||||
Point[] p = new Point[2];
|
||||
p[0] = gf.createPoint(new Coordinate(p1[0], p1[1]));
|
||||
p[1] = gf.createPoint(new Coordinate(p2[0], p2[1]));
|
||||
|
||||
// TODO: implement argument for other CRSes
|
||||
RenderedImage workImage = image;
|
||||
if (!workImage.getColorModel().hasAlpha()) {
|
||||
// Add alpha or we'll get ugly projection "bars"
|
||||
workImage = addAlpha(workImage);
|
||||
}
|
||||
GridCoverage2D coverage = MapUtil.constructGridCoverage(
|
||||
"MicroEngine Grid", workImage, crs, p);
|
||||
|
||||
GridCoverage2D projCoverage = MapUtil.reprojectCoverage(coverage,
|
||||
MapUtil.LATLON_PROJECTION);
|
||||
|
||||
gridGeometry = (GridGeometry2D) projCoverage.getGridGeometry();
|
||||
crs = gridGeometry.getCoordinateReferenceSystem();
|
||||
|
||||
if (projCoverage.getRenderedImage() instanceof RenderedOp) {
|
||||
reprojectedImage = ((RenderedOp) projCoverage
|
||||
.getRenderedImage()).getAsBufferedImage();
|
||||
} else {
|
||||
reprojectedImage = (BufferedImage) projCoverage
|
||||
.getRenderedImage();
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
e1.printStackTrace();
|
||||
throw new MicroEngineException("Error projecting image", e1);
|
||||
}
|
||||
|
||||
JAI.getDefaultInstance().getTileCache().flush();
|
||||
return reprojectedImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an Alpha layer in images without one (jpegs)
|
||||
*
|
||||
* @param img
|
||||
* the image to modify
|
||||
* @return the image
|
||||
*/
|
||||
private RenderedImage addAlpha(RenderedImage img) {
|
||||
ParameterBlock pb = new ParameterBlock();
|
||||
|
||||
Byte[] bandValues = new Byte[] { new Byte((byte) 255) };
|
||||
|
||||
pb.add(new Float(img.getWidth()));
|
||||
pb.add(new Float(img.getHeight()));
|
||||
pb.add(bandValues);
|
||||
PlanarImage alphaPlane = JAI.create("Constant", pb, null);
|
||||
|
||||
ParameterBlock pb2 = new ParameterBlock();
|
||||
pb2.removeParameters();
|
||||
pb2.removeSources();
|
||||
pb2.addSource(img);
|
||||
pb2.addSource(alphaPlane);
|
||||
|
||||
long t0 = System.currentTimeMillis();
|
||||
PlanarImage ro = JAI.create("BandMerge", pb2, null);
|
||||
long tDelta = System.currentTimeMillis() - t0;
|
||||
|
||||
logger.debug("Adding alpha layer took: " + tDelta + " (ms)");
|
||||
|
||||
return ro;
|
||||
|
||||
}
|
||||
|
||||
public GridGeometry2D getGridGeometry() {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
public void setGridGeometry(GridGeometry2D aGridGeometry) {
|
||||
gridGeometry = aGridGeometry;
|
||||
}
|
||||
|
||||
public BufferedImage getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(BufferedImage aImage) {
|
||||
image = aImage;
|
||||
}
|
||||
|
||||
public CoordinateReferenceSystem getCrs() {
|
||||
return crs;
|
||||
}
|
||||
|
||||
public void setCrs(CoordinateReferenceSystem aCrs) {
|
||||
crs = aCrs;
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/22/09 173_partB mgamazaychikov Initial Creation
|
||||
# 05/20/14 2913 bsteffen Remove unused imports
|
||||
#
|
||||
|
||||
import BaseRequest
|
||||
|
@ -76,7 +77,6 @@ class GempakMosaicImgLinkRequest(BaseRequest.BaseRequest):
|
|||
from com.raytheon.edex.uengine.tasks.decode import FileIn
|
||||
from com.raytheon.edex.uengine.tasks.output import FileOut
|
||||
from gov.noaa.nws.ncep.edex.plugin.mosaic.uengine import DecodeMosaicImage
|
||||
from com.raytheon.edex.uengine.tasks.process import ColorMapImage, ReprojectImage, ImageOut
|
||||
response = ArrayList()
|
||||
size = self.queryResults.size()
|
||||
for i in range(size):
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 12/22/09 173_partB mgamazaychikov Initial Creation
|
||||
# 05/20/14 2913 bsteffen Remove unused imports
|
||||
#
|
||||
|
||||
import BaseRequest
|
||||
|
@ -92,7 +93,6 @@ class GempakRadarImgLinkRequest(BaseRequest.BaseRequest):
|
|||
from com.raytheon.edex.uengine.tasks.decode import FileIn
|
||||
from com.raytheon.edex.uengine.tasks.output import FileOut
|
||||
from gov.noaa.nws.ncep.edex.uengine.tasks.radar import GempakDecodeRadarImage
|
||||
from com.raytheon.edex.uengine.tasks.process import ColorMapImage, ReprojectImage, ImageOut
|
||||
response = ArrayList()
|
||||
size = self.queryResults.size()
|
||||
for i in range(size):
|
||||
|
|
|
@ -31,6 +31,7 @@ from com.raytheon.edex.uengine.tasks.decode import FileIn
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 04/14/08 njensen Initial Creation.
|
||||
# 05/20/14 2913 bsteffen Remove image creation
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -38,7 +39,6 @@ class GridRequest(BaseRequest.BaseRequest):
|
|||
|
||||
def __init__(self, pluginName):
|
||||
BaseRequest.BaseRequest.__init__(self, pluginName)
|
||||
self.__createImage = False
|
||||
self.__reproject = False
|
||||
self.__colormap = "BW"
|
||||
self.__format = "png"
|
||||
|
@ -56,9 +56,6 @@ class GridRequest(BaseRequest.BaseRequest):
|
|||
|
||||
def reprojectImage(self, reproject):
|
||||
self.__reproject = reproject
|
||||
|
||||
def requestImage(self, image):
|
||||
self.__createImage = image
|
||||
|
||||
def requestKml(self, kml):
|
||||
self.__kml = kml
|
||||
|
@ -68,10 +65,7 @@ class GridRequest(BaseRequest.BaseRequest):
|
|||
if self.queryResults is None or self.queryResults.size() == 0:
|
||||
return self.makeNullResponse()
|
||||
else:
|
||||
if self.__createImage:
|
||||
return self.__makeImageResponse()
|
||||
else:
|
||||
return self.makeResponse()
|
||||
return self.makeResponse()
|
||||
|
||||
def makeResponse(self):
|
||||
from com.raytheon.uf.common.message.response import ResponseMessageGeneric
|
||||
|
@ -85,42 +79,4 @@ class GridRequest(BaseRequest.BaseRequest):
|
|||
def makeNullResponse(self):
|
||||
response = ArrayList()
|
||||
return response
|
||||
|
||||
def __makeImageResponse(self):
|
||||
from com.raytheon.edex.uengine.tasks.grib import GribMap
|
||||
from com.raytheon.edex.uengine.tasks.process import ColorMapImage, ReprojectImage, ImageOut
|
||||
from com.raytheon.edex.uengine.tasks.output import FileOut
|
||||
from com.raytheon.edex.uengine.tasks.response import MakeResponseUri
|
||||
from com.raytheon.uf.common.geospatial import MapUtil
|
||||
response = ArrayList()
|
||||
size = self.queryResults.size()
|
||||
for i in range(size):
|
||||
currentQuery = self.queryResults.get(i)
|
||||
geom = MapUtil.getGridGeometry(currentQuery.getSpatialObject())
|
||||
crs = geom.getCoordinateReferenceSystem()
|
||||
fileIn = FileIn(self.plugin, currentQuery)
|
||||
gribMap = GribMap(self.plugin, self.__colormap, fileIn.execute(), geom)
|
||||
gribMap.setScaleFactor(self.__scaleFactor)
|
||||
imageData = gribMap.execute()
|
||||
geom = gribMap.getGridGeometry()
|
||||
colorMap = ColorMapImage(self.__colormap, imageData, geom)
|
||||
imageOut = None
|
||||
if self.__reproject:
|
||||
reproject = ReprojectImage(colorMap.execute(), geom, crs)
|
||||
reprojectedImage = reproject.execute()
|
||||
imageOut = ImageOut(reprojectedImage, self.__format, reproject.getGridGeometry())
|
||||
else:
|
||||
imageOut = ImageOut(colorMap.execute(), self.__format,geom)
|
||||
fileOut = FileOut(imageOut.execute(), self.__format)
|
||||
writeFile = fileOut.execute()
|
||||
makeResponse = MakeResponseUri(writeFile, None, currentQuery.getIdentifier(), self.__format)
|
||||
response.add(makeResponse.execute())
|
||||
if self.__kml:
|
||||
from com.raytheon.edex.uengine.tasks.output import KmlImage
|
||||
kmlImage = KmlImage(writeFile, geom)
|
||||
kmlFile = kmlImage.execute()
|
||||
kmlResponse = MakeResponseUri(kmlFile, None, None, "kml")
|
||||
response.add(kmlResponse.execute())
|
||||
|
||||
return response
|
||||
|
|
@ -10,6 +10,7 @@ from java.util import ArrayList
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 09/2009 144 T. Lee Initial Creation.
|
||||
# 05/20/14 2913 bsteffen Remove image creation
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -17,7 +18,6 @@ class McidasRequest(BaseRequest.BaseRequest):
|
|||
|
||||
def __init__(self,):
|
||||
BaseRequest.BaseRequest.__init__(self, "mcidas")
|
||||
self.__createImage = False
|
||||
self.__reproject = False
|
||||
self.__colormap = "BW"
|
||||
self.__format = "png"
|
||||
|
@ -32,9 +32,6 @@ class McidasRequest(BaseRequest.BaseRequest):
|
|||
def reprojectImage(self, reproject):
|
||||
self.__reproject = reproject
|
||||
|
||||
def requestImage(self, image):
|
||||
self.__createImage = image
|
||||
|
||||
def requestKml(self, kml):
|
||||
self.__kml = kml
|
||||
|
||||
|
@ -43,41 +40,4 @@ class McidasRequest(BaseRequest.BaseRequest):
|
|||
if self.queryResults is None or self.queryResults.size() == 0:
|
||||
self.makeNullResponse()
|
||||
else:
|
||||
if self.__createImage:
|
||||
return self.__makeImageResponse()
|
||||
else:
|
||||
return self.makeResponse()
|
||||
|
||||
def __makeImageResponse(self):
|
||||
from com.raytheon.edex.uengine.tasks.decode import FileIn
|
||||
from com.raytheon.edex.uengine.tasks.process import ColorMapImage, ReprojectImage, ImageOut
|
||||
from com.raytheon.edex.uengine.tasks.output import FileOut
|
||||
from com.raytheon.edex.uengine.tasks.response import MakeResponseUri
|
||||
from com.raytheon.uf.common.geospatial import MapUtil
|
||||
response = ArrayList()
|
||||
size = self.queryResults.size()
|
||||
for i in range(size):
|
||||
currentQuery = self.queryResults.get(i)
|
||||
geom = MapUtil.getGridGeometry(currentQuery.getSpatialObject())
|
||||
crs = geom.getCoordinateReferenceSystem()
|
||||
fileIn = FileIn(self.plugin, currentQuery)
|
||||
record = fileIn.execute()
|
||||
colorMap = ColorMapImage(self.__colormap, record.getDataObject(), geom)
|
||||
imageOut = None
|
||||
if self.__reproject:
|
||||
reproject = ReprojectImage(colorMap.execute(), geom, crs)
|
||||
reprojectedImage = reproject.execute()
|
||||
imageOut = ImageOut(reprojectedImage, self.__format, reproject.getGridGeometry())
|
||||
else:
|
||||
imageOut = ImageOut(colorMap.execute(), self.__format, geom)
|
||||
fileOut = FileOut(imageOut.execute(), self.__format)
|
||||
writeFile = fileOut.execute()
|
||||
makeResponse = MakeResponseUri(writeFile, None, currentQuery.getIdentifier(), self.__format)
|
||||
response.add(makeResponse.execute())
|
||||
if self.__kml:
|
||||
from com.raytheon.edex.uengine.tasks.output import KmlImage
|
||||
kmlImage = KmlImage(writeFile, geom)
|
||||
kmlFile = kmlImage.execute()
|
||||
kmlResponse = MakeResponseUri(kmlFile, None, None, "kml")
|
||||
response.add(kmlResponse.execute())
|
||||
return response
|
||||
return self.makeResponse()
|
||||
|
|
|
@ -30,6 +30,7 @@ from java.util import ArrayList
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 04/14/08 njensen Initial Creation.
|
||||
# 05/20/14 2913 bsteffen Remove image creation
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -37,7 +38,6 @@ class RadarRequest(BaseRequest.BaseRequest):
|
|||
|
||||
def __init__(self):
|
||||
BaseRequest.BaseRequest.__init__(self, "radar")
|
||||
self.__createImage = False
|
||||
self.__reproject = False
|
||||
self.__colormap = "BW"
|
||||
self.__format = "png"
|
||||
|
@ -52,9 +52,6 @@ class RadarRequest(BaseRequest.BaseRequest):
|
|||
def reprojectImage(self, reproject):
|
||||
self.__reproject = reproject
|
||||
|
||||
def requestImage(self, image):
|
||||
self.__createImage = image
|
||||
|
||||
def requestKml(self, kml):
|
||||
self.__kml = kml
|
||||
|
||||
|
@ -63,44 +60,5 @@ class RadarRequest(BaseRequest.BaseRequest):
|
|||
if self.queryResults is None or self.queryResults.size() == 0:
|
||||
self.makeNullResponse()
|
||||
else:
|
||||
if self.__createImage:
|
||||
return self.__makeImageResponse()
|
||||
else:
|
||||
return self.makeResponse()
|
||||
|
||||
def __makeImageResponse(self):
|
||||
from com.raytheon.edex.uengine.tasks.decode import FileIn
|
||||
from com.raytheon.edex.uengine.tasks.radar import DecodeRadarImage
|
||||
from com.raytheon.edex.uengine.tasks.process import ColorMapImage, ReprojectImage, ImageOut
|
||||
from com.raytheon.edex.uengine.tasks.output import FileOut
|
||||
from com.raytheon.edex.uengine.tasks.response import MakeResponseUri
|
||||
response = ArrayList()
|
||||
size = self.queryResults.size()
|
||||
for i in range(size):
|
||||
currentQuery = self.queryResults.get(i)
|
||||
fileIn = FileIn(self.plugin, currentQuery)
|
||||
records = fileIn.retrieveGroup()
|
||||
radarImage = DecodeRadarImage(currentQuery, records)
|
||||
geom = radarImage.getGridGeometry()
|
||||
crs = radarImage.getCrs()
|
||||
colorMap = ColorMapImage(self.__colormap, radarImage.execute(), geom)
|
||||
imageOut = None
|
||||
if self.__reproject:
|
||||
reproject = ReprojectImage(colorMap.execute(), geom, crs)
|
||||
reprojectedImage = reproject.execute()
|
||||
imageOut = ImageOut(reprojectedImage, self.__format, reproject.getGridGeometry())
|
||||
else:
|
||||
imageOut = ImageOut(colorMap.execute(), self.__format, geom)
|
||||
fileOut = FileOut(imageOut.execute(), self.__format)
|
||||
writeFile = fileOut.execute()
|
||||
makeResponse = MakeResponseUri(writeFile, None, currentQuery.getIdentifier(), self.__format)
|
||||
response.add(makeResponse.execute())
|
||||
if self.__kml:
|
||||
from com.raytheon.edex.uengine.tasks.output import KmlImage
|
||||
kmlImage = KmlImage(writeFile, geom)
|
||||
kmlFile = kmlImage.execute()
|
||||
kmlResponse = MakeResponseUri(kmlFile, None, None, "kml")
|
||||
response.add(kmlResponse.execute())
|
||||
|
||||
return response
|
||||
return self.makeResponse()
|
||||
|
|
@ -30,6 +30,7 @@ from java.util import ArrayList
|
|||
# Date Ticket# Engineer Description
|
||||
# ------------ ---------- ----------- --------------------------
|
||||
# 04/14/08 njensen Initial Creation.
|
||||
# 05/20/14 2913 bsteffen Remove image creation
|
||||
#
|
||||
#
|
||||
|
||||
|
@ -37,7 +38,6 @@ class SatelliteRequest(BaseRequest.BaseRequest):
|
|||
|
||||
def __init__(self):
|
||||
BaseRequest.BaseRequest.__init__(self, "satellite")
|
||||
self.__createImage = False
|
||||
self.__reproject = False
|
||||
self.__colormap = "BW"
|
||||
self.__format = "png"
|
||||
|
@ -52,9 +52,6 @@ class SatelliteRequest(BaseRequest.BaseRequest):
|
|||
def reprojectImage(self, reproject):
|
||||
self.__reproject = reproject
|
||||
|
||||
def requestImage(self, image):
|
||||
self.__createImage = image
|
||||
|
||||
def requestKml(self, kml):
|
||||
self.__kml = kml
|
||||
|
||||
|
@ -63,43 +60,6 @@ class SatelliteRequest(BaseRequest.BaseRequest):
|
|||
if self.queryResults is None or self.queryResults.size() == 0:
|
||||
self.makeNullResponse()
|
||||
else:
|
||||
if self.__createImage:
|
||||
return self.__makeImageResponse()
|
||||
else:
|
||||
return self.makeResponse()
|
||||
|
||||
def __makeImageResponse(self):
|
||||
from com.raytheon.edex.uengine.tasks.decode import FileIn
|
||||
from com.raytheon.edex.uengine.tasks.process import ColorMapImage, ReprojectImage, ImageOut
|
||||
from com.raytheon.edex.uengine.tasks.output import FileOut
|
||||
from com.raytheon.edex.uengine.tasks.response import MakeResponseUri
|
||||
from com.raytheon.uf.common.geospatial import MapUtil
|
||||
response = ArrayList()
|
||||
size = self.queryResults.size()
|
||||
for i in range(size):
|
||||
currentQuery = self.queryResults.get(i)
|
||||
geom = MapUtil.getGridGeometry(currentQuery.getSpatialObject())
|
||||
crs = geom.getCoordinateReferenceSystem()
|
||||
fileIn = FileIn(self.plugin, currentQuery)
|
||||
record = fileIn.execute()
|
||||
colorMap = ColorMapImage(self.__colormap, record.getDataObject(), geom)
|
||||
imageOut = None
|
||||
if self.__reproject:
|
||||
reproject = ReprojectImage(colorMap.execute(), geom, crs)
|
||||
reprojectedImage = reproject.execute()
|
||||
imageOut = ImageOut(reprojectedImage, self.__format, reproject.getGridGeometry())
|
||||
else:
|
||||
imageOut = ImageOut(colorMap.execute(), self.__format, geom)
|
||||
fileOut = FileOut(imageOut.execute(), self.__format)
|
||||
writeFile = fileOut.execute()
|
||||
makeResponse = MakeResponseUri(writeFile, None, currentQuery.getIdentifier(), self.__format)
|
||||
response.add(makeResponse.execute())
|
||||
if self.__kml:
|
||||
from com.raytheon.edex.uengine.tasks.output import KmlImage
|
||||
kmlImage = KmlImage(writeFile, geom)
|
||||
kmlFile = kmlImage.execute()
|
||||
kmlResponse = MakeResponseUri(kmlFile, None, None, "kml")
|
||||
response.add(kmlResponse.execute())
|
||||
|
||||
return response
|
||||
return self.makeResponse()
|
||||
|
||||
|
Loading…
Add table
Reference in a new issue