Omaha #4079 Move contours to ufcore.
Former-commit-id: bd6f391f1213d02b8f11dc06dd920c3f0caaf824
This commit is contained in:
parent
af0a2cb242
commit
43c45be7b3
21 changed files with 0 additions and 6255 deletions
|
@ -96,13 +96,6 @@
|
|||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.viz.core.contours"
|
||||
download-size="0"
|
||||
install-size="0"
|
||||
version="0.0.0"
|
||||
unpack="false"/>
|
||||
|
||||
<plugin
|
||||
id="com.raytheon.uf.viz.spellchecker"
|
||||
download-size="0"
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>com.raytheon.viz.core.contours</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>
|
|
@ -1,22 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Contour Generation and Display
|
||||
Bundle-SymbolicName: com.raytheon.viz.core.contours
|
||||
Bundle-Version: 1.15.2.qualifier
|
||||
Bundle-Vendor: Raytheon
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Require-Bundle: com.raytheon.uf.viz.core;bundle-version="1.14.1",
|
||||
org.eclipse.core.runtime;bundle-version="3.8.0",
|
||||
org.eclipse.ui;bundle-version="3.8.0",
|
||||
com.raytheon.uf.common.geospatial;bundle-version="1.14.0",
|
||||
com.raytheon.uf.common.util,
|
||||
com.raytheon.uf.common.wxmath,
|
||||
com.raytheon.uf.common.style,
|
||||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.common.numeric;bundle-version="1.14.0",
|
||||
org.apache.commons.collections
|
||||
Import-Package: com.raytheon.viz.core.interval
|
||||
Export-Package: com.raytheon.viz.core.contours,
|
||||
com.raytheon.viz.core.contours.rsc.displays,
|
||||
com.raytheon.viz.core.contours.util
|
|
@ -1,4 +0,0 @@
|
|||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
|
@ -1,279 +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.viz.core.contours;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
||||
import com.raytheon.uf.common.numeric.source.DataSource;
|
||||
import com.raytheon.uf.common.style.contour.ContourPreferences;
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.viz.core.contours.ContourSupport.ContourGroup;
|
||||
|
||||
/**
|
||||
* ContourCreateRequest
|
||||
*
|
||||
* A request containing all the data needed for a ContourManagerJob to create
|
||||
* contours. The created contours are placed back into this object so keep a
|
||||
* reference around to check for finished contours.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Feb 25, 2011 ekladstrup Initial creation
|
||||
* Feb 27, 2014 2791 bsteffen Switch from IDataRecord to DataSource
|
||||
*
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author ekladstrup
|
||||
* @version 1
|
||||
*/
|
||||
public class ContourCreateRequest {
|
||||
|
||||
public ContourCreateRequest(String identifier, DataSource[] source,
|
||||
float level, IExtent pixelExtent, double currentDensity,
|
||||
double currentMagnification, GeneralGridGeometry imageGridGeometry,
|
||||
IGraphicsTarget target, IMapDescriptor descriptor,
|
||||
ContourPreferences prefs, float zoom) {
|
||||
super();
|
||||
this.identifier = identifier;
|
||||
this.source = source;
|
||||
this.level = level;
|
||||
this.pixelExtent = pixelExtent;
|
||||
this.imageGridGeometry = imageGridGeometry;
|
||||
this.target = target;
|
||||
this.descriptor = descriptor;
|
||||
this.prefs = prefs;
|
||||
this.currentDensity = currentDensity;
|
||||
this.currentMagnification = currentMagnification;
|
||||
this.zoom = zoom;
|
||||
this.canceled = false;
|
||||
this.contourGroup = null;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public void setIdentifier(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public DataSource[] getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(DataSource[] source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public float getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(float level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public IExtent getPixelExtent() {
|
||||
return pixelExtent;
|
||||
}
|
||||
|
||||
public void setPixelExtent(IExtent pixelExtent) {
|
||||
this.pixelExtent = pixelExtent;
|
||||
}
|
||||
|
||||
public double getCurrentDensity() {
|
||||
return currentDensity;
|
||||
}
|
||||
|
||||
public void setCurrentDensity(double currentDensity) {
|
||||
this.currentDensity = currentDensity;
|
||||
}
|
||||
|
||||
public double getCurrentMagnification() {
|
||||
return currentMagnification;
|
||||
}
|
||||
|
||||
public void setCurrentMagnification(double currentMagnification) {
|
||||
this.currentMagnification = currentMagnification;
|
||||
}
|
||||
|
||||
public GeneralGridGeometry getImageGridGeometry() {
|
||||
return imageGridGeometry;
|
||||
}
|
||||
|
||||
public void setImageGridGeometry(GeneralGridGeometry imageGridGeometry) {
|
||||
this.imageGridGeometry = imageGridGeometry;
|
||||
}
|
||||
|
||||
public IGraphicsTarget getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
public void setTarget(IGraphicsTarget target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
public IMapDescriptor getDescriptor() {
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
public void setDescriptor(IMapDescriptor descriptor) {
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
public ContourPreferences getPrefs() {
|
||||
return prefs;
|
||||
}
|
||||
|
||||
public void setPrefs(ContourPreferences prefs) {
|
||||
this.prefs = prefs;
|
||||
}
|
||||
|
||||
public float getZoom() {
|
||||
return zoom;
|
||||
}
|
||||
|
||||
public void setZoom(float zoom) {
|
||||
this.zoom = zoom;
|
||||
}
|
||||
|
||||
public boolean isCanceled() {
|
||||
return canceled;
|
||||
}
|
||||
|
||||
public void setCanceled(boolean cancel) {
|
||||
this.canceled = cancel;
|
||||
}
|
||||
|
||||
public ContourGroup getContourGroup() {
|
||||
return contourGroup;
|
||||
}
|
||||
|
||||
public synchronized void setContourGroup(ContourGroup contourGroup) {
|
||||
// synchronized so disposed can't get set after it is checked
|
||||
if (!this.disposed) {
|
||||
this.contourGroup = contourGroup;
|
||||
} else {
|
||||
contourGroup.negValueShape.dispose();
|
||||
contourGroup.posValueShape.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private String identifier;
|
||||
|
||||
private DataSource[] source;
|
||||
|
||||
private float level;
|
||||
|
||||
private IExtent pixelExtent;
|
||||
|
||||
private double currentDensity;
|
||||
|
||||
private double currentMagnification;
|
||||
|
||||
private GeneralGridGeometry imageGridGeometry;
|
||||
|
||||
private IGraphicsTarget target;
|
||||
|
||||
private IMapDescriptor descriptor;
|
||||
|
||||
private ContourPreferences prefs;
|
||||
|
||||
private float zoom;
|
||||
|
||||
private boolean canceled;
|
||||
|
||||
private ContourGroup contourGroup;
|
||||
|
||||
private boolean disposed = false;
|
||||
|
||||
public boolean equals(Object arg) {
|
||||
boolean rval = true;
|
||||
|
||||
if (!(arg instanceof ContourCreateRequest)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ContourCreateRequest rhs = (ContourCreateRequest) arg;
|
||||
|
||||
// right now comparing:
|
||||
// identifier, level, pixelExtent, currentDensity, currentMagnification,
|
||||
// prefs, zoom, imageGridGeometry, mapGridGeometry
|
||||
// NOT COMPARING:
|
||||
// record, worldGridToCRSTransform, target, descriptor
|
||||
// Should never use canceled or contourGroup to check equality
|
||||
if (identifier != null && !identifier.equals(rhs.getIdentifier())) {
|
||||
rval = false;
|
||||
} else if (!(level == rhs.getLevel())) {
|
||||
rval = false;
|
||||
} else if (pixelExtent != null
|
||||
&& !(pixelExtent.equals(rhs.getPixelExtent()))) {
|
||||
rval = false;
|
||||
} else if (!(currentDensity == rhs.getCurrentDensity())) {
|
||||
rval = false;
|
||||
} else if (!(currentMagnification == rhs.getCurrentMagnification())) {
|
||||
rval = false;
|
||||
} else if (prefs != null && !(this.prefs.equals(rhs.getPrefs()))) {
|
||||
rval = false;
|
||||
} else if (!(zoom == rhs.getZoom())) {
|
||||
rval = false;
|
||||
} else if (imageGridGeometry != null
|
||||
&& !(this.imageGridGeometry.equals(rhs.getImageGridGeometry()))) {
|
||||
rval = false;
|
||||
}
|
||||
|
||||
// if nothing set rval to false (not equal)
|
||||
// check that references to null are the same
|
||||
// if this instances references are not null then
|
||||
// rhs with null references should be caught above
|
||||
// so only worry about this.* == null and rhs.* != null
|
||||
if (rval == true) {
|
||||
if (identifier == null && rhs.getIdentifier() != null) {
|
||||
rval = false;
|
||||
} else if (pixelExtent == null && rhs.getPixelExtent() != null) {
|
||||
rval = false;
|
||||
} else if (prefs == null && rhs.getPrefs() != null) {
|
||||
rval = false;
|
||||
} else if (imageGridGeometry == null
|
||||
&& rhs.getImageGridGeometry() != null) {
|
||||
rval = false;
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
public synchronized void dispose() {
|
||||
// synchronized to avoid leaking memory because of a missed dispose
|
||||
this.disposed = true;
|
||||
if (contourGroup != null) {
|
||||
this.contourGroup.posValueShape.dispose();
|
||||
this.contourGroup.negValueShape.dispose();
|
||||
this.contourGroup = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,140 +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.viz.core.contours;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
|
||||
import com.raytheon.viz.core.contours.ContourSupport.ContourGroup;
|
||||
|
||||
/**
|
||||
* ContourManagerJob
|
||||
*
|
||||
* Provides a job that can create contours asynchronously
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Oct 24, 2007 chammack Initial Creation.
|
||||
* Feb 27, 2014 2791 bsteffen Switch from IDataRecord to DataSource
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1
|
||||
*/
|
||||
public class ContourManagerJob extends Job {
|
||||
|
||||
private static ContourManagerJob instance;
|
||||
|
||||
private ConcurrentLinkedQueue<ContourCreateRequest> requestQueue;
|
||||
|
||||
private ContourManagerJob() {
|
||||
super("Contouring...");
|
||||
this.requestQueue = new ConcurrentLinkedQueue<ContourCreateRequest>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get instance
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static synchronized ContourManagerJob getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new ContourManagerJob();
|
||||
instance.setSystem(false);
|
||||
instance.schedule();
|
||||
}
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request a contour group
|
||||
*
|
||||
* @param identifier
|
||||
* @param record
|
||||
* @param level
|
||||
* @param extent
|
||||
* @param currentDensity
|
||||
* @param worldGridToCRSTransform
|
||||
* @param imageGridGeometry
|
||||
* @param mapGridGeometry
|
||||
* @param target
|
||||
* @param descriptor
|
||||
* @param prefs
|
||||
* @return
|
||||
*/
|
||||
public void request(ContourCreateRequest request) {
|
||||
this.requestQueue.add(request);
|
||||
|
||||
if (this.getState() != Job.RUNNING) {
|
||||
this.schedule();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @seeorg.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
|
||||
* IProgressMonitor)
|
||||
*/
|
||||
@Override
|
||||
protected IStatus run(IProgressMonitor monitor) {
|
||||
|
||||
ContourCreateRequest req;
|
||||
while ((req = this.requestQueue.poll()) != null) {
|
||||
this.setName("Contouring");
|
||||
|
||||
try {
|
||||
if (req.isCanceled() || req.getContourGroup() != null) {
|
||||
;// request has been canceled or contours exist
|
||||
} else {
|
||||
long t0 = System.currentTimeMillis();
|
||||
ContourGroup cg = null;
|
||||
cg = ContourSupport.createContours(req.getSource(),
|
||||
req.getLevel(), req.getPixelExtent(),
|
||||
req.getCurrentDensity(),
|
||||
req.getCurrentMagnification(),
|
||||
req.getImageGridGeometry(), req.getTarget(),
|
||||
req.getDescriptor(), req.getPrefs(), req.getZoom());
|
||||
// setContourGroup will check if cg needs to be disposed
|
||||
req.setContourGroup(cg);
|
||||
System.out.println("Total time taken: "
|
||||
+ (System.currentTimeMillis() - t0));
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
return new Status(Status.ERROR, ContourManagerJob.class
|
||||
.getPackage().getName(),
|
||||
"Error creating contours", e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
}
|
|
@ -1,550 +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.viz.core.contours;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.eclipse.swt.graphics.RGB;
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.geometry.DirectPosition2D;
|
||||
import org.geotools.geometry.jts.JTS;
|
||||
import org.opengis.coverage.grid.GridEnvelope;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||
import com.raytheon.uf.common.geospatial.data.GeographicDataSource;
|
||||
import com.raytheon.uf.common.numeric.DataUtilities;
|
||||
import com.raytheon.uf.common.numeric.buffer.FloatBufferWrapper;
|
||||
import com.raytheon.uf.common.numeric.dest.DataDestination;
|
||||
import com.raytheon.uf.common.numeric.filter.FillValueFilter;
|
||||
import com.raytheon.uf.common.numeric.filter.InverseFillValueFilter;
|
||||
import com.raytheon.uf.common.numeric.source.DataSource;
|
||||
import com.raytheon.uf.common.style.contour.ContourPreferences;
|
||||
import com.raytheon.uf.common.wxmath.Constants;
|
||||
import com.raytheon.uf.common.wxmath.DistFilter;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.LineStyle;
|
||||
import com.raytheon.uf.viz.core.PixelExtent;
|
||||
import com.raytheon.uf.viz.core.datastructure.LoopProperties;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont;
|
||||
import com.raytheon.uf.viz.core.drawables.IFont.Style;
|
||||
import com.raytheon.uf.viz.core.drawables.IRenderable;
|
||||
import com.raytheon.uf.viz.core.drawables.PaintProperties;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.uf.viz.core.map.MapDescriptor;
|
||||
import com.raytheon.viz.core.contours.ContourSupport.ContourGroup;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
|
||||
/**
|
||||
* Generalized contour renderable
|
||||
*
|
||||
* May be embedded in other renderable displays or form the basis of contour
|
||||
* resources
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 10, 2008 1233 chammack Initial creation
|
||||
* Jul 18, 2013 2199 mschenke Made code only smooth data once
|
||||
* Aug 23, 2013 2157 dgilling Remove meteolib dependency.
|
||||
* Feb 27, 2014 2791 bsteffen Switch from IDataRecord to DataSource and
|
||||
* reduce loop freezing.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public abstract class ContourRenderable implements IRenderable {
|
||||
|
||||
private ContourGroup[] contourGroup;
|
||||
|
||||
private Map<String, ContourCreateRequest> requestMap;
|
||||
|
||||
private final IMapDescriptor descriptor;
|
||||
|
||||
private LineStyle lineStyle;
|
||||
|
||||
private RGB color;
|
||||
|
||||
private double density = 1.0;
|
||||
|
||||
private double magnification = 1.0;
|
||||
|
||||
private int outlineWidth;
|
||||
|
||||
private final String uuid;
|
||||
|
||||
private DataSource[] data;
|
||||
|
||||
// This is the width of CONUS
|
||||
private static final double METERS_AT_BASE_ZOOMLEVEL = 5878649.0;
|
||||
|
||||
private static final double BASE_CANVAS_SIZE = 1000.0;
|
||||
|
||||
private static final double ZOOM_REACTION_FACTOR = .45;
|
||||
|
||||
private static final int NUMBER_CONTOURING_LEVELS = 10;
|
||||
|
||||
public abstract DataSource[] getData() throws VizException;
|
||||
|
||||
public abstract GeneralGridGeometry getGridGeometry() throws VizException;
|
||||
|
||||
public abstract ContourPreferences getPreferences() throws VizException;
|
||||
|
||||
private IFont font;
|
||||
|
||||
private IFont minMaxFont;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param styleRule
|
||||
* @param descriptor
|
||||
* @param callback
|
||||
* @param lineStyle
|
||||
*/
|
||||
public ContourRenderable(IMapDescriptor descriptor) {
|
||||
|
||||
this.descriptor = descriptor;
|
||||
uuid = UUID.randomUUID().toString();
|
||||
this.requestMap = new HashMap<String, ContourCreateRequest>();
|
||||
}
|
||||
|
||||
private DataSource[] getContourData() throws VizException {
|
||||
if (data == null) {
|
||||
data = getData();
|
||||
if (data != null) {
|
||||
GeneralGridGeometry gridGeometry = getGridGeometry();
|
||||
ContourPreferences contourPrefs = getPreferences();
|
||||
if (gridGeometry != null && contourPrefs != null) {
|
||||
data = smoothData(data, gridGeometry, contourPrefs);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set color
|
||||
*
|
||||
* @param color
|
||||
* the color to set
|
||||
*/
|
||||
public void setColor(RGB color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param density
|
||||
* the density to set
|
||||
*/
|
||||
public void setDensity(double density) {
|
||||
if (density > 4.0f) {
|
||||
density = 4.0f;
|
||||
}
|
||||
this.density = density;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param magnification
|
||||
* the magnification to set
|
||||
*/
|
||||
public void setMagnification(double magnification) {
|
||||
if (this.magnification != magnification) {
|
||||
if (font != null) {
|
||||
font.dispose();
|
||||
font = null;
|
||||
}
|
||||
if (minMaxFont != null) {
|
||||
minMaxFont.dispose();
|
||||
minMaxFont = null;
|
||||
}
|
||||
}
|
||||
this.magnification = magnification;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set outline width
|
||||
*
|
||||
* @param outlineWidth
|
||||
* the outlineWidth to set
|
||||
*/
|
||||
public void setOutlineWidth(int outlineWidth) {
|
||||
this.outlineWidth = outlineWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the line style
|
||||
*
|
||||
* @param lineStyle
|
||||
* the lineStyle to set
|
||||
*/
|
||||
public void setLineStyle(LineStyle lineStyle) {
|
||||
this.lineStyle = lineStyle;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.core.drawables.IRenderable#paint(com.raytheon.viz.core
|
||||
* .IGraphicsTarget, com.raytheon.viz.core.drawables.PaintProperties)
|
||||
*/
|
||||
@Override
|
||||
public void paint(IGraphicsTarget target, PaintProperties paintProps)
|
||||
throws VizException {
|
||||
synchronized (this) {
|
||||
if (this.density == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (contourGroup == null) {
|
||||
contourGroup = new ContourGroup[NUMBER_CONTOURING_LEVELS];
|
||||
}
|
||||
|
||||
if (contourGroup != null) {
|
||||
if (font == null) {
|
||||
font = target.getDefaultFont();
|
||||
|
||||
font = target.initializeFont(font.getFontName(),
|
||||
(float) (font.getFontSize() / 1.4 * magnification),
|
||||
null);
|
||||
}
|
||||
|
||||
if (minMaxFont == null) {
|
||||
minMaxFont = target.getDefaultFont();
|
||||
|
||||
minMaxFont = target
|
||||
.initializeFont(
|
||||
minMaxFont.getFontName(),
|
||||
(float) (minMaxFont.getFontSize() / 1.3 * magnification),
|
||||
new Style[] { Style.BOLD });
|
||||
}
|
||||
|
||||
// To convert from i to zoomLevel, take i + 1.0 / 2 so
|
||||
// contourGroup[0] is at zoomLevel 0.5, contourGroup[1] is at
|
||||
// zoomLevel 1, etc.
|
||||
int i = contourGroup.length - 1;
|
||||
double mapWidth = ((MapDescriptor) this.descriptor)
|
||||
.getMapWidth();
|
||||
double widthInMeters = mapWidth * paintProps.getZoomLevel();
|
||||
while (i >= 0) {
|
||||
double curlvl = (METERS_AT_BASE_ZOOMLEVEL)
|
||||
* (Math.pow(ZOOM_REACTION_FACTOR, (i - 1.0) / 2));
|
||||
curlvl *= paintProps.getCanvasBounds().width
|
||||
/ BASE_CANVAS_SIZE;
|
||||
if (widthInMeters <= curlvl || i == 0) {
|
||||
boolean contains = (contourGroup[i] == null || contourGroup[i].lastUsedPixelExtent == null) ? false
|
||||
: (contourGroup[i].lastUsedPixelExtent
|
||||
.getEnvelope()
|
||||
.contains(((PixelExtent) paintProps
|
||||
.getView().getExtent())
|
||||
.getEnvelope()));
|
||||
// calculate the pixel density
|
||||
float pixelDensity = (float) (paintProps
|
||||
.getCanvasBounds().width / paintProps.getView()
|
||||
.getExtent().getWidth());
|
||||
|
||||
double pdRatio = contourGroup[i] == null ? 1
|
||||
: pixelDensity
|
||||
/ contourGroup[i].lastPixelDensity;
|
||||
// Run contours if:
|
||||
// 1. Contours was never ran before -or-
|
||||
// 2. The area currently viewed is outside of the
|
||||
// contoured window -or-
|
||||
// 3. The density has changed
|
||||
// 4. The pixel density has changed significantly
|
||||
if (contourGroup[i] == null || !contains
|
||||
|| contourGroup[i].lastDensity != density
|
||||
|| pdRatio > 2 || pdRatio < 0.5) {
|
||||
|
||||
GeneralGridGeometry gridGeometry = getGridGeometry();
|
||||
ContourPreferences contourPrefs = getPreferences();
|
||||
|
||||
// If required data unavailable, quit now
|
||||
if (gridGeometry == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DataSource[] dataRecord = getContourData();
|
||||
if (dataRecord == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ContourGroup cg = null;
|
||||
// generate the identifier
|
||||
String identifier = uuid + "::" + this + "::" + i;
|
||||
// grab the existing request
|
||||
ContourCreateRequest existingRequest = requestMap
|
||||
.get(identifier);
|
||||
// create a new request
|
||||
ContourCreateRequest request = new ContourCreateRequest(
|
||||
identifier, dataRecord, (i + 1) / 2.0f,
|
||||
paintProps.getView().getExtent(), density,
|
||||
magnification, gridGeometry, target,
|
||||
descriptor, contourPrefs, pixelDensity);
|
||||
|
||||
if (existingRequest != null) {
|
||||
// check if new request needs to replace old
|
||||
if (!(request.equals(existingRequest))) {
|
||||
// cancel old request
|
||||
existingRequest.setCanceled(true);
|
||||
// add new request
|
||||
requestMap.put(identifier, request);
|
||||
// send request
|
||||
ContourManagerJob.getInstance().request(
|
||||
request);
|
||||
}
|
||||
} else {
|
||||
// there is no exiting request, insert new one
|
||||
requestMap.put(identifier, request);
|
||||
ContourManagerJob.getInstance()
|
||||
.request(request);
|
||||
}
|
||||
|
||||
int retries = 0;
|
||||
LoopProperties loopProps = paintProps
|
||||
.getLoopProperties();
|
||||
if (loopProps != null && loopProps.isLooping()) {
|
||||
/**
|
||||
* If the display is looping, wait a few ms to
|
||||
* let contouring finish so that if the
|
||||
* contouring is fast enough the user is not
|
||||
* presented with empty frames. If too many
|
||||
* resources do this, it freezes the UI so scale
|
||||
* the sleep time based off the number of
|
||||
* resources because empty frames are better
|
||||
* than freezing. This scaling also gives
|
||||
* everyone a chance to queue up work so that
|
||||
* multiprocessing is done more efficiently.
|
||||
*/
|
||||
retries = 100 / descriptor.getResourceList()
|
||||
.size();
|
||||
}
|
||||
do {
|
||||
// grab request from map
|
||||
request = requestMap.get(identifier);
|
||||
cg = request.getContourGroup();
|
||||
retries--;
|
||||
try {
|
||||
if (cg == null && retries > 0) {
|
||||
Thread.sleep(10);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
retries = 0;
|
||||
}
|
||||
} while (cg == null && retries > 0);
|
||||
|
||||
if (cg != null) {
|
||||
if (cg != contourGroup[i]) {
|
||||
// Dispose old wireframe shapes
|
||||
if (contourGroup[i] != null
|
||||
&& contourGroup[i].posValueShape != null) {
|
||||
contourGroup[i].posValueShape.dispose();
|
||||
}
|
||||
|
||||
if (contourGroup[i] != null
|
||||
&& contourGroup[i].negValueShape != null) {
|
||||
contourGroup[i].negValueShape.dispose();
|
||||
}
|
||||
|
||||
contourGroup[i] = cg;
|
||||
contourGroup[i].posValueShape.compile();
|
||||
contourGroup[i].negValueShape.compile();
|
||||
}
|
||||
} else {
|
||||
target.setNeedsRefresh(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (contourGroup[i] != null
|
||||
&& paintProps
|
||||
.getView()
|
||||
.getExtent()
|
||||
.intersects(
|
||||
contourGroup[i].lastUsedPixelExtent)) {
|
||||
// System.out.println("Painting group at " + i);
|
||||
drawContourGroup(target, contourGroup[i]);
|
||||
} else {
|
||||
// see if we can display a higher level
|
||||
if (i > 0) {
|
||||
int j = i - 1;
|
||||
if (contourGroup[j] != null) {
|
||||
if (contourGroup[j].posValueShape != null) {
|
||||
if (contourGroup[j].lastUsedPixelExtent
|
||||
.intersects(paintProps
|
||||
.getView().getExtent())) {
|
||||
drawContourGroup(target,
|
||||
contourGroup[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
target.setNeedsRefresh(true);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private DataSource[] smoothData(DataSource[] dataRecord,
|
||||
GeneralGridGeometry gridGeometry, ContourPreferences contourPrefs)
|
||||
throws VizException {
|
||||
if (contourPrefs != null && contourPrefs.getSmoothingDistance() != null) {
|
||||
// Calculate the Diagnol Distance of the Grid In Meters.
|
||||
DirectPosition2D upperCorner = new DirectPosition2D(gridGeometry
|
||||
.getEnvelope().getUpperCorner());
|
||||
DirectPosition2D lowerCorner = new DirectPosition2D(gridGeometry
|
||||
.getEnvelope().getLowerCorner());
|
||||
double distanceInM;
|
||||
try {
|
||||
MathTransform crs2ll = MapUtil
|
||||
.getTransformToLatLon(gridGeometry
|
||||
.getCoordinateReferenceSystem());
|
||||
crs2ll.transform(upperCorner, upperCorner);
|
||||
crs2ll.transform(lowerCorner, lowerCorner);
|
||||
upperCorner.x = MapUtil.correctLon(upperCorner.x);
|
||||
lowerCorner.x = MapUtil.correctLon(lowerCorner.x);
|
||||
distanceInM = JTS
|
||||
.orthodromicDistance(
|
||||
new Coordinate(lowerCorner.getOrdinate(0),
|
||||
lowerCorner.getOrdinate(1)),
|
||||
new Coordinate(upperCorner.getOrdinate(0),
|
||||
upperCorner.getOrdinate(1)), MapUtil
|
||||
.getLatLonProjection());
|
||||
} catch (Exception e) {
|
||||
throw new VizException(e);
|
||||
}
|
||||
// Calculate the Diagnol Distance in Points
|
||||
GridEnvelope range = gridGeometry.getGridRange();
|
||||
int nx = range.getSpan(0);
|
||||
int ny = range.getSpan(1);
|
||||
double distanceInPoints = Math.sqrt(nx * nx + ny * ny);
|
||||
// Determine the number of points to smooth, assume
|
||||
// smoothingDistance is in km
|
||||
float npts = (float) (distanceInPoints
|
||||
* contourPrefs.getSmoothingDistance() / (distanceInM / 1000));
|
||||
FloatBufferWrapper data = new FloatBufferWrapper(nx, ny);
|
||||
DataDestination dest = InverseFillValueFilter.apply(
|
||||
(DataDestination) data, Constants.LEGACY_NAN);
|
||||
DataUtilities.copy(dataRecord[0], dest, nx, ny);
|
||||
float[] dataArray = data.getArray();
|
||||
dataArray = DistFilter.filter(dataArray, npts, nx, ny, 1);
|
||||
data = new FloatBufferWrapper(dataArray, nx, ny);
|
||||
DataSource source = FillValueFilter.apply((DataSource) data,
|
||||
Constants.LEGACY_NAN);
|
||||
source = new GeographicDataSource(source, gridGeometry);
|
||||
return new DataSource[] { source };
|
||||
} else {
|
||||
return dataRecord;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispose the renderable
|
||||
*/
|
||||
public void dispose() {
|
||||
if (contourGroup != null) {
|
||||
for (ContourGroup c : contourGroup) {
|
||||
if (c == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c.posValueShape != null) {
|
||||
c.posValueShape.dispose();
|
||||
}
|
||||
if (c.negValueShape != null) {
|
||||
c.negValueShape.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> keys = requestMap.keySet();
|
||||
for (String key : keys) {
|
||||
requestMap.get(key).dispose();
|
||||
}
|
||||
requestMap.clear();
|
||||
|
||||
if (font != null) {
|
||||
font.dispose();
|
||||
font = null;
|
||||
}
|
||||
if (minMaxFont != null) {
|
||||
minMaxFont.dispose();
|
||||
minMaxFont = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void drawContourGroup(IGraphicsTarget target,
|
||||
ContourGroup contourGroup) throws VizException {
|
||||
|
||||
LineStyle posLineStyle = null;
|
||||
LineStyle negLineStyle = null;
|
||||
|
||||
ContourPreferences prefs = getPreferences();
|
||||
|
||||
if (prefs != null
|
||||
&& prefs.getPositiveLinePattern() != null
|
||||
&& (this.lineStyle == null || this.lineStyle == LineStyle.DEFAULT)) {
|
||||
posLineStyle = LineStyle.valueOf(prefs.getPositiveLinePattern());
|
||||
} else if (this.lineStyle == null
|
||||
|| this.lineStyle == LineStyle.DEFAULT) {
|
||||
posLineStyle = LineStyle.SOLID;
|
||||
} else {
|
||||
posLineStyle = this.lineStyle;
|
||||
}
|
||||
|
||||
if (prefs != null
|
||||
&& prefs.getNegativeLinePattern() != null
|
||||
&& (this.lineStyle == null || this.lineStyle == LineStyle.DEFAULT)) {
|
||||
negLineStyle = LineStyle.valueOf(prefs.getNegativeLinePattern());
|
||||
} else if (this.lineStyle == null
|
||||
|| this.lineStyle == LineStyle.DEFAULT) {
|
||||
negLineStyle = LineStyle.DASHED_LARGE;
|
||||
} else {
|
||||
negLineStyle = this.lineStyle;
|
||||
}
|
||||
|
||||
// if (this.lineStyle == null || this.lineStyle == LineStyle.DEFAULT) {
|
||||
// posLineStyle = LineStyle.SOLID;
|
||||
// negLineStyle = LineStyle.DASHED_LARGE;
|
||||
// } else {
|
||||
// posLineStyle = this.lineStyle;
|
||||
// negLineStyle = this.lineStyle;
|
||||
// }
|
||||
|
||||
contourGroup.drawContours(target, this.color, this.outlineWidth,
|
||||
posLineStyle, negLineStyle, font, minMaxFont);
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,123 +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.viz.core.contours.cache;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
|
||||
import com.raytheon.uf.viz.core.IExtent;
|
||||
|
||||
/**
|
||||
* Key for a cache for an envelope of a subgrid
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 4, 2011 7747 njensen Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author njensen
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class SubGridCacheKey {
|
||||
|
||||
private IExtent extent;
|
||||
|
||||
private GeneralGridGeometry mapGridGeometry;
|
||||
|
||||
private GeneralGridGeometry imageGridGeometry;
|
||||
|
||||
public SubGridCacheKey(IExtent extent, GeneralGridGeometry mapGridGeometry,
|
||||
GeneralGridGeometry imageGridGeometry) {
|
||||
this.extent = extent;
|
||||
this.mapGridGeometry = mapGridGeometry;
|
||||
this.imageGridGeometry = imageGridGeometry;
|
||||
}
|
||||
|
||||
public IExtent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
|
||||
public void setExtent(IExtent extent) {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
public GeneralGridGeometry getMapGridGeometry() {
|
||||
return mapGridGeometry;
|
||||
}
|
||||
|
||||
public void setMapGridGeometry(GeneralGridGeometry mapGridGeometry) {
|
||||
this.mapGridGeometry = mapGridGeometry;
|
||||
}
|
||||
|
||||
public GeneralGridGeometry getImageGridGeometry() {
|
||||
return imageGridGeometry;
|
||||
}
|
||||
|
||||
public void setImageGridGeometry(GeneralGridGeometry imageGridGeometry) {
|
||||
this.imageGridGeometry = imageGridGeometry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((extent == null) ? 0 : extent.hashCode());
|
||||
result = prime
|
||||
* result
|
||||
+ ((imageGridGeometry == null) ? 0 : imageGridGeometry
|
||||
.hashCode());
|
||||
result = prime * result
|
||||
+ ((mapGridGeometry == null) ? 0 : mapGridGeometry.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SubGridCacheKey other = (SubGridCacheKey) obj;
|
||||
if (extent == null) {
|
||||
if (other.extent != null)
|
||||
return false;
|
||||
} else if (!extent.equals(other.extent))
|
||||
return false;
|
||||
if (imageGridGeometry == null) {
|
||||
if (other.imageGridGeometry != null)
|
||||
return false;
|
||||
} else if (!imageGridGeometry.equals(other.imageGridGeometry))
|
||||
return false;
|
||||
if (mapGridGeometry == null) {
|
||||
if (other.mapGridGeometry != null)
|
||||
return false;
|
||||
} else if (!mapGridGeometry.equals(other.mapGridGeometry))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,24 +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.
|
||||
**/
|
||||
/**
|
||||
* Provides contouring support
|
||||
*
|
||||
*/
|
||||
package com.raytheon.viz.core.contours;
|
|
@ -1,96 +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.viz.core.contours.rsc.displays;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import org.geotools.coverage.grid.GeneralGridGeometry;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.data.GeographicDataSource;
|
||||
import com.raytheon.uf.common.numeric.source.DataSource;
|
||||
import com.raytheon.uf.common.style.contour.ContourPreferences;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
import com.raytheon.viz.core.contours.ContourRenderable;
|
||||
|
||||
/**
|
||||
* Displays contours from any data source
|
||||
*
|
||||
* Currently implemented using the D2D contouring capability
|
||||
*
|
||||
* <pre>
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jul 11, 2008 1233 chammack Initial creation
|
||||
* Feb 27, 2014 2791 bsteffen Switch from IDataRecord to DataSource
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author chammack
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class GriddedContourDisplay extends ContourRenderable {
|
||||
|
||||
private ContourPreferences preferences;
|
||||
|
||||
protected GridGeometry2D gridGeometry;
|
||||
|
||||
protected DataSource source;
|
||||
|
||||
public GriddedContourDisplay(IMapDescriptor descriptor,
|
||||
final GridGeometry2D gridGeometry, final FloatBuffer fb) {
|
||||
this(descriptor, gridGeometry, new GeographicDataSource(fb,
|
||||
gridGeometry));
|
||||
}
|
||||
|
||||
public GriddedContourDisplay(IMapDescriptor descriptor,
|
||||
final GridGeometry2D gridGeometry, final DataSource source) {
|
||||
super(descriptor);
|
||||
this.gridGeometry = gridGeometry;
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource[] getData() throws VizException {
|
||||
return new DataSource[] { source };
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneralGridGeometry getGridGeometry() throws VizException {
|
||||
return gridGeometry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContourPreferences getPreferences() throws VizException {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param preferences
|
||||
* the preferences to set
|
||||
*/
|
||||
public void setPreferences(ContourPreferences preferences) {
|
||||
this.preferences = preferences;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,75 +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.viz.core.contours.rsc.displays;
|
||||
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
|
||||
import com.raytheon.uf.common.geospatial.data.GeographicDataSource;
|
||||
import com.raytheon.uf.common.numeric.source.DataSource;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.map.IMapDescriptor;
|
||||
|
||||
/**
|
||||
*
|
||||
* Performs same functions as the original GriddedVectorDisplay using wireframe
|
||||
* shapes instead of svg for much faster performance. This is still slightly
|
||||
* experimental but seems to work well. It should also have the drawing code
|
||||
* extracted to a class similar to PointWindDisplay so wireframe shape barbs and
|
||||
* arrows can be used elsewhere.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Jun 22, 2010 bsteffen Initial creation
|
||||
* Feb 07, 2011 7948 bkowal added a public method to get the
|
||||
* direction.
|
||||
* Feb 27, 2014 2791 bsteffen Switch from IDataRecord to DataSource
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author bsteffen
|
||||
* @version 1.0
|
||||
*/
|
||||
public class GriddedStreamlineDisplay extends GriddedContourDisplay {
|
||||
|
||||
private DataSource vSource;
|
||||
|
||||
public GriddedStreamlineDisplay(IMapDescriptor descriptor,
|
||||
GridGeometry2D gridGeometry, FloatBuffer ufb, FloatBuffer vfb) {
|
||||
super(descriptor, gridGeometry, ufb);
|
||||
this.vSource = new GeographicDataSource(vfb, gridGeometry);
|
||||
}
|
||||
|
||||
public GriddedStreamlineDisplay(IMapDescriptor descriptor,
|
||||
GridGeometry2D gridGeometry, DataSource ufb, DataSource vfb) {
|
||||
super(descriptor, gridGeometry, ufb);
|
||||
this.vSource = vfb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataSource[] getData() throws VizException {
|
||||
return new DataSource[] { source, vSource };
|
||||
}
|
||||
|
||||
}
|
|
@ -1,62 +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.viz.core.contours.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contains a list of the contours and their associated values.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 23, 2010 #4583 rjpeter Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class ContourContainer {
|
||||
public final List<float[]> xyContourPoints;
|
||||
|
||||
public final List<Float> contourVals;
|
||||
|
||||
public final List<float[]> minLabelPoints;
|
||||
|
||||
public final List<float[]> maxLabelPoints;
|
||||
|
||||
public final List<Float> minVals;
|
||||
|
||||
public final List<Float> maxVals;
|
||||
|
||||
public ContourContainer(int capacity) {
|
||||
xyContourPoints = new ArrayList<float[]>(capacity);
|
||||
contourVals = new ArrayList<Float>(capacity);
|
||||
minLabelPoints = new ArrayList<float[]>();
|
||||
maxLabelPoints = new ArrayList<float[]>();
|
||||
minVals = new ArrayList<Float>();
|
||||
maxVals = new ArrayList<Float>();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,62 +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.viz.core.contours.util;
|
||||
|
||||
/**
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* May 27, 2010 rjpeter Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class FortConConfig {
|
||||
public int mode;
|
||||
|
||||
public float[] seed;
|
||||
|
||||
public float badlo;
|
||||
|
||||
public float badhi;
|
||||
|
||||
public float xOffset;
|
||||
|
||||
public float yOffset;
|
||||
|
||||
public int labelSpacingLine;
|
||||
|
||||
public int labelSpacingOverall;
|
||||
|
||||
public int minMaxRadius;
|
||||
|
||||
public boolean generateMins;
|
||||
|
||||
public boolean generateMaxes;
|
||||
|
||||
public String labelFormat;
|
||||
}
|
|
@ -1,169 +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.viz.core.contours.util;
|
||||
|
||||
/**
|
||||
* Bidirectional x/y point buffer.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* Apr 23, 2010 4583 rjpeter Initial creation
|
||||
* Feb 27, 2014 2791 bsteffen Remove unused constructor arg
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author rjpeter
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class PointBuffer {
|
||||
private float[] buffer;
|
||||
|
||||
private boolean forwardDirection = true;
|
||||
|
||||
// location of the next write
|
||||
private int index = 0;
|
||||
|
||||
private int size = 0;
|
||||
|
||||
// inclusive
|
||||
private int minIndex = 0;
|
||||
|
||||
private float xOffset;
|
||||
|
||||
private float yOffset;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param capacity
|
||||
* Capacity in x,y points
|
||||
* @param initialIndex
|
||||
* @param forwardDirection
|
||||
*/
|
||||
public PointBuffer(int capacity, int initialIndex) {
|
||||
buffer = new float[capacity * 2];
|
||||
minIndex = initialIndex;
|
||||
index = initialIndex;
|
||||
}
|
||||
|
||||
public void setDirection(boolean forward) {
|
||||
forwardDirection = forward;
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
public void setNextWriteIndex(int index) {
|
||||
this.index = index;
|
||||
if (size == 0) {
|
||||
minIndex = this.index;
|
||||
}
|
||||
|
||||
// not reseting size, will happen automatically first time data is
|
||||
// written
|
||||
}
|
||||
|
||||
public void setXOffset(float offset) {
|
||||
xOffset = offset;
|
||||
}
|
||||
|
||||
public void setYOffset(float offset) {
|
||||
yOffset = offset;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param numberToAdd
|
||||
* number of vals to add to the buffer. Ex: for a single x/y
|
||||
* point this should be 2
|
||||
*/
|
||||
protected void ensureCapacityFor(int numberToAdd) {
|
||||
if (forwardDirection) {
|
||||
int minSize = index + numberToAdd;
|
||||
if (minSize >= buffer.length) {
|
||||
int newSize = buffer.length * 2;
|
||||
if (newSize < minSize) {
|
||||
newSize = minSize;
|
||||
}
|
||||
|
||||
float[] tmp = new float[newSize];
|
||||
System.arraycopy(buffer, minIndex, tmp, minIndex, size);
|
||||
buffer = tmp;
|
||||
}
|
||||
} else {
|
||||
int numNeeded = numberToAdd - index;
|
||||
if (numNeeded > 0) {
|
||||
int newSize = buffer.length * 2;
|
||||
if (newSize - buffer.length < numNeeded) {
|
||||
newSize += numNeeded;
|
||||
}
|
||||
|
||||
int sizeOffset = newSize - buffer.length;
|
||||
int newMinIndex = minIndex + sizeOffset;
|
||||
float[] tmp = new float[newSize];
|
||||
System.arraycopy(buffer, minIndex, tmp, newMinIndex, size);
|
||||
buffer = tmp;
|
||||
minIndex = newMinIndex;
|
||||
index += sizeOffset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void put(float x, float y) {
|
||||
ensureCapacityFor(2);
|
||||
buffer[index++] = x + xOffset;
|
||||
buffer[index++] = y + yOffset;
|
||||
|
||||
if (forwardDirection) {
|
||||
if (index > minIndex + size) {
|
||||
size = index - minIndex;
|
||||
}
|
||||
} else {
|
||||
index -= 4;
|
||||
if (index < minIndex) {
|
||||
int oldIndex = minIndex;
|
||||
minIndex = index + 2;
|
||||
size += oldIndex - minIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int capacity() {
|
||||
return buffer.length;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public float[] getPoints() {
|
||||
float[] rval = new float[size];
|
||||
System.arraycopy(buffer, minIndex, rval, 0, size);
|
||||
return rval;
|
||||
}
|
||||
|
||||
public int getMinIndex() {
|
||||
return minIndex;
|
||||
}
|
||||
}
|
|
@ -1,85 +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.viz.core.contours.util;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An object that contains a list of coordinates used to draw stream lines over
|
||||
* a grid.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 21, 2013 #1999 dgilling Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dgilling
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public class StreamLineContainer {
|
||||
|
||||
public static class StreamLinePoint {
|
||||
|
||||
private final float x;
|
||||
|
||||
private final float y;
|
||||
|
||||
public StreamLinePoint(float xPoint, float yPoint) {
|
||||
this.x = xPoint;
|
||||
this.y = yPoint;
|
||||
}
|
||||
|
||||
public float getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public float getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final List<List<StreamLinePoint>> streamLines;
|
||||
|
||||
public StreamLineContainer() {
|
||||
this(new LinkedList<List<StreamLinePoint>>());
|
||||
}
|
||||
|
||||
private StreamLineContainer(List<List<StreamLinePoint>> listImpl) {
|
||||
streamLines = listImpl;
|
||||
}
|
||||
|
||||
public static StreamLineContainer emptyContainer() {
|
||||
List<List<StreamLinePoint>> listImpl = Collections.emptyList();
|
||||
return new StreamLineContainer(listImpl);
|
||||
}
|
||||
|
||||
public boolean addLine(List<StreamLinePoint> points) {
|
||||
return streamLines.add(points);
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,75 +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.viz.core.contours.util;
|
||||
|
||||
/**
|
||||
* Configuration parameters for calculating stream lines.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jun 26, 2013 #1999 dgilling Initial creation
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author dgilling
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
public final class StrmPakConfig {
|
||||
|
||||
public float asize;
|
||||
|
||||
public float minspc;
|
||||
|
||||
public float maxspc;
|
||||
|
||||
public float badlo;
|
||||
|
||||
public float badhi;
|
||||
|
||||
/**
|
||||
* Creates a new configuration to run StrmPak.
|
||||
*
|
||||
* @param asize
|
||||
* Size of arrows in MVI.
|
||||
* @param minspc
|
||||
* If greater than one, no two streamlines will approach any
|
||||
* closer than this number of cells. If less than one, a
|
||||
* streamline will terminate if it runs through 1/minspc
|
||||
* consecutive already occupied cells.
|
||||
* @param maxspc
|
||||
* No streamline will be started any closer than this number of
|
||||
* cells to an existing streamline.
|
||||
* @param badlo
|
||||
* @param badhi
|
||||
*/
|
||||
public StrmPakConfig(float asize, float minspc, float maxspc, float badlo,
|
||||
float badhi) {
|
||||
this.asize = asize;
|
||||
this.minspc = minspc;
|
||||
this.maxspc = maxspc;
|
||||
this.badlo = badlo;
|
||||
this.badhi = badhi;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue