Merge branch 'field_14.3.1' of ssh://collaborate3.nws.noaa.gov:29418/AWIPS2_Dev_Baseline into master_14.3.1
Former-commit-id:0f6b0f3d9d
[formerly 0813f96fbb673fdbbdb2c0f049ec722a80b212f9] Former-commit-id:a155bbd8c1
This commit is contained in:
commit
125760432b
10 changed files with 373 additions and 129 deletions
|
@ -28,6 +28,7 @@ import javax.xml.bind.annotation.XmlAccessorType;
|
|||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
|
||||
import com.raytheon.uf.viz.truecolor.extension.ITrueColorImagingExtension.Channel;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +42,7 @@ import com.raytheon.uf.viz.truecolor.extension.ITrueColorImagingExtension.Channe
|
|||
* ------------- -------- ----------- --------------------------
|
||||
* Aug 20, 2012 mschenke Initial creation
|
||||
* Apr 18, 2014 2947 bsteffen Support unitless data.
|
||||
*
|
||||
* Sep 9, 2014 DR 17313 jgerth Support for ColorMapParameters
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -60,7 +61,9 @@ public class ChannelInfo {
|
|||
@XmlElement
|
||||
private double rangeMax = 1.0;
|
||||
|
||||
private Unit<?> unit = Unit.ONE;
|
||||
private Unit<?> unit;
|
||||
|
||||
private ColorMapParameters parameters;
|
||||
|
||||
/**
|
||||
* @return the channel
|
||||
|
@ -144,6 +147,14 @@ public class ChannelInfo {
|
|||
: null;
|
||||
}
|
||||
|
||||
public ColorMapParameters getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(ColorMapParameters parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.truecolor.extension.ITrueColorImagingExtension.Channel;
|
||||
|
||||
/**
|
||||
|
@ -37,18 +38,26 @@ import com.raytheon.uf.viz.truecolor.extension.ITrueColorImagingExtension.Channe
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 16, 2012 mschenke Initial creation
|
||||
* Aug 22, 2014 DR 17313 jgerth Support for load properties
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author mschenke
|
||||
* @version 1.0
|
||||
*/
|
||||
/**
|
||||
* @author awips
|
||||
*
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class ChannelResource {
|
||||
|
||||
@XmlElement
|
||||
protected AbstractResourceData resourceData;
|
||||
|
||||
@XmlElement
|
||||
protected LoadProperties loadProperties;
|
||||
|
||||
@XmlElement
|
||||
protected Channel channel;
|
||||
|
||||
|
@ -100,6 +109,21 @@ public class ChannelResource {
|
|||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loadProperties
|
||||
*/
|
||||
public LoadProperties getLoadProperties() {
|
||||
return loadProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loadProperties
|
||||
* the loadProperties to set
|
||||
*/
|
||||
public void setLoadProperties(LoadProperties loadProperties) {
|
||||
this.loadProperties = loadProperties;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
|
|
@ -25,11 +25,13 @@ import java.util.IdentityHashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.Unit;
|
||||
|
||||
import org.eclipse.swt.graphics.Rectangle;
|
||||
import org.opengis.referencing.crs.CoordinateReferenceSystem;
|
||||
|
||||
import com.raytheon.uf.common.colormap.prefs.ColorMapParameters;
|
||||
import com.raytheon.uf.common.geospatial.ReferencedCoordinate;
|
||||
import com.raytheon.uf.common.status.UFStatus.Priority;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
|
@ -69,6 +71,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* ------------- -------- ----------- --------------------------
|
||||
* Aug 06, 2012 mschenke Initial creation
|
||||
* Apr 18, 2014 2947 bsteffen Support unitless data.
|
||||
* Sep 10, 2014 DR 17313 jgerth Add inspect method
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -140,7 +143,7 @@ public class TrueColorResourceGroup extends
|
|||
* Mapping to keep colormap parameters in sync with ChannelInfo in
|
||||
* resourceData
|
||||
*/
|
||||
private Map<ColorMapParameters, ChannelInfo> channelInfoMap = new IdentityHashMap<ColorMapParameters, ChannelInfo>();
|
||||
private Map<ColorMapCapability, ChannelInfo> channelInfoMap = new IdentityHashMap<ColorMapCapability, ChannelInfo>();
|
||||
|
||||
/**
|
||||
* @param resourceData
|
||||
|
@ -246,9 +249,9 @@ public class TrueColorResourceGroup extends
|
|||
for (ChannelResource cr : resourceData.getChannelResources()) {
|
||||
for (ResourcePair rp : resources) {
|
||||
if (cr.getResourceData() == rp.getResourceData()) {
|
||||
DisplayedChannelResource displayedResource = new DisplayedChannelResource(
|
||||
DisplayedChannelResource displayedResource = new DisplayedChannelResource(
|
||||
cr, rp.getResource());
|
||||
AbstractVizResource<?, ?> resource = rp.getResource();
|
||||
AbstractVizResource<?, ?> resource = rp.getResource();
|
||||
resource.init(target);
|
||||
|
||||
// Check resource for required capabilities
|
||||
|
@ -256,16 +259,7 @@ public class TrueColorResourceGroup extends
|
|||
if (resource.hasCapability(ImagingCapability.class)) {
|
||||
ImagingCapability imaging = resource
|
||||
.getCapability(ImagingCapability.class);
|
||||
if (imaging.getProvider() != null) {
|
||||
if (resource
|
||||
.hasCapability(ColorMapCapability.class) == false) {
|
||||
error = "does not have ColorMapCapability";
|
||||
} else if (resource.getCapability(
|
||||
ColorMapCapability.class)
|
||||
.getColorMapParameters() == null) {
|
||||
error = "does not have ColorMapParameters set";
|
||||
}
|
||||
} else {
|
||||
if (imaging.getProvider() == null) {
|
||||
error = "does not have image provider set on the ImagingCapability";
|
||||
}
|
||||
} else {
|
||||
|
@ -279,35 +273,32 @@ public class TrueColorResourceGroup extends
|
|||
|
||||
if (error == null) {
|
||||
// No errors so far, check for ChannelInfo override
|
||||
ColorMapParameters params = resource.getCapability(
|
||||
ColorMapCapability.class)
|
||||
ColorMapCapability cmapCap = resource
|
||||
.getCapability(ColorMapCapability.class);
|
||||
ColorMapParameters params = cmapCap
|
||||
.getColorMapParameters();
|
||||
|
||||
ChannelInfo ci = resourceData
|
||||
.getChannelInfo(displayedResource.getChannel());
|
||||
if (ci == null
|
||||
|| ci.getUnit().isCompatible(
|
||||
params.getDataUnit())) {
|
||||
if (ci == null) {
|
||||
ci = new ChannelInfo();
|
||||
ci.setChannel(displayedResource.getChannel());
|
||||
resourceData.setChannelInfo(ci);
|
||||
} else {
|
||||
params.setDisplayUnit(ci.getUnit());
|
||||
params.setColorMapMin((float) params
|
||||
.getDisplayToDataConverter().convert(
|
||||
ci.getRangeMin()));
|
||||
params.setColorMapMax((float) params
|
||||
.getDisplayToDataConverter().convert(
|
||||
ci.getRangeMax()));
|
||||
if (ci == null) {
|
||||
ci = new ChannelInfo();
|
||||
ci.setChannel(displayedResource.getChannel());
|
||||
if (params != null) {
|
||||
ci.setUnit(params.getColorMapUnit());
|
||||
ci.setRangeMin(params.getColorMapMin());
|
||||
ci.setRangeMax(params.getColorMapMax());
|
||||
}
|
||||
channelInfoMap.put(params, ci);
|
||||
resourceChanged(
|
||||
ChangeType.CAPABILITY,
|
||||
resource.getCapability(ColorMapCapability.class));
|
||||
} else {
|
||||
error = "is not compatible with custom ChannelInfo for Channel="
|
||||
+ displayedResource.getChannel();
|
||||
resourceData.setChannelInfo(ci);
|
||||
}
|
||||
|
||||
channelInfoMap.put(cmapCap, ci);
|
||||
|
||||
if (params != null && params.getColorMapUnit() == null) {
|
||||
// no colormap units set, default to ChannelInfo
|
||||
params.setColorMapUnit(ci.getUnit());
|
||||
}
|
||||
|
||||
initializeParameters(ci, params);
|
||||
}
|
||||
|
||||
if (error != null) {
|
||||
|
@ -317,7 +308,9 @@ public class TrueColorResourceGroup extends
|
|||
+ error);
|
||||
resources.remove(rp);
|
||||
} else {
|
||||
resource.getResourceData().addChangeListener(this);
|
||||
// Listener will handle case where params are changed
|
||||
// after the fact and we will reinitialize
|
||||
resource.getResourceData().addChangeListener(this);
|
||||
displayedResources.put(displayedResource.getChannel(),
|
||||
displayedResource);
|
||||
}
|
||||
|
@ -430,19 +423,90 @@ public class TrueColorResourceGroup extends
|
|||
if (toDisplay == null) {
|
||||
toDisplay = UnitConverter.IDENTITY;
|
||||
}
|
||||
ChannelInfo ci = channelInfoMap.get(params);
|
||||
ChannelInfo ci = channelInfoMap.get(object);
|
||||
if (ci != null) {
|
||||
ci.setRangeMin(toDisplay.convert(
|
||||
params.getColorMapMin()));
|
||||
ci.setRangeMax(toDisplay.convert(
|
||||
params.getColorMapMax()));
|
||||
ci.setUnit(params.getDisplayUnit());
|
||||
if (ci.getParameters() != params) {
|
||||
// Reinitialize params from channel info
|
||||
initializeParameters(ci, params);
|
||||
} else {
|
||||
ci.setRangeMin(toDisplay.convert(params
|
||||
.getColorMapMin()));
|
||||
ci.setRangeMax(toDisplay.convert(params
|
||||
.getColorMapMax()));
|
||||
ci.setUnit(params.getDisplayUnit());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
issueRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String inspect(ReferencedCoordinate coord) throws VizException {
|
||||
String label = "";
|
||||
for (Channel c : Channel.values()) {
|
||||
DisplayedChannelResource dcr = displayedResources.get(c);
|
||||
if (dcr != null) {
|
||||
String ri = dcr.resource.inspect(coord);
|
||||
label += c.name() + ": " + ri;
|
||||
if (dcr.resource.hasCapability(ColorMapCapability.class) && ri.replaceAll("[^\\d]", "").length() > 0) {
|
||||
ColorMapParameters cmp = dcr.resource.getCapability(ColorMapCapability.class).getColorMapParameters();
|
||||
UnitConverter uc = cmp.getColorMapToDisplayConverter();
|
||||
if (uc == null)
|
||||
uc = UnitConverter.IDENTITY;
|
||||
double cmmax = uc.convert(cmp.getColorMapMax());
|
||||
double cmmin = uc.convert(cmp.getColorMapMin());
|
||||
String rirall;
|
||||
if (ri.charAt(0) == ('-'))
|
||||
rirall = "-" + (ri.substring(1) + "x").replaceAll("[^\\d.]", " ");
|
||||
else
|
||||
rirall = (ri + "x").replaceAll("[^\\d.]", " ");
|
||||
try {
|
||||
double value = Double.parseDouble(rirall.substring(0,rirall.indexOf(" ")));
|
||||
double percent = ((value - cmmin) * 100.0 / (cmmax - cmmin));
|
||||
if (percent < 0)
|
||||
percent = 0.0;
|
||||
else if (percent > 100)
|
||||
percent = 100.0;
|
||||
label += " (" + Math.round(percent) + "%)\n";
|
||||
} catch (Exception e) {
|
||||
label += "\n";
|
||||
}
|
||||
} else
|
||||
label += "\n";
|
||||
}
|
||||
}
|
||||
if (label.length() > 0)
|
||||
return label;
|
||||
else
|
||||
return "NO DATA";
|
||||
}
|
||||
|
||||
private static void initializeParameters(ChannelInfo ci,
|
||||
ColorMapParameters params) {
|
||||
if (params != null) {
|
||||
ci.setParameters(params);
|
||||
if (ci.getUnit() != null && params.getColorMapUnit() != null
|
||||
&& ci.getUnit().isCompatible(params.getColorMapUnit())) {
|
||||
params.setDisplayUnit(ci.getUnit());
|
||||
UnitConverter displayToCmap = params
|
||||
.getDisplayToColorMapConverter();
|
||||
params.setColorMapMin(
|
||||
(float) displayToCmap.convert(ci.getRangeMin()),
|
||||
true);
|
||||
params.setColorMapMax(
|
||||
(float) displayToCmap.convert(ci.getRangeMax()),
|
||||
true);
|
||||
} else {
|
||||
UnitConverter cmapToDisplay = params
|
||||
.getColorMapToDisplayConverter();
|
||||
ci.setRangeMin(cmapToDisplay.convert(params.getColorMapMin()));
|
||||
ci.setRangeMax(cmapToDisplay.convert(params.getColorMapMax()));
|
||||
ci.setUnit(params.getDisplayUnit());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<DisplayedChannelResource> getChannelResources() {
|
||||
return displayedResources.values();
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ import com.raytheon.uf.viz.truecolor.extension.ITrueColorImagingExtension.Channe
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 6, 2012 mschenke Initial creation
|
||||
* Aug 22, 2014 DR 17313 jgerth Support for load properties
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -94,16 +95,19 @@ public class TrueColorResourceGroupData extends AbstractResourceData implements
|
|||
}
|
||||
};
|
||||
for (ChannelResource resource : channelResources) {
|
||||
addResource(resource.getResourceData());
|
||||
addResource(resource.getResourceData(), resource.getLoadProperties());
|
||||
}
|
||||
}
|
||||
return resourceList;
|
||||
}
|
||||
|
||||
private void addResource(AbstractResourceData resourceData) {
|
||||
private void addResource(AbstractResourceData resourceData, LoadProperties loadProp) {
|
||||
ResourcePair rp = new ResourcePair();
|
||||
rp.setResourceData(resourceData);
|
||||
rp.setLoadProperties(new LoadProperties());
|
||||
if (loadProp == null)
|
||||
rp.setLoadProperties(new LoadProperties());
|
||||
else
|
||||
rp.setLoadProperties(loadProp);
|
||||
rp.setProperties(new ResourceProperties());
|
||||
resourceList.add(rp);
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ import com.raytheon.viz.core.gl.objects.GLTextureObject;
|
|||
* Oct 16, 2013 2333 mschenke Cleaned up load shader method, used isScaled.
|
||||
* Added support for colormapping in non-data unit.
|
||||
* Nov 20, 2013 2492 bsteffen Mosaic in image units.
|
||||
*
|
||||
* Aug 21, 2014 DR 17313 jgerth Support for true color
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -212,7 +212,8 @@ public class GLColormappedImageExtension extends AbstractGLSLImagingExtension
|
|||
// datamapping is not set, the data has already been mapped to
|
||||
// colorMapUnits and we need not do anything
|
||||
GLDataMapping dataMapping = glImage.getDataMapping();
|
||||
if (dataMapping == null && colorMapParameters.getDataMapping() == null) {
|
||||
if (dataMapping == null && colorMapParameters.getDataMapping() == null &&
|
||||
colorMapParameters.getColorMap() != null) {
|
||||
Unit<?> dataUnit = glImage.getDataUnit();
|
||||
int colorMapSize = colorMapParameters.getColorMap().getSize();
|
||||
float colorMapMin = colorMapParameters.getColorMapMin();
|
||||
|
|
|
@ -22,6 +22,8 @@ package com.raytheon.viz.grid.rsc.general;
|
|||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -64,12 +66,14 @@ import com.raytheon.uf.common.style.contour.ContourPreferences;
|
|||
import com.raytheon.uf.common.style.image.ColorMapParameterFactory;
|
||||
import com.raytheon.uf.common.style.image.ImagePreferences;
|
||||
import com.raytheon.uf.common.time.DataTime;
|
||||
import com.raytheon.uf.viz.core.DrawableImage;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.VizApp;
|
||||
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderable;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintStatus;
|
||||
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension.ImageProvider;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
|
||||
|
@ -125,7 +129,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Jan 14, 2014 2594 bsteffen Switch vector mag/dir to use data source
|
||||
* instead of raw float data.
|
||||
* Feb 28, 2014 2791 bsteffen Switch all data to use data source.
|
||||
*
|
||||
* Aug 21, 2014 DR 17313 jgerth Implements ImageProvider
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -134,7 +138,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* @param <T>
|
||||
*/
|
||||
public abstract class AbstractGridResource<T extends AbstractResourceData>
|
||||
extends AbstractVizResource<T, IMapDescriptor> {
|
||||
extends AbstractVizResource<T, IMapDescriptor> implements ImageProvider {
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(AbstractGridResource.class);
|
||||
|
||||
|
@ -345,6 +349,7 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
|
|||
this.getCapability(ImagingCapability.class)
|
||||
.setInterpolationState(true);
|
||||
}
|
||||
this.getCapability(ImagingCapability.class).setProvider(this);
|
||||
altDisplayTypes.add(DisplayType.CONTOUR);
|
||||
break;
|
||||
case BARB:
|
||||
|
@ -438,43 +443,6 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
DataTime time = paintProps.getDataTime();
|
||||
if (time == null) {
|
||||
time = getTimeForResource();
|
||||
}
|
||||
if (time == null) {
|
||||
return;
|
||||
}
|
||||
synchronized (renderableMap) {
|
||||
if (renderableMap.containsKey(time)) {
|
||||
for (IRenderable renderable : renderableMap.get(time)) {
|
||||
renderable.paint(target, paintProps);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
List<GeneralGridData> dataList = requestData(time);
|
||||
if (dataList == null) {
|
||||
updatePaintStatus(PaintStatus.INCOMPLETE);
|
||||
return;
|
||||
}
|
||||
|
||||
List<IRenderable> renderableList = new ArrayList<IRenderable>(
|
||||
dataList.size());
|
||||
for (GeneralGridData data : dataList) {
|
||||
IRenderable renderable = createRenderable(target, data);
|
||||
if (renderable != null) {
|
||||
renderableList.add(renderable);
|
||||
renderable.paint(target, paintProps);
|
||||
}
|
||||
}
|
||||
renderableMap.put(time, renderableList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a renderable for this data.
|
||||
*
|
||||
|
@ -999,4 +967,63 @@ public abstract class AbstractGridResource<T extends AbstractResourceData>
|
|||
return new ArrayList<PluginDataObject>(list);
|
||||
}
|
||||
|
||||
public Collection<DrawableImage> getImages(IGraphicsTarget target, PaintProperties paintProps) throws VizException {
|
||||
if (getCapability(DisplayTypeCapability.class).getDisplayType() != DisplayType.IMAGE) {
|
||||
throw new VizException("Grid resource not configured for image rendering");
|
||||
}
|
||||
Collection<IRenderable> renderables = getOrCreateRenderables(target, paintProps);
|
||||
if (renderables.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<DrawableImage> images = new ArrayList<DrawableImage>();
|
||||
for (IRenderable renderable : renderables) {
|
||||
images.addAll(((TileSetRenderable)renderable).getImagesToRender(target, paintProps));
|
||||
}
|
||||
return images;
|
||||
}
|
||||
|
||||
protected Collection<IRenderable> getOrCreateRenderables(
|
||||
IGraphicsTarget target, PaintProperties paintProps)
|
||||
throws VizException {
|
||||
DataTime time = paintProps.getDataTime();
|
||||
if (time == null) {
|
||||
time = getTimeForResource();
|
||||
}
|
||||
if (time == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<IRenderable> renderables;
|
||||
|
||||
synchronized (renderableMap) {
|
||||
if (renderableMap.containsKey(time)) {
|
||||
renderables = renderableMap.get(time);
|
||||
} else {
|
||||
List<GeneralGridData> dataList = requestData(time);
|
||||
if (dataList == null) {
|
||||
updatePaintStatus(PaintStatus.INCOMPLETE);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
renderables = new ArrayList<IRenderable>(dataList.size());
|
||||
for (GeneralGridData data : dataList) {
|
||||
IRenderable renderable = createRenderable(target, data);
|
||||
if (renderable != null) {
|
||||
renderables.add(renderable);
|
||||
}
|
||||
}
|
||||
renderableMap.put(time, renderables);
|
||||
}
|
||||
}
|
||||
return renderables;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
for (IRenderable renderable : getOrCreateRenderables(target, paintProps)) {
|
||||
renderable.paint(target, paintProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,6 +101,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* Apr 09, 2014 2947 bsteffen Improve flexibility of sat derived
|
||||
* parameters, implement ImageProvider
|
||||
* May 06, 2014 njensen Improve error message
|
||||
* Aug 21, 2014 DR 17313 jgerth Set no data value if no data mapping
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -354,7 +355,8 @@ public class SatResource extends
|
|||
if (persisted != null) {
|
||||
colorMapParameters.applyPersistedParameters(persisted);
|
||||
}
|
||||
colorMapParameters.setNoDataValue(0);
|
||||
if (colorMapParameters.getDataMapping() == null)
|
||||
colorMapParameters.setNoDataValue(0);
|
||||
|
||||
getCapability(ColorMapCapability.class).setColorMapParameters(
|
||||
colorMapParameters);
|
||||
|
@ -423,7 +425,7 @@ public class SatResource extends
|
|||
if (dataMapping != null) {
|
||||
// if the pixel value matches the data mapping entry use that
|
||||
// label instead
|
||||
String label = dataMapping.getLabelValueForDataValue(measuredValue);
|
||||
String label = dataMapping.getSampleOrLabelValueForDataValue(measuredValue);
|
||||
if (label != null) {
|
||||
return label;
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ import com.vividsolutions.jts.geom.Envelope;
|
|||
* Sep 30, 2013 2333 mschenke Refactored to store points in crs space
|
||||
* Apr 15, 2014 3017 bsteffen Add new getCoverage methods to support
|
||||
* either one corner + dx/dy or two corners.
|
||||
*
|
||||
* Sep 15, 2014 DR 17303 jgerth Support for second standard latitude
|
||||
* </pre>
|
||||
*/
|
||||
public class SatSpatialFactory {
|
||||
|
@ -141,18 +141,20 @@ public class SatSpatialFactory {
|
|||
* @param ny
|
||||
* the number of rows of data.
|
||||
* @param lov
|
||||
* the longitude orientatition, used by
|
||||
* the longitude orientation, used by
|
||||
* {@link #PROJ_CYLIN_EQUIDISTANT}, {@link #PROJ_LAMBERT},
|
||||
* {@link #PROJ_POLAR}.
|
||||
* @param latin
|
||||
* the latitude at which the projection is tangent to the earths
|
||||
* surface, used by {@link #PROJ_CYLIN_EQUIDISTANT},
|
||||
* {@link #PROJ_LAMBERT}, {@link #PROJ_MERCATOR}.
|
||||
* @param latin2
|
||||
* the second standard latitude, used by {@link #PROJ_LAMBERT}.
|
||||
* @param la1
|
||||
* the latitude of a corner of the grid, if dy is positive this
|
||||
* is an upper corner.
|
||||
* @param lo1
|
||||
* the longitide of a corner of the grid, if dx is positive this
|
||||
* the longitude of a corner of the grid, if dx is positive this
|
||||
* is a left corner
|
||||
* @param dx
|
||||
* the distance between columns measured in CRS meters.
|
||||
|
@ -163,10 +165,10 @@ public class SatSpatialFactory {
|
|||
* @throws DecoderException
|
||||
*/
|
||||
public SatMapCoverage getCoverageSingleCorner(int crsType, int nx, int ny,
|
||||
double lov, double latin, double la1, double lo1, double dx,
|
||||
double lov, double latin, double latin2, double la1, double lo1, double dx,
|
||||
double dy) throws DecoderException {
|
||||
try {
|
||||
ProjectedCRS crs = createCRS(crsType, lov, latin, 0.0);
|
||||
ProjectedCRS crs = createCRS(crsType, lov, latin, latin2, 0.0);
|
||||
DirectPosition2D corner = new DirectPosition2D(lo1, la1);
|
||||
MathTransform fromLatLon = MapUtil.getTransformFromLatLon(crs);
|
||||
fromLatLon.transform(corner, corner);
|
||||
|
@ -193,10 +195,19 @@ public class SatSpatialFactory {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link #getCoverageSingleCorner(int, int, int, double, double, double, double, double, double, double)}
|
||||
*/
|
||||
public SatMapCoverage getCoverageSingleCorner(int crsType, int nx, int ny,
|
||||
double lov, double latin, double la1, double lo1, double dx,
|
||||
double dy) throws DecoderException {
|
||||
return getCoverageSingleCorner(crsType, nx, ny, lov, latin, latin, la1, lo1, dx, dy);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Create a {@link SatMapCoverage} with an area defined by two corners. The
|
||||
* two corners must be opposite(diagnol) from eachother. They caan be either
|
||||
* two corners must be opposite (diagonal) from each other. They can be either
|
||||
* the upper left and lower right or the upper right and lower left corners.
|
||||
*
|
||||
* @param crsType
|
||||
|
@ -204,36 +215,38 @@ public class SatSpatialFactory {
|
|||
* {@link #PROJ_CYLIN_EQUIDISTANT}, {@link #PROJ_LAMBERT},
|
||||
* {@link #PROJ_MERCATOR}, {@link #PROJ_POLAR}.
|
||||
* @param lov
|
||||
* the longitude orientatition, used by
|
||||
* the longitude orientation, used by
|
||||
* {@link #PROJ_CYLIN_EQUIDISTANT}, {@link #PROJ_LAMBERT},
|
||||
* {@link #PROJ_POLAR}.
|
||||
* @param latin
|
||||
* the latitude at which the projection is tangent to the earths
|
||||
* surface, used by {@link #PROJ_CYLIN_EQUIDISTANT},
|
||||
* {@link #PROJ_LAMBERT}, {@link #PROJ_MERCATOR}.
|
||||
* @param latin2
|
||||
* the second standard latitude, used by {@link #PROJ_LAMBERT}.
|
||||
* @param la1
|
||||
* the latitude of a corner of the grid.
|
||||
* @param lo1
|
||||
* the longitide of a corner of the grid.
|
||||
* the longitude of a corner of the grid.
|
||||
* @param la2
|
||||
* the latitude of a corner of the grid., should be opposite
|
||||
* corner from la1.
|
||||
* @param lo2
|
||||
* the longitide of a corner of the grid, should be opposite
|
||||
* the longitude of a corner of the grid, should be opposite
|
||||
* corner from lo1
|
||||
* @return a {@link SatMapCoverage} matching these parameters that has been
|
||||
* loaded from or persisted to the database.
|
||||
* @throws DecoderException
|
||||
*/
|
||||
public SatMapCoverage getCoverageTwoCorners(int crsType, int nx, int ny,
|
||||
double lov, double latin, double la1, double lo1, double la2,
|
||||
double lov, double latin, double latin2, double la1, double lo1, double la2,
|
||||
double lo2) throws DecoderException {
|
||||
try {
|
||||
double cm = 0.0;
|
||||
if ((lo1 > 0.0) && (lo2 < 0.0)) {
|
||||
cm = 180.0;
|
||||
}
|
||||
ProjectedCRS crs = createCRS(crsType, lov, latin, cm);
|
||||
ProjectedCRS crs = createCRS(crsType, lov, latin, latin2, cm);
|
||||
DirectPosition2D corner1 = new DirectPosition2D(lo1, la1);
|
||||
DirectPosition2D corner2 = new DirectPosition2D(lo2, la2);
|
||||
MathTransform fromLatLon = MapUtil.getTransformFromLatLon(crs);
|
||||
|
@ -262,6 +275,15 @@ public class SatSpatialFactory {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link #getCoverageTwoCorners(int, int, int, double, double, double, double, double, double, double)}
|
||||
*/
|
||||
public SatMapCoverage getCoverageTwoCorners(int crsType, int nx, int ny,
|
||||
double lov, double latin, double la1, double lo1, double la2,
|
||||
double lo2) throws DecoderException {
|
||||
return getCoverageTwoCorners(crsType, nx, ny, lov, latin, latin, la1, lo1, la2, lo2);
|
||||
}
|
||||
|
||||
/** Load or persist a {@link SatMapCoverage} */
|
||||
private synchronized SatMapCoverage checkPersisted(
|
||||
SatMapCoverage mapCoverage) {
|
||||
|
@ -294,25 +316,27 @@ public class SatSpatialFactory {
|
|||
* {@link #PROJ_CYLIN_EQUIDISTANT}, {@link #PROJ_LAMBERT},
|
||||
* {@link #PROJ_MERCATOR}, {@link #PROJ_POLAR}. * @param lov
|
||||
* @param lov
|
||||
* the longitude orientatition, used by
|
||||
* the longitude orientation, used by
|
||||
* {@link #PROJ_CYLIN_EQUIDISTANT}, {@link #PROJ_LAMBERT},
|
||||
* {@link #PROJ_POLAR}.
|
||||
* @param latin
|
||||
* the latitude at which the projection is tangent to the earths
|
||||
* surface, used by {@link #PROJ_CYLIN_EQUIDISTANT},
|
||||
* {@link #PROJ_LAMBERT}, {@link #PROJ_MERCATOR}.
|
||||
* @param latin2
|
||||
* the second standard latitude, used by {@link #PROJ_LAMBERT}.
|
||||
* @param cm
|
||||
* the central meridian of the projection, only used by
|
||||
* {@link #PROJ_MERCATOR}.
|
||||
* @return
|
||||
*/
|
||||
private static ProjectedCRS createCRS(int crsType, double lov,
|
||||
double latin, double cm) {
|
||||
double latin, double latin2, double cm) {
|
||||
switch (crsType) {
|
||||
case PROJ_MERCATOR:
|
||||
return createMercatorCrs(latin, cm);
|
||||
case PROJ_LAMBERT:
|
||||
return createLambertCrs(latin, lov);
|
||||
return createLambertCrs(latin, latin2, lov);
|
||||
case PROJ_CYLIN_EQUIDISTANT:
|
||||
return createEqCylCrs(latin, lov);
|
||||
default:
|
||||
|
@ -325,9 +349,9 @@ public class SatSpatialFactory {
|
|||
MapUtil.AWIPS_EARTH_RADIUS, latin, cm);
|
||||
}
|
||||
|
||||
private static ProjectedCRS createLambertCrs(double latin, double lov) {
|
||||
private static ProjectedCRS createLambertCrs(double latin, double latin2, double lov) {
|
||||
return MapUtil.constructLambertConformal(MapUtil.AWIPS_EARTH_RADIUS,
|
||||
MapUtil.AWIPS_EARTH_RADIUS, latin, latin, lov);
|
||||
MapUtil.AWIPS_EARTH_RADIUS, latin, latin2, lov);
|
||||
}
|
||||
|
||||
private static ProjectedCRS createEqCylCrs(double latin, double lov) {
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.uf.common.units.PiecewisePixel;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* 6/2013 DR 16070 jgerth Interpolation capability
|
||||
* Aug 2, 2013 2211 mschenke Backed out 16070 changes
|
||||
* Aug 21, 2014 DR 17313 jgerth New methods
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -249,7 +250,7 @@ public class DataMappingPreferences {
|
|||
} else if (">".equals(operator)) {
|
||||
greaterThanEntries.add(entry);
|
||||
Collections
|
||||
.sort(greaterThanEntries, Collections.reverseOrder());
|
||||
.sort(greaterThanEntries, Collections.reverseOrder());
|
||||
} else if ("<".equals(operator)) {
|
||||
lessThanEntries.add(entry);
|
||||
Collections.sort(lessThanEntries);
|
||||
|
@ -289,4 +290,80 @@ public class DataMappingPreferences {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a number against the pixelValue in each entry based on the
|
||||
* operator until the first match is found.
|
||||
*
|
||||
* jjg 7/24/2014
|
||||
*
|
||||
* @param dataValue
|
||||
* the data value to match
|
||||
* @return The entry sample, if one exists.
|
||||
*/
|
||||
public String getSampleValueForDataValue(double dataValue) {
|
||||
for (DataMappingEntry entry : equalsEntries) {
|
||||
Double entryValue = entry.getPixelValue();
|
||||
if (entryValue.equals(dataValue)) {
|
||||
return entry.getSample();
|
||||
}
|
||||
}
|
||||
|
||||
for (DataMappingEntry entry : lessThanEntries) {
|
||||
Double entryValue = entry.getPixelValue();
|
||||
if (dataValue < entryValue) {
|
||||
return entry.getSample();
|
||||
}
|
||||
}
|
||||
|
||||
for (DataMappingEntry entry : greaterThanEntries) {
|
||||
Double entryValue = entry.getPixelValue();
|
||||
if (dataValue > entryValue) {
|
||||
return entry.getSample();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Matches a number against the pixelValue in each entry based on the
|
||||
* operator until the first match is found.
|
||||
*
|
||||
* jjg 7/24/2014
|
||||
*
|
||||
* @param dataValue
|
||||
* the data value to match
|
||||
* @return The entry sample or label, if one exists.
|
||||
*/
|
||||
public String getSampleOrLabelValueForDataValue(double dataValue) {
|
||||
for (DataMappingEntry entry : equalsEntries) {
|
||||
Double entryValue = entry.getPixelValue();
|
||||
if (entryValue.equals(dataValue)) {
|
||||
if (entry.getSample() == null)
|
||||
return entry.getLabel();
|
||||
else
|
||||
return entry.getSample();
|
||||
}
|
||||
}
|
||||
|
||||
for (DataMappingEntry entry : lessThanEntries) {
|
||||
Double entryValue = entry.getPixelValue();
|
||||
if (dataValue < entryValue) {
|
||||
if (entry.getSample() == null)
|
||||
return entry.getLabel();
|
||||
else
|
||||
return entry.getSample();
|
||||
}
|
||||
}
|
||||
|
||||
for (DataMappingEntry entry : greaterThanEntries) {
|
||||
Double entryValue = entry.getPixelValue();
|
||||
if (dataValue > entryValue) {
|
||||
if (entry.getSample() == null)
|
||||
return entry.getLabel();
|
||||
else
|
||||
return entry.getSample();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ import com.raytheon.uf.edex.decodertools.time.TimeTools;
|
|||
* IDataRecord required by the SatelliteDao
|
||||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Apr 15, 2014 3017 bsteffen Call new methods in SatSpatialFactory
|
||||
* Sep 11, 2014 DR 17303 jgerth Support for second standard latitude
|
||||
* </pre>
|
||||
*
|
||||
* @author tk
|
||||
|
@ -116,26 +117,26 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
netCdfFile = NetcdfFile.openInMemory(filename, data);
|
||||
|
||||
// set the source; Alaska Region
|
||||
if (source == null) {
|
||||
source = "Source"; // use to look up source value; default of
|
||||
// Source
|
||||
String gaSourceStr = "Unknown";
|
||||
Attribute gaSource = netCdfFile.findGlobalAttribute("source");
|
||||
if (gaSource != null) {
|
||||
gaSourceStr = gaSource.getStringValue().trim();
|
||||
}
|
||||
record.setSource(getSource(source)); // lookup source value
|
||||
record.setSource(getSource(gaSourceStr).replace("/", " ")); // lookup source value
|
||||
|
||||
// set the creating entity
|
||||
Attribute satName = netCdfFile.findGlobalAttribute("satelliteName");
|
||||
|
||||
String entity = null; // "HRPT"; "GOESR-PG"; "Blended2";
|
||||
if (satName != null) {
|
||||
entity = satName.getStringValue();
|
||||
entity = satName.getStringValue().trim();
|
||||
}
|
||||
|
||||
if (entity != null) {
|
||||
String parsed = getCreatingEntity(entity);
|
||||
if ((parsed != null) && (parsed.length() > 0)) {
|
||||
record.setCreatingEntity(parsed);
|
||||
record.setCreatingEntity(parsed.replace("/", " "));
|
||||
} else {
|
||||
record.setCreatingEntity(entity);
|
||||
record.setCreatingEntity(entity.replace("/", " "));
|
||||
}
|
||||
} else {
|
||||
record.setCreatingEntity("Unknown");
|
||||
|
@ -156,9 +157,9 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
pev = getPhysicalElement(entity, channel);
|
||||
String element = pev.name;
|
||||
if (pev.name != null) {
|
||||
record.setPhysicalElement(element);
|
||||
record.setPhysicalElement(element.replace("/", " "));
|
||||
} else {
|
||||
record.setPhysicalElement(channel);
|
||||
record.setPhysicalElement(channel.replace("/", " "));
|
||||
}
|
||||
} else {
|
||||
record.setPhysicalElement("Imager Visible");
|
||||
|
@ -181,10 +182,10 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
|
||||
// read the valid time in seconds and store the time in milliseconds
|
||||
long time = netCdfFile.findVariable("validTime").readScalarLong(); // time
|
||||
// in
|
||||
// seconds
|
||||
// in
|
||||
// seconds
|
||||
calendar.setTimeInMillis(time * 1000); // need to convert seconds to
|
||||
// milliseconds
|
||||
// milliseconds
|
||||
|
||||
/*
|
||||
* Date date = new Date(); // used for setting the test data time
|
||||
|
@ -199,9 +200,10 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
.getNumericValue().floatValue();
|
||||
|
||||
int mapProjection = SatSpatialFactory.PROJ_POLAR; // STEREOGRAPHIC
|
||||
// projection
|
||||
// default
|
||||
// projection
|
||||
// default
|
||||
float latin = 0.0f; // set to zero for Stereographic projections
|
||||
Attribute rot = netCdfFile.findGlobalAttribute("rotation");
|
||||
float rotation = 0.0f;
|
||||
|
||||
// read the projection
|
||||
|
@ -214,6 +216,9 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
if (projection.equalsIgnoreCase("LAMBERT")
|
||||
|| projection.equalsIgnoreCase("LAMBERT_CONFORMAL")) {
|
||||
mapProjection = SatSpatialFactory.PROJ_LAMBERT;
|
||||
if (rot != null) {
|
||||
rotation = rot.getNumericValue().floatValue();
|
||||
}
|
||||
} else if (projection.equalsIgnoreCase("MERCATOR")) {
|
||||
mapProjection = SatSpatialFactory.PROJ_MERCATOR;
|
||||
} else if (projection
|
||||
|
@ -222,7 +227,6 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
}
|
||||
|
||||
} else {
|
||||
Attribute rot = netCdfFile.findGlobalAttribute("rotation");
|
||||
if (rot != null) {
|
||||
rotation = rot.getNumericValue().floatValue();
|
||||
// STEREOGRAPHIC projection add rotation to lov
|
||||
|
@ -274,9 +278,15 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
"Unable to decode Satellite: Encountered Unknown projection");
|
||||
} // end of if map projection block
|
||||
|
||||
SatMapCoverage mapCoverage = SatSpatialFactory.getInstance()
|
||||
.getCoverageTwoCorners(mapProjection, nx, ny, lov, latin,
|
||||
la1, lo1, la2, lo2);
|
||||
SatMapCoverage mapCoverage;
|
||||
if (mapProjection == SatSpatialFactory.PROJ_LAMBERT && rot != null && rotation != latin)
|
||||
mapCoverage = SatSpatialFactory.getInstance()
|
||||
.getCoverageTwoCorners(mapProjection, nx, ny, lov, latin, rotation,
|
||||
la1, lo1, la2, lo2);
|
||||
else
|
||||
mapCoverage = SatSpatialFactory.getInstance()
|
||||
.getCoverageTwoCorners(mapProjection, nx, ny, lov, latin,
|
||||
la1, lo1, la2, lo2);
|
||||
|
||||
record.setTraceId(traceId);
|
||||
record.setCoverage(mapCoverage);
|
||||
|
@ -357,4 +367,4 @@ public class RegionalSatDecoder extends AbstractDecoder {
|
|||
this.filename = file;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue