Merge "Issue #704 fixes to random resources and optimization of radar projection transforms" into development
Former-commit-id:ac131f24a7
[formerly98fee4da65
] [formerly 49ef2584bb32b7882f3a7c1ead60871aac7fea1c [formerly96c4d9301f
]] [formerly22d4de96fd
[formerly96c4d9301f
[formerly 995d7e08ade1a3e10ac8ab51aa24f900091054de]]] Former-commit-id:22d4de96fd
Former-commit-id: 557b270d676bd6c4e359eed4f238f776eafeaf84 [formerly71a1826611
] Former-commit-id:00e6701ce9
This commit is contained in:
commit
1fce9da432
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.AbstractVizResource;
|
||||
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
|
||||
|
@ -52,11 +50,12 @@ import com.raytheon.uf.viz.ncwf.Activator;
|
|||
*/
|
||||
@XmlAccessorType(XmlAccessType.NONE)
|
||||
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
|
||||
private String name;
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!super.equals(obj)) {
|
||||
|
@ -65,13 +64,13 @@ public class NcwfPolygonResourceData extends AbstractRequestableResourceData {
|
|||
if (obj instanceof NcwfPolygonResourceData == false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
NcwfPolygonResourceData other = (NcwfPolygonResourceData) obj;
|
||||
|
||||
if (other.name.equals(name)) {
|
||||
if (!other.name.equals(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -100,7 +99,5 @@ public class NcwfPolygonResourceData extends AbstractRequestableResourceData {
|
|||
public void setName(String 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.geospatial.MapUtil;
|
||||
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.IGraphicsTarget;
|
||||
import com.raytheon.uf.viz.core.IGraphicsTarget.HorizontalAlignment;
|
||||
|
@ -556,26 +557,18 @@ public class RedbookFrame implements IRenderable {
|
|||
|
||||
if (!symbols) {
|
||||
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) {
|
||||
double yext = y + bounds.getHeight() * yRatio * (top ? 1 : -1);
|
||||
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);
|
||||
dstring.textStyle = TextStyle.BLANKED;
|
||||
}
|
||||
target.drawString(
|
||||
font,
|
||||
s,
|
||||
x,
|
||||
y,
|
||||
0.0,
|
||||
TextStyle.NORMAL,
|
||||
this.redbookResource.getCapability(
|
||||
ColorableCapability.class).getColor(),
|
||||
HorizontalAlignment.LEFT, top ? VerticalAlignment.TOP
|
||||
: VerticalAlignment.BOTTOM, null);
|
||||
target.drawStrings(dstring);
|
||||
return bounds.getWidth() * xRatio;
|
||||
} else {
|
||||
double width = s.length() * 12 * xRatio * magnification;
|
||||
|
|
|
@ -78,25 +78,17 @@ public class AzimuthRangeMapProjection extends ObliqueStereographic {
|
|||
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
|
||||
protected Point2D transformNormalized(double lon, double lat, Point2D dest)
|
||||
throws ProjectionException {
|
||||
Point2D tmp = new Point2D.Double();
|
||||
super.transformNormalized(lon, lat, tmp);
|
||||
double azimuth = Math.toDegrees(Math.atan2(tmp.getX(), tmp.getY()));
|
||||
double range = scaleFactor * semiMajor
|
||||
* Math.hypot(tmp.getX(), tmp.getY());
|
||||
double x = tmp.getX();
|
||||
double y = 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) {
|
||||
dest.setLocation(azimuth, range);
|
||||
return dest;
|
||||
|
|
|
@ -106,24 +106,48 @@ public class RadialBinMapProjection extends AzimuthRangeMapProjection {
|
|||
@Override
|
||||
protected Point2D transformNormalized(double lon, double lat, Point2D dest)
|
||||
throws ProjectionException {
|
||||
if (dest == null) {
|
||||
dest = new Point2D.Double();
|
||||
}
|
||||
Point2D tmp = new Point2D.Double();
|
||||
tmp = super.transformNormalized(lon, lat, tmp);
|
||||
double az = tmp.getX();
|
||||
double ran = tmp.getY();
|
||||
// System.out.println(ran);
|
||||
double radial = Double.NaN;
|
||||
double bin = ran / flatBinLength;
|
||||
float nextAngle = normalAngleData[0] + 360;
|
||||
az = normalizeAngle(normalAngleData[0], nextAngle, az);
|
||||
for (int i = normalAngleData.length - 1; i >= 0; i -= 1) {
|
||||
float prevAngle = normalAngleData[i];
|
||||
if (prevAngle <= az && nextAngle > az) {
|
||||
radial = (i) + (az - prevAngle) / (nextAngle - prevAngle);
|
||||
break;
|
||||
}
|
||||
prevAngle = nextAngle;
|
||||
float firstAngle = normalAngleData[0];
|
||||
float lastAngle = normalAngleData[normalAngleData.length - 1];
|
||||
// normalize the range for az
|
||||
while (az < firstAngle) {
|
||||
az += 360;
|
||||
}
|
||||
while (az > firstAngle + 360) {
|
||||
az -= 360;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue