Omaha #4633 Implement an alternative daylight transition based off sunrise/sunset times.
Former-commit-id: 2461e886221639fb8de4bb39770936ab9be05848
This commit is contained in:
parent
e420de3c85
commit
a05fa0b924
19 changed files with 1315 additions and 11 deletions
|
@ -9,9 +9,6 @@
|
|||
name="com.raytheon.uf.viz.auto.transition.AutoTransitionAction"
|
||||
sortID="50">
|
||||
</contextualMenu>
|
||||
</extension>
|
||||
<extension
|
||||
point="com.raytheon.viz.ui.contextualMenu">
|
||||
<contextualMenu
|
||||
actionClass="com.raytheon.uf.viz.auto.transition.ConfigureAutoTransitionAction"
|
||||
capabilityClass="com.raytheon.uf.viz.auto.transition.AutoTransitionResource"
|
||||
|
|
7
cave/com.raytheon.uf.viz.daylight.transition/.classpath
Normal file
7
cave/com.raytheon.uf.viz.daylight.transition/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
28
cave/com.raytheon.uf.viz.daylight.transition/.project
Normal file
28
cave/com.raytheon.uf.viz.daylight.transition/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.uf.viz.daylight.transition</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,21 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Daylight Transition
|
||||
Bundle-SymbolicName: com.raytheon.uf.viz.daylight.transition;singleton:=true
|
||||
Bundle-Version: 1.15.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: com.raytheon.viz.ui;bundle-version="1.15.1",
|
||||
com.raytheon.uf.viz.core;bundle-version="1.15.1",
|
||||
com.raytheon.uf.common.time;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.geospatial;bundle-version="1.14.2",
|
||||
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||
com.raytheon.uf.viz.core.rsc;bundle-version="1.14.1",
|
||||
javax.measure;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.colormap;bundle-version="1.15.0",
|
||||
com.raytheon.viz.satellite;bundle-version="1.15.0",
|
||||
com.raytheon.uf.common.dataplugin.satellite;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.dataplugin;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.numeric;bundle-version="1.14.0",
|
||||
com.raytheon.viz.awipstools;bundle-version="1.14.0"
|
||||
Import-Package: com.raytheon.viz.core.rsc
|
|
@ -0,0 +1,5 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
19
cave/com.raytheon.uf.viz.daylight.transition/plugin.xml
Normal file
19
cave/com.raytheon.uf.viz.daylight.transition/plugin.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="com.raytheon.viz.ui.contextualMenu">
|
||||
<contextualMenu
|
||||
actionClass="com.raytheon.uf.viz.daylight.transition.DaylightTransitionAction"
|
||||
capabilityClass="com.raytheon.viz.core.rsc.BlendedResource"
|
||||
name="com.raytheon.uf.viz.daylight.transition.AutoTransitionAction"
|
||||
sortID="52">
|
||||
</contextualMenu>
|
||||
<contextualMenu
|
||||
actionClass="com.raytheon.uf.viz.daylight.transition.ConfigureDaylightTransitionAction"
|
||||
capabilityClass="com.raytheon.uf.viz.daylight.transition.resource.DaylightTransitionBlendedResource"
|
||||
name="com.raytheon.uf.viz.daylight.transition.ConfigureDaylightTransitionAction"
|
||||
sortID="53">
|
||||
</contextualMenu>
|
||||
</extension>
|
||||
</plugin>
|
|
@ -0,0 +1,61 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition;
|
||||
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
|
||||
import com.raytheon.uf.viz.daylight.transition.resource.DaylightTransitionBlendedResource;
|
||||
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Action which opens the {@link DaylightTransitionDialog}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class ConfigureDaylightTransitionAction extends AbstractRightClickAction {
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Configure Daylight Transition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
DaylightTransitionBlendedResource resource = (DaylightTransitionBlendedResource) selectedRsc
|
||||
.getResource();
|
||||
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
|
||||
.getShell();
|
||||
new DaylightTransitionDialog(shell, resource).open();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition;
|
||||
|
||||
import com.raytheon.uf.common.serialization.SerializationException;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.procedures.ProcedureXmlManager;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceGroup;
|
||||
import com.raytheon.uf.viz.core.time.TimeMatchingJob;
|
||||
import com.raytheon.uf.viz.daylight.transition.resource.DaylightTransitionBlendedResource;
|
||||
import com.raytheon.uf.viz.daylight.transition.resource.DaylightTransitionBlendedResourceData;
|
||||
import com.raytheon.viz.core.rsc.BlendedResource;
|
||||
import com.raytheon.viz.core.rsc.BlendedResourceData;
|
||||
import com.raytheon.viz.satellite.rsc.SatBlendedResource;
|
||||
import com.raytheon.viz.satellite.rsc.SatResource;
|
||||
import com.raytheon.viz.ui.cmenu.AbstractRightClickAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* Action which converts a {@link BlendedResource} into a
|
||||
* {@link DaylightTransitionBlendedResource}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DaylightTransitionAction extends AbstractRightClickAction {
|
||||
|
||||
private static final transient IUFStatusHandler logger = UFStatus
|
||||
.getHandler(DaylightTransitionAction.class);
|
||||
|
||||
public DaylightTransitionAction() {
|
||||
super(AS_CHECK_BOX);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
BlendedResource resource = (BlendedResource) selectedRsc.getResource();
|
||||
for (ResourcePair pair : resource.getResourceList()) {
|
||||
if (!(pair.getResource() instanceof SatResource)
|
||||
&& !(pair.getResource() instanceof SatBlendedResource)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private DaylightTransitionBlendedResourceData getResourceData() {
|
||||
if (selectedRsc.getResource() instanceof DaylightTransitionBlendedResource) {
|
||||
return ((DaylightTransitionBlendedResource) selectedRsc
|
||||
.getResource()).getResourceData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChecked() {
|
||||
DaylightTransitionBlendedResourceData data = getResourceData();
|
||||
if (data != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Daylight Transition";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ProcedureXmlManager jaxb = ProcedureXmlManager.getInstance();
|
||||
/* Use jaxb serialization to safely make a clone of the resource. */
|
||||
ResourceGroup group = new ResourceGroup();
|
||||
group.getResourceList().add(selectedRsc);
|
||||
try {
|
||||
String baseXml = jaxb.marshal(group);
|
||||
group = jaxb.unmarshal(ResourceGroup.class, baseXml);
|
||||
} catch (SerializationException e) {
|
||||
logger.error("Unable to initialize Daylight Transition.", e);
|
||||
}
|
||||
ResourcePair pair = group.getResourceList().get(0);
|
||||
|
||||
AbstractVizResource<?, ?> oldResource = selectedRsc.getResource();
|
||||
if (oldResource instanceof DaylightTransitionBlendedResource) {
|
||||
BlendedResourceData resourceData = ((DaylightTransitionBlendedResourceData) pair
|
||||
.getResourceData()).toBlended();
|
||||
selectedRsc.setResourceData(resourceData);
|
||||
} else {
|
||||
BlendedResourceData resourceData = new DaylightTransitionBlendedResourceData(
|
||||
(BlendedResourceData) pair.getResourceData());
|
||||
selectedRsc.setResourceData(resourceData);
|
||||
}
|
||||
selectedRsc.setLoadProperties(pair.getLoadProperties());
|
||||
selectedRsc.setResource(null);
|
||||
try {
|
||||
selectedRsc.instantiateResource(oldResource.getDescriptor());
|
||||
} catch (VizException e) {
|
||||
logger.error("Unable to initialize Daylight Transition.", e);
|
||||
selectedRsc.setResource(oldResource);
|
||||
return;
|
||||
}
|
||||
oldResource.dispose();
|
||||
TimeMatchingJob.scheduleTimeMatch(oldResource.getDescriptor());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,222 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition;
|
||||
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.events.SelectionAdapter;
|
||||
import org.eclipse.swt.events.SelectionEvent;
|
||||
import org.eclipse.swt.layout.GridData;
|
||||
import org.eclipse.swt.layout.GridLayout;
|
||||
import org.eclipse.swt.layout.RowData;
|
||||
import org.eclipse.swt.layout.RowLayout;
|
||||
import org.eclipse.swt.widgets.Button;
|
||||
import org.eclipse.swt.widgets.Combo;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import org.eclipse.swt.widgets.Layout;
|
||||
import org.eclipse.swt.widgets.Scale;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.IDisposeListener;
|
||||
import com.raytheon.uf.viz.daylight.transition.resource.DaylightTransitionBlendedResource;
|
||||
import com.raytheon.uf.viz.daylight.transition.resource.DaylightTransitionBlendedResourceData;
|
||||
import com.raytheon.viz.ui.dialogs.CaveSWTDialog;
|
||||
|
||||
/**
|
||||
*
|
||||
* Dialog for configuring a {@link DaylightTransitionBlendedResource}.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DaylightTransitionDialog extends CaveSWTDialog implements
|
||||
IDisposeListener {
|
||||
|
||||
private final DaylightTransitionBlendedResource resource;
|
||||
|
||||
private int originalTransitionIndex;
|
||||
|
||||
private int originalDelta;
|
||||
|
||||
private Combo resourceCombo;
|
||||
|
||||
private Scale deltaSlider;
|
||||
|
||||
private Text deltaText;
|
||||
|
||||
public DaylightTransitionDialog(Shell parentShell,
|
||||
DaylightTransitionBlendedResource resource) {
|
||||
super(parentShell);
|
||||
this.resource = resource;
|
||||
setText("Configure Daylight Transition");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
resource.registerListener(this);
|
||||
new Label(shell, SWT.NONE).setText("Transition Resource: ");
|
||||
resourceCombo = new Combo(shell, SWT.READ_ONLY);
|
||||
for (ResourcePair pair : resource.getResourceList()) {
|
||||
resourceCombo.add(pair.getResource().getName());
|
||||
}
|
||||
resourceCombo.select(resource.getResourceData().getTransitionIndex());
|
||||
GridData layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
layoutData.horizontalSpan = 2;
|
||||
resourceCombo.setLayoutData(layoutData);
|
||||
|
||||
resourceCombo.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
resourceComboSelected();
|
||||
}
|
||||
});
|
||||
|
||||
new Label(shell, SWT.NONE).setText("Sun Offset Minutes: ");
|
||||
deltaSlider = new Scale(shell, SWT.HORIZONTAL);
|
||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false);
|
||||
layoutData.minimumWidth = 100;
|
||||
deltaSlider.setLayoutData(layoutData);
|
||||
deltaSlider
|
||||
.setToolTipText("The amount of time after sunrise and before sunset to mask the data.");
|
||||
|
||||
originalDelta = resource.getResourceData().getSunDelta();
|
||||
originalTransitionIndex = resource.getResourceData()
|
||||
.getTransitionIndex();
|
||||
|
||||
deltaSlider.setSelection(originalDelta);
|
||||
|
||||
deltaText = new Text(shell, SWT.BORDER | SWT.READ_ONLY);
|
||||
layoutData = new GridData(SWT.FILL, SWT.CENTER, false, false);
|
||||
layoutData.widthHint = 50;
|
||||
deltaText.setLayoutData(layoutData);
|
||||
deltaText.setText(Double.toString(originalDelta));
|
||||
|
||||
deltaSlider.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
sliderSelected();
|
||||
}
|
||||
});
|
||||
Composite buttonComp = new Composite(shell, SWT.NONE);
|
||||
layoutData = new GridData(SWT.RIGHT, SWT.CENTER, false, false);
|
||||
layoutData.horizontalSpan = 3;
|
||||
buttonComp.setLayoutData(layoutData);
|
||||
|
||||
buttonComp.setLayout(new RowLayout(SWT.HORIZONTAL));
|
||||
Button okButton = new Button(buttonComp, SWT.PUSH);
|
||||
okButton.setText("OK");
|
||||
okButton.setLayoutData(new RowData(100, SWT.DEFAULT));
|
||||
okButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
okPressed();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Button cancelButton = new Button(buttonComp, SWT.PUSH);
|
||||
cancelButton.setText("Cancel");
|
||||
cancelButton.setLayoutData(new RowData(100, SWT.DEFAULT));
|
||||
cancelButton.addSelectionListener(new SelectionAdapter() {
|
||||
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
cancelPressed();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void resourceComboSelected() {
|
||||
resource.getResourceData().setTransitionIndex(
|
||||
resourceCombo.getSelectionIndex());
|
||||
resource.getResourceData().applyTransitionIndex();
|
||||
|
||||
sliderSelected();
|
||||
}
|
||||
|
||||
protected void sliderSelected() {
|
||||
resource.getResourceData().setSunDelta(deltaSlider.getSelection());
|
||||
resource.issueRefresh();
|
||||
deltaText.setText(Integer.toString(deltaSlider.getSelection()));
|
||||
}
|
||||
|
||||
protected void okPressed() {
|
||||
close();
|
||||
}
|
||||
|
||||
protected void cancelPressed() {
|
||||
DaylightTransitionBlendedResourceData resourceData = resource
|
||||
.getResourceData();
|
||||
resourceData.setSunDelta(originalDelta);
|
||||
if (resourceData.getTransitionIndex() != originalTransitionIndex) {
|
||||
resourceData.setTransitionIndex(originalTransitionIndex);
|
||||
resourceData.applyTransitionIndex();
|
||||
}
|
||||
resource.issueRefresh();
|
||||
close();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
GridLayout mainLayout = new GridLayout(3, false);
|
||||
mainLayout.marginHeight = 3;
|
||||
mainLayout.marginWidth = 3;
|
||||
return mainLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void disposed() {
|
||||
resource.unregisterListener(this);
|
||||
super.disposed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disposed(AbstractVizResource<?, ?> rsc) {
|
||||
if (rsc == resource) {
|
||||
Display.getCurrent().asyncExec(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.resource;
|
||||
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.BlendableCapability;
|
||||
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
|
||||
import com.raytheon.viz.core.rsc.BlendedResource;
|
||||
|
||||
/**
|
||||
*
|
||||
* Provides the ability to blend two satellite resources with one of them
|
||||
* becoming transparent when it is night.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DaylightTransitionBlendedResource extends BlendedResource {
|
||||
|
||||
private DaylightTransitionBlendedResourceData resourceData;
|
||||
|
||||
public DaylightTransitionBlendedResource(
|
||||
DaylightTransitionBlendedResourceData data, LoadProperties props) {
|
||||
super(data, props);
|
||||
this.resourceData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintInternal(IGraphicsTarget target,
|
||||
PaintProperties paintProps) throws VizException {
|
||||
BlendableCapability blendable = getCapability(BlendableCapability.class);
|
||||
blendable.toggle(resourceData.getTransitionIndex());
|
||||
super.paintInternal(target, paintProps);
|
||||
blendable.toggle(1 - resourceData.getTransitionIndex());
|
||||
super.paintInternal(target, paintProps);
|
||||
getCapability(BlendableCapability.class).setAlphaStep(
|
||||
BlendableCapability.BLEND_MAX / 2);
|
||||
for (ResourcePair pair : getResourceList()) {
|
||||
pair.getResource().getCapability(ImagingCapability.class)
|
||||
.setAlpha(1.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaylightTransitionBlendedResourceData getResourceData() {
|
||||
return resourceData;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,207 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.uf.viz.core.drawables.IDescriptor;
|
||||
import com.raytheon.uf.viz.core.drawables.ResourcePair;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractResourceData;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.core.rsc.ResourceList;
|
||||
import com.raytheon.uf.viz.core.time.TimeMatchingJob;
|
||||
import com.raytheon.viz.core.rsc.BlendedResourceData;
|
||||
import com.raytheon.viz.satellite.rsc.SatBlendedResource;
|
||||
import com.raytheon.viz.satellite.rsc.SatBlendedResourceData;
|
||||
import com.raytheon.viz.satellite.rsc.SatResourceData;
|
||||
|
||||
/**
|
||||
*
|
||||
* Serializable data for {@link DaylightTransitionBlendedResource}
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class DaylightTransitionBlendedResourceData extends BlendedResourceData {
|
||||
|
||||
private static final transient IUFStatusHandler logger = UFStatus
|
||||
.getHandler(DaylightTransitionBlendedResourceData.class);
|
||||
|
||||
@XmlElement
|
||||
private int transitionIndex = 1;
|
||||
|
||||
@XmlElement
|
||||
private int sunDelta = 75;
|
||||
|
||||
public DaylightTransitionBlendedResourceData() {
|
||||
|
||||
}
|
||||
|
||||
public DaylightTransitionBlendedResourceData(BlendedResourceData blended) {
|
||||
this.resourceList = blended.getResourceList();
|
||||
applyTransitionIndex();
|
||||
}
|
||||
|
||||
private AbstractResourceData convertResourceData(AbstractResourceData data) {
|
||||
if (data instanceof SatBlendedResourceData) {
|
||||
SatBlendedResourceData sbrd1 = (SatBlendedResourceData) data;
|
||||
SatBlendedResourceData sbrd2 = new SatBlendedResourceData();
|
||||
for (ResourcePair pair : sbrd1.getResourceList()) {
|
||||
ResourcePair newPair = new ResourcePair();
|
||||
newPair.setResourceData(convertResourceData(pair
|
||||
.getResourceData()));
|
||||
newPair.setProperties(pair.getProperties());
|
||||
newPair.setLoadProperties(pair.getLoadProperties());
|
||||
sbrd2.getResourceList().add(newPair);
|
||||
}
|
||||
return sbrd2;
|
||||
} else if (data instanceof SatResourceData) {
|
||||
return new DaylightTransitionSatResourceData((SatResourceData) data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public BlendedResourceData toBlended() {
|
||||
BlendedResourceData blended = new BlendedResourceData();
|
||||
ResourceList resourceList = blended.getResourceList();
|
||||
for (ResourcePair pair : this.getResourceList()) {
|
||||
ResourcePair newPair = new ResourcePair();
|
||||
newPair.setResourceData(unconvertResourceData(pair
|
||||
.getResourceData()));
|
||||
resourceList.add(pair);
|
||||
}
|
||||
return blended;
|
||||
}
|
||||
|
||||
private AbstractResourceData unconvertResourceData(AbstractResourceData data) {
|
||||
if (data instanceof SatBlendedResourceData) {
|
||||
SatBlendedResourceData sbrd1 = (SatBlendedResourceData) data;
|
||||
SatBlendedResourceData sbrd2 = new SatBlendedResourceData();
|
||||
for (ResourcePair pair : sbrd1.getResourceList()) {
|
||||
ResourcePair newPair = new ResourcePair();
|
||||
newPair.setResourceData(unconvertResourceData(pair
|
||||
.getResourceData()));
|
||||
newPair.setProperties(pair.getProperties());
|
||||
newPair.setLoadProperties(pair.getLoadProperties());
|
||||
sbrd2.getResourceList().add(newPair);
|
||||
}
|
||||
return sbrd2;
|
||||
} else if (data instanceof DaylightTransitionSatResourceData) {
|
||||
return ((DaylightTransitionSatResourceData) data)
|
||||
.toSatResourceData();
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DaylightTransitionBlendedResource construct(
|
||||
LoadProperties loadProperties, IDescriptor descriptor)
|
||||
throws VizException {
|
||||
for (ResourcePair pair : resourceList) {
|
||||
updateSunDelta(pair);
|
||||
}
|
||||
return new DaylightTransitionBlendedResource(this, loadProperties);
|
||||
}
|
||||
|
||||
private void updateSunDelta(ResourcePair pair) {
|
||||
if (pair.getResourceData() instanceof SatBlendedResourceData) {
|
||||
SatBlendedResourceData sbrd = (SatBlendedResourceData) pair
|
||||
.getResourceData();
|
||||
for (ResourcePair rp : sbrd.getResourceList()) {
|
||||
updateSunDelta(rp);
|
||||
}
|
||||
SatBlendedResource resource = (SatBlendedResource) pair
|
||||
.getResource();
|
||||
if (resource != null) {
|
||||
resource.recycle();
|
||||
TimeMatchingJob.scheduleTimeMatch(resource.getDescriptor());
|
||||
}
|
||||
} else if (pair.getResourceData() instanceof DaylightTransitionSatResourceData) {
|
||||
DaylightTransitionSatResourceData dtsrd = (DaylightTransitionSatResourceData) pair
|
||||
.getResourceData();
|
||||
dtsrd.setSunDelta(sunDelta);
|
||||
}
|
||||
}
|
||||
|
||||
public int getTransitionIndex() {
|
||||
return transitionIndex;
|
||||
}
|
||||
|
||||
public void setTransitionIndex(int transitionIndex) {
|
||||
this.transitionIndex = transitionIndex;
|
||||
}
|
||||
|
||||
public void applyTransitionIndex() {
|
||||
int index = 0;
|
||||
for (ResourcePair pair : this.resourceList) {
|
||||
if (index == transitionIndex) {
|
||||
pair.setResourceData(convertResourceData(pair
|
||||
.getResourceData()));
|
||||
} else {
|
||||
pair.setResourceData(unconvertResourceData(pair
|
||||
.getResourceData()));
|
||||
}
|
||||
if (pair.getResource() != null) {
|
||||
IDescriptor descriptor = pair.getResource().getDescriptor();
|
||||
pair.getResource().dispose();
|
||||
pair.setResource(null);
|
||||
try {
|
||||
pair.instantiateResource(descriptor, false);
|
||||
} catch (VizException e) {
|
||||
logger.error("Unable to create new resource.", e);
|
||||
}
|
||||
}
|
||||
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getSunDelta() {
|
||||
return sunDelta;
|
||||
}
|
||||
|
||||
public void setSunDelta(int sunDelta) {
|
||||
this.sunDelta = sunDelta;
|
||||
if (resourceList != null) {
|
||||
for (ResourcePair pair : resourceList) {
|
||||
updateSunDelta(pair);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.resource;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.uf.viz.daylight.transition.tileset.DaylightTransitionTileSetRenderable;
|
||||
import com.raytheon.viz.satellite.rsc.SatResource;
|
||||
import com.raytheon.viz.satellite.tileset.SatTileSetRenderable;
|
||||
|
||||
/**
|
||||
*
|
||||
* An extension of the {@link SatResource} that substitutes a
|
||||
* {@link DaylightTransitionTileSetRenderable} in order to block out data when
|
||||
* there is no sunlight.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DaylightTransitionSatResource extends SatResource {
|
||||
|
||||
private final DaylightTransitionSatResourceData resourceData;
|
||||
|
||||
public DaylightTransitionSatResource(
|
||||
DaylightTransitionSatResourceData data, LoadProperties props) {
|
||||
super(data, props);
|
||||
this.resourceData = data;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SatTileSetRenderable createTileSet(SatelliteRecord record) {
|
||||
SatTileSetRenderable tileSet = new DaylightTransitionTileSetRenderable(
|
||||
this, record, resourceData.getSunDelta());
|
||||
tileSet.project(descriptor.getGridGeometry());
|
||||
return tileSet;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.resource;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.PluginDataObject;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||
import com.raytheon.viz.satellite.rsc.SatResourceData;
|
||||
|
||||
/**
|
||||
*
|
||||
* An extension of the {@link SatResourceData} that constructs a
|
||||
* {@link DaylightTransitionSatResource} in order to block out data when there
|
||||
* is no sunlight.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
public class DaylightTransitionSatResourceData extends SatResourceData {
|
||||
|
||||
private int sunDelta = 75;
|
||||
|
||||
public DaylightTransitionSatResourceData() {
|
||||
|
||||
}
|
||||
|
||||
public DaylightTransitionSatResourceData(SatResourceData resourceData) {
|
||||
setMetadataMap(resourceData.getMetadataMap());
|
||||
}
|
||||
|
||||
public SatResourceData toSatResourceData() {
|
||||
SatResourceData resourceData = new SatResourceData();
|
||||
resourceData.setMetadataMap(getMetadataMap());
|
||||
return resourceData;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractVizResource<?, ?> constructResource(
|
||||
LoadProperties loadProperties, PluginDataObject[] objects) {
|
||||
records = new SatelliteRecord[objects.length];
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
records[i] = (SatelliteRecord) objects[i];
|
||||
}
|
||||
return new DaylightTransitionSatResource(this, loadProperties);
|
||||
}
|
||||
|
||||
public int getSunDelta() {
|
||||
return sunDelta;
|
||||
}
|
||||
|
||||
public void setSunDelta(int sunDelta) {
|
||||
this.sunDelta = sunDelta;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.tileset;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.util.Calendar;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.colormap.image.ColorMapData;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.common.status.IUFStatusHandler;
|
||||
import com.raytheon.uf.common.status.UFStatus;
|
||||
import com.raytheon.viz.satellite.tileset.SatDataRetriever;
|
||||
|
||||
/**
|
||||
*
|
||||
* An extension of the {@link SatDataRetriever} that blocks out data when there
|
||||
* is no sunlight.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DaylightTransitionDataRetriever extends SatDataRetriever {
|
||||
|
||||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(DaylightTransitionDataRetriever.class);
|
||||
|
||||
private final GridGeometry2D tileGeometry;
|
||||
|
||||
private final int sunDelta;
|
||||
|
||||
private final double nightTimeFillValue;
|
||||
|
||||
public DaylightTransitionDataRetriever(SatelliteRecord record, int level,
|
||||
GridGeometry2D tileGeometry, int sunDelta,
|
||||
double nightTimeFillValue) {
|
||||
super(record, level, tileGeometry.getGridRange2D());
|
||||
this.tileGeometry = tileGeometry;
|
||||
this.sunDelta = sunDelta;
|
||||
this.nightTimeFillValue = nightTimeFillValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorMapData getColorMapData() {
|
||||
ColorMapData data = super.getColorMapData();
|
||||
Calendar time = record.getDataTime().getRefTimeAsCalendar();
|
||||
try {
|
||||
SunriseSunsetCache cache = SunriseSunsetCache.getCache(
|
||||
tileGeometry, time);
|
||||
Buffer buffer = data.getBuffer();
|
||||
for (int i = 0; i < datasetBounds.width; i += 1) {
|
||||
for (int j = 0; j < datasetBounds.height; j += 1) {
|
||||
if (!cache.isDay(i, j, time, sunDelta)) {
|
||||
int index = j * datasetBounds.width + i;
|
||||
if (buffer instanceof ByteBuffer) {
|
||||
((ByteBuffer) buffer).put(index,
|
||||
(byte) nightTimeFillValue);
|
||||
} else if (buffer instanceof ShortBuffer) {
|
||||
((ShortBuffer) buffer).put(index,
|
||||
(short) nightTimeFillValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
statusHandler.error("Unable to determine daylight transition", e);
|
||||
}
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.tileset;
|
||||
|
||||
import com.raytheon.uf.common.colormap.image.ColorMapData;
|
||||
import com.raytheon.uf.common.dataplugin.satellite.SatelliteRecord;
|
||||
import com.raytheon.uf.viz.core.tile.Tile;
|
||||
import com.raytheon.viz.satellite.rsc.SatResource;
|
||||
import com.raytheon.viz.satellite.tileset.SatTileSetRenderable;
|
||||
|
||||
/**
|
||||
*
|
||||
* An extension of the {@link SatTileSetRenderable} that uses a
|
||||
* {@link DaylightTransitionDataRetriever} in order to block out data when there
|
||||
* is no sunlight.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class DaylightTransitionTileSetRenderable extends SatTileSetRenderable {
|
||||
|
||||
private final SatelliteRecord record;
|
||||
|
||||
private final int sunDelta;
|
||||
|
||||
public DaylightTransitionTileSetRenderable(SatResource resource,
|
||||
SatelliteRecord record, int sunDelta) {
|
||||
super(resource, record);
|
||||
this.record = record;
|
||||
this.sunDelta = sunDelta;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ColorMapData retrieveRecordData(Tile tile) {
|
||||
double noDataValue = colormapping.getColorMapParameters()
|
||||
.getNoDataValue();
|
||||
return new DaylightTransitionDataRetriever(record, tile.tileLevel,
|
||||
tile.tileGeometry, sunDelta, noDataValue).getColorMapData();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,189 @@
|
|||
/**
|
||||
* 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.uf.viz.daylight.transition.tileset;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.geotools.coverage.grid.GridCoordinates2D;
|
||||
import org.geotools.coverage.grid.GridEnvelope2D;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.referencing.CRS;
|
||||
import org.geotools.referencing.crs.DefaultGeographicCRS;
|
||||
import org.opengis.geometry.DirectPosition;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.uf.common.numeric.buffer.ShortBufferWrapper;
|
||||
import com.raytheon.uf.common.time.util.TimeUtil;
|
||||
import com.raytheon.viz.awipstools.common.SunriseSunsetCalculator;
|
||||
|
||||
/**
|
||||
*
|
||||
* A cache of sunrise/sunset times to speed up retrieving multiple frames of
|
||||
* satellite data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 28, 2015 4633 bsteffen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class SunriseSunsetCache {
|
||||
|
||||
private static final Map<Key, Reference<SunriseSunsetCache>> cache = new HashMap<>();
|
||||
|
||||
private final ShortBufferWrapper sunRise;
|
||||
|
||||
private final ShortBufferWrapper sunSet;
|
||||
|
||||
private SunriseSunsetCache(GridGeometry2D gg, Calendar time)
|
||||
throws Exception {
|
||||
MathTransform mt = CRS.findMathTransform(
|
||||
gg.getCoordinateReferenceSystem(), DefaultGeographicCRS.WGS84);
|
||||
GridEnvelope2D range = gg.getGridRange2D();
|
||||
int width = range.width;
|
||||
int height = range.height;
|
||||
sunRise = new ShortBufferWrapper(width, height);
|
||||
sunSet = new ShortBufferWrapper(width, height);
|
||||
int year = time.get(Calendar.YEAR);
|
||||
int month = time.get(Calendar.MONTH) + 1;
|
||||
int day = time.get(Calendar.DAY_OF_MONTH);
|
||||
for (int i = 0; i < width; i += 1) {
|
||||
for (int j = 0; j < height; j += 1) {
|
||||
GridCoordinates2D gc = new GridCoordinates2D(range.x + i,
|
||||
range.y + j);
|
||||
DirectPosition dp = gg.gridToWorld(gc);
|
||||
mt.transform(dp, dp);
|
||||
double longitude = dp.getOrdinate(0);
|
||||
double latitude = dp.getOrdinate(1);
|
||||
SunriseSunsetCalculator ssc = new SunriseSunsetCalculator();
|
||||
ssc.calculate(longitude, latitude, "GMT", year, month, day);
|
||||
int sunRise = ssc.getSunriseHour() * TimeUtil.MINUTES_PER_HOUR
|
||||
+ ssc.getSunriseMinute();
|
||||
int sunSet = ssc.getSunsetHour() * TimeUtil.MINUTES_PER_HOUR
|
||||
+ ssc.getSunsetMinute();
|
||||
this.sunRise.setDataValue(sunRise, i, j);
|
||||
this.sunSet.setDataValue(sunSet, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDay(int x, int y, Calendar time, int sunDelta) {
|
||||
int minutes = time.get(Calendar.HOUR_OF_DAY)
|
||||
* TimeUtil.MINUTES_PER_HOUR
|
||||
+ time.get(Calendar.MINUTE);
|
||||
int sunRise = (int) this.sunRise.getDataValue(x, y);
|
||||
int sunSet = (int) this.sunSet.getDataValue(x, y);
|
||||
sunRise += sunDelta;
|
||||
if (sunRise > TimeUtil.MINUTES_PER_DAY) {
|
||||
sunRise -= TimeUtil.MINUTES_PER_DAY;
|
||||
}
|
||||
sunSet -= sunDelta;
|
||||
if (sunSet < 0) {
|
||||
sunSet += TimeUtil.MINUTES_PER_DAY;
|
||||
}
|
||||
if (sunRise < sunSet && (minutes < sunRise || minutes > sunSet)) {
|
||||
return false;
|
||||
} else if (sunSet < sunRise && (minutes > sunSet && minutes < sunRise)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized SunriseSunsetCache getCache(GridGeometry2D gg,
|
||||
Calendar time) throws Exception {
|
||||
Key k = new Key(gg, time);
|
||||
SunriseSunsetCache c = null;
|
||||
Reference<SunriseSunsetCache> r = cache.get(k);
|
||||
if (r != null) {
|
||||
c = r.get();
|
||||
}
|
||||
if (c == null) {
|
||||
c = new SunriseSunsetCache(gg, time);
|
||||
cache.put(k, new SoftReference<>(c));
|
||||
}
|
||||
return c;
|
||||
|
||||
}
|
||||
|
||||
private static class Key {
|
||||
|
||||
public final GridGeometry2D gg;
|
||||
|
||||
public final int year;
|
||||
|
||||
public final int month;
|
||||
|
||||
public final int day;
|
||||
|
||||
public Key(GridGeometry2D gg, Calendar time) {
|
||||
this.gg = gg;
|
||||
year = time.get(Calendar.YEAR);
|
||||
month = time.get(Calendar.MONTH) + 1;
|
||||
day = time.get(Calendar.DAY_OF_MONTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + day;
|
||||
result = prime * result + ((gg == null) ? 0 : gg.hashCode());
|
||||
result = prime * result + month;
|
||||
result = prime * result + year;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Key other = (Key) obj;
|
||||
if (day != other.day)
|
||||
return false;
|
||||
if (gg == null) {
|
||||
if (other.gg != null)
|
||||
return false;
|
||||
} else if (!gg.equals(other.gg))
|
||||
return false;
|
||||
if (month != other.month)
|
||||
return false;
|
||||
if (year != other.year)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -35,6 +35,7 @@ package com.raytheon.viz.awipstools.common;
|
|||
* function so that it would be
|
||||
* capable of recognizing additional
|
||||
* timezones.
|
||||
* Jul 28, 2015 4633 bsteffen Remove println
|
||||
* </pre>
|
||||
*
|
||||
* @author Eric Babin
|
||||
|
@ -283,9 +284,6 @@ public class SunriseSunsetCalculator {
|
|||
if (w8 == 0)
|
||||
sunriseTime = "No Sunset this date";
|
||||
}
|
||||
|
||||
System.out.println(sunriseTime + " : " + sunriseAzimuth + " "
|
||||
+ sunsetTime + " : " + sunsetAzimuth);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Satellite Visualization Plug-in
|
||||
Bundle-SymbolicName: com.raytheon.viz.satellite;singleton:=true
|
||||
Bundle-Version: 1.14.0.qualifier
|
||||
Bundle-Version: 1.15.0.qualifier
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-Vendor: Raytheon
|
||||
|
@ -31,5 +31,6 @@ Import-Package: com.raytheon.viz.awipstools,
|
|||
com.raytheon.viz.core.rsc,
|
||||
com.raytheon.viz.core.rsc.hdf5
|
||||
Export-Package: com.raytheon.viz.satellite,
|
||||
com.raytheon.viz.satellite.rsc
|
||||
com.raytheon.viz.satellite.rsc,
|
||||
com.raytheon.viz.satellite.tileset
|
||||
Bundle-ClassPath: com.raytheon.viz.satellite.jar
|
||||
|
|
|
@ -87,12 +87,12 @@ import com.raytheon.uf.viz.core.rsc.interrogation.InterrogationKey;
|
|||
import com.raytheon.uf.viz.core.rsc.interrogation.Interrogator;
|
||||
import com.raytheon.uf.viz.core.rsc.interrogation.StringInterrogationKey;
|
||||
import com.raytheon.uf.viz.datacube.DataCubeContainer;
|
||||
import com.raytheon.viz.awipstools.IToolChangedListener;
|
||||
import com.raytheon.viz.satellite.SatelliteConstants;
|
||||
import com.raytheon.viz.satellite.inventory.DerivedSatelliteRecord;
|
||||
import com.raytheon.viz.satellite.tileset.SatDataRetriever;
|
||||
import com.raytheon.viz.satellite.tileset.SatTileSetRenderable;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.raytheon.viz.awipstools.IToolChangedListener;
|
||||
|
||||
/**
|
||||
* Provides satellite raster rendering support
|
||||
|
@ -136,6 +136,8 @@ import com.raytheon.viz.awipstools.IToolChangedListener;
|
|||
* Feb 17, 2015 4135 bsteffen Set no data value for derived products.
|
||||
* Mar 3, 2015 DCS 14960 jgerth Retrieve legend from style rules if available
|
||||
* Apr 15, 2014 4388 bsteffen Use fill value from record.
|
||||
* Jul 28, 2015 4633 bsteffen Create tileset in resource so it can be
|
||||
* overridden for daylight transition.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -250,8 +252,7 @@ public class SatResource extends
|
|||
}
|
||||
}
|
||||
if (tileSet == null) {
|
||||
tileSet = new SatTileSetRenderable(SatResource.this, record);
|
||||
tileSet.project(descriptor.getGridGeometry());
|
||||
tileSet = createTileSet(record);
|
||||
tileMap.put(record.getCoverage(), tileSet);
|
||||
}
|
||||
}
|
||||
|
@ -306,6 +307,13 @@ public class SatResource extends
|
|||
addDataObject(data.getRecords());
|
||||
}
|
||||
|
||||
protected SatTileSetRenderable createTileSet(SatelliteRecord record) {
|
||||
SatTileSetRenderable tileSet = new SatTileSetRenderable(
|
||||
this, record);
|
||||
tileSet.project(descriptor.getGridGeometry());
|
||||
return tileSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected DataTime getDataObjectTime(PluginDataObject pdo) {
|
||||
if (initialized == false) {
|
||||
|
|
Loading…
Add table
Reference in a new issue