Issue #358 Cleaned up mesh extension and API to use geotools for

defining a mesh.  This is better practice than using arbitrary
MathTransform objects as it is well defined and allows for serialization
of the mesh to occur.

Former-commit-id: 8fb7eccb73 [formerly 6e5964df9d] [formerly 50765e8a34 [formerly 7e4abe637edacca71e1e1c98d99521cd33415fb0]]
Former-commit-id: 50765e8a34
Former-commit-id: cf440b3884
This commit is contained in:
Max Schenkelberg 2012-03-14 09:49:32 -05:00
parent f78b932abb
commit 8f08fab0a7
45 changed files with 748 additions and 913 deletions

View file

@ -36,7 +36,6 @@ import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IRenderedImage;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
@ -127,16 +126,15 @@ public interface IGraphicsTarget extends IImagingExtension {
ColorMapParameters optionalParams);
/**
* This method will create an IRenderedImage object from a RenderedImage
* callback. The callback is used to construct the RenderableImage when it
* is needed. All targets need to support IImage creation for RenderedImage.
* Other IImage construction methods should be done through extensions
* This method will create an IImage object from a RenderedImage callback.
* The callback is used to construct the RenderableImage when it is needed.
* All targets need to support IImage creation for RenderedImage. Other
* IImage construction methods should be done through extensions
*
* @param imageCallback
* @return
*/
public abstract IRenderedImage initializeRaster(
IRenderedImageCallback imageCallback);
public abstract IImage initializeRaster(IRenderedImageCallback imageCallback);
/**
* Given the font, construct it with default values for the font

View file

@ -19,11 +19,10 @@
**/
package com.raytheon.uf.viz.core;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.operation.MathTransform;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.raytheon.uf.viz.core.drawables.IRenderable;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Base for any mesh 2D/3D, Quad/Triangle -- etc
@ -42,26 +41,6 @@ import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
public interface IMesh extends IRenderable {
/**
* Calculate all the mesh vertices and texture coordinates
*
* @param pc
* @param tile
* @param toLatLon
* translate the tile coordinates to lat/lon coords if the tile
* envelope is not already
*/
public abstract void calculateMesh(PixelCoverage pc, ImageTile tile,
MathTransform toLatLon);
/**
* Calculate all the mesh vertices and texture coordinates
*
* @param pc
* @param gg
*/
public void calculateMesh(PixelCoverage pc, GridGeometry2D gg);
/**
* Dispose of the mesh data
*/
@ -73,4 +52,12 @@ public interface IMesh extends IRenderable {
* @param extent
*/
public boolean intersects(IExtent extent);
/**
* Reprojects the mesh into the new target geometry
*
* @param targetGeometry
*/
public void reproject(GeneralGridGeometry targetGeometry)
throws VizException;
}

View file

@ -20,7 +20,6 @@
package com.raytheon.uf.viz.core.drawables;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
@ -72,16 +71,6 @@ public interface IImage {
*/
public abstract void stage() throws VizException;
/**
* Load the staged data into something that can be used by the target.
* Errors may be thrown if image is not in correct state when called, see
* getStatus() to check image state
*
* @param target
* @throws VizException
*/
public abstract void target(IGraphicsTarget target) throws VizException;
/**
* @return the status
*/

View file

@ -1,50 +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.uf.viz.core.drawables;
import java.awt.image.RenderedImage;
/**
* IImage object represents java RenderedImage
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 5, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public interface IRenderedImage extends IImage {
/**
* Get the RenderedImage associated with this object
*
* @return
*/
public RenderedImage getImage();
}

View file

@ -0,0 +1,143 @@
/**
* 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.core.drawables;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
import com.raytheon.uf.viz.core.drawables.IImage.Status;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.drawables.ext.TextureLoader;
import com.raytheon.uf.viz.core.exception.VizException;
/**
* Support class for rendering images to a target
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 13, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class ImagingSupport {
protected static final TextureLoader textureLoader = TextureLoader
.getInstance();
/**
* Prepares images for painting by staging and/or targeting the image
*
* @param target
* @param images
* @throws VizException
*/
public static void prepareImages(IGraphicsTarget target,
DrawableImage... images) throws VizException {
for (DrawableImage di : images) {
IImage image = di.getImage();
RasterMode mode = di.getMode();
if (image.getStatus() != Status.LOADED
&& image.getStatus() != Status.STAGED) {
if (mode == RasterMode.ASYNCHRONOUS) {
textureLoader.requestLoad(image);
target.setNeedsRefresh(true);
} else if (mode == RasterMode.SYNCHRONOUS) {
image.stage();
}
}
}
}
/**
* Routes the images to be rendered by their proper extensions, expects
* images have already been "prepared" (Status=STAGED)
*
* @param target
* @param paintProps
* @param images
* @return
* @throws VizException
*/
public static boolean routeImages(IGraphicsTarget target,
PaintProperties paintProps, DrawableImage[] images)
throws VizException {
boolean rval = true;
boolean skipped = false;
List<DrawableImage> bulk = new ArrayList<DrawableImage>();
Class<? extends IImagingExtension> lastExt = null;
for (DrawableImage di : images) {
IImage image = di.getImage();
IImage.Status imageSts = image.getStatus();
if (imageSts == IImage.Status.LOADED
|| imageSts == IImage.Status.STAGED) {
Class<? extends IImagingExtension> imageExt = image
.getExtensionClass();
if (imageExt.equals(lastExt) == false && bulk.size() > 0) {
DrawableImage[] extImages = bulk
.toArray(new DrawableImage[bulk.size()]);
// Render what we have
IImagingExtension impl = target.getExtension(lastExt);
rval &= impl.drawRasters(paintProps, extImages);
bulk.clear();
}
bulk.add(di);
lastExt = imageExt;
} else {
skipped = true;
}
}
if (bulk.size() > 0) {
// Render what is left
IImagingExtension impl = target.getExtension(lastExt);
rval &= impl.drawRasters(paintProps,
bulk.toArray(new DrawableImage[bulk.size()]));
}
return rval & skipped;
}
/**
* Prepares the images, then routes them for rendering
*
* @param paintProps
* @param images
* @return
*/
public static boolean drawRasters(IGraphicsTarget target,
PaintProperties paintProps, DrawableImage[] images)
throws VizException {
prepareImages(target, images);
return routeImages(target, paintProps, images);
}
}

View file

@ -78,6 +78,7 @@ public abstract class GraphicsExtension<T extends IGraphicsTarget> {
this.target = (T) target;
return getCompatibilityValue(this.target);
} catch (ClassCastException e) {
this.target = null;
return Compatibilty.INCOMPATIBLE;
}
}

View file

@ -77,9 +77,8 @@ public class GraphicsExtensionManager {
int bestVal = -1;
for (Class<?> eClass : extensions) {
if (extensionClass.isAssignableFrom(eClass)) {
GraphicsExtension<?> graphicsExt;
try {
graphicsExt = GraphicsExtension.class.cast(eClass
GraphicsExtension<?> graphicsExt = GraphicsExtension.class.cast(eClass
.newInstance());
int val = graphicsExt.setTarget(target);
if (val > bestVal) {

View file

@ -19,14 +19,7 @@
**/
package com.raytheon.uf.viz.core.drawables.ext;
import java.util.ArrayList;
import java.util.List;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IImage.Status;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
@ -61,100 +54,4 @@ public interface IImagingExtension extends IGraphicsExtensionInterface {
public boolean drawRasters(PaintProperties paintProps,
DrawableImage... images) throws VizException;
public static class ImagingSupport {
protected static final TextureLoader textureLoader = TextureLoader
.getInstance();
/**
* Prepares images for painting by staging and/or targeting the image
*
* @param target
* @param images
* @throws VizException
*/
public static void prepareImages(IGraphicsTarget target,
DrawableImage... images) throws VizException {
for (DrawableImage di : images) {
IImage image = di.getImage();
RasterMode mode = di.getMode();
if (image.getStatus() != Status.LOADED) {
if (image.getStatus() != Status.STAGED) {
if (mode == RasterMode.ASYNCHRONOUS) {
textureLoader.requestLoad(image);
target.setNeedsRefresh(true);
} else if (mode == RasterMode.SYNCHRONOUS) {
image.stage();
}
}
if (image.getStatus() == Status.STAGED) {
image.target(target);
}
}
}
}
/**
* Routes the images to be rendered by their proper extensions
*
* @param target
* @param paintProps
* @param images
* @return
* @throws VizException
*/
public static boolean routeImages(IGraphicsTarget target,
PaintProperties paintProps, DrawableImage[] images)
throws VizException {
boolean rval = true;
boolean skipped = false;
List<DrawableImage> bulk = new ArrayList<DrawableImage>();
Class<? extends IImagingExtension> lastExt = null;
for (DrawableImage di : images) {
IImage image = di.getImage();
if (image.getStatus() == IImage.Status.LOADED) {
Class<? extends IImagingExtension> imageExt = image
.getExtensionClass();
if (imageExt.equals(lastExt) == false && bulk.size() > 0) {
DrawableImage[] extImages = bulk
.toArray(new DrawableImage[bulk.size()]);
// Render what we have
IImagingExtension impl = target.getExtension(lastExt);
rval &= impl.drawRasters(paintProps, extImages);
bulk.clear();
}
bulk.add(di);
lastExt = imageExt;
} else {
skipped = true;
}
}
if (bulk.size() > 0) {
// Render what is left
IImagingExtension impl = target.getExtension(lastExt);
rval &= impl.drawRasters(paintProps,
bulk.toArray(new DrawableImage[bulk.size()]));
}
return rval & skipped;
}
/**
* Prepares the images, then routes them for rendering
*
* @param paintProps
* @param images
* @return
*/
public static boolean drawRasters(IGraphicsTarget target,
PaintProperties paintProps, DrawableImage[] images)
throws VizException {
prepareImages(target, images);
return routeImages(target, paintProps, images);
}
}
}

View file

@ -237,16 +237,4 @@ public class ColormappedImage implements IColormappedImage,
image.stage();
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.drawables.IImage#target(com.raytheon.uf.viz.
* core.IGraphicsTarget)
*/
@Override
public void target(IGraphicsTarget target) throws VizException {
image.target(target);
}
}

View file

@ -19,6 +19,9 @@
**/
package com.raytheon.uf.viz.core.map;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.exception.VizException;
@ -43,14 +46,14 @@ import com.raytheon.uf.viz.core.exception.VizException;
public interface IMapMeshExtension extends IGraphicsExtensionInterface {
/**
* Create a mesh
*
* @param descriptor
* Constructs a mesh for mapping the imageGeometry onto the targetGeometry
*
* @param imageGeometry
* @param targetGeometry
* @return
* @throws VizException
*/
public abstract IMesh constructMesh(IMapDescriptor descriptor)
throws VizException;
public abstract IMesh constructMesh(GridGeometry2D imageGeometry,
GeneralGridGeometry targetGeometry) throws VizException;
}

View file

@ -21,23 +21,115 @@ package com.raytheon.uf.viz.core.rsc.hdf5;
import java.awt.Rectangle;
import com.raytheon.uf.viz.core.PixelCoverage;
import org.geotools.coverage.grid.GeneralGridEnvelope;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.GeneralEnvelope;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.coverage.grid.GridEnvelope;
import org.opengis.geometry.Envelope;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.vividsolutions.jts.geom.Coordinate;
/**
* ImageTile is an object that represents an image (or part of an image)
* geospatially, it contains a grid geometry that represents the projection and
* size of the image and a PixelCoverage which contains the screen projected
* data for the image. Because a single ImageTile can represent multiple images,
* this class does not contain the actual image it represents so the tile can be
* shared between images
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 13, 2012 mschenke Initial creation
*
* </pre>
*
* @author mschenke
* @version 1.0
*/
public class ImageTile {
public com.vividsolutions.jts.geom.Envelope envelope;
public double elevation;
public GridGeometry2D imageGeometry;
public PixelCoverage coverage;
public Rectangle rect;
/**
* Checks to see if the x/y coordinate is contained by the ImageTile's CRS
* Envelope
*
* @param x
* @param y
* @return
*/
public boolean contains(double x, double y) {
Envelope env = imageGeometry.getEnvelope();
return env.getMinimum(0) <= x && env.getMaximum(0) >= x
&& env.getMinimum(1) <= y && env.getMaximum(1) >= y;
}
// TODO clean up occlusionQueries move to GLImage?
public int query = -1;
/**
* Checks to see if the Coordinate is contained by the ImageTile's CRS
* Envelope
*
* @param c
* @return
*/
public boolean contains(Coordinate c) {
return contains(c.x, c.y);
}
public boolean occlude = false;
/**
* Set the grid geometry of the tile given the image rectangle and the
* referenced envelope
*
* @param rect
* @param env
*/
public void setGridGeometry(Rectangle rect, ReferencedEnvelope env) {
GeneralGridEnvelope gge = new GeneralGridEnvelope(rect);
GeneralEnvelope ge = new GeneralEnvelope(env);
imageGeometry = new GridGeometry2D(gge, ge);
}
/**
* Set the image geometry
*
* @param imageGeometry
*/
public void setGridGeometry(GridGeometry2D imageGeometry) {
this.imageGeometry = imageGeometry;
}
/**
* Get the image rectangle. This could be a subsection of a larger image so
* x and y may not be 0,0
*
* @return
*/
public Rectangle getRectangle() {
GridEnvelope env = imageGeometry.getGridRange();
return new Rectangle(env.getLow(0), env.getLow(1), env.getSpan(0),
env.getSpan(1));
}
/**
* Get the spatially referenced envelope of the image tile
*
* @return
*/
public ReferencedEnvelope getEnvelope() {
return new ReferencedEnvelope(imageGeometry.getEnvelope());
}
/**
* Dispose the image tile, disposes of the coverage object associated with
* it
*/
public void dispose() {
if (coverage != null) {
coverage.dispose();

View file

@ -1,163 +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.uf.viz.core.rsc.hdf5;
import java.util.concurrent.ConcurrentHashMap;
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 org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.IMeshCallback;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.rsc.RenderingOrderFactory;
/**
* Persistent job used to calculate mesh tiles outside of the rendering thread
*
* <pre>
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Mar 1, 2007 chammack Initial Creation.
*
* </pre>
*
* @author cnh
* @version 1
*/
public class MeshCalculatorJob extends Job {
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(MeshCalculatorJob.class);
private static MeshCalculatorJob instance;
private ConcurrentLinkedQueue<PixelCoverage> requests;
private ConcurrentHashMap<PixelCoverage, MeshParameters> map;
private MeshCalculatorJob() {
super("Mesh Calculator");
requests = new ConcurrentLinkedQueue<PixelCoverage>();
map = new ConcurrentHashMap<PixelCoverage, MeshParameters>();
}
/**
* Request to have the mesh be calculated in the mesh thread
*
* @param mesh
* @param tile
* @param preTransform
*/
public synchronized void requestLoad(IMesh mesh, ImageTile tile,
MathTransform preTransform) {
if (!requests.contains(tile.coverage)) {
MeshParameters params = new MeshParameters();
params.tile = tile;
params.mesh = mesh;
params.preTransform = preTransform;
map.put(tile.coverage, params);
requests.add(tile.coverage);
}
instance.schedule();
}
/**
* Request to have the mesh be calculated in the mesh thread, with the
* callback being notified after the mesh has been calculated
*
* @param callback
* @param mesh
* @param tile
* @param preTransform
*/
public synchronized void requestLoad(IMeshCallback callback, IMesh mesh,
ImageTile tile, MathTransform preTransform) {
if (!requests.contains(tile.coverage)) {
MeshParameters params = new MeshParameters();
params.tile = tile;
params.mesh = mesh;
params.preTransform = preTransform;
params.callback = callback;
map.put(tile.coverage, params);
requests.add(tile.coverage);
}
instance.schedule();
}
public static synchronized MeshCalculatorJob getInstance() {
if (instance == null) {
instance = new MeshCalculatorJob();
instance.setSystem(true);
}
return instance;
}
/*
* (non-Javadoc)
*
* @seeorg.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.
* IProgressMonitor)
*/
@Override
protected IStatus run(IProgressMonitor monitor) {
while (requests.size() > 0) {
PixelCoverage coverage = requests.peek();
try {
MeshParameters p = map.get(coverage);
coverage.setMesh(null);
p.mesh.calculateMesh(coverage, p.tile, p.preTransform);
coverage.setMesh(p.mesh);
if (p.callback != null) {
p.callback.meshCalculated(p.tile);
}
} catch (Throwable t) {
statusHandler.handle(Priority.PROBLEM, "An error occured during mesh calculations, some images may not be properly reprojected.", t);
}
map.remove(coverage);
requests.remove();
}
return Status.OK_STATUS;
}
private class MeshParameters {
// public MapDescriptor mapDescriptor;
public IMesh mesh;
public ImageTile tile;
public MathTransform preTransform;
public IMeshCallback callback;
}
}

View file

@ -46,8 +46,6 @@ import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.HDF5Util;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
@ -55,15 +53,12 @@ import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormappedImageExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.IResourceDataChanged;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Envelope;
/**
* NPP VIIRS resource. Responsible for drawing a single color band
@ -194,8 +189,8 @@ public class VIIRSResource extends
data.projectionData = new float[][] { lonFloats, latFloats };
data.tile = new ImageTile();
data.tile.rect = new Rectangle(0, 0, width, height);
data.tile.envelope = new Envelope(0, width, 0, height);
// data.tile.rect = new Rectangle(0, 0, width, height);
// data.tile.envelope = new Envelope(0, width, 0, height);
calculateMesh(data, target);
@ -384,20 +379,21 @@ public class VIIRSResource extends
*/
private void calculateMesh(VIIRSData frame, IGraphicsTarget target)
throws VizException {
Rectangle tile = frame.tile.rect;
frame.tile.coverage = new PixelCoverage(new Coordinate(tile.getMinX(),
tile.getMinY()),
new Coordinate(tile.getMaxX(), tile.getMinY()), new Coordinate(
tile.getMaxX(), tile.getMaxY()), new Coordinate(
tile.getMinX(), tile.getMaxY()));
IMesh mesh = target.getExtension(IMapMeshExtension.class)
.constructMesh(descriptor);
mesh.calculateMesh(frame.tile.coverage, frame.tile,
new VIIRSDataMathTransform(frame.projectionData,
frame.tile.rect.width, frame.tile.rect.height));
frame.projectionData = null;
frame.tile.coverage.setMesh(mesh);
frame.projectionData = null;
// Rectangle tile = frame.tile.rect;
// frame.tile.coverage = new PixelCoverage(new
// Coordinate(tile.getMinX(),
// tile.getMinY()),
// new Coordinate(tile.getMaxX(), tile.getMinY()), new Coordinate(
// tile.getMaxX(), tile.getMaxY()), new Coordinate(
// tile.getMinX(), tile.getMaxY()));
// IMesh mesh = target.getExtension(IMapMeshExtension.class)
// .constructMesh(descriptor);
// mesh.calculateMesh(frame.tile.coverage, frame.tile,
// new VIIRSDataMathTransform(frame.projectionData,
// frame.tile.rect.width, frame.tile.rect.height));
// frame.projectionData = null;
// frame.tile.coverage.setMesh(mesh);
// frame.projectionData = null;
}
/**

View file

@ -21,18 +21,18 @@ package com.raytheon.uf.viz.radar.gl;
import javax.media.opengl.GL;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.AbstractGLMesh;
import com.raytheon.viz.core.gl.GLGeometryObject2D;
import com.raytheon.viz.core.gl.GLGeometryObject2D.GLGeometryObjectData;
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinateKey;
/**
@ -58,17 +58,20 @@ public class RadarRadialMesh extends AbstractGLMesh {
/** The record to build the mesh for */
private RadarRecord record;
private IMapDescriptor descriptor;
public RadarRadialMesh(IMapDescriptor descriptor, RadarRecord record) {
super(GL.GL_TRIANGLE_STRIP, descriptor);
public RadarRadialMesh(RadarRecord record,
GeneralGridGeometry targetGeometry) throws VizException {
super(GL.GL_TRIANGLE_STRIP);
this.record = record;
this.descriptor = descriptor;
initialize(
RadarUtil.constructGridGeometry(record.getCRS(),
RadarUtil.calculateExtent(record),
Math.max(record.getNumBins(), record.getNumRadials())),
targetGeometry);
}
@Override
protected double[][][] generateWorldCoords(ImageTile tile, MathTransform mt)
throws TransformException {
protected double[][][] generateWorldCoords(GridGeometry2D imageGeometry,
MathTransform mt) throws TransformException {
int horizontalDivisions = key.horizontalDivisions;
int verticalDivisions = key.verticalDivisions + 1;
@ -76,10 +79,6 @@ public class RadarRadialMesh extends AbstractGLMesh {
// get dx and dy for texture points
float dX = (1.0f / (key.horizontalDivisions));
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
GL.GL_TRIANGLE_STRIP, GL.GL_VERTEX_ARRAY));
vertexCoords.allocate(2 * verticalDivisions * horizontalDivisions);
// set up our angle data for the radials
float[] angles = record.getAngleData();
int height = 2 * verticalDivisions;
@ -166,7 +165,8 @@ public class RadarRadialMesh extends AbstractGLMesh {
}
@Override
protected SharedCoordinateKey generateKey(ImageTile tile, MathTransform mt) {
protected SharedCoordinateKey generateKey(GridGeometry2D imageGeometry,
MathTransform mt) {
try {
return new SharedCoordinateKey(record.getNumRadials(),
getNumVerticalDivisions(mt, record));
@ -202,7 +202,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
in[1] = 0;
toLatLon.transform(in, 0, out, 0, 1);
double[] start = descriptor.worldToPixel(out);
double[] start = worldToPixel(out);
for (int i = 0; i < angles.length; ++i) {
// grab end
@ -215,7 +215,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
in[0] = range * sinAz;
in[1] = range * cosAz;
toLatLon.transform(in, 0, out, 0, 1);
out = descriptor.worldToPixel(out);
out = worldToPixel(out);
int[] curPow2 = new int[] { (int) Math.floor(Math.log(numBins)
/ Math.log(2)) };
@ -256,7 +256,7 @@ public class RadarRadialMesh extends AbstractGLMesh {
double[] in = new double[] { rangeToTry * sinAz, rangeToTry * cosAz };
double[] actual = new double[3];
toLatLon.transform(in, 0, actual, 0, 1);
actual = descriptor.worldToPixel(actual);
actual = worldToPixel(actual);
// Get linear interpolated point
double[] interp = new double[] { (endLoc[0] + startLoc[0]) / 2,

View file

@ -24,19 +24,14 @@ import java.util.HashMap;
import java.util.Map;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
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.rsc.hdf5.ImageTile;
/**
*
@ -161,8 +156,6 @@ public class RadarRadialMeshCache {
private int refCount = 0;
private boolean calculated = false;
private RadarSharedMesh(IMesh mesh, CacheKey key) {
this.mesh = mesh;
this.key = key;
@ -174,26 +167,6 @@ public class RadarRadialMeshCache {
mesh.paint(target, paintProps);
}
@Override
public synchronized void calculateMesh(PixelCoverage pc,
ImageTile tile, MathTransform toLatLon) {
if (!calculated) {
mesh.calculateMesh(pc, tile, toLatLon);
calculated = true;
}
}
@Override
public synchronized void calculateMesh(PixelCoverage pc,
GridGeometry2D gg) {
if (!calculated) {
mesh.calculateMesh(pc, gg);
calculated = true;
}
}
@Override
public void dispose() {
refCount -= 1;
@ -209,6 +182,19 @@ public class RadarRadialMeshCache {
refCount += 1;
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.IMesh#reproject(org.geotools.coverage.grid
* .GeneralGridGeometry)
*/
@Override
public void reproject(GeneralGridGeometry targetGeometry)
throws VizException {
mesh.reproject(targetGeometry);
}
@Override
public boolean intersects(IExtent extent) {
return mesh.intersects(extent);
@ -237,8 +223,8 @@ public class RadarRadialMeshCache {
RadarSharedMesh mesh = cache.get(key);
if (mesh == null) {
// System.out.println("Mesh Cache miss");
IMesh baseMesh = new RadarRadialMesh(
(IMapDescriptor) descriptor, radarData);
IMesh baseMesh = new RadarRadialMesh(radarData,
descriptor.getGridGeometry());
mesh = new RadarSharedMesh(baseMesh, key);
cache.put(key, mesh);
} else {

View file

@ -27,6 +27,7 @@ import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.IOffscreenRenderingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
@ -98,6 +99,7 @@ public class GLRadarMosaicImageExtension extends AbstractGLSLImagingExtension
extension.renderOffscreen(mosaicImage);
DrawableImage[] imagesToMosaic = mosaicImage
.getImagesToMosaic();
// Make sure images are staged before we mosaic them
ImagingSupport.prepareImages(target, imagesToMosaic);
drawRasters(paintProps, imagesToMosaic);
} finally {

View file

@ -46,6 +46,7 @@ import com.raytheon.uf.common.datastorage.records.FloatDataRecord;
import com.raytheon.uf.common.datastorage.records.IDataRecord;
import com.raytheon.uf.common.geospatial.CRSCache;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.util.WorldWrapChecker;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -60,7 +61,6 @@ import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.map.WorldWrapChecker;
import com.raytheon.uf.viz.core.style.LabelingPreferences;
import com.raytheon.viz.core.contours.cache.SubGridCacheKey;
import com.raytheon.viz.core.contours.util.ContourContainer;
@ -1337,7 +1337,8 @@ public class ContourSupport {
throws TransformException {
long tZ0 = System.currentTimeMillis();
WorldWrapChecker wwc = new WorldWrapChecker(descriptor);
WorldWrapChecker wwc = new WorldWrapChecker(
descriptor.getGridGeometry());
List<float[]> splitLines = new ArrayList<float[]>();
List<Float> dupValues = new ArrayList<Float>();

View file

@ -19,31 +19,30 @@
**/
package com.raytheon.viz.core.gl;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import javax.media.opengl.GL;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.geospatial.util.WorldWrapChecker;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
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.WorldWrapChecker;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.jobs.JobPool;
import com.raytheon.viz.core.gl.GLGeometryObject2D.GLGeometryObjectData;
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinateKey;
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinates;
import com.vividsolutions.jts.geom.Envelope;
/**
* Abstract GLMesh
@ -63,22 +62,65 @@ import com.vividsolutions.jts.geom.Envelope;
public abstract class AbstractGLMesh implements IMesh {
protected boolean shouldDraw = true;
private static final JobPool calculator = new JobPool("Mesh Calculator", 2,
false);
private boolean compiled = false;
protected static enum State {
NEW, CALCULATING, CALCULATED, COMPILED, INVALID;
}
protected GLGeometryObject2D vertexCoords;
private State internalState = State.NEW;
protected SharedCoordinateKey key;
private GLGeometryObject2D vertexCoords;
private SharedCoordinates sharedTextureCoords;
protected IMapDescriptor descriptor;
protected SharedCoordinateKey key;
public AbstractGLMesh(int geometryType, IMapDescriptor descriptor) {
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
geometryType, GL.GL_VERTEX_ARRAY));
this.descriptor = descriptor;
private Runnable calculate = new Runnable() {
@Override
public void run() {
synchronized (calculate) {
if (internalState == State.CALCULATING) {
// If we aren't in CALCULATING state, we were disposed while
// waiting to run and shouldn't run now
if (calculateMesh()) {
internalState = State.CALCULATED;
} else {
internalState = State.INVALID;
}
}
}
}
};
private int geometryType;
private MathTransform imageCRSToLatLon;
private MathTransform latLonToTargetGrid;
private GeneralGridGeometry targetGeometry;
private GridGeometry2D imageGeometry;
protected AbstractGLMesh(int geometryType) {
this.geometryType = geometryType;
}
protected final void initialize(GridGeometry2D imageGeometry,
GeneralGridGeometry targetGeometry) throws VizException {
this.imageGeometry = imageGeometry;
if (imageGeometry != null) {
try {
imageCRSToLatLon = MapUtil.getTransformToLatLon(imageGeometry
.getCoordinateReferenceSystem());
} catch (Throwable t) {
throw new VizException(
"Error construcing image to lat/lon transform", t);
}
}
reproject(targetGeometry);
}
/*
@ -88,9 +130,13 @@ public abstract class AbstractGLMesh implements IMesh {
* com.raytheon.viz.core.IMesh#paint(com.raytheon.viz.core.IGraphicsTarget)
*/
@Override
public synchronized void paint(IGraphicsTarget target,
public final synchronized void paint(IGraphicsTarget target,
PaintProperties paintProps) throws VizException {
if (!shouldDraw) {
if (internalState == State.NEW) {
throw new VizException(
"Class did not properly call initialize on construction");
} else if (internalState == State.INVALID) {
// Don't paint if invalid to avoid crashes
return;
}
@ -101,65 +147,87 @@ public abstract class AbstractGLMesh implements IMesh {
glTarget = (IGLTarget) target;
if (sharedTextureCoords == null) {
if (internalState == State.CALCULATED) {
// We finished calculating the mesh, compile it
try {
sharedTextureCoords = SharedCoordMap.get(key, glTarget);
}
if (!compiled) {
vertexCoords.compile(glTarget.getGl());
compiled = true;
internalState = State.COMPILED;
} catch (VizException e) {
internalState = State.INVALID;
throw e;
}
}
if (internalState == State.COMPILED) {
GLGeometryPainter.paintGeometries(glTarget.getGl(), vertexCoords,
sharedTextureCoords.getTextureCoords());
} else {
target.setNeedsRefresh(true);
}
}
@Override
public synchronized void dispose() {
public final synchronized void dispose() {
// Synchronize on calculate so we don't dispose while running
synchronized (calculate) {
// Cancel calculation job from running
calculator.cancel(calculate);
// dispose and reset vertexCoords
if (vertexCoords != null) {
vertexCoords.dispose();
vertexCoords = null;
}
if (sharedTextureCoords != null) {
SharedCoordMap.remove(key);
sharedTextureCoords = null;
}
shouldDraw = false;
internalState = State.INVALID;
}
}
/*
* (non-Javadoc)
*
* @see
* com.raytheon.viz.core.IMesh#calculateMesh(com.raytheon.viz.core.PixelCoverage
* , org.opengis.coverage.grid.GridGeometry)
* @see com.raytheon.uf.viz.core.IMesh#reproject(org.geotools.coverage.grid.
* GeneralGridGeometry)
*/
public void calculateMesh(PixelCoverage pc, GridGeometry2D gg) {
MathTransform toLL = null;
ImageTile tile = null;
@Override
public final void reproject(GeneralGridGeometry targetGeometry)
throws VizException {
if (targetGeometry.equals(this.targetGeometry) == false) {
dispose();
this.targetGeometry = targetGeometry;
// Set up convenience transforms
try {
toLL = CRS.findMathTransform(gg.getCoordinateReferenceSystem(),
DefaultGeographicCRS.WGS84);
tile = new ImageTile();
tile.coverage = pc;
tile.rect = new Rectangle(gg.getGridRange().getLow(0), gg
.getGridRange().getLow(1), gg.getGridRange().getHigh(0), gg
.getGridRange().getHigh(1));
tile.envelope = new Envelope(gg.getEnvelope().getMinimum(0), gg
.getEnvelope().getMaximum(0), gg.getEnvelope()
.getMinimum(1), gg.getEnvelope().getMaximum(1));
} catch (Exception e) {
}
calculateMesh(pc, tile, toLL);
DefaultMathTransformFactory factory = new DefaultMathTransformFactory();
latLonToTargetGrid = factory.createConcatenatedTransform(
MapUtil.getTransformFromLatLon(targetGeometry
.getCoordinateReferenceSystem()),
targetGeometry.getGridToCRS(PixelInCell.CELL_CENTER)
.inverse());
} catch (Throwable t) {
internalState = State.INVALID;
throw new VizException("Error projecting mesh", t);
}
@Override
public void calculateMesh(PixelCoverage pc, ImageTile tile, MathTransform mt) {
shouldDraw = false;
key = generateKey(tile, mt);
internalState = State.CALCULATING;
calculator.schedule(calculate);
}
}
private boolean calculateMesh() {
key = generateKey(imageGeometry, imageCRSToLatLon);
try {
double[][][] worldCoordinates = generateWorldCoords(tile, mt);
double[][][] worldCoordinates = generateWorldCoords(imageGeometry,
imageCRSToLatLon);
vertexCoords = new GLGeometryObject2D(new GLGeometryObjectData(
geometryType, GL.GL_VERTEX_ARRAY));
vertexCoords.allocate(worldCoordinates.length
* worldCoordinates[0].length);
// Check for world wrapping
WorldWrapChecker wwc = new WorldWrapChecker(descriptor);
WorldWrapChecker wwc = new WorldWrapChecker(targetGeometry);
for (int i = 0; i < worldCoordinates.length; ++i) {
double[][] strip = worldCoordinates[i];
@ -176,7 +244,7 @@ public abstract class AbstractGLMesh implements IMesh {
prev1 = null;
prev2 = null;
}
vSegment.add(descriptor.worldToPixel(next));
vSegment.add(worldToPixel(next));
prev2 = prev1;
prev1 = next;
@ -185,14 +253,28 @@ public abstract class AbstractGLMesh implements IMesh {
vertexCoords.addSegment(vSegment.toArray(new double[vSegment
.size()][]));
}
shouldDraw = true;
return true;
} catch (Exception e) {
e.printStackTrace();
shouldDraw = false;
Activator.statusHandler.handle(Priority.PROBLEM,
"Error calculating mesh", e);
}
return false;
}
pc.setMesh(this);
protected final double[] worldToPixel(double[] world) {
double[] in = null;
if (world.length == 2) {
in = new double[] { world[0], world[1], 0.0 };
} else {
in = world;
}
double[] out = new double[in.length];
try {
latLonToTargetGrid.transform(in, 0, out, 0, 1);
} catch (TransformException e) {
return null;
}
return out;
}
/*
@ -207,10 +289,11 @@ public abstract class AbstractGLMesh implements IMesh {
return false;
}
protected abstract SharedCoordinateKey generateKey(ImageTile tile,
MathTransform mt);
protected abstract SharedCoordinateKey generateKey(
GridGeometry2D imageGeometry, MathTransform mt);
protected abstract double[][][] generateWorldCoords(ImageTile tile,
MathTransform mt) throws TransformException;
protected abstract double[][][] generateWorldCoords(
GridGeometry2D imageGeometry, MathTransform mt)
throws TransformException;
}

View file

@ -33,7 +33,8 @@ import com.raytheon.uf.viz.core.localization.HierarchicalPreferenceStore;
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
private static final transient IUFStatusHandler statusHandler = UFStatus
public static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(Activator.class);
// The plug-in ID

View file

@ -35,6 +35,7 @@ import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IImage.Status;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
@ -119,6 +120,15 @@ public abstract class AbstractGLImagingExtension extends
PixelCoverage extent = di.getCoverage();
synchronized (glImage) {
if (glImage.getStatus() == Status.STAGED) {
glImage.target(target);
}
if (glImage.getStatus() != Status.LOADED) {
++continues;
continue;
}
int textureType = glImage.getTextureStorageType();
if (lastTextureType != textureType) {

View file

@ -30,7 +30,6 @@ import javax.media.jai.PlanarImage;
import javax.media.opengl.GL;
import com.raytheon.uf.viz.core.data.IRenderedImageCallback;
import com.raytheon.uf.viz.core.drawables.IRenderedImage;
import com.raytheon.uf.viz.core.drawables.ext.IImagingExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.internal.cache.IImageCacheable;
@ -57,8 +56,7 @@ import com.sun.opengl.util.texture.TextureIO;
* @author chammack
*
*/
public class GLImage extends AbstractGLImage implements IRenderedImage,
IImageCacheable {
public class GLImage extends AbstractGLImage implements IImageCacheable {
/** The memory resident texture */
private TextureData theStagedData;
@ -73,8 +71,7 @@ public class GLImage extends AbstractGLImage implements IRenderedImage,
protected int size;
public GLImage(IRenderedImageCallback preparer,
Class<? extends IImagingExtension> extensionClass) {
public GLImage(IRenderedImageCallback preparer, Class<? extends IImagingExtension> extensionClass) {
super(extensionClass);
theTexture = null;
this.imagePreparer = preparer;
@ -83,7 +80,7 @@ public class GLImage extends AbstractGLImage implements IRenderedImage,
/*
* (non-Javadoc)
*
* @see com.raytheon.viz.core.drawables.IRenderedImage#getImage()
* @see com.raytheon.viz.core.drawables.IImage#getImage()
*/
public RenderedImage getImage() {
return theImage;

View file

@ -21,17 +21,17 @@ package com.raytheon.viz.core.gl.internal;
import javax.media.opengl.GL;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.viz.core.gl.AbstractGLMesh;
import com.raytheon.viz.core.gl.Activator;
import com.raytheon.viz.core.gl.SharedCoordMap.SharedCoordinateKey;
import com.vividsolutions.jts.geom.Envelope;
/**
*
@ -51,11 +51,10 @@ import com.vividsolutions.jts.geom.Envelope;
*/
public class GLMesh2DStrips extends AbstractGLMesh {
private static final transient IUFStatusHandler statusHandler = UFStatus
.getHandler(GLMesh2DStrips.class);
public GLMesh2DStrips(IMapDescriptor descriptor) {
super(GL.GL_TRIANGLE_STRIP, descriptor);
public GLMesh2DStrips(GridGeometry2D imageGeometry,
GeneralGridGeometry targetGeometry) throws VizException {
super(GL.GL_TRIANGLE_STRIP);
initialize(imageGeometry, targetGeometry);
}
/*
@ -67,12 +66,14 @@ public class GLMesh2DStrips extends AbstractGLMesh {
* org.opengis.referencing.operation.MathTransform)
*/
@Override
public double[][][] generateWorldCoords(ImageTile tile, MathTransform mt)
throws TransformException {
double worldMinX = tile.envelope.getMinX();
double worldMinY = tile.envelope.getMinY();
double worldWidth = tile.envelope.getWidth();
double worldHeight = tile.envelope.getHeight();
public double[][][] generateWorldCoords(GridGeometry2D imageGeometry,
MathTransform mt) throws TransformException {
ReferencedEnvelope envelope = new ReferencedEnvelope(
imageGeometry.getEnvelope());
double worldMinX = envelope.getMinX();
double worldMinY = envelope.getMinY();
double worldWidth = envelope.getWidth();
double worldHeight = envelope.getHeight();
// get dx and dy for texture points
@ -141,12 +142,16 @@ public class GLMesh2DStrips extends AbstractGLMesh {
private static final int MIN_VERT_DIVS = 1;
@Override
protected SharedCoordinateKey generateKey(ImageTile tile, MathTransform mt) {
protected SharedCoordinateKey generateKey(GridGeometry2D imageGeometry,
MathTransform mt) {
int width = imageGeometry.getGridRange().getSpan(0);
int height = imageGeometry.getGridRange().getSpan(1);
try {
int maxHorzDiv = Math.max(tile.rect.width / 4, MIN_HORZ_DIVS);
int maxVertDiv = Math.max(tile.rect.height / 4, MIN_VERT_DIVS);
int maxHorzDiv = Math.max(width / 4, MIN_HORZ_DIVS);
int maxVertDiv = Math.max(height / 4, MIN_VERT_DIVS);
Envelope envelope = tile.envelope;
ReferencedEnvelope envelope = new ReferencedEnvelope(
imageGeometry.getEnvelope());
double[] tl = { envelope.getMinX(), envelope.getMaxY() };
double[] tr = { envelope.getMaxX(), envelope.getMaxY() };
double[] bl = { envelope.getMinX(), envelope.getMinY() };
@ -195,12 +200,11 @@ public class GLMesh2DStrips extends AbstractGLMesh {
return new SharedCoordinateKey(vertDiv, horzDiv);
} catch (Exception e) {
statusHandler
Activator.statusHandler
.handle(Priority.PROBLEM,
"Error calculating divisions needed for image, defaulting to dims/4",
e);
return new SharedCoordinateKey(tile.rect.height / 4,
tile.rect.width / 4);
return new SharedCoordinateKey(height / 4, width / 4);
}
}
@ -213,12 +217,12 @@ public class GLMesh2DStrips extends AbstractGLMesh {
if (r1 == null) {
r1 = new double[p1.length];
mt.transform(p1, 0, r1, 0, 1);
r1 = descriptor.worldToPixel(r1);
r1 = worldToPixel(r1);
}
if (r3 == null) {
r3 = new double[p3.length];
mt.transform(p3, 0, r3, 0, 1);
r3 = descriptor.worldToPixel(r3);
r3 = worldToPixel(r3);
}
if (r1 == null || r3 == null) {
// if the image has some points outside the valid range of the
@ -229,7 +233,7 @@ public class GLMesh2DStrips extends AbstractGLMesh {
double[] p2 = { (p1[0] + p3[0]) / 2, (p1[1] + p3[1]) / 2 };
double[] r2 = new double[p2.length];
mt.transform(p2, 0, r2, 0, 1);
r2 = descriptor.worldToPixel(r2);
r2 = worldToPixel(r2);
double[] interp2 = { (r1[0] + r3[0]) / 2, (r1[1] + r3[1]) / 2 };
double dX = r2[0] - interp2[0];
double dY = r2[1] - interp2[1];

View file

@ -82,9 +82,9 @@ import com.raytheon.uf.viz.core.drawables.IFont;
import com.raytheon.uf.viz.core.drawables.IFont.Style;
import com.raytheon.uf.viz.core.drawables.IImage;
import com.raytheon.uf.viz.core.drawables.IRenderableDisplay;
import com.raytheon.uf.viz.core.drawables.IRenderedImage;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.drawables.ImagingSupport;
import com.raytheon.uf.viz.core.drawables.PaintProperties;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension.IGraphicsExtensionInterface;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtensionManager;
@ -1787,7 +1787,7 @@ public class GLTarget implements IGLTarget {
* .uf.viz.core.data.IRenderedImageCallback)
*/
@Override
public IRenderedImage initializeRaster(IRenderedImageCallback imageCallback) {
public IImage initializeRaster(IRenderedImageCallback imageCallback) {
return new GLImage(imageCallback, GLDefaultImagingExtension.class);
}

View file

@ -19,10 +19,12 @@
**/
package com.raytheon.viz.core.gl.internal.ext;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.coverage.grid.GridGeometry2D;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.drawables.ext.GraphicsExtension;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
import com.raytheon.viz.core.gl.IGLTarget;
import com.raytheon.viz.core.gl.internal.GLMesh2DStrips;
@ -51,12 +53,14 @@ public class GLMapMeshExtension extends GraphicsExtension<IGLTarget> implements
* (non-Javadoc)
*
* @see
* com.raytheon.uf.viz.core.map.IMapMeshExtension#constructMesh(com.raytheon
* .uf.viz.core.map.IMapDescriptor)
* com.raytheon.uf.viz.core.map.IMapMeshExtension#constructMesh(org.geotools
* .coverage.grid.GridGeometry2D,
* org.geotools.coverage.grid.GeneralGridGeometry)
*/
@Override
public IMesh constructMesh(IMapDescriptor descriptor) throws VizException {
return new GLMesh2DStrips(descriptor);
public IMesh constructMesh(GridGeometry2D imageGeometry,
GeneralGridGeometry targetGeometry) throws VizException {
return new GLMesh2DStrips(imageGeometry, targetGeometry);
}
/*

View file

@ -139,7 +139,8 @@ public class GriddedImageDisplay2 extends AbstractTileSet {
}
// tile bounds
Rectangle rect = this.tileSet.getTileSet().get(level)[i][j].rect;
Rectangle rect = this.tileSet.getTileSet().get(level)[i][j]
.getRectangle();
// total width
int width = gridGeometry[level].getGridRange().getSpan(0);
IImage image = null;

View file

@ -54,7 +54,6 @@ import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IExtent;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IGraphicsTarget.RasterMode;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.IMeshCallback;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.VizApp;
@ -71,7 +70,6 @@ import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.rsc.hdf5.MeshCalculatorJob;
import com.vividsolutions.jts.geom.Coordinate;
/**
@ -388,15 +386,8 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
if (generalEnv.intersects(generalMapEnv, true)) {
tiles[i][j] = new ImageTile();
tiles[i][j].rect = new Rectangle(startX, startY,
effectiveWidth, effectiveHeight);
tiles[i][j].envelope = env;
tiles[i][j].elevation = this.elevation;
// System.out.println(tiles[i][j].envelope.toString());
tiles[i][j].rect.width = effectiveWidth;
tiles[i][j].rect.height = effectiveHeight;
tiles[i][j].setGridGeometry(new Rectangle(startX,
startY, effectiveWidth, effectiveHeight), env);
}
}
@ -416,8 +407,7 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
for (int i = 0; i < tiles.length; i++) {
for (int j = 0; j < tiles[i].length; j++) {
ImageTile tile = tiles[i][j];
if (tile != null && tile.occlude == false) {
if (tile.coverage != null
if (tile != null && tile.coverage != null
&& tile.coverage.intersects(extent)) {
IImage image = imageMap.get(tile);
if (image == null || image.getStatus() == Status.FAILED
@ -437,7 +427,6 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
}
}
}
}
startCreateTileJobs(lvl, target, tilesToCreate);
}
@ -488,9 +477,8 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
for (int i = 0; i < tiles.length; i++) {
for (int j = 0; j < tiles[i].length; j++) {
ImageTile tile = tiles[i][j];
if (tile != null && tile.occlude == false) {
if (tile.coverage != null
if (tile != null
&& tile.coverage != null
&& tile.coverage.intersects(paintProps.getView()
.getExtent())
&& tile.coverage.intersects(paintProps
@ -499,7 +487,6 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
}
}
}
}
List<DrawableImage> drawableImages = new ArrayList<DrawableImage>();
@ -534,11 +521,10 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
needDrawLower = true;
if (tile.coverage != null && tile.coverage.getMesh() == null) {
IMesh mesh = target.getExtension(IMapMeshExtension.class)
.constructMesh(mapDescriptor);
MeshCalculatorJob.getInstance().requestLoad(this, mesh,
tile, this.localProjToLL);
tile.coverage.setMesh(target.getExtension(
IMapMeshExtension.class)
.constructMesh(tile.imageGeometry,
mapDescriptor.getGridGeometry()));
target.setNeedsRefresh(true);
}
}
@ -789,6 +775,7 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
continue;
}
ReferencedEnvelope envelope = tile.getEnvelope();
if (sharedGeometryTileSet != null
&& sharedGeometryTileSet.tileSet != tileSet) {
ImageTile baseTile = sharedGeometryTileSet.tileSet
@ -801,9 +788,8 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
double[] ur = new double[2];
try {
ReferencedEnvelope envelope = ((ReferencedEnvelope) tile.envelope)
.transform(mapDescriptor.getCRS(),
false);
envelope = envelope.transform(
mapDescriptor.getCRS(), false);
ll[0] = envelope.getMinX();
ll[1] = envelope.getMinY();
@ -856,11 +842,9 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
tile.coverage = new PixelCoverage(ulc, urc,
lrc, llc);
}
} else {
if (tile.envelope != null) {
} else if (envelope != null) {
tile.coverage = mapDescriptor
.worldToPixel(tile.envelope);
}
.worldToPixel(envelope);
}
}
@ -916,7 +900,7 @@ public abstract class AbstractTileSet implements IRenderable, IMeshCallback {
for (int i = 0; i < tiles.length; i++) {
for (int j = 0; j < tiles[0].length; j++) {
ImageTile tile = tiles[i][j];
if (tile != null && tile.envelope.contains(out[0], out[1])) {
if (tile != null && tile.contains(out[0], out[1])) {
int coordX = (int) (outCoords[0]);
int coordY = (int) (outCoords[1]);

View file

@ -111,8 +111,8 @@ public class FileBasedTileSet extends AbstractTileSet {
.initializeRaster(
new HDF5DataRetriever(new File(this.hdf5File), "/"
+ this.group + "/" + this.dataset
+ "-interpolated/" + level,
this.tileSet.getTile(level, i, j).rect),
+ "-interpolated/" + level, this.tileSet
.getTile(level, i, j).getRectangle()),
rsc.getCapability(ColorMapCapability.class)
.getColorMapParameters());
return raster;

View file

@ -172,8 +172,8 @@ public class MemoryBasedTileSet extends AbstractTileSet {
protected IImage createTile(IGraphicsTarget target, int level, int i, int j)
throws VizException {
IDataPreparer preparer = CMDataPreparerManager.getDataPreparer(
loadedData[level], this.tileSet.getTile(level, i, j).rect,
dims[level]);
loadedData[level], this.tileSet.getTile(level, i, j)
.getRectangle(), dims[level]);
return target.initializeRaster(preparer,
rsc.getCapability(ColorMapCapability.class)
.getColorMapParameters());

View file

@ -22,12 +22,12 @@ package com.raytheon.viz.core.rsc.jts;
import org.eclipse.swt.graphics.RGB;
import com.raytheon.uf.common.geospatial.ReferencedGeometry;
import com.raytheon.uf.common.geospatial.util.WorldWrapCorrector;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IShadedShape;
import com.raytheon.uf.viz.core.drawables.IWireframeShape;
import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapDescriptor;
import com.raytheon.uf.viz.core.map.WorldWrapCorrector;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
@ -107,7 +107,8 @@ public class JTSCompiler {
this.descriptor = descriptor;
this.pointStyle = pointStyle;
if (descriptor instanceof IMapDescriptor) {
this.corrector = new WorldWrapCorrector((IMapDescriptor) descriptor);
this.corrector = new WorldWrapCorrector(
descriptor.getGridGeometry());
}
}

View file

@ -142,7 +142,8 @@ public class TopoTileSet extends FileBasedTileSet {
return target.getExtension(IColormappedImageExtension.class)
.initializeRaster(
new HDF5DataRetriever(new File(this.hdf5File), dataset,
this.tileSet.getTile(level, i, j).rect),
this.tileSet.getTile(level, i, j)
.getRectangle()),
rsc.getCapability(ColorMapCapability.class)
.getColorMapParameters());
}

View file

@ -392,7 +392,7 @@ public class GridResource extends
for (int j = 0; j < tiles[0].length; j++) {
ImageTile tile = tiles[i][j];
if (tile != null
&& tile.envelope.contains(envelopeCoordinates[0],
&& tile.contains(envelopeCoordinates[0],
envelopeCoordinates[1])) {
int coordX = (int) (imageCoordinates[0]);
int coordY = (int) (imageCoordinates[1]);

View file

@ -182,6 +182,7 @@ public class AbstractRadarResource<D extends IDescriptor> extends
*/
@Override
protected void disposeInternal() {
radarRecords.clear();
upperTextMap.clear();
RadarTextResourceData.removeRadarTextResource(descriptor);

View file

@ -31,13 +31,9 @@ import javax.measure.converter.MultiplyConverter;
import javax.measure.converter.UnitConverter;
import javax.measure.unit.Unit;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import org.opengis.referencing.datum.PixelInCell;
import org.opengis.referencing.operation.MathTransform;
import org.opengis.referencing.operation.TransformException;
@ -57,6 +53,7 @@ import com.raytheon.uf.viz.core.IMeshCallback;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.VizApp;
import com.raytheon.uf.viz.core.data.IColorMapDataRetrievalCallback;
import com.raytheon.uf.viz.core.drawables.ColorMapLoader;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IDescriptor;
import com.raytheon.uf.viz.core.drawables.IImage;
@ -70,7 +67,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.rsc.hdf5.MeshCalculatorJob;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.awipstools.capabilities.RangeRingsOverlayCapability;
@ -188,64 +184,16 @@ public class RadarImageResource<D extends IDescriptor> extends
ColorMapParameters params = getColorMapParameters(target,
populatedRecord);
ImageTile tile = new ImageTile();
RadarRecord record = populatedRecord;
try {
// Attempt to create envelope, adapted from AbstractTileSet
double maxExtent = RadarUtil.calculateExtent(record);
GridGeometry2D geom = RadarUtil.constructGridGeometry(
record.getCRS(), maxExtent,
Math.max(record.getNumBins(), record.getNumRadials()));
MathTransform mt = geom.getGridToCRS(PixelInCell.CELL_CORNER);
double[] ul = new double[3];
double[] lr = new double[3];
double[] in = new double[2];
in[0] = 0;
in[1] = 0;
mt.transform(in, 0, ul, 0, 1);
in[0] = record.getNumRadials();
in[1] = record.getNumBins();
mt.transform(in, 0, lr, 0, 1);
tile.envelope = new ReferencedEnvelope(ul[0], lr[0], ul[1], lr[1],
record.getCRS());
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, "Error constructing extent",
e);
PixelCoverage coverage = buildCoverage(target, populatedRecord);
if (coverage.getMesh() == null) {
coverage.setMesh(buildMesh(target, populatedRecord));
}
tile.rect = new Rectangle(0, 0, populatedRecord.getNumBins(),
populatedRecord.getNumRadials());
if (tile.coverage == null) {
tile.coverage = buildCoverage(target, tile, populatedRecord);
}
if (tile.coverage.getMesh() == null) {
IMesh mesh = buildMesh(target, populatedRecord);
if (mesh != null) {
try {
MeshCalculatorJob.getInstance().requestLoad(
this,
mesh,
tile,
CRS.findMathTransform(populatedRecord.getCRS(),
DefaultGeographicCRS.WGS84));
} catch (FactoryException e) {
statusHandler
.handle(Priority.PROBLEM,
"Error finding math transform to lat/lon for radar record",
e);
}
}
}
IImage image = createImage(target, params, record, tile.rect);
IImage image = createImage(target, params, populatedRecord,
new Rectangle(0, 0, populatedRecord.getNumBins(),
populatedRecord.getNumRadials()));
DrawableImage dImage = images.put(populatedRecord.getDataTime(),
new DrawableImage(image, tile.coverage));
new DrawableImage(image, coverage));
if (dImage != null) {
disposeImage(dImage);
}
@ -322,7 +270,7 @@ public class RadarImageResource<D extends IDescriptor> extends
colorMapName = "Radar/OSF/16 Level Reflectivity";
}
params.setColorMap(target.buildColorMap(colorMapName));
params.setColorMap(ColorMapLoader.loadColorMap(colorMapName));
}
@ -614,7 +562,7 @@ public class RadarImageResource<D extends IDescriptor> extends
return null;
}
public PixelCoverage buildCoverage(IGraphicsTarget target, ImageTile tile,
public PixelCoverage buildCoverage(IGraphicsTarget target,
VizRadarRecord timeRecord) throws VizException {
return new PixelCoverage(new Coordinate(0, 0), 0, 0);
}

View file

@ -21,16 +21,13 @@ package com.raytheon.viz.radar.rsc.image;
import java.awt.Rectangle;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.FactoryException;
import org.geotools.coverage.grid.GridGeometry2D;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil;
import com.raytheon.uf.viz.core.DrawableImage;
import com.raytheon.uf.viz.core.IGraphicsTarget;
import com.raytheon.uf.viz.core.IMesh;
import com.raytheon.uf.viz.core.PixelCoverage;
import com.raytheon.uf.viz.core.drawables.ColorMapParameters;
import com.raytheon.uf.viz.core.drawables.IImage;
@ -39,7 +36,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.IMapMeshExtension;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.viz.radar.VizRadarRecord;
import com.raytheon.viz.radar.interrogators.IRadarInterrogator;
import com.raytheon.viz.radar.rsc.RadarImageResource;
@ -85,22 +81,19 @@ public class RadarRasterResource extends RadarImageResource<MapDescriptor> {
}
@Override
public PixelCoverage buildCoverage(IGraphicsTarget target, ImageTile tile,
public PixelCoverage buildCoverage(IGraphicsTarget target,
VizRadarRecord timeRecord) throws VizException {
if (sharedCoverage == null) {
sharedCoverage = super.buildCoverage(target, tile, timeRecord);
double maxExtent = RadarUtil.calculateExtent(timeRecord);
GridGeometry2D geom = RadarUtil.constructGridGeometry(
timeRecord.getCRS(),
maxExtent,
Math.max(timeRecord.getNumBins(),
timeRecord.getNumRadials()));
IMesh mesh = target.getExtension(IMapMeshExtension.class)
.constructMesh(descriptor);
try {
mesh.calculateMesh(sharedCoverage, tile, CRS.findMathTransform(
timeRecord.getCRS(), DefaultGeographicCRS.WGS84));
} catch (FactoryException e) {
statusHandler
.handle(Priority.PROBLEM,
"Error finding math transform to lat/lon for radar record",
e);
}
sharedCoverage = super.buildCoverage(target, timeRecord);
sharedCoverage.setMesh(target.getExtension(IMapMeshExtension.class)
.constructMesh(geom, descriptor.getGridGeometry()));
}
return sharedCoverage;
}
@ -115,17 +108,9 @@ public class RadarRasterResource extends RadarImageResource<MapDescriptor> {
@Override
public void project(CoordinateReferenceSystem crs) throws VizException {
super.project(crs);
if (sharedCoverage != null) {
sharedCoverage.dispose();
sharedCoverage = null;
if (sharedCoverage != null && sharedCoverage.getMesh() != null) {
sharedCoverage.getMesh().reproject(descriptor.getGridGeometry());
}
// TODO dispose just the coverage, not the image.
for (DrawableImage image : images.values()) {
if (image != null) {
image.dispose();
}
}
images.clear();
}
@Override

View file

@ -59,7 +59,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.TimeMatchBasisCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.viz.awipstools.capabilities.RangeRingsOverlayCapability;
import com.raytheon.viz.core.contours.util.VectorGraphicsRenderable;
import com.raytheon.viz.radar.RadarHelper;
@ -184,7 +183,7 @@ public class RadarXYResource extends RadarImageResource<RadarXYDescriptor> {
* com.raytheon.viz.radar.RadarTimeRecord.RadarTiltRecord)
*/
@Override
public PixelCoverage buildCoverage(IGraphicsTarget target, ImageTile tile,
public PixelCoverage buildCoverage(IGraphicsTarget target,
VizRadarRecord radarRecord) throws VizException {
double width = radarRecord.getNumBins();
double height = radarRecord.getNumRadials();

View file

@ -40,7 +40,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.xy.map.rsc.IInsetMapResource;
import com.raytheon.viz.radar.VizRadarRecord;
import com.raytheon.viz.radar.interrogators.IRadarInterrogator;
@ -181,7 +180,7 @@ public class RadarXsectXYResource extends RadarXYResource implements
* com.raytheon.viz.radar.RadarTimeRecord.RadarTiltRecord)
*/
@Override
public PixelCoverage buildCoverage(IGraphicsTarget target, ImageTile tile,
public PixelCoverage buildCoverage(IGraphicsTarget target,
VizRadarRecord rec) throws VizException {
int iStart = rec.getIstart();
int jStart = rec.getJstart();

View file

@ -128,7 +128,7 @@ public class SatFileBasedTileSet extends FileBasedTileSet {
int j = (Integer) key.getKey(2);
ImageTile tile = this.tileSet.getTile(level, i, j);
if (tile != null) {
Rectangle tileRect = tile.rect;
Rectangle tileRect = tile.getRectangle();
ByteBuffer tileData = ByteBuffer.allocate(tileRect.height
* tileRect.width);
@ -147,8 +147,7 @@ public class SatFileBasedTileSet extends FileBasedTileSet {
try {
IImage raster = target.getExtension(
IColormappedImageExtension.class).initializeRaster(
new SatDataRetriever(pdo, level,
this.tileSet.getTile(level, i, j).rect,
new SatDataRetriever(pdo, level, tileRect,
signed, tileData), cmp);
if (raster != null) {
addImage(raster, level, i, j);
@ -180,10 +179,11 @@ public class SatFileBasedTileSet extends FileBasedTileSet {
if (cmp != null && cmp.getDataUnit() instanceof GenericPixel) {
signed = true;
}
return target.getExtension(IColormappedImageExtension.class)
return target
.getExtension(IColormappedImageExtension.class)
.initializeRaster(
new SatDataRetriever(pdo, level, this.tileSet.getTile(
level, i, j).rect, signed, null), cmp);
level, i, j).getRectangle(), signed, null), cmp);
}
@Override
@ -193,7 +193,7 @@ public class SatFileBasedTileSet extends FileBasedTileSet {
// joining adjacent requests.
List<Rectangle> rectangles = new ArrayList<Rectangle>();
for (Point p : tilesToCreate) {
rectangles.add(tileSet.getTile(lvl, p.x, p.y).rect);
rectangles.add(tileSet.getTile(lvl, p.x, p.y).getRectangle());
}
// Join together any adjacent rectangles
for (int i = 0; i < rectangles.size(); i++) {
@ -228,7 +228,8 @@ public class SatFileBasedTileSet extends FileBasedTileSet {
for (Point p : tilesToCreate) {
int i = p.x;
int j = p.y;
Rectangle tileRectangle = tileSet.getTileSet().get(lvl)[i][j].rect;
Rectangle tileRectangle = tileSet.getTileSet().get(lvl)[i][j]
.getRectangle();
MultiKey key = new MultiKey(lvl, i, j);
if (bigRectangle.equals(tileRectangle)) {
// This tile is my big rectangle, schedule single tile

View file

@ -377,6 +377,22 @@ public class VizWorkbenchManager implements IPartListener, IPartListener2,
if (parts != null) {
parts.add((IEditorPart) part);
}
IEditorPart active = activeEditorMap.get(part.getSite()
.getWorkbenchWindow());
if (active == null) {
// Active will be null if our active editor became hidden, try
// and get an active editor from the page
active = part.getSite().getPage().getActiveEditor();
if (active == null) {
// Active will be null here if the page doesn't have an
// active editor so we should use the part that became
// visible
active = (IEditorPart) part;
}
activeEditorMap
.put(part.getSite().getWorkbenchWindow(), active);
}
}
}

View file

@ -17,12 +17,19 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.map;
package com.raytheon.uf.common.geospatial.util;
import org.geotools.coverage.grid.GeneralGridGeometry;
import org.geotools.referencing.CRS;
import org.geotools.referencing.operation.DefaultMathTransformFactory;
import org.geotools.referencing.operation.projection.MapProjection;
import org.geotools.referencing.operation.projection.MapProjection.AbstractProvider;
import org.opengis.parameter.ParameterValueGroup;
import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Given a descriptor of a map, this class will check line segments for wrapping
@ -50,9 +57,9 @@ public class WorldWrapChecker {
private boolean checkForWrapping = false;
public WorldWrapChecker(IMapDescriptor descriptor) {
MapProjection worldProjection = CRS.getMapProjection(descriptor
.getCRS());
public WorldWrapChecker(GeneralGridGeometry worldGeometry) {
MapProjection worldProjection = CRS.getMapProjection(worldGeometry
.getCoordinateReferenceSystem());
double centralMeridian = 0.0;
if (worldProjection != null) {
ParameterValueGroup group = worldProjection.getParameterValues();
@ -71,12 +78,27 @@ public class WorldWrapChecker {
double r1 = inverseCentralMeridian - 359.9;
double r2 = inverseCentralMeridian - 359.8;
double xl1 = descriptor.worldToPixel(new double[] { l1, 0.0 })[0];
double xl2 = descriptor.worldToPixel(new double[] { l2, 0.0 })[0];
double xr1 = descriptor.worldToPixel(new double[] { r1, 0.0 })[0];
double xr2 = descriptor.worldToPixel(new double[] { r2, 0.0 })[0];
try {
MathTransform latLonToGrid = new DefaultMathTransformFactory()
.createConcatenatedTransform(MapUtil
.getTransformFromLatLon(worldGeometry
.getCoordinateReferenceSystem()),
worldGeometry.getGridToCRS().inverse());
double[] in = new double[] { l1, 0.0, l2, 0.0, r1, 0.0, r2, 0.0 };
double[] out = new double[in.length];
latLonToGrid.transform(in, 0, out, 0, 4);
double xl1 = out[0];
double xl2 = out[2];
double xr1 = out[4];
double xr2 = out[6];
checkForWrapping = Math.abs(xl1 - xr1) > Math.abs(xl2 - xr2);
} catch (Throwable t) {
UFStatus.getHandler().handle(Priority.PROBLEM,
"Error determing world wrap checking", t);
}
}
/**

View file

@ -17,12 +17,14 @@
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.core.map;
package com.raytheon.uf.common.geospatial.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.geotools.coverage.grid.GeneralGridGeometry;
import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.GeometryCollection;
@ -53,12 +55,12 @@ public class WorldWrapCorrector {
private WorldWrapChecker checker;
/**
* Constructs of world wrap corrector for the specified descriptor
* Constructs of world wrap corrector for the specified world
*
* @param descriptor
*/
public WorldWrapCorrector(IMapDescriptor descriptor) {
checker = new WorldWrapChecker(descriptor);
public WorldWrapCorrector(GeneralGridGeometry worldGeometry) {
checker = new WorldWrapChecker(worldGeometry);
}
/**

View file

@ -73,7 +73,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.rsc.hdf5.MeshCalculatorJob;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.awipstools.capabilities.RangeRingsOverlayCapability;
@ -322,70 +321,20 @@ public abstract class RadarImageResource<D extends IDescriptor> extends
tiltRecord.tile = new ImageTile();
}
if (tiltRecord.tile.coverage == null) {
tiltRecord.tile.coverage = buildCoverage(target, tiltRecord);
}
try {
RadarRecord record = populatedRecord;
// Attempt to create envelope, adapted from AbstractTileSet
double maxExtent = RadarUtil.calculateExtent(record);
GridGeometry2D geom = RadarUtil.constructGridGeometry(
record.getCRS(), maxExtent,
Math.max(record.getNumBins(), record.getNumRadials()));
MathTransform mt = geom.getGridToCRS(PixelInCell.CELL_CORNER);
double[] ul = new double[3];
double[] lr = new double[3];
double[] in = new double[2];
in[0] = 0;
in[1] = 0;
mt.transform(in, 0, ul, 0, 1);
in[0] = record.getNumRadials();
in[1] = record.getNumBins();
mt.transform(in, 0, lr, 0, 1);
tiltRecord.tile.envelope = new ReferencedEnvelope(ul[0], lr[0], ul[1], lr[1],
record.getCRS());
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM,
"Error constructing extent", e);
}
tiltRecord.tile.rect = new Rectangle(0, 0,
populatedRecord.getNumBins(), populatedRecord.getNumRadials());
if (tiltRecord.tile.coverage.getMesh() == null) {
IMesh mesh = buildMesh(target, tiltRecord);
tiltRecord.tile.coverage.setMesh(buildMesh(target, tiltRecord));
}
if (mesh != null) {
try {
MeshCalculatorJob.getInstance().requestLoad(
this,
mesh,
tiltRecord.tile,
CRS.findMathTransform(populatedRecord.getCRS(),
DefaultGeographicCRS.WGS84));
} catch (FactoryException e) {
statusHandler.handle(
Priority.PROBLEM,
"Error finding math transform to lat/lon for radar record",
e);
}
}
}
Rectangle rect = new Rectangle(0, 0, populatedRecord.getNumBins(),
populatedRecord.getNumRadials());
tiltRecord.image = target.initializeRaster(CMDataPreparerManager
.getDataPreparer(BufferUtil.wrapDirect(
toImageData(tiltRecord.params, populatedRecord),
new Rectangle(0, 0, populatedRecord.getNumBins(),
populatedRecord.getNumRadials())),
tiltRecord.tile.rect, new int[] {
tiltRecord.tile.rect.width,
tiltRecord.tile.rect.height }),
populatedRecord.getNumRadials())), rect,
new int[] { rect.width, rect.height }),
tiltRecord.params);
}

View file

@ -36,7 +36,6 @@ import com.raytheon.uf.viz.core.map.MapDescriptor;
import com.raytheon.uf.viz.core.rsc.LoadProperties;
import com.raytheon.uf.viz.core.rsc.ResourceType;
import com.raytheon.uf.viz.core.rsc.capabilities.ColorMapCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.MeshCalculatorJob;
import com.raytheon.viz.awipstools.capabilities.EAVCapability;
import com.raytheon.viz.awipstools.common.EstimatedActualVelocity;
import com.raytheon.viz.radar.IRadarRecordMetadata;
@ -150,17 +149,8 @@ public class RadarRadialResource extends RadarImageResource<MapDescriptor> {
super.project(crs);
for (RadarTimeRecord rtr : radarRecords.values()) {
if (rtr.tile != null && rtr.tile.coverage.getMesh() != null) {
try {
MeshCalculatorJob.getInstance().requestLoad(
this,
rtr.tile.coverage.getMesh(),
rtr.tile,
CRS.findMathTransform(rtr.radarCacheObject.getMetadata().getCRS(),
DefaultGeographicCRS.WGS84));
} catch (FactoryException e) {
statusHandler.handle(Priority.PROBLEM,
"Error constructing transform for mesh", e);
}
rtr.tile.coverage.getMesh().reproject(
descriptor.getGridGeometry());
} else {
refreshDisplay = true;
}

View file

@ -78,7 +78,6 @@ import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.ImagingCapability;
import com.raytheon.uf.viz.core.rsc.capabilities.OutlineCapability;
import com.raytheon.uf.viz.core.rsc.hdf5.ImageTile;
import com.raytheon.uf.viz.core.rsc.hdf5.MeshCalculatorJob;
import com.raytheon.uf.viz.core.style.DataMappingPreferences;
import com.raytheon.uf.viz.core.style.DataMappingPreferences.DataMappingEntry;
import com.raytheon.viz.awipstools.capabilities.RangeRingsOverlayCapability;
@ -336,64 +335,16 @@ public abstract class RadarImageResource<D extends IDescriptor> extends
ColorMapParameters params = getColorMapParameters(target,
populatedRecord);
ImageTile tile = new ImageTile();
RadarRecord record = populatedRecord;
try {
// Attempt to create envelope, adapted from AbstractTileSet
double maxExtent = RadarUtil.calculateExtent(record);
GridGeometry2D geom = RadarUtil.constructGridGeometry(
record.getCRS(), maxExtent,
Math.max(record.getNumBins(), record.getNumRadials()));
MathTransform mt = geom.getGridToCRS(PixelInCell.CELL_CORNER);
double[] ul = new double[3];
double[] lr = new double[3];
double[] in = new double[2];
in[0] = 0;
in[1] = 0;
mt.transform(in, 0, ul, 0, 1);
in[0] = record.getNumRadials();
in[1] = record.getNumBins();
mt.transform(in, 0, lr, 0, 1);
tile.envelope = new ReferencedEnvelope(ul[0], lr[0], ul[1], lr[1],
record.getCRS());
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, "Error constructing extent",
e);
PixelCoverage coverage = buildCoverage(target, populatedRecord);
if (coverage.getMesh() == null) {
coverage.setMesh(buildMesh(target, populatedRecord));
}
tile.rect = new Rectangle(0, 0, populatedRecord.getNumBins(),
populatedRecord.getNumRadials());
if (tile.coverage == null) {
tile.coverage = buildCoverage(target, tile, populatedRecord);
}
if (tile.coverage.getMesh() == null) {
IMesh mesh = buildMesh(target, populatedRecord);
if (mesh != null) {
try {
MeshCalculatorJob.getInstance().requestLoad(
this,
mesh,
tile,
CRS.findMathTransform(populatedRecord.getCRS(),
DefaultGeographicCRS.WGS84));
} catch (FactoryException e) {
statusHandler
.handle(Priority.PROBLEM,
"Error finding math transform to lat/lon for radar record",
e);
}
}
}
IImage image = createImage(target, params, record, tile.rect);
IImage image = createImage(target, params, populatedRecord,
new Rectangle(0, 0, populatedRecord.getNumBins(),
populatedRecord.getNumRadials()));
DrawableImage dImage = images.put(populatedRecord.getDataTime(),
new DrawableImage(image, tile.coverage));
new DrawableImage(image, coverage));
if (dImage != null) {
disposeImage(dImage);
}
@ -748,7 +699,7 @@ public abstract class RadarImageResource<D extends IDescriptor> extends
return null;
}
public PixelCoverage buildCoverage(IGraphicsTarget target, ImageTile tile,
public PixelCoverage buildCoverage(IGraphicsTarget target,
VizRadarRecord timeRecord) throws VizException {
return new PixelCoverage(new Coordinate(0, 0), 0, 0);
}

View file

@ -10,12 +10,14 @@ package gov.noaa.nws.ncep.viz.rsc.ncradar.rsc.image;
import java.awt.Rectangle;
import java.util.HashMap;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.referencing.CRS;
import org.geotools.referencing.crs.DefaultGeographicCRS;
import org.opengis.referencing.FactoryException;
import org.opengis.referencing.crs.CoordinateReferenceSystem;
import com.raytheon.uf.common.dataplugin.radar.RadarRecord;
import com.raytheon.uf.common.dataplugin.radar.util.RadarUtil;
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.common.time.DataTime;
@ -127,22 +129,19 @@ public class RadarRasterResource extends RadarImageResource<MapDescriptor> {
}
@Override
public PixelCoverage buildCoverage(IGraphicsTarget target, ImageTile tile,
public PixelCoverage buildCoverage(IGraphicsTarget target,
VizRadarRecord timeRecord) throws VizException {
if (sharedCoverage == null) {
sharedCoverage = super.buildCoverage(target, tile, timeRecord);
double maxExtent = RadarUtil.calculateExtent(timeRecord);
GridGeometry2D geom = RadarUtil.constructGridGeometry(
timeRecord.getCRS(),
maxExtent,
Math.max(timeRecord.getNumBins(),
timeRecord.getNumRadials()));
IMesh mesh = target.getExtension(IMapMeshExtension.class)
.constructMesh(descriptor);
try {
mesh.calculateMesh(sharedCoverage, tile, CRS.findMathTransform(
timeRecord.getCRS(), DefaultGeographicCRS.WGS84));
} catch (FactoryException e) {
statusHandler
.handle(Priority.PROBLEM,
"Error finding math transform to lat/lon for radar record",
e);
}
sharedCoverage = super.buildCoverage(target, timeRecord);
sharedCoverage.setMesh(target.getExtension(IMapMeshExtension.class)
.constructMesh(geom, descriptor.getGridGeometry()));
}
return sharedCoverage;
}

View file

@ -6,6 +6,7 @@ package gov.noaa.nws.ncep.viz.rsc.satellite.rsc;
import java.awt.Rectangle;
import java.util.Map;
import org.geotools.coverage.grid.GridGeometry2D;
import org.geotools.geometry.GeneralEnvelope;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.opengis.referencing.datum.PixelInCell;
@ -15,6 +16,7 @@ import org.opengis.referencing.operation.MathTransform;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.datastorage.StorageException;
import com.raytheon.uf.common.geospatial.MapUtil;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -96,7 +98,11 @@ public class McidasFileBasedTileSet extends SatFileBasedTileSet {
}
try {
ReferencedEnvelope mapEnv = new ReferencedEnvelope(
this.mapDescriptor.getGridGeometry().getEnvelope());
mapEnv = mapEnv.transform(MapUtil.LATLON_PROJECTION, false);
GeneralEnvelope generalMapEnv = new GeneralEnvelope(mapEnv);
generalMapEnv.normalize(false);
startY = 0;
for (int j = 0; j < totalTilesY; j++) {
startY = j * (inTileSize);
@ -127,18 +133,23 @@ public class McidasFileBasedTileSet extends SatFileBasedTileSet {
mathTransform[level].transform(in, 0, lr, 0, 1);
ReferencedEnvelope env = new ReferencedEnvelope(ul[0],
lr[0], ul[1], lr[1], gridGeometry[0]
.getCoordinateReferenceSystem());
lr[0], ul[1], lr[1],
gridGeometry[0].getCoordinateReferenceSystem());
GeneralEnvelope generalEnv = new GeneralEnvelope(
env.transform(MapUtil.LATLON_PROJECTION, false));
// tiles which cross the dateline will almost always be
// created since normalizing changes their range to
// -180,180. If this is causing problems then instead of
// normalizing we should split envelopes that cross the
// dateline.
generalEnv.normalize(false);
// only create the tile if env overlaps the map
if (generalEnv.intersects(generalMapEnv, true)) {
tiles[i][j] = new ImageTile();
tiles[i][j].rect = new Rectangle(startX, startY,
effectiveWidth, effectiveHeight);
tiles[i][j].envelope = env;
tiles[i][j].elevation = this.elevation;
tiles[i][j].rect.width = effectiveWidth;
tiles[i][j].rect.height = effectiveHeight;
tiles[i][j].setGridGeometry(new Rectangle(startX,
startY, effectiveWidth, effectiveHeight), env);
}
}
}
@ -224,6 +235,7 @@ public class McidasFileBasedTileSet extends SatFileBasedTileSet {
continue;
}
ReferencedEnvelope envelope = tile.getEnvelope();
//if (this.sharedGeometryTileSet != null) {
// ImageTile baseTile = sharedGeometryTileSet.tileSet
// .getTileSet().get(level)[i][j];
@ -236,9 +248,8 @@ public class McidasFileBasedTileSet extends SatFileBasedTileSet {
double[] ur = new double[2];
try {
ReferencedEnvelope envelope = ((ReferencedEnvelope) tile.envelope)
.transform(mapDescriptor.getCRS(),
false);
envelope = tile.getEnvelope().transform(
mapDescriptor.getCRS(), false);
ll[0] = envelope.getMinX();
ll[1] = envelope.getMinY();
@ -251,20 +262,25 @@ public class McidasFileBasedTileSet extends SatFileBasedTileSet {
lr[0] = envelope.getMaxX();
lr[1] = envelope.getMinY();
mapDescriptor.getGridGeometry().getGridToCRS()
.inverse().transform(ul, 0, ul, 0, 1);
mapDescriptor.getGridGeometry().getGridToCRS()
.inverse().transform(ll, 0, ll, 0, 1);
mapDescriptor.getGridGeometry().getGridToCRS()
.inverse().transform(lr, 0, lr, 0, 1);
mapDescriptor.getGridGeometry().getGridToCRS()
.inverse().transform(ur, 0, ur, 0, 1);
mapDescriptor.getGridGeometry()
.getGridToCRS().inverse()
.transform(ul, 0, ul, 0, 1);
mapDescriptor.getGridGeometry()
.getGridToCRS().inverse()
.transform(ll, 0, ll, 0, 1);
mapDescriptor.getGridGeometry()
.getGridToCRS().inverse()
.transform(lr, 0, lr, 0, 1);
mapDescriptor.getGridGeometry()
.getGridToCRS().inverse()
.transform(ur, 0, ur, 0, 1);
} catch (Throwable t) {
// Skip tile on error
statusHandler.handle(Priority.VERBOSE,
"Error reprojecting tile " + i + ":"
+ j + " at level " + level, t);
"Error reprojecting tile " + i
+ ":" + j + " at level "
+ level, t);
ul = ll = lr = ur = null;
tileLevel[i][j] = null;
}
@ -274,19 +290,21 @@ public class McidasFileBasedTileSet extends SatFileBasedTileSet {
tile.coverage = null;
} else {
Coordinate ulc = new Coordinate(ul[0], ul[1], 0);
Coordinate llc = new Coordinate(ll[0], ll[1], 0);
Coordinate lrc = new Coordinate(lr[0], lr[1], 0);
Coordinate urc = new Coordinate(ur[0], ur[1], 0);
Coordinate ulc = new Coordinate(ul[0],
ul[1], 0);
Coordinate llc = new Coordinate(ll[0],
ll[1], 0);
Coordinate lrc = new Coordinate(lr[0],
lr[1], 0);
Coordinate urc = new Coordinate(ur[0],
ur[1], 0);
tile.coverage = new PixelCoverage(ulc, urc,
lrc, llc);
}
} else {
if (tile.envelope != null) {
} else if (envelope != null) {
tile.coverage = mapDescriptor
.worldToPixel(tile.envelope);
}
.worldToPixel(envelope);
}
}