Issue #704 fixes to random resources and optimization of radar projection transforms
Former-commit-id: 7619165ce45efe9dbad045adfaaf978acee782be
This commit is contained in:
parent
d317777ee6
commit
601d46661c
4 changed files with 60 additions and 54 deletions
|
@ -32,8 +32,6 @@ import com.raytheon.uf.viz.core.exception.VizException;
|
||||||
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
|
import com.raytheon.uf.viz.core.rsc.AbstractRequestableResourceData;
|
||||||
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
import com.raytheon.uf.viz.core.rsc.AbstractVizResource;
|
||||||
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
import com.raytheon.uf.viz.core.rsc.LoadProperties;
|
||||||
import com.raytheon.uf.viz.core.status.StatusConstants;
|
|
||||||
import com.raytheon.uf.viz.ncwf.Activator;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ResourceData for Ncwf resources
|
* The ResourceData for Ncwf resources
|
||||||
|
@ -52,7 +50,8 @@ import com.raytheon.uf.viz.ncwf.Activator;
|
||||||
*/
|
*/
|
||||||
@XmlAccessorType(XmlAccessType.NONE)
|
@XmlAccessorType(XmlAccessType.NONE)
|
||||||
public class NcwfPolygonResourceData extends AbstractRequestableResourceData {
|
public class NcwfPolygonResourceData extends AbstractRequestableResourceData {
|
||||||
private static final transient IUFStatusHandler statusHandler = UFStatus.getHandler(NcwfPolygonResourceData.class);
|
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||||
|
.getHandler(NcwfPolygonResourceData.class);
|
||||||
|
|
||||||
@XmlAttribute
|
@XmlAttribute
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -68,7 +67,7 @@ public class NcwfPolygonResourceData extends AbstractRequestableResourceData {
|
||||||
|
|
||||||
NcwfPolygonResourceData other = (NcwfPolygonResourceData) obj;
|
NcwfPolygonResourceData other = (NcwfPolygonResourceData) obj;
|
||||||
|
|
||||||
if (other.name.equals(name)) {
|
if (!other.name.equals(name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,6 +100,4 @@ public class NcwfPolygonResourceData extends AbstractRequestableResourceData {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||||
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
import com.raytheon.uf.common.datastorage.records.ByteDataRecord;
|
||||||
import com.raytheon.uf.common.geospatial.MapUtil;
|
import com.raytheon.uf.common.geospatial.MapUtil;
|
||||||
import com.raytheon.uf.common.time.DataTime;
|
import com.raytheon.uf.common.time.DataTime;
|
||||||
|
import com.raytheon.uf.viz.core.DrawableString;
|
||||||
import com.raytheon.uf.viz.core.IExtent;
|
import com.raytheon.uf.viz.core.IExtent;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
import com.raytheon.uf.viz.core.IGraphicsTarget;
|
||||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||||
|
@ -556,26 +557,18 @@ public class RedbookFrame implements IRenderable {
|
||||||
|
|
||||||
if (!symbols) {
|
if (!symbols) {
|
||||||
IFont font = redbookResource.getRenderingFont();
|
IFont font = redbookResource.getRenderingFont();
|
||||||
Rectangle2D bounds = target.getStringBounds(font, s);
|
DrawableString dstring = new DrawableString(s, this.redbookResource
|
||||||
|
.getCapability(ColorableCapability.class).getColor());
|
||||||
|
dstring.setCoordinates(x, y);
|
||||||
|
dstring.font = font;
|
||||||
|
dstring.horizontalAlignment = HorizontalAlignment.LEFT;
|
||||||
|
dstring.verticallAlignment = top ? VerticalAlignment.TOP
|
||||||
|
: VerticalAlignment.BOTTOM;
|
||||||
|
Rectangle2D bounds = target.getStringsBounds(dstring);
|
||||||
if (blanked) {
|
if (blanked) {
|
||||||
double yext = y + bounds.getHeight() * yRatio * (top ? 1 : -1);
|
dstring.textStyle = TextStyle.BLANKED;
|
||||||
PixelExtent pe = new PixelExtent(x, x + bounds.getWidth()
|
|
||||||
* xRatio, Math.min(y, yext) + yRatio, Math.max(y, yext)
|
|
||||||
+ yRatio);
|
|
||||||
target.drawShadedRect(pe, new RGB(0, 0, 0),
|
|
||||||
paintProps.getAlpha(), null);
|
|
||||||
}
|
}
|
||||||
target.drawString(
|
target.drawStrings(dstring);
|
||||||
font,
|
|
||||||
s,
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
0.0,
|
|
||||||
TextStyle.NORMAL,
|
|
||||||
this.redbookResource.getCapability(
|
|
||||||
ColorableCapability.class).getColor(),
|
|
||||||
HorizontalAlignment.LEFT, top ? VerticalAlignment.TOP
|
|
||||||
: VerticalAlignment.BOTTOM, null);
|
|
||||||
return bounds.getWidth() * xRatio;
|
return bounds.getWidth() * xRatio;
|
||||||
} else {
|
} else {
|
||||||
double width = s.length() * 12 * xRatio * magnification;
|
double width = s.length() * 12 * xRatio * magnification;
|
||||||
|
|
|
@ -78,25 +78,17 @@ public class AzimuthRangeMapProjection extends ObliqueStereographic {
|
||||||
return super.inverseTransformNormalized(x, y, dest);
|
return super.inverseTransformNormalized(x, y, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double normalizeAngle(double rangeLow, double rangeHigh,
|
|
||||||
double angle) {
|
|
||||||
while (angle < rangeLow) {
|
|
||||||
angle += 360;
|
|
||||||
}
|
|
||||||
while (angle > rangeHigh) {
|
|
||||||
angle -= 360;
|
|
||||||
}
|
|
||||||
return angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Point2D transformNormalized(double lon, double lat, Point2D dest)
|
protected Point2D transformNormalized(double lon, double lat, Point2D dest)
|
||||||
throws ProjectionException {
|
throws ProjectionException {
|
||||||
Point2D tmp = new Point2D.Double();
|
Point2D tmp = new Point2D.Double();
|
||||||
super.transformNormalized(lon, lat, tmp);
|
super.transformNormalized(lon, lat, tmp);
|
||||||
double azimuth = Math.toDegrees(Math.atan2(tmp.getX(), tmp.getY()));
|
double x = tmp.getX();
|
||||||
double range = scaleFactor * semiMajor
|
double y = tmp.getY();
|
||||||
* Math.hypot(tmp.getX(), tmp.getY());
|
double azimuth = Math.toDegrees(Math.atan2(x, y));
|
||||||
|
// Math.hypot is more accurate than the sqrt approach but much much
|
||||||
|
// slower.
|
||||||
|
double range = scaleFactor * semiMajor * Math.sqrt(x * x + y * y);
|
||||||
if (dest != null) {
|
if (dest != null) {
|
||||||
dest.setLocation(azimuth, range);
|
dest.setLocation(azimuth, range);
|
||||||
return dest;
|
return dest;
|
||||||
|
|
|
@ -106,24 +106,48 @@ public class RadialBinMapProjection extends AzimuthRangeMapProjection {
|
||||||
@Override
|
@Override
|
||||||
protected Point2D transformNormalized(double lon, double lat, Point2D dest)
|
protected Point2D transformNormalized(double lon, double lat, Point2D dest)
|
||||||
throws ProjectionException {
|
throws ProjectionException {
|
||||||
|
if (dest == null) {
|
||||||
|
dest = new Point2D.Double();
|
||||||
|
}
|
||||||
Point2D tmp = new Point2D.Double();
|
Point2D tmp = new Point2D.Double();
|
||||||
tmp = super.transformNormalized(lon, lat, tmp);
|
tmp = super.transformNormalized(lon, lat, tmp);
|
||||||
double az = tmp.getX();
|
double az = tmp.getX();
|
||||||
double ran = tmp.getY();
|
double ran = tmp.getY();
|
||||||
// System.out.println(ran);
|
|
||||||
double radial = Double.NaN;
|
|
||||||
double bin = ran / flatBinLength;
|
double bin = ran / flatBinLength;
|
||||||
float nextAngle = normalAngleData[0] + 360;
|
float firstAngle = normalAngleData[0];
|
||||||
az = normalizeAngle(normalAngleData[0], nextAngle, az);
|
float lastAngle = normalAngleData[normalAngleData.length - 1];
|
||||||
for (int i = normalAngleData.length - 1; i >= 0; i -= 1) {
|
// normalize the range for az
|
||||||
float prevAngle = normalAngleData[i];
|
while (az < firstAngle) {
|
||||||
if (prevAngle <= az && nextAngle > az) {
|
az += 360;
|
||||||
radial = (i) + (az - prevAngle) / (nextAngle - prevAngle);
|
}
|
||||||
break;
|
while (az > firstAngle + 360) {
|
||||||
}
|
az -= 360;
|
||||||
prevAngle = nextAngle;
|
}
|
||||||
|
if (az >= lastAngle) {
|
||||||
|
// special case of az is not between two normalizedAngles
|
||||||
|
double radial = normalAngleData.length - 1 + (az - lastAngle)
|
||||||
|
/ (firstAngle + 360 - lastAngle);
|
||||||
|
dest.setLocation(radial, bin);
|
||||||
|
} else {
|
||||||
|
// start off with a guess for the index
|
||||||
|
int index = (int) ((az - firstAngle) * (normalAngleData.length - 1) / (lastAngle - firstAngle));
|
||||||
|
// increase index if we guessed to low
|
||||||
|
float nextAngle = normalAngleData[index];
|
||||||
|
while (nextAngle <= az) {
|
||||||
|
index += 1;
|
||||||
|
nextAngle = normalAngleData[index];
|
||||||
|
}
|
||||||
|
index -= 1;
|
||||||
|
// decrease index if we guessed to high.
|
||||||
|
float prevAngle = normalAngleData[index];
|
||||||
|
while (prevAngle > az) {
|
||||||
|
nextAngle = prevAngle;
|
||||||
|
prevAngle = normalAngleData[--index];
|
||||||
|
}
|
||||||
|
// interpolate a result.
|
||||||
|
double radial = index + (az - prevAngle) / (nextAngle - prevAngle);
|
||||||
|
dest.setLocation(radial, bin);
|
||||||
}
|
}
|
||||||
dest.setLocation(radial, bin);
|
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue