Merge "Omaha #5166: Update logging to use SLF4J:cpgsrv,cwat,ffmp,fssobs,preciprate,qpf,scan,vil,urifilter" into omaha_16.2.2
Former-commit-id: 68be4acc9b14eddabcff32bc07d2e9269121186a
This commit is contained in:
commit
f051eb8708
12 changed files with 210 additions and 156 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Composite Product Generator (CPG) Plug-in
|
||||
Bundle-SymbolicName: com.raytheon.uf.edex.cpgsrv
|
||||
Bundle-Version: 1.12.1174.qualifier
|
||||
Bundle-Version: 1.15.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Require-Bundle: com.raytheon.edex.common,
|
||||
com.raytheon.uf.common.status;bundle-version="1.10.13",
|
||||
|
@ -10,8 +10,8 @@ Require-Bundle: com.raytheon.edex.common,
|
|||
com.raytheon.uf.common.stats;bundle-version="1.0.0",
|
||||
com.raytheon.uf.edex.event;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.event;bundle-version="1.0.0"
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.edex.cpgsrv
|
||||
Import-Package: com.raytheon.uf.common.monitor.cpg,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
|
|
|
@ -22,8 +22,8 @@ package com.raytheon.uf.edex.cpgsrv;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.message.DataURINotificationMessage;
|
||||
|
||||
|
@ -38,8 +38,9 @@ import com.raytheon.uf.common.dataplugin.message.DataURINotificationMessage;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jan 5, 2010 chammack Initial creation
|
||||
* Jan 5, 2010 chammack Initial creation
|
||||
* Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin
|
||||
* Dec 14, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,7 +50,7 @@ import com.raytheon.uf.common.dataplugin.message.DataURINotificationMessage;
|
|||
|
||||
public class CPGDispatcher {
|
||||
|
||||
private Log log = LogFactory.getLog(CPGDispatcher.class);
|
||||
private Logger log = LoggerFactory.getLogger(CPGDispatcher.class);
|
||||
|
||||
private List<CompositeProductGenerator> generatorSet;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ package com.raytheon.uf.edex.cpgsrv;
|
|||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.urifilter.IURIFilter;
|
||||
import com.raytheon.edex.urifilter.URIFilter;
|
||||
|
@ -58,14 +58,15 @@ import com.raytheon.uf.edex.database.plugin.PluginDao;
|
|||
* SOFTWARE HISTORY
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* 02/07/2009 1981 dhladky Initial Creation.
|
||||
* 30NOV2012 1372 dhladky Added statistics.
|
||||
* 02/05/2013 1580 mpduff EventBus refactor.
|
||||
* 02/12/2013 1615 bgonzale Changed ProcessEvent pluginName to dataType.
|
||||
* 02/07/2009 1981 dhladky Initial Creation.
|
||||
* 30NOV2012 1372 dhladky Added statistics.
|
||||
* 02/05/2013 1580 mpduff EventBus refactor.
|
||||
* 02/12/2013 1615 bgonzale Changed ProcessEvent pluginName to dataType.
|
||||
* Feb 15, 2013 1638 mschenke Moved DataURINotificationMessage to uf.common.dataplugin
|
||||
* Apr 17, 2014 2726 rjpeter Updated to send alerts directly to notification route.
|
||||
* Aug 26, 2014 3503 bclement moved initialization to context state processor pre-start method
|
||||
* Sep.09, 2015 4756 dhladky Check for possible null filters indicating bad configurations.
|
||||
* Dec 14, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* @author dhladky
|
||||
|
@ -104,7 +105,7 @@ public abstract class CompositeProductGenerator implements
|
|||
public DataTime productTime = null;
|
||||
|
||||
/** The logger */
|
||||
public final Log logger = LogFactory.getLog(getClass());
|
||||
public final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
/** monitor config **/
|
||||
public MonitorStateConfigurationManager msc = null;
|
||||
|
@ -116,7 +117,7 @@ public abstract class CompositeProductGenerator implements
|
|||
|
||||
/** Allowed interval between filter config errors **/
|
||||
protected static final long ERROR_COUNT_INTERVAL_TIME = TimeUtil.MILLIS_PER_MINUTE * 2;
|
||||
|
||||
|
||||
/** Keeps track of last config error message time */
|
||||
protected long last_error_time = 0l;
|
||||
|
||||
|
@ -222,7 +223,8 @@ public abstract class CompositeProductGenerator implements
|
|||
}
|
||||
} else {
|
||||
long time = System.currentTimeMillis();
|
||||
if (((time - last_error_time) > ERROR_COUNT_INTERVAL_TIME) || last_error_time == 0l) {
|
||||
if (((time - last_error_time) > ERROR_COUNT_INTERVAL_TIME)
|
||||
|| last_error_time == 0l) {
|
||||
last_error_time = time;
|
||||
logger.error(getGeneratorName()
|
||||
+ ": Filter for this generator is null, check configuration!");
|
||||
|
|
|
@ -30,4 +30,4 @@ Import-Package: com.raytheon.edex.urifilter,
|
|||
com.raytheon.uf.common.util,
|
||||
com.raytheon.uf.edex.core,
|
||||
com.raytheon.uf.edex.plugin.scan.common,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
|
|
|
@ -25,7 +25,7 @@ Import-Package: com.raytheon.uf.common.dataplugin.grid,
|
|||
com.raytheon.uf.common.status,
|
||||
com.raytheon.uf.edex.dat.utils,
|
||||
com.raytheon.uf.edex.plugin.scan.common,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.edex.plugin.ffmp,
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.Map.Entry;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.geotools.coverage.grid.GeneralGridEnvelope;
|
||||
import org.geotools.coverage.grid.GridGeometry2D;
|
||||
import org.geotools.coverage.grid.InvalidGridGeometryException;
|
||||
|
@ -47,6 +46,7 @@ import org.opengis.referencing.crs.ProjectedCRS;
|
|||
import org.opengis.referencing.operation.MathTransform;
|
||||
import org.opengis.referencing.operation.MathTransform2D;
|
||||
import org.opengis.referencing.operation.TransformException;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.SourceBin;
|
||||
import com.raytheon.uf.common.dataplugin.ffmp.SourceBinEntry;
|
||||
|
@ -76,7 +76,8 @@ import com.vividsolutions.jts.geom.TopologyException;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 6, 2011 10593 dfriedma Initial creation
|
||||
* May 1, 2013 15684 zhao Add code to handle possible TopologyException
|
||||
* May 1, 2013 15684 zhao Add code to handle possible TopologyException
|
||||
* Dec 14, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -88,61 +89,84 @@ public class RadarSBLGenerator {
|
|||
private enum MappingMethod {
|
||||
BIN_CENTER, ALL_BINS
|
||||
}
|
||||
|
||||
private static final String DEBUG_FILE_NAME_PATTERN = "ffmp/sources/human-readable-%s.txt";
|
||||
|
||||
private static final String CONFIG_FILE_NAME = "ffmp/RadarSBLGenerator.txt";
|
||||
private Log logger;
|
||||
|
||||
private Logger logger;
|
||||
|
||||
private boolean debug;
|
||||
|
||||
private MappingMethod mappingMethod = MappingMethod.BIN_CENTER;
|
||||
|
||||
private PrintStream debugStream;
|
||||
|
||||
|
||||
public RadarSBLGenerator(FFMPConfig config) {
|
||||
logger = config.getGenerator().logger;
|
||||
loadConfiguration();
|
||||
}
|
||||
|
||||
public SourceBinList generate(String sourceId, Set<Long> basinSet, Map<Long, Geometry> basinMap, RadarRecord radarRec) throws InvalidGridGeometryException, FactoryException, MismatchedDimensionException, TransformException {
|
||||
|
||||
public SourceBinList generate(String sourceId, Set<Long> basinSet,
|
||||
Map<Long, Geometry> basinMap, RadarRecord radarRec)
|
||||
throws InvalidGridGeometryException, FactoryException,
|
||||
MismatchedDimensionException, TransformException {
|
||||
SourceBinList result = null;
|
||||
logger.info(String.format("RadarSBLGenerator: Using %s method", mappingMethod));
|
||||
logger.info(String.format("RadarSBLGenerator: Using %s method",
|
||||
mappingMethod));
|
||||
if (debug)
|
||||
debugStream = getDebugStream(sourceId);
|
||||
try {
|
||||
long t0 = System.currentTimeMillis();
|
||||
if (mappingMethod == MappingMethod.BIN_CENTER)
|
||||
result = generateWithBinCenters(sourceId, basinSet, basinMap, radarRec);
|
||||
result = generateWithBinCenters(sourceId, basinSet, basinMap,
|
||||
radarRec);
|
||||
else if (mappingMethod == MappingMethod.ALL_BINS)
|
||||
result = generateWithAllBins(sourceId, basinSet, basinMap, radarRec);
|
||||
result = generateWithAllBins(sourceId, basinSet, basinMap,
|
||||
radarRec);
|
||||
else
|
||||
return null;
|
||||
long t = System.currentTimeMillis();
|
||||
logger.info(String.format("RadarSBLGenerator: source %s, %s: %1.1f seconds", sourceId, mappingMethod,
|
||||
(double) (t-t0) / 1000));
|
||||
logger.info(String.format(
|
||||
"RadarSBLGenerator: source %s, %s: %1.1f seconds",
|
||||
sourceId, mappingMethod, (double) (t - t0) / 1000));
|
||||
} finally {
|
||||
if (debugStream != null)
|
||||
debugStream.close();
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private SourceBinList generateWithBinCenters(String sourceId, Set<Long> basinSet, Map<Long, Geometry> basinMap, RadarRecord radarRec) throws InvalidGridGeometryException, FactoryException, MismatchedDimensionException, TransformException {
|
||||
|
||||
private SourceBinList generateWithBinCenters(String sourceId,
|
||||
Set<Long> basinSet, Map<Long, Geometry> basinMap,
|
||||
RadarRecord radarRec) throws InvalidGridGeometryException,
|
||||
FactoryException, MismatchedDimensionException, TransformException {
|
||||
SourceBinList sbl = new SourceBinList(sourceId);
|
||||
|
||||
Map<Long, Geometry> xformedBasinMap = new HashMap<Long, Geometry>(basinSet.size());
|
||||
|
||||
MathTransform mt = CRSCache.getInstance().getTransformFromLatLon(radarRec.getCRS());
|
||||
MathTransform mtToLL = CRSCache.getInstance().getTransformToLatLon(radarRec.getCRS());
|
||||
|
||||
int searchGridLen = Math.max(1, (int) (Math.sqrt(basinSet.size()) + 0.5));
|
||||
GridGeometry2D searchGridGeometry = getSearchGridGeometry(radarRec, searchGridLen);
|
||||
ArrayList<Long>[] searchGrid = new ArrayList[searchGridLen * searchGridLen];
|
||||
|
||||
Map<Long, Geometry> xformedBasinMap = new HashMap<Long, Geometry>(
|
||||
basinSet.size());
|
||||
|
||||
MathTransform mt = CRSCache.getInstance().getTransformFromLatLon(
|
||||
radarRec.getCRS());
|
||||
MathTransform mtToLL = CRSCache.getInstance().getTransformToLatLon(
|
||||
radarRec.getCRS());
|
||||
|
||||
int searchGridLen = Math.max(1,
|
||||
(int) (Math.sqrt(basinSet.size()) + 0.5));
|
||||
GridGeometry2D searchGridGeometry = getSearchGridGeometry(radarRec,
|
||||
searchGridLen);
|
||||
ArrayList<Long>[] searchGrid = new ArrayList[searchGridLen
|
||||
* searchGridLen];
|
||||
for (int i = 0; i < searchGrid.length; i++)
|
||||
searchGrid[i] = new ArrayList<Long>(4);
|
||||
|
||||
HashMap<Long,ArrayList<Short>> rblMap = null;
|
||||
|
||||
HashMap<Long, ArrayList<Short>> rblMap = null;
|
||||
if (debugStream != null)
|
||||
rblMap = new HashMap<Long, ArrayList<Short>>();
|
||||
|
||||
MathTransform2D w2g = searchGridGeometry.getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
|
||||
MathTransform2D w2g = searchGridGeometry
|
||||
.getCRSToGrid2D(PixelOrientation.UPPER_LEFT);
|
||||
DirectPosition2D pw = new DirectPosition2D();
|
||||
DirectPosition2D pg = new DirectPosition2D();
|
||||
DirectPosition2D pe = new DirectPosition2D();
|
||||
|
@ -157,23 +181,23 @@ public class RadarSBLGenerator {
|
|||
Coordinate[] bbCoords = bb.getCoordinates();
|
||||
pw.x = bbCoords[0].x;
|
||||
pw.y = bbCoords[0].y;
|
||||
w2g.transform((Point2D)pw, pg);
|
||||
w2g.transform((Point2D) pw, pg);
|
||||
int minx = Math.max(0, (int) Math.floor(pg.x));
|
||||
int miny = Math.max(0, (int) Math.floor(pg.y));
|
||||
|
||||
pw.x = bbCoords[2].x;
|
||||
pw.y = bbCoords[2].y;
|
||||
w2g.transform((Point2D)pw, pg);
|
||||
w2g.transform((Point2D) pw, pg);
|
||||
int maxx = Math.min(searchGridLen, (int) Math.floor(pg.x));
|
||||
int maxy = Math.min(searchGridLen, (int) Math.floor(pg.y));
|
||||
|
||||
|
||||
// Grid y-coords are flipped.
|
||||
if (maxy < miny) {
|
||||
int t = maxy;
|
||||
int t = maxy;
|
||||
maxy = miny;
|
||||
miny = t;
|
||||
}
|
||||
|
||||
|
||||
int b = miny * searchGridLen;
|
||||
for (int j = miny; j <= maxy; ++j) {
|
||||
for (int i = minx; i <= maxx; ++i) {
|
||||
|
@ -182,25 +206,28 @@ public class RadarSBLGenerator {
|
|||
b += searchGridLen;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (xformedBasinMap.isEmpty())
|
||||
return sbl;
|
||||
|
||||
HashMap<Long, ArrayList<SourceBinEntry>> sbeMap = new HashMap<Long, ArrayList<SourceBinEntry>>(basinSet.size());
|
||||
|
||||
GeometryFactory gf = xformedBasinMap.values().iterator().next().getFactory();
|
||||
|
||||
double eFactor = Math.cos(Math.toRadians(radarRec.getTrueElevationAngle()));
|
||||
|
||||
HashMap<Long, ArrayList<SourceBinEntry>> sbeMap = new HashMap<Long, ArrayList<SourceBinEntry>>(
|
||||
basinSet.size());
|
||||
|
||||
GeometryFactory gf = xformedBasinMap.values().iterator().next()
|
||||
.getFactory();
|
||||
|
||||
double eFactor = Math.cos(Math.toRadians(radarRec
|
||||
.getTrueElevationAngle()));
|
||||
double[] binSizes = new double[radarRec.getNumBins()];
|
||||
double cc = Math.PI / 180 / 2;
|
||||
double r0 = 0;
|
||||
for (int ib = 0; ib < radarRec.getNumBins(); ++ib) {
|
||||
double r1 = (ib + 1) * radarRec.getGateResolution() * eFactor;
|
||||
binSizes[ib] = cc * (r1*r1 - r0*r0);
|
||||
binSizes[ib] = cc * (r1 * r1 - r0 * r0);
|
||||
r0 = r1;
|
||||
}
|
||||
|
||||
//Long lastPfaf = null;
|
||||
// Long lastPfaf = null;
|
||||
Geometry lastBasinGeometry = null;
|
||||
ArrayList<SourceBinEntry> lastSBEL = null;
|
||||
ArrayList<Short> lastRBL = null;
|
||||
|
@ -209,36 +236,39 @@ public class RadarSBLGenerator {
|
|||
double a = (ir + 0.5) * Math.PI / 180; // center of the radial
|
||||
double sin = Math.sin(a);
|
||||
double cos = Math.cos(a);
|
||||
|
||||
|
||||
for (int ib = 0; ib < radarRec.getNumBins(); ++ib) {
|
||||
double r = (ib + 0.5) * radarRec.getGateResolution() * eFactor;
|
||||
pw.x = r * sin; // clockwise from north
|
||||
pw.y = r * cos;
|
||||
cw.x = pw.x;
|
||||
cw.y = pw.y;
|
||||
|
||||
|
||||
Point p = gf.createPoint(cw);
|
||||
if (lastBasinGeometry != null && lastBasinGeometry.contains(p)) {
|
||||
// nothing
|
||||
} else {
|
||||
lastBasinGeometry = null;
|
||||
|
||||
w2g.transform((Point2D)pw, pg);
|
||||
|
||||
w2g.transform((Point2D) pw, pg);
|
||||
int i = (int) pg.x;
|
||||
int j = (int) pg.y;
|
||||
if (i >= 0 && i < searchGridLen && j >= 0 && j < searchGridLen) {
|
||||
if (i >= 0 && i < searchGridLen && j >= 0
|
||||
&& j < searchGridLen) {
|
||||
for (Long pfaf : searchGrid[j * searchGridLen + i]) {
|
||||
Geometry geom = xformedBasinMap.get(pfaf);
|
||||
//DR15684
|
||||
// DR15684
|
||||
boolean geomContainsPointP = false;
|
||||
try {
|
||||
geomContainsPointP = geom.contains(p);
|
||||
geomContainsPointP = geom.contains(p);
|
||||
} catch (TopologyException e) {
|
||||
logger.warn(String.format("RadarSBLGenerator: caught a TopologyException: %s", e.getMessage()));
|
||||
throw e;
|
||||
logger.warn(String
|
||||
.format("RadarSBLGenerator: caught a TopologyException: %s",
|
||||
e.getMessage()));
|
||||
throw e;
|
||||
}
|
||||
if (geomContainsPointP) {
|
||||
//lastPfaf = pfaf;
|
||||
// lastPfaf = pfaf;
|
||||
lastBasinGeometry = geom;
|
||||
lastSBEL = sbeMap.get(pfaf);
|
||||
if (lastSBEL == null) {
|
||||
|
@ -257,7 +287,7 @@ public class RadarSBLGenerator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (lastBasinGeometry != null) {
|
||||
SourceBinEntry sbe = new SourceBinEntry();
|
||||
mtToLL.transform(pw, pe);
|
||||
|
@ -271,7 +301,7 @@ public class RadarSBLGenerator {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Assign a bin to any basins that were missed above
|
||||
for (Long key : basinSet) {
|
||||
ArrayList<SourceBinEntry> sbel = sbeMap.get(key);
|
||||
|
@ -279,26 +309,26 @@ public class RadarSBLGenerator {
|
|||
if (sbel == null && (geom = basinMap.get(key)) != null) {
|
||||
sbel = new ArrayList<SourceBinEntry>();
|
||||
sbeMap.put(key, sbel);
|
||||
|
||||
|
||||
SourceBinEntry sbe = new SourceBinEntry();
|
||||
sbe.coor = new Coordinate(geom.getCentroid().getCoordinate());
|
||||
sbe.area = 1;
|
||||
sbel.add(sbe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (Entry<Long, ArrayList<SourceBinEntry>> entry : sbeMap.entrySet()) {
|
||||
sbl.addBin(entry.getKey(), new SourceBin(entry.getValue()));
|
||||
}
|
||||
|
||||
if (debugStream != null) {
|
||||
|
||||
if (debugStream != null) {
|
||||
PrintStream dbg = debugStream;
|
||||
for (Entry<Long, ArrayList<Short>> entry : rblMap.entrySet()) {
|
||||
dbg.format("%012d : ", entry.getKey());
|
||||
int lrp = -1;
|
||||
ArrayList<Short> a = entry.getValue();
|
||||
ArrayList<SourceBinEntry> sbel = sbeMap.get(entry.getKey());
|
||||
for (int i = 0; i < a.size(); ) {
|
||||
for (int i = 0; i < a.size();) {
|
||||
int ir = a.get(i++);
|
||||
int ib = a.get(i++);
|
||||
if (lrp != ir) {
|
||||
|
@ -318,38 +348,45 @@ public class RadarSBLGenerator {
|
|||
dbg.print('\n');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return sbl;
|
||||
}
|
||||
|
||||
private GridGeometry2D getSearchGridGeometry(RadarRecord radarRec, int gridLen) {
|
||||
private GridGeometry2D getSearchGridGeometry(RadarRecord radarRec,
|
||||
int gridLen) {
|
||||
ProjectedCRS crs = radarRec.getCRS();
|
||||
GeneralEnvelope generalEnvelope = new GeneralEnvelope(2);
|
||||
generalEnvelope.setCoordinateReferenceSystem(crs);
|
||||
|
||||
double range = radarRec.getGateResolution()
|
||||
* radarRec.getNumBins()
|
||||
double range = radarRec.getGateResolution() * radarRec.getNumBins()
|
||||
* Math.cos(Math.toRadians(radarRec.getTrueElevationAngle()));
|
||||
|
||||
generalEnvelope.setRange(0, -range, range);
|
||||
generalEnvelope.setRange(1, -range, range);
|
||||
|
||||
GridGeometry2D searchGridGeometry = new GridGeometry2D(new GeneralGridEnvelope(
|
||||
new int[] { 0, 0 }, new int[] { gridLen, gridLen }, false), generalEnvelope);
|
||||
GridGeometry2D searchGridGeometry = new GridGeometry2D(
|
||||
new GeneralGridEnvelope(new int[] { 0, 0 }, new int[] {
|
||||
gridLen, gridLen }, false), generalEnvelope);
|
||||
return searchGridGeometry;
|
||||
}
|
||||
|
||||
private SourceBinList generateWithAllBins(String sourceId, Set<Long> basinSet, Map<Long, Geometry> basinMap, RadarRecord radarRec) throws InvalidGridGeometryException, FactoryException, MismatchedDimensionException, TransformException {
|
||||
|
||||
private SourceBinList generateWithAllBins(String sourceId,
|
||||
Set<Long> basinSet, Map<Long, Geometry> basinMap,
|
||||
RadarRecord radarRec) throws InvalidGridGeometryException,
|
||||
FactoryException, MismatchedDimensionException, TransformException {
|
||||
SourceBinList sbl = new SourceBinList(sourceId);
|
||||
int nRadials = radarRec.getNumRadials();
|
||||
int nBins = radarRec.getNumBins();
|
||||
|
||||
MathTransform mt = CRSCache.getInstance().getTransformFromLatLon(radarRec.getCRS());
|
||||
MathTransform mtToLL = CRSCache.getInstance().getTransformToLatLon(radarRec.getCRS());
|
||||
|
||||
double eFactor = Math.cos(Math.toRadians(radarRec.getTrueElevationAngle()));
|
||||
|
||||
GeometryFactory gf = new GeometryFactory(); //.values().iterator().next().getFactory();
|
||||
|
||||
MathTransform mt = CRSCache.getInstance().getTransformFromLatLon(
|
||||
radarRec.getCRS());
|
||||
MathTransform mtToLL = CRSCache.getInstance().getTransformToLatLon(
|
||||
radarRec.getCRS());
|
||||
|
||||
double eFactor = Math.cos(Math.toRadians(radarRec
|
||||
.getTrueElevationAngle()));
|
||||
|
||||
GeometryFactory gf = new GeometryFactory(); // .values().iterator().next().getFactory();
|
||||
|
||||
Geometry[] radarBinGeometries = new Geometry[nRadials * nBins];
|
||||
Coordinate[] radarBinLLs = new Coordinate[nRadials * nBins];
|
||||
|
@ -362,14 +399,14 @@ public class RadarSBLGenerator {
|
|||
double a = ir * Math.PI / 180;
|
||||
double sin = Math.sin(a);
|
||||
double cos = Math.cos(a);
|
||||
|
||||
|
||||
for (int ib = 0; ib <= nBins; ++ib) {
|
||||
double r = ib * radarRec.getGateResolution() * eFactor;
|
||||
radialCoords1[ib] = new Coordinate(
|
||||
r * sin, // clockwise from north
|
||||
radialCoords1[ib] = new Coordinate(r * sin, // clockwise from
|
||||
// north
|
||||
r * cos);
|
||||
}
|
||||
|
||||
|
||||
if (ir > 0) {
|
||||
double am = (ir + 0.5) * Math.PI / 180;
|
||||
double sinm = Math.sin(am);
|
||||
|
@ -382,13 +419,14 @@ public class RadarSBLGenerator {
|
|||
coors[3] = radialCoords1[ib - 1];
|
||||
// make a closed object
|
||||
coors[4] = coors[0];
|
||||
|
||||
|
||||
LinearRing lr = gf.createLinearRing(coors);
|
||||
Polygon poly = gf.createPolygon(lr, null);
|
||||
|
||||
|
||||
int bidx = (ir - 1) * nBins + (ib - 1);
|
||||
radarBinGeometries[bidx] = poly;
|
||||
double rm = (ib + 0.5) * radarRec.getGateResolution() * eFactor;
|
||||
double rm = (ib + 0.5) * radarRec.getGateResolution()
|
||||
* eFactor;
|
||||
pw.x = rm * sinm;
|
||||
pw.y = rm * cosm;
|
||||
mtToLL.transform(pw, pe);
|
||||
|
@ -396,20 +434,20 @@ public class RadarSBLGenerator {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
tCoords = radialCoords0;
|
||||
radialCoords0 = radialCoords1;
|
||||
radialCoords1 = tCoords;
|
||||
}
|
||||
|
||||
|
||||
int[] polarRange = new int[4]; // bin0,rad0, b1,r1, inclusive
|
||||
int[] binCoords = new int[80]; // b1,r1, b2,r2 ...
|
||||
Coordinate[] polarCoords = new Coordinate[4];
|
||||
for (int i = 0; i < 4; ++i)
|
||||
polarCoords[i] = new Coordinate();
|
||||
|
||||
|
||||
PrintStream dbg = debugStream;
|
||||
|
||||
|
||||
for (Long key : basinSet) {
|
||||
Geometry basinGeom = basinMap.get(key);
|
||||
if (basinGeom == null)
|
||||
|
@ -418,22 +456,25 @@ public class RadarSBLGenerator {
|
|||
Geometry xformedGeom = JTS.transform(basinGeom, mt);
|
||||
Coordinate[] shell;
|
||||
if (xformedGeom instanceof Polygon)
|
||||
shell = ((Polygon) xformedGeom).getExteriorRing().getCoordinates();
|
||||
shell = ((Polygon) xformedGeom).getExteriorRing()
|
||||
.getCoordinates();
|
||||
else
|
||||
shell = xformedGeom.convexHull().getCoordinates();
|
||||
|
||||
|
||||
if (binCoords.length < shell.length * 2)
|
||||
binCoords = new int[shell.length * 2];
|
||||
for (int i = 0; i < shell.length; ++i) {
|
||||
double x = shell[i].x;
|
||||
double y = shell[i].y;
|
||||
binCoords[i * 2] = (int) (Math.sqrt(x*x + y*y) / (radarRec.getGateResolution() * eFactor));
|
||||
binCoords[i * 2] = (int) (Math.sqrt(x * x + y * y) / (radarRec
|
||||
.getGateResolution() * eFactor));
|
||||
double atan = Math.atan2(x, y); // clockwise from north
|
||||
/* Make the angle positive so that truncating results in
|
||||
/*
|
||||
* Make the angle positive so that truncating results in
|
||||
* consistent rounding for all angles.
|
||||
*/
|
||||
if (atan < 0)
|
||||
atan += 2 * Math.PI;
|
||||
atan += 2 * Math.PI;
|
||||
int b = (int) (atan * 180 / Math.PI);
|
||||
binCoords[i * 2 + 1] = b;
|
||||
}
|
||||
|
@ -442,11 +483,11 @@ public class RadarSBLGenerator {
|
|||
|
||||
ArrayList<SourceBinEntry> sbel = new ArrayList<SourceBinEntry>();
|
||||
double basinArea = xformedGeom.getArea();
|
||||
|
||||
|
||||
if (dbg != null)
|
||||
dbg.format("%012d : ", key);
|
||||
int lrp = -1;
|
||||
|
||||
|
||||
int ir = polarRange[1] - 1;
|
||||
do {
|
||||
++ir;
|
||||
|
@ -455,13 +496,14 @@ public class RadarSBLGenerator {
|
|||
for (int ib = polarRange[0]; ib <= polarRange[2]; ++ib) {
|
||||
int bidx = ir * nBins + ib;
|
||||
|
||||
Geometry intersectGeo = xformedGeom.intersection(radarBinGeometries[bidx]);
|
||||
if (! intersectGeo.isEmpty()) {
|
||||
Geometry intersectGeo = xformedGeom
|
||||
.intersection(radarBinGeometries[bidx]);
|
||||
if (!intersectGeo.isEmpty()) {
|
||||
SourceBinEntry sbe = new SourceBinEntry();
|
||||
sbe.coor = new Coordinate(radarBinLLs[bidx]);
|
||||
sbe.area = intersectGeo.getArea() / basinArea;;
|
||||
sbe.area = intersectGeo.getArea() / basinArea;
|
||||
sbel.add(sbe);
|
||||
|
||||
|
||||
if (dbg != null) {
|
||||
if (lrp != ir) {
|
||||
if (lrp != -1)
|
||||
|
@ -475,7 +517,7 @@ public class RadarSBLGenerator {
|
|||
}
|
||||
}
|
||||
} while (ir != polarRange[3]);
|
||||
|
||||
|
||||
if (dbg != null) {
|
||||
if (lrp != -1)
|
||||
dbg.print(") ");
|
||||
|
@ -484,40 +526,47 @@ public class RadarSBLGenerator {
|
|||
dbg.format("%1.2f ", sbe.area);
|
||||
dbg.print('\n');
|
||||
}
|
||||
|
||||
|
||||
sbl.addBin(key, new SourceBin(sbel));
|
||||
}
|
||||
|
||||
|
||||
return sbl;
|
||||
}
|
||||
|
||||
private int[] a = new int[40];
|
||||
|
||||
private int[] b = new int[40];
|
||||
|
||||
/** Given a list of radar bin coordinates, return the range of radials/bins that
|
||||
* contains all of them.
|
||||
* @param binCoords Radar bin coordinates radial0, bin0, radial1, bin1, ...
|
||||
* @param nCoords The number of (radial,bin) pairs in binCoords
|
||||
* @param polarRange Upon return, contains startRadial, startBin, endRadial, endBin.
|
||||
* The values are inclusive. startBin may be greater than endBin, indicating
|
||||
* wrap-around from 359 to 0.
|
||||
|
||||
/**
|
||||
* Given a list of radar bin coordinates, return the range of radials/bins
|
||||
* that contains all of them.
|
||||
*
|
||||
* @param binCoords
|
||||
* Radar bin coordinates radial0, bin0, radial1, bin1, ...
|
||||
* @param nCoords
|
||||
* The number of (radial,bin) pairs in binCoords
|
||||
* @param polarRange
|
||||
* Upon return, contains startRadial, startBin, endRadial,
|
||||
* endBin. The values are inclusive. startBin may be greater than
|
||||
* endBin, indicating wrap-around from 359 to 0.
|
||||
*/
|
||||
private void calcPolarRange(int[] binCoords, int nCoords, int[] polarRange) {
|
||||
/* Implementation: If all points fit within a less-than-180-degree
|
||||
* sector, we only need to examine bins within the sector (further
|
||||
* bounded by the min and max range.) Otherwise, we must examine all
|
||||
/*
|
||||
* Implementation: If all points fit within a less-than-180-degree
|
||||
* sector, we only need to examine bins within the sector (further
|
||||
* bounded by the min and max range.) Otherwise, we must examine all
|
||||
* bins within the circle defined by the max range.
|
||||
*
|
||||
* Actual test is "less than 179 degrees" to be safe.
|
||||
*/
|
||||
|
||||
|
||||
if (a.length < nCoords) {
|
||||
a = new int[nCoords];
|
||||
b = new int[nCoords];
|
||||
}
|
||||
int minr = binCoords[0];
|
||||
int maxr = minr;
|
||||
|
||||
|
||||
int nc2 = nCoords * 2;
|
||||
for (int i = 2; i < nc2; i += 2) {
|
||||
minr = Math.min(minr, binCoords[i]);
|
||||
|
@ -525,26 +574,26 @@ public class RadarSBLGenerator {
|
|||
}
|
||||
polarRange[0] = minr;
|
||||
polarRange[2] = maxr;
|
||||
|
||||
|
||||
int j = 0;
|
||||
for (int i = 1; i < nc2; i += 2)
|
||||
a[j++] = binCoords[i];
|
||||
Arrays.sort(a, 0, nCoords);
|
||||
|
||||
/* If there is a greater-than-179-degree gap between two points,
|
||||
* try scanning from the other side.
|
||||
/*
|
||||
* If there is a greater-than-179-degree gap between two points, try
|
||||
* scanning from the other side.
|
||||
*/
|
||||
int trys = 0;
|
||||
Ltry:
|
||||
while (true) {
|
||||
Ltry: while (true) {
|
||||
for (int i = 1; i < nCoords; ++i) {
|
||||
if (a[i] - a[i-1] >= 179) {
|
||||
if (a[i] - a[i - 1] >= 179) {
|
||||
if (trys == 0) {
|
||||
for (j = i; j < nCoords; ++j)
|
||||
a[j] = a[j] - 360;
|
||||
System.arraycopy(a, 0, b, nCoords - i, i);
|
||||
System.arraycopy(a, i, b, 0, nCoords - i);
|
||||
System.arraycopy(b, 0, a, 0, nCoords);
|
||||
System.arraycopy(b, 0, a, 0, nCoords);
|
||||
++trys;
|
||||
continue Ltry;
|
||||
} else {
|
||||
|
@ -557,10 +606,10 @@ public class RadarSBLGenerator {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
int an = a[nCoords - 1];
|
||||
if (an - a[0] < 179) {
|
||||
polarRange[1] = a[0] >= 0 ? a[0] : a[0] + 360;
|
||||
polarRange[1] = a[0] >= 0 ? a[0] : a[0] + 360;
|
||||
polarRange[3] = an >= 0 ? an : an + 360;
|
||||
} else {
|
||||
polarRange[0] = 0;
|
||||
|
@ -574,11 +623,11 @@ public class RadarSBLGenerator {
|
|||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
|
||||
LocalizationFile lf = pm.getLocalizationFile(lc,
|
||||
LocalizationFile lf = pm.getLocalizationFile(lc,
|
||||
String.format(DEBUG_FILE_NAME_PATTERN, sourceId));
|
||||
|
||||
|
||||
File file = lf.getFile();
|
||||
|
||||
|
||||
try {
|
||||
logger.info(String.format("Saving human-readable bin list to %s",
|
||||
lf));
|
||||
|
@ -588,19 +637,19 @@ public class RadarSBLGenerator {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void loadConfiguration() {
|
||||
IPathManager pm = PathManagerFactory.getPathManager();
|
||||
LocalizationContext lc = pm.getContext(LocalizationType.COMMON_STATIC,
|
||||
LocalizationLevel.SITE);
|
||||
|
||||
LocalizationFile lf = pm.getLocalizationFile(lc, CONFIG_FILE_NAME);
|
||||
|
||||
|
||||
File file = lf.getFile();
|
||||
if (! file.exists())
|
||||
if (!file.exists())
|
||||
return;
|
||||
Properties p = new Properties();
|
||||
|
||||
|
||||
try {
|
||||
InputStream inStream = new FileInputStream(file);
|
||||
try {
|
||||
|
@ -611,7 +660,7 @@ public class RadarSBLGenerator {
|
|||
} catch (IOException e) {
|
||||
logger.error(String.format("%s: %s", file, e.getMessage()));
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
debug = Boolean.parseBoolean(p.getProperty("debug"));
|
||||
} catch (Exception e) {
|
||||
|
@ -623,5 +672,5 @@ public class RadarSBLGenerator {
|
|||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -25,4 +25,4 @@ Import-Package: com.raytheon.uf.common.monitor.config,
|
|||
com.raytheon.uf.edex.pointdata,
|
||||
javax.measure.converter,
|
||||
javax.measure.unit,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
**/
|
||||
package com.raytheon.uf.edex.plugin.fssobs.common;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.raytheon.edex.urifilter.URIGenerateMessage;
|
||||
import com.raytheon.uf.common.dataplugin.PluginException;
|
||||
|
@ -46,6 +46,7 @@ import com.raytheon.uf.edex.plugin.fssobs.FSSObsUtils;
|
|||
* Aug 30, 2013 2298 rjpeter Make getPluginName abstract
|
||||
* Sep 04, 2014 3220 skorolev Removed cwa and monitorUse from data set.
|
||||
* Sep 18, 2015 3873 skorolev Removed identical constant definitions.
|
||||
* Dec 14, 2015 5166 kbisanz Update logging to use SLF4J
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -68,7 +69,8 @@ public class FSSObsConfig {
|
|||
private FSSObsRecord tableRow;
|
||||
|
||||
/** The logger */
|
||||
protected transient final Log logger = LogFactory.getLog(getClass());
|
||||
protected transient final Logger logger = LoggerFactory
|
||||
.getLogger(getClass());
|
||||
|
||||
public FSSObsConfig(URIGenerateMessage genMessage, FSSObsGenerator generator)
|
||||
throws Exception {
|
||||
|
|
|
@ -2,9 +2,9 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Preciprate Plug-in
|
||||
Bundle-SymbolicName: com.raytheon.uf.edex.plugin.preciprate
|
||||
Bundle-Version: 1.12.1174.qualifier
|
||||
Bundle-Version: 1.15.0.qualifier
|
||||
Bundle-Vendor: RAYTHEON
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: com.raytheon.uf.edex.cpgsrv;bundle-version="1.11.7";resolution:=optional,
|
||||
com.raytheon.edex.common;bundle-version="1.11.7",
|
||||
com.raytheon.uf.common.monitor;bundle-version="1.11.7",
|
||||
|
@ -15,4 +15,4 @@ Require-Bundle: com.raytheon.uf.edex.cpgsrv;bundle-version="1.11.7";resolution:=
|
|||
com.raytheon.uf.common.dataplugin.radar;bundle-version="1.0.0",
|
||||
com.raytheon.uf.common.localization;bundle-version="1.12.1174"
|
||||
Import-Package: com.raytheon.uf.edex.plugin.scan.common,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
|
|
|
@ -23,7 +23,7 @@ Import-Package: com.raytheon.edex.urifilter,
|
|||
com.raytheon.uf.common.dataplugin.grid,
|
||||
com.raytheon.uf.edex.core,
|
||||
com.raytheon.uf.edex.plugin.scan.common,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Export-Package: com.raytheon.uf.edex.plugin.qpf,
|
||||
com.raytheon.uf.edex.plugin.qpf.common
|
||||
|
|
|
@ -25,4 +25,4 @@ Export-Package: com.raytheon.uf.edex.plugin.scan,
|
|||
Import-Package: com.raytheon.uf.edex.menus,
|
||||
javax.measure.converter,
|
||||
javax.measure.unit,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
|
|
|
@ -20,7 +20,7 @@ Import-Package: com.raytheon.edex.urifilter,
|
|||
com.raytheon.uf.common.time,
|
||||
com.raytheon.uf.common.util.registry,
|
||||
com.raytheon.uf.edex.plugin.scan.common,
|
||||
org.apache.commons.logging
|
||||
org.slf4j
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.raytheon.uf.edex.plugin.vil,
|
||||
|
|
Loading…
Add table
Reference in a new issue