Merge branch 'development' of ssh://lightning.omaha.us.ray.com:29418/AWIPS2_baseline into development
Conflicts: cave/com.raytheon.viz.texteditor/src/com/raytheon/viz/texteditor/dialogs/TextEditorDialog.java Former-commit-id:8a574a91cf
[formerly f3d80ac86697be7042fa20d52e3116e72b77f2a6] Former-commit-id:0bb64a8706
This commit is contained in:
commit
2a9f8eaa4d
16 changed files with 776 additions and 364 deletions
|
@ -257,7 +257,7 @@ public class AfosBrowserDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void shellClosed(ShellEvent event) {
|
||||
// Block the disposal of this dialog.
|
||||
AfosBrowserDlg.this.shell.setVisible(false);
|
||||
AfosBrowserDlg.this.hide();
|
||||
isAfosActive = false;
|
||||
event.doit = false;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ public class AfosBrowserDlg extends CaveSWTDialog implements
|
|||
.getAfosCommand(currentAfosCommand));
|
||||
|
||||
setReturnValue(false);
|
||||
shell.setVisible(false);
|
||||
hide();
|
||||
isAfosActive = false;
|
||||
}
|
||||
});
|
||||
|
@ -569,19 +569,15 @@ public class AfosBrowserDlg extends CaveSWTDialog implements
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
setReturnValue(false);
|
||||
shell.setVisible(false);
|
||||
hide();
|
||||
isAfosActive = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
if (shell.isVisible() == false) {
|
||||
shell.setVisible(true);
|
||||
isAfosActive = true;
|
||||
}
|
||||
|
||||
shell.setActive();
|
||||
bringToTop();
|
||||
isAfosActive = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -301,6 +301,7 @@ import com.raytheon.viz.ui.dialogs.SWTMessageBox;
|
|||
* 10OCT2012 1229 rferrel Changed AwipsBrowserDlg to non-blocking.
|
||||
* 12OCT2012 15418 D.Friedman Do not store product when sending in operational mode.
|
||||
* Do not use changed BBB from OUPResponse.
|
||||
* 17OCT2012 1229 rferrel Changes for non-blocking SWTMessageBox.
|
||||
* </pre>
|
||||
*
|
||||
* @author lvenable
|
||||
|
@ -1009,6 +1010,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
|
||||
private AfosBrowserDlg afosBrowser;
|
||||
|
||||
private boolean displayAfosBrowser = false;
|
||||
|
||||
private boolean cancelDoClose = false;
|
||||
|
||||
/**
|
||||
* Where the last modified text event started.
|
||||
*/
|
||||
|
@ -1240,8 +1245,10 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
shell.addShellListener(new ShellAdapter() {
|
||||
@Override
|
||||
public void shellClosed(ShellEvent event) {
|
||||
if (!cancelEditor(true)) {
|
||||
shell.setVisible(true);
|
||||
if (inEditMode) {
|
||||
cancelDoClose = true;
|
||||
cancelEditor(true);
|
||||
bringToTop();
|
||||
event.doit = false;
|
||||
return;
|
||||
}
|
||||
|
@ -1260,12 +1267,20 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
return;
|
||||
}
|
||||
|
||||
if (afosBrowser != null
|
||||
&& afosBrowser.isAfosBrowserActive()) {
|
||||
afosBrowser.hide();
|
||||
displayAfosBrowser = true;
|
||||
} else {
|
||||
displayAfosBrowser = false;
|
||||
}
|
||||
|
||||
if (browser != null) {
|
||||
browser.getShell().setVisible(false);
|
||||
browser.hide();
|
||||
}
|
||||
|
||||
// Block the disposal of this dialog.
|
||||
shell.setVisible(false);
|
||||
hide();
|
||||
event.doit = false;
|
||||
}
|
||||
});
|
||||
|
@ -1274,7 +1289,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
@Override
|
||||
public void widgetDisposed(DisposeEvent e) {
|
||||
inEditMode = false;
|
||||
shell.dispose();
|
||||
close();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1535,9 +1550,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
@Override
|
||||
public void widgetSelected(SelectionEvent event) {
|
||||
if (disposeOnExit == true) {
|
||||
shell.dispose();
|
||||
close();
|
||||
} else {
|
||||
shell.setVisible(false);
|
||||
hide();
|
||||
}
|
||||
inEditMode = false;
|
||||
}
|
||||
|
@ -3797,7 +3812,7 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
* true if prompting desired
|
||||
*/
|
||||
private boolean cancelEditor(boolean prompt) {
|
||||
if (shell.isDisposed()) {
|
||||
if (isDisposed()) {
|
||||
// If the shell has been disposed due to closing of a parent,
|
||||
// do not follow the normal cancel procedure.
|
||||
return false;
|
||||
|
@ -3807,11 +3822,30 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
SWTMessageBox mb = new SWTMessageBox(shell, "Cancel Editor",
|
||||
"Any unsaved changes will be lost. Cancel anyway?",
|
||||
SWT.ICON_QUESTION | SWT.YES | SWT.NO | SWT.ICON_WARNING);
|
||||
Object rval = mb.open();
|
||||
if (!(rval instanceof Integer) || ((Integer) rval) == SWT.NO) {
|
||||
return false;
|
||||
}
|
||||
mb.setCloseCallback(new ICloseCallback() {
|
||||
|
||||
@Override
|
||||
public void dialogClosed(Object returnValue) {
|
||||
if (returnValue instanceof Integer) {
|
||||
int rval = (Integer) returnValue;
|
||||
if (rval == SWT.YES) {
|
||||
doCancelEditor();
|
||||
if (cancelDoClose) {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
cancelDoClose = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
mb.open();
|
||||
return false;
|
||||
}
|
||||
return doCancelEditor();
|
||||
}
|
||||
|
||||
private boolean doCancelEditor() {
|
||||
|
||||
stopAutoSave();
|
||||
|
||||
|
@ -4356,12 +4390,12 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
* Display the AFOS Browser dialog.
|
||||
*/
|
||||
private void displayAfosBrowser() {
|
||||
if (afosBrowser == null || afosBrowser.isDisposed() == true) {
|
||||
if (mustCreate(afosBrowser)) {
|
||||
afosBrowser = new AfosBrowserDlg(shell, shell.getText(), this,
|
||||
token);
|
||||
afosBrowser.open();
|
||||
} else {
|
||||
afosBrowser.showDialog();
|
||||
afosBrowser.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4374,17 +4408,13 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
open();
|
||||
}
|
||||
|
||||
if (shell.isVisible() == false) {
|
||||
shell.setVisible(true);
|
||||
}
|
||||
|
||||
shell.setActive();
|
||||
if (afosBrowser != null && afosBrowser.isAfosBrowserActive()) {
|
||||
bringToTop();
|
||||
if (displayAfosBrowser) {
|
||||
afosBrowser.showDialog();
|
||||
}
|
||||
|
||||
if (browser != null) {
|
||||
browser.getShell().setVisible(true);
|
||||
browser.bringToTop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4393,9 +4423,9 @@ public class TextEditorDialog extends CaveSWTDialog implements VerifyListener,
|
|||
return;
|
||||
}
|
||||
|
||||
if (shell != null && shell.isVisible() == true) {
|
||||
shell.setVisible(false);
|
||||
}
|
||||
// Allow the shell listener to clean up other dialogs and then hide the
|
||||
// dialog.
|
||||
close();
|
||||
inEditMode = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ import com.raytheon.viz.ui.dialogs.SetTimeDialog;
|
|||
* Aug 23,2012 #1087 dgilling Allow DRT mode to be engaged
|
||||
* regardless of practice or
|
||||
* operational mode.
|
||||
* Oct 17, 2012 1229 rferrel Changes for non-blocking SetTimeDialog.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -49,9 +50,7 @@ public class ShowTimeDialog extends AbstractHandler {
|
|||
|
||||
@Override
|
||||
public Object execute(ExecutionEvent arg0) throws ExecutionException {
|
||||
if (!SetTimeDialog.getInstance().isOpen()) {
|
||||
SetTimeDialog.getInstance().open();
|
||||
}
|
||||
SetTimeDialog.openDialog();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ import org.eclipse.swt.widgets.Shell;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Apr 7, 2011 lvenable Initial creation
|
||||
* Oct 18, 2012 1229 rferrel Made dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -92,13 +93,15 @@ public class SWTMessageBox extends CaveSWTDialogBase {
|
|||
* @param swtMessageBoxStyle
|
||||
* Style for icon and buttons.
|
||||
*/
|
||||
public SWTMessageBox(Shell parent, String title, String message, int swtMessageBoxStyle) {
|
||||
this(parent, title, message, swtMessageBoxStyle, SWT.PRIMARY_MODAL, false);
|
||||
public SWTMessageBox(Shell parent, String title, String message,
|
||||
int swtMessageBoxStyle) {
|
||||
this(parent, title, message, swtMessageBoxStyle, SWT.PRIMARY_MODAL,
|
||||
false);
|
||||
}
|
||||
|
||||
public SWTMessageBox(Shell parent, String title, String message, int swtMessageBoxStyle, int modalSetting,
|
||||
boolean centerMessage) {
|
||||
super(parent, SWT.DIALOG_TRIM | modalSetting);
|
||||
public SWTMessageBox(Shell parent, String title, String message,
|
||||
int swtMessageBoxStyle, int modalSetting, boolean centerMessage) {
|
||||
super(parent, SWT.DIALOG_TRIM | modalSetting, CAVE.DO_NOT_BLOCK);
|
||||
this.swtMessageBoxStyle = swtMessageBoxStyle;
|
||||
this.message = message;
|
||||
this.centerMessage = centerMessage;
|
||||
|
|
|
@ -53,6 +53,7 @@ import com.raytheon.viz.ui.VizWorkbenchManager;
|
|||
* Dec 03,2007 461 bphillip Added action functionality
|
||||
* May 21, 2008 1122 ebabin Updated to use new StatusBarDisplay.
|
||||
* 09JUL2008 1234 ebabin Updates for color, and display issues.
|
||||
* Oct 17, 2012 1229 rferrel Made dialog non-blocking.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -108,16 +109,18 @@ public class SetTimeDialog extends CaveSWTDialog {
|
|||
|
||||
private static SetTimeDialog instance;
|
||||
|
||||
public static synchronized SetTimeDialog getInstance() {
|
||||
if (instance == null) {
|
||||
/**
|
||||
* This allows only one instance of this dialog to be displayed.
|
||||
*/
|
||||
public static synchronized void openDialog() {
|
||||
if (instance == null || instance.getShell() == null
|
||||
|| instance.isDisposed()) {
|
||||
instance = new SetTimeDialog(VizWorkbenchManager.getInstance()
|
||||
.getCurrentWindow().getShell());
|
||||
instance.open();
|
||||
} else {
|
||||
instance.bringToTop();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public SetTimeDialog(Shell parent) {
|
||||
this(parent, "Set Time");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,19 +131,39 @@ public class SetTimeDialog extends CaveSWTDialog {
|
|||
* @param title
|
||||
* Window title.
|
||||
*/
|
||||
public SetTimeDialog(Shell parent, String title) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT);
|
||||
if (title == null) {
|
||||
title = "Set Time";
|
||||
}
|
||||
setText(title);
|
||||
private SetTimeDialog(Shell parent) {
|
||||
super(parent, SWT.DIALOG_TRIM, CAVE.PERSPECTIVE_INDEPENDENT
|
||||
| CAVE.DO_NOT_BLOCK);
|
||||
setText("Set Time");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#disposed()
|
||||
*/
|
||||
@Override
|
||||
protected synchronized void disposed() {
|
||||
instance = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#constructShellLayout()
|
||||
*/
|
||||
@Override
|
||||
protected Layout constructShellLayout() {
|
||||
return new GridLayout(1, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.raytheon.viz.ui.dialogs.CaveSWTDialogBase#initializeComponents(org
|
||||
* .eclipse.swt.widgets.Shell)
|
||||
*/
|
||||
@Override
|
||||
protected void initializeComponents(Shell shell) {
|
||||
createTopRadioButtons();
|
||||
|
|
|
@ -10,8 +10,14 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import javax.measure.converter.UnitConverter;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.geotools.geometry.jts.JTS;
|
||||
import org.geotools.referencing.GeodeticCalculator;
|
||||
import org.opengis.referencing.operation.MathTransform;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PathcastConfiguration;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
|
@ -21,62 +27,115 @@ import com.raytheon.uf.common.geospatial.SpatialQueryFactory;
|
|||
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.uf.viz.core.maps.rsc.DbMapQueryFactory;
|
||||
import com.raytheon.viz.core.map.GeoUtil;
|
||||
import com.raytheon.viz.warngen.gis.ClosestPoint;
|
||||
import com.raytheon.viz.warngen.gis.ClosestPointComparator;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.Point;
|
||||
|
||||
/**
|
||||
*
|
||||
* TODO Add Description
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* pre-history
|
||||
* Sep 25, 2012 #15425 Qinglu Lin Added getGid().
|
||||
* Sep 25, 2012 #15425 Qinglu Lin Added getGid().
|
||||
* Oct 17, 2012 jsanchez Added pathcast algorithm.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
* @author jsanchez
|
||||
* @version 1.0
|
||||
*/
|
||||
abstract public class AbstractDbSourceDataAdaptor {
|
||||
|
||||
protected Set<String> sortFields = new HashSet<String>(
|
||||
Arrays.asList(new String[] { "distance", "area", "parentArea" }));
|
||||
private static final String transformedKey = "com.raytheon.transformed";
|
||||
|
||||
protected PointSourceConfiguration pointConfig;
|
||||
private static final String GEOM_FIELD = "the_geom";
|
||||
|
||||
protected Set<String> undatabasedSortableFields = new HashSet<String>(
|
||||
Arrays.asList(new String[] {
|
||||
ClosestPointComparator.Sort.DISTANCE.toString(),
|
||||
ClosestPointComparator.Sort.AREA.toString(),
|
||||
ClosestPointComparator.Sort.PARENTAREA.toString() }));
|
||||
|
||||
protected GeodeticCalculator gc = new GeodeticCalculator();
|
||||
|
||||
protected Geometry searchArea;
|
||||
|
||||
protected String localizedSite;
|
||||
|
||||
abstract protected Set<String> createSpatialQueryField();
|
||||
protected SpatialQueryResult[] ptFeatures;
|
||||
|
||||
abstract protected ClosestPoint createClosestPoint(Set<String> ptFields,
|
||||
SpatialQueryResult ptRslt);
|
||||
protected Map<String, RequestConstraint> filter;
|
||||
|
||||
abstract protected Map<String, RequestConstraint> processFilterSubstitution();
|
||||
protected Set<String> ptFields;
|
||||
|
||||
public Collection<ClosestPoint> getData(WarngenConfiguration config,
|
||||
PointSourceConfiguration pointConfig, Geometry searchArea,
|
||||
protected String[] sortBy;
|
||||
|
||||
abstract protected Set<String> createSpatialQueryField(String pointField,
|
||||
String[] sortBy);
|
||||
|
||||
abstract protected ClosestPoint createClosestPoint(String pointField,
|
||||
Set<String> ptFields, SpatialQueryResult ptRslt);
|
||||
|
||||
abstract protected Map<String, RequestConstraint> processFilterSubstitution(
|
||||
Map<String, RequestConstraint> filter);
|
||||
|
||||
public AbstractDbSourceDataAdaptor(
|
||||
PathcastConfiguration pathcastConfiguration,
|
||||
UnitConverter distanceToMeters, Geometry searchArea,
|
||||
String localizedSite) throws VizException {
|
||||
this.pointConfig = pointConfig;
|
||||
this.searchArea = searchArea;
|
||||
this.localizedSite = localizedSite;
|
||||
this.sortBy = pathcastConfiguration.getSortBy();
|
||||
this.searchArea = searchArea;
|
||||
this.ptFields = createSpatialQueryField(
|
||||
pathcastConfiguration.getPointField(), sortBy);
|
||||
this.filter = processFilterSubstitution(pathcastConfiguration
|
||||
.getFilter());
|
||||
this.ptFeatures = spatialQuery(pathcastConfiguration.getPointSource(),
|
||||
null);
|
||||
}
|
||||
|
||||
Map<String, RequestConstraint> filter = processFilterSubstitution();
|
||||
Set<String> ptFields = createSpatialQueryField();
|
||||
List<ClosestPoint> points = null;
|
||||
public AbstractDbSourceDataAdaptor(
|
||||
PointSourceConfiguration pointSourceConfiguration,
|
||||
Geometry searchArea, String localizedSite) throws VizException {
|
||||
this.localizedSite = localizedSite;
|
||||
this.sortBy = pointSourceConfiguration.getSortBy();
|
||||
this.searchArea = searchArea;
|
||||
this.ptFields = createSpatialQueryField(
|
||||
pointSourceConfiguration.getPointField(), sortBy);
|
||||
this.filter = processFilterSubstitution(pointSourceConfiguration
|
||||
.getFilter());
|
||||
this.ptFeatures = spatialQuery(
|
||||
pointSourceConfiguration.getPointSource(), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the maps database depending on the point source set in the
|
||||
* config.
|
||||
*
|
||||
* @param pointSource
|
||||
* @param decimationTolerance
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
private SpatialQueryResult[] spatialQuery(String pointSource,
|
||||
Double decimationTolerance) throws VizException {
|
||||
|
||||
SpatialQueryResult[] ptFeatures = null;
|
||||
long t0 = System.currentTimeMillis();
|
||||
try {
|
||||
long t0 = System.currentTimeMillis();
|
||||
SpatialQueryResult[] ptFeatures = null;
|
||||
Double decimationTolerance = pointConfig
|
||||
.getGeometryDecimationTolerance();
|
||||
String field = "the_geom";
|
||||
|
||||
if (decimationTolerance != null && decimationTolerance > 0) {
|
||||
// find available tolerances
|
||||
List<Double> results = DbMapQueryFactory
|
||||
.getMapQuery(
|
||||
"mapdata."
|
||||
+ pointConfig.getPointSource()
|
||||
.toLowerCase(), field)
|
||||
List<Double> results = DbMapQueryFactory.getMapQuery(
|
||||
"mapdata." + pointSource.toLowerCase(), GEOM_FIELD)
|
||||
.getLevels();
|
||||
Collections.sort(results, Collections.reverseOrder());
|
||||
|
||||
|
@ -99,53 +158,212 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
String suffix = "_"
|
||||
+ StringUtils.replaceChars(
|
||||
df.format(decimationTolerance), '.', '_');
|
||||
ptFeatures = SpatialQueryFactory.create().query(
|
||||
pointConfig.getPointSource(), field + suffix,
|
||||
ptFeatures = SpatialQueryFactory.create().query(pointSource,
|
||||
GEOM_FIELD + suffix,
|
||||
ptFields.toArray(new String[ptFields.size()]),
|
||||
searchArea, filter, SearchMode.INTERSECTS);
|
||||
} else {
|
||||
ptFeatures = SpatialQueryFactory.create().query(
|
||||
pointConfig.getPointSource(),
|
||||
ptFeatures = SpatialQueryFactory.create().query(pointSource,
|
||||
ptFields.toArray(new String[ptFields.size()]),
|
||||
searchArea, filter, SearchMode.INTERSECTS);
|
||||
}
|
||||
System.out.println("Retrieve location data for '" + pointSource
|
||||
+ "' = " + (System.currentTimeMillis() - t0));
|
||||
} catch (SpatialException e) {
|
||||
throw new VizException("Error querying " + pointSource + " table: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
if (ptFeatures != null) {
|
||||
points = new ArrayList<ClosestPoint>(ptFeatures.length);
|
||||
} else {
|
||||
points = new ArrayList<ClosestPoint>(0);
|
||||
}
|
||||
return ptFeatures;
|
||||
}
|
||||
|
||||
for (SpatialQueryResult ptRslt : ptFeatures) {
|
||||
if (ptRslt != null && ptRslt.geometry != null) {
|
||||
Object nameObj = ptRslt.attributes.get(pointConfig
|
||||
.getPointField());
|
||||
if (nameObj != null) {
|
||||
ClosestPoint cp = createClosestPoint(ptFields, ptRslt);
|
||||
points.add(cp);
|
||||
}
|
||||
/**
|
||||
* Returns the data of the points/areas relative to the searchArea
|
||||
*
|
||||
* @param config
|
||||
* @param pointConfig
|
||||
* @param localizedSite
|
||||
* @return
|
||||
* @throws VizException
|
||||
*/
|
||||
public Collection<ClosestPoint> getData(WarngenConfiguration config,
|
||||
PointSourceConfiguration pointConfig, String localizedSite)
|
||||
throws VizException {
|
||||
List<ClosestPoint> points = null;
|
||||
|
||||
String pointField = pointConfig.getPointField();
|
||||
if (ptFeatures != null) {
|
||||
points = new ArrayList<ClosestPoint>(ptFeatures.length);
|
||||
} else {
|
||||
points = new ArrayList<ClosestPoint>(0);
|
||||
}
|
||||
|
||||
for (SpatialQueryResult ptRslt : ptFeatures) {
|
||||
if (ptRslt != null && ptRslt.geometry != null) {
|
||||
Object nameObj = ptRslt.attributes.get(pointConfig
|
||||
.getPointField());
|
||||
if (nameObj != null) {
|
||||
ClosestPoint cp = createClosestPoint(pointField, ptFields,
|
||||
ptRslt);
|
||||
cp.setGid(getGid(ptFields, ptRslt.attributes));
|
||||
points.add(cp);
|
||||
}
|
||||
}
|
||||
System.out.println("Retrieve location data for '"
|
||||
+ pointConfig.getVariable() + "' = "
|
||||
+ (System.currentTimeMillis() - t0));
|
||||
} catch (SpatialException e) {
|
||||
throw new VizException("Error querying "
|
||||
+ pointConfig.getPointSource() + " table: "
|
||||
+ e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of implacted points/areas that are relative to the
|
||||
* centroid.
|
||||
*
|
||||
* @param pcGeom
|
||||
* @param centroid
|
||||
* @param areaFeatures
|
||||
* @param pcArea
|
||||
* @param pcParentArea
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public List<ClosestPoint> getPathcastData(
|
||||
PathcastConfiguration pathcastConfiguration,
|
||||
UnitConverter distanceToMeters, MathTransform latLonToLocal,
|
||||
Geometry pcGeom, Point centroid, SpatialQueryResult[] areaFeatures,
|
||||
String pcArea, String pcParentArea) throws Exception {
|
||||
String pointField = pathcastConfiguration.getPointField();
|
||||
String areaField = pathcastConfiguration.getAreaField();
|
||||
String parentAreaField = pathcastConfiguration.getParentAreaField();
|
||||
double thresholdInMeters = distanceToMeters
|
||||
.convert(pathcastConfiguration.getDistanceThreshold());
|
||||
|
||||
if (latLonToLocal != null) {
|
||||
for (SpatialQueryResult rslt : ptFeatures) {
|
||||
rslt.attributes.put(transformedKey,
|
||||
JTS.transform(rslt.geometry, latLonToLocal));
|
||||
}
|
||||
}
|
||||
|
||||
Geometry localPCGeom = null;
|
||||
if (pcGeom != null) {
|
||||
localPCGeom = JTS.transform(pcGeom, latLonToLocal);
|
||||
}
|
||||
|
||||
// Find closest points
|
||||
List<ClosestPoint> points = new ArrayList<ClosestPoint>(
|
||||
ptFeatures.length);
|
||||
for (SpatialQueryResult pointRslt : ptFeatures) {
|
||||
Geometry localPt = (Geometry) pointRslt.attributes
|
||||
.get(transformedKey);
|
||||
double minDist = Double.MAX_VALUE;
|
||||
Coordinate closestCoord = null;
|
||||
if (localPCGeom != null) {
|
||||
Coordinate[] localPts = localPCGeom.getCoordinates();
|
||||
Coordinate[] latLonPts = pcGeom.getCoordinates();
|
||||
for (int i = 0; i < localPts.length; ++i) {
|
||||
Coordinate loc = localPts[i];
|
||||
double distance = loc.distance(localPt.getCoordinate());
|
||||
if (distance <= thresholdInMeters && distance < minDist) {
|
||||
minDist = distance;
|
||||
closestCoord = latLonPts[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
closestCoord = centroid.getCoordinate();
|
||||
minDist = 0;
|
||||
}
|
||||
|
||||
if (closestCoord != null) {
|
||||
boolean found = false;
|
||||
String area = null;
|
||||
String parentArea = null;
|
||||
for (SpatialQueryResult areaRslt : areaFeatures) {
|
||||
if (areaRslt.geometry.contains(pointRslt.geometry)) {
|
||||
area = String.valueOf(areaRslt.attributes
|
||||
.get(areaField));
|
||||
parentArea = String.valueOf(areaRslt.attributes
|
||||
.get(parentAreaField));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
area = pcArea;
|
||||
parentArea = pcParentArea;
|
||||
}
|
||||
|
||||
ClosestPoint cp = createClosestPoint(pointField, pointRslt,
|
||||
minDist, closestCoord, area, parentArea,
|
||||
distanceToMeters.inverse());
|
||||
points.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> fields = null;
|
||||
if (pathcastConfiguration.getSortBy() != null) {
|
||||
fields = Arrays.asList(pathcastConfiguration.getSortBy());
|
||||
} else {
|
||||
fields = new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
if (!fields.isEmpty()) {
|
||||
// Sort the points based on sortBy fields
|
||||
Collections.sort(points, new ClosestPointComparator(fields));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a closestPoint setting the distance, azimuth, etc. Used for
|
||||
* pathcast calculations
|
||||
*
|
||||
* @param pointRslt
|
||||
* @param minDist
|
||||
* @param closestCoord
|
||||
* @param area
|
||||
* @param parentArea
|
||||
* @return
|
||||
*/
|
||||
private ClosestPoint createClosestPoint(String pointField,
|
||||
SpatialQueryResult pointRslt, double minDist,
|
||||
Coordinate closestCoord, String area, String parentArea,
|
||||
UnitConverter metersToDistance) {
|
||||
|
||||
ClosestPoint cp = createClosestPoint(pointField, ptFields, pointRslt);
|
||||
cp.setDistance(minDist);
|
||||
cp.setRoundedDistance((int) metersToDistance.convert(minDist));
|
||||
gc.setStartingGeographicPoint(cp.getPoint().x, cp.getPoint().y);
|
||||
gc.setDestinationGeographicPoint(closestCoord.x, closestCoord.y);
|
||||
cp.setAzimuth(gc.getAzimuth());
|
||||
cp.setOppositeAzimuth(ClosestPoint.adjustAngle(cp.getAzimuth() + 180));
|
||||
cp.setRoundedAzimuth(GeoUtil.roundAzimuth(cp.getAzimuth()));
|
||||
cp.setOppositeRoundedAzimuth(ClosestPoint.adjustAngle(cp
|
||||
.getRoundedAzimuth() + 180));
|
||||
cp.setArea(area);
|
||||
cp.setParentArea(parentArea);
|
||||
cp.setGid(getGid(ptFields, pointRslt.attributes));
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the population from the attributes.
|
||||
*
|
||||
* @param ptFields
|
||||
* @param attributes
|
||||
* @return
|
||||
*/
|
||||
protected int getPopulation(Set<String> ptFields,
|
||||
Map<String, Object> attributes) {
|
||||
int population = 0;
|
||||
|
||||
if (ptFields.contains("population")) {
|
||||
if (ptFields.contains(String
|
||||
.valueOf(ClosestPointComparator.Sort.POPULATION))) {
|
||||
try {
|
||||
population = Integer.valueOf(String.valueOf(attributes
|
||||
.get("population")));
|
||||
population = Integer
|
||||
.valueOf(String.valueOf(attributes.get(String
|
||||
.valueOf(ClosestPointComparator.Sort.POPULATION))));
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
|
@ -154,14 +372,23 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
return population;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the warngenlev from the attributes.
|
||||
*
|
||||
* @param ptFields
|
||||
* @param attributes
|
||||
* @return
|
||||
*/
|
||||
protected int getWangenlev(Set<String> ptFields,
|
||||
Map<String, Object> attributes) {
|
||||
int warngenlev = 0;
|
||||
int warngenlev = 3;
|
||||
|
||||
if (ptFields.contains("warngenlev")) {
|
||||
if (ptFields.contains(String
|
||||
.valueOf(ClosestPointComparator.Sort.WARNGENLEV))) {
|
||||
try {
|
||||
warngenlev = Integer.valueOf(String.valueOf(attributes
|
||||
.get("warngenlev")));
|
||||
warngenlev = Integer
|
||||
.valueOf(String.valueOf(attributes.get(String
|
||||
.valueOf(ClosestPointComparator.Sort.WARNGENLEV))));
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
}
|
||||
|
@ -170,16 +397,22 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
return warngenlev;
|
||||
}
|
||||
|
||||
protected int getGid(Set<String> ptFields,
|
||||
Map<String, Object> attributes) {
|
||||
/**
|
||||
* Returns the gid.
|
||||
*
|
||||
* @param ptFields
|
||||
* @param attributes
|
||||
* @return
|
||||
*/
|
||||
protected int getGid(Set<String> ptFields, Map<String, Object> attributes) {
|
||||
int gid = 0;
|
||||
|
||||
if (ptFields.contains("gid")) {
|
||||
if (ptFields.contains(String.valueOf(ClosestPointComparator.Sort.GID))) {
|
||||
try {
|
||||
gid = Integer.valueOf(String.valueOf(attributes
|
||||
.get("gid")));
|
||||
gid = Integer.valueOf(String.valueOf(attributes.get(String
|
||||
.valueOf(ClosestPointComparator.Sort.GID))));
|
||||
} catch (Exception e) {
|
||||
// Ignore
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,16 @@
|
|||
**/
|
||||
package com.raytheon.viz.warngen.config;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PathcastConfiguration;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration.PointType;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* Creates data adaptors for PointSource and Pathcast data.
|
||||
* Creates data adaptors for PointSource data.
|
||||
*
|
||||
* <pre>
|
||||
*
|
||||
|
@ -32,6 +37,7 @@ import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 26, 2011 bgonzale Initial creation
|
||||
* Oct 17, 2012 jsanchez Allowed adaptor to be used for pathcast.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -41,15 +47,32 @@ import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration
|
|||
|
||||
public class DataAdaptorFactory {
|
||||
|
||||
public static AbstractDbSourceDataAdaptor createPointSource(
|
||||
PointSourceConfiguration pointConfig) {
|
||||
public static AbstractDbSourceDataAdaptor createDataAdaptor(
|
||||
PointSourceConfiguration pointConfig, Geometry searchArea,
|
||||
String localizedSite) throws VizException {
|
||||
AbstractDbSourceDataAdaptor adaptor = null;
|
||||
if (pointConfig.getType() == PointType.AREA) {
|
||||
adaptor = new DbAreaSourceDataAdaptor(pointConfig, searchArea,
|
||||
localizedSite);
|
||||
} else if (pointConfig.getType() == PointType.POINT) {
|
||||
adaptor = new DbPointSourceDataAdaptor(pointConfig, searchArea,
|
||||
localizedSite);
|
||||
}
|
||||
return adaptor;
|
||||
}
|
||||
|
||||
public static AbstractDbSourceDataAdaptor createPathcastDataAdaptor(
|
||||
PathcastConfiguration pathcastConfiguration,
|
||||
UnitConverter distanceToMeters, Geometry searchArea,
|
||||
String localizedSite) throws VizException {
|
||||
AbstractDbSourceDataAdaptor adaptor = null;
|
||||
|
||||
if (pointConfig.getType() == PointType.AREA) {
|
||||
adaptor = new DbAreaSourceDataAdaptor();
|
||||
} else if (pointConfig.getType() == PointType.POINT) {
|
||||
adaptor = new DbPointSourceDataAdaptor();
|
||||
if (pathcastConfiguration.getType() == PointType.AREA) {
|
||||
adaptor = new DbAreaSourceDataAdaptor(pathcastConfiguration,
|
||||
distanceToMeters, searchArea, localizedSite);
|
||||
} else if (pathcastConfiguration.getType() == PointType.POINT) {
|
||||
adaptor = new DbPointSourceDataAdaptor(pathcastConfiguration,
|
||||
distanceToMeters, searchArea, localizedSite);
|
||||
}
|
||||
|
||||
return adaptor;
|
||||
|
|
|
@ -2,31 +2,40 @@ package com.raytheon.viz.warngen.config;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
|
||||
import org.geotools.referencing.GeodeticCalculator;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PathcastConfiguration;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.warngen.PreferenceUtil;
|
||||
import com.raytheon.viz.warngen.gis.ClosestPoint;
|
||||
import com.raytheon.viz.warngen.gis.GisUtil;
|
||||
import com.raytheon.viz.warngen.gis.GisUtil.Direction;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Envelope;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
||||
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* @author jsanchez
|
||||
* Sep 25, 2012 #15425 Qinglu Lin Updated createClosestPoint().
|
||||
* Date Ticket# Engineer Description ------------ ---------- -----------
|
||||
* --------------------------
|
||||
*
|
||||
* @author jsanchez Sep 25, 2012 #15425 Qinglu Lin Updated createClosestPoint().
|
||||
*
|
||||
*/
|
||||
public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
||||
|
@ -37,26 +46,41 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
|
||||
private static final String cwaField = "cwa";
|
||||
|
||||
private GeodeticCalculator gc = new GeodeticCalculator();
|
||||
public DbAreaSourceDataAdaptor(PathcastConfiguration pathcastConfiguration,
|
||||
UnitConverter distanceToMeters, Geometry searchArea,
|
||||
String localizedSite) throws VizException {
|
||||
super(pathcastConfiguration, distanceToMeters, searchArea,
|
||||
localizedSite);
|
||||
}
|
||||
|
||||
public DbAreaSourceDataAdaptor(
|
||||
PointSourceConfiguration pointSourceConfiguration,
|
||||
Geometry searchArea, String localizedSite) throws VizException {
|
||||
super(pointSourceConfiguration, searchArea, localizedSite);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
protected Set<String> createSpatialQueryField() {
|
||||
protected Set<String> createSpatialQueryField(String pointField,
|
||||
String[] sortBy) {
|
||||
Set<String> ptFields = new HashSet<String>();
|
||||
ptFields.add(pointConfig.getPointField());
|
||||
ptFields.add(pointField);
|
||||
ptFields.add(useDirectionField);
|
||||
ptFields.add(suppressedDirectionsField);
|
||||
|
||||
List<String> fields = new ArrayList<String>();
|
||||
if (pointConfig.getSortBy() != null) {
|
||||
fields = Arrays.asList(pointConfig.getSortBy());
|
||||
List<String> fields = null;
|
||||
if (sortBy != null && sortBy.length > 0) {
|
||||
fields = Arrays.asList(sortBy);
|
||||
} else {
|
||||
fields = new ArrayList<String>(0);
|
||||
}
|
||||
|
||||
// Sort fields don't exist in the db.
|
||||
for (String field : fields) {
|
||||
if (sortFields.contains(field.toLowerCase()) == false) {
|
||||
ptFields.add(field.toLowerCase());
|
||||
if (undatabasedSortableFields.contains(field.toUpperCase()) == false) {
|
||||
ptFields.add(field.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,15 +88,14 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Creates a closest point object.
|
||||
*/
|
||||
@Override
|
||||
protected ClosestPoint createClosestPoint(Set<String> ptFields,
|
||||
SpatialQueryResult ptRslt) {
|
||||
protected ClosestPoint createClosestPoint(String pointField,
|
||||
Set<String> ptFields, SpatialQueryResult ptRslt) {
|
||||
Map<String, Object> attributes = ptRslt.attributes;
|
||||
|
||||
String name = String
|
||||
.valueOf(attributes.get(pointConfig.getPointField()));
|
||||
String name = String.valueOf(attributes.get(pointField));
|
||||
Coordinate point = ptRslt.geometry.getCoordinate();
|
||||
int population = getPopulation(ptFields, attributes);
|
||||
int warngenlev = getWangenlev(ptFields, attributes);
|
||||
|
@ -80,62 +103,16 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
ptRslt.geometry);
|
||||
int gid = getGid(ptFields, attributes);
|
||||
|
||||
return new ClosestPoint(name, point, population, warngenlev, partOfArea, gid);
|
||||
return new ClosestPoint(name, point, population, warngenlev,
|
||||
partOfArea, gid);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ptFields
|
||||
* @param attributes
|
||||
* @param geom
|
||||
* @return
|
||||
* Processes the filter to set the localized site.
|
||||
*/
|
||||
private List<String> getPartOfArea(Set<String> ptFields,
|
||||
Map<String, Object> attributes, Geometry geom) {
|
||||
List<String> partOfArea = null;
|
||||
|
||||
boolean userDirections = Boolean.valueOf(String.valueOf(attributes
|
||||
.get(useDirectionField)));
|
||||
if (userDirections) {
|
||||
Geometry intersection = searchArea.intersection(geom);
|
||||
partOfArea = GisUtil.asStringList(GisUtil.calculatePortion(geom,
|
||||
intersection, gc, ""));
|
||||
|
||||
if (attributes.get(suppressedDirectionsField) != null) {
|
||||
String suppressedDirections = String.valueOf(
|
||||
attributes.get(suppressedDirectionsField))
|
||||
.toLowerCase();
|
||||
// supdirs can be 'nse', for example
|
||||
// TODO create an enum constructor for Directions
|
||||
for (int i = 0; i < suppressedDirections.length(); i++) {
|
||||
switch (suppressedDirections.charAt(i)) {
|
||||
case 'n':
|
||||
partOfArea.remove(Direction.NORTH.toString());
|
||||
break;
|
||||
case 's':
|
||||
partOfArea.remove(Direction.SOUTH.toString());
|
||||
break;
|
||||
case 'e':
|
||||
partOfArea.remove(Direction.EAST.toString());
|
||||
break;
|
||||
case 'w':
|
||||
partOfArea.remove(Direction.WEST.toString());
|
||||
break;
|
||||
case 'c':
|
||||
partOfArea.remove(Direction.CENTRAL.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return partOfArea;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, RequestConstraint> processFilterSubstitution() {
|
||||
Map<String, RequestConstraint> filter = pointConfig.getFilter();
|
||||
protected Map<String, RequestConstraint> processFilterSubstitution(
|
||||
Map<String, RequestConstraint> filter) {
|
||||
if (filter != null) {
|
||||
// Process substitutes for filter
|
||||
for (RequestConstraint rc : filter.values()) {
|
||||
|
@ -152,4 +129,139 @@ public class DbAreaSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
|
||||
return filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the part of area impacted if the userDirectionField is set to
|
||||
* true.
|
||||
*
|
||||
* @param ptFields
|
||||
* @param attributes
|
||||
* @param geom
|
||||
* @return
|
||||
*/
|
||||
private List<String> getPartOfArea(Set<String> ptFields,
|
||||
Map<String, Object> attributes, Geometry geom) {
|
||||
List<String> partOfArea = null;
|
||||
|
||||
boolean userDirections = Boolean.valueOf(String.valueOf(attributes
|
||||
.get(useDirectionField)));
|
||||
if (userDirections) {
|
||||
PreparedGeometry prepGeom = PreparedGeometryFactory.prepare(geom);
|
||||
if (prepGeom.intersects(searchArea) && !prepGeom.within(searchArea)) {
|
||||
Geometry intersection = searchArea.intersection(geom);
|
||||
partOfArea = GisUtil.asStringList(calculateLocationPortion(
|
||||
geom, intersection, gc));
|
||||
|
||||
if (attributes.get(suppressedDirectionsField) != null) {
|
||||
String suppressedDirections = String.valueOf(
|
||||
attributes.get(suppressedDirectionsField))
|
||||
.toLowerCase();
|
||||
// supdirs can be 'nse', for example
|
||||
// TODO create an enum constructor for Directions
|
||||
for (int i = 0; i < suppressedDirections.length(); i++) {
|
||||
switch (suppressedDirections.charAt(i)) {
|
||||
case 'n':
|
||||
partOfArea.remove(Direction.NORTH.toString());
|
||||
break;
|
||||
case 's':
|
||||
partOfArea.remove(Direction.SOUTH.toString());
|
||||
break;
|
||||
case 'e':
|
||||
partOfArea.remove(Direction.EAST.toString());
|
||||
break;
|
||||
case 'w':
|
||||
partOfArea.remove(Direction.WEST.toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (partOfArea != null && !partOfArea.isEmpty()) {
|
||||
return partOfArea;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper class to store cardinal ranges
|
||||
*
|
||||
* @author jsanchez
|
||||
*
|
||||
*/
|
||||
private static class CardinalRange {
|
||||
public EnumSet<Direction> directions;
|
||||
|
||||
public double lowRange;
|
||||
|
||||
public double highRange;
|
||||
|
||||
public CardinalRange(EnumSet<Direction> directions, double lowRange,
|
||||
double highRange) {
|
||||
this.directions = directions;
|
||||
this.lowRange = lowRange;
|
||||
this.highRange = highRange;
|
||||
}
|
||||
}
|
||||
|
||||
private static CardinalRange[] ranges = new CardinalRange[] {
|
||||
new CardinalRange(EnumSet.of(Direction.NORTH), 0, 22.5),
|
||||
new CardinalRange(EnumSet.of(Direction.NORTH, Direction.EAST),
|
||||
22.5, 67.5),
|
||||
new CardinalRange(EnumSet.of(Direction.EAST), 67.5, 112.5),
|
||||
new CardinalRange(EnumSet.of(Direction.SOUTH, Direction.EAST),
|
||||
112.5, 157.5),
|
||||
new CardinalRange(EnumSet.of(Direction.SOUTH), 157.5, 202.5),
|
||||
new CardinalRange(EnumSet.of(Direction.SOUTH, Direction.WEST),
|
||||
202.5, 247.5),
|
||||
new CardinalRange(EnumSet.of(Direction.WEST), 247.5, 292.5),
|
||||
new CardinalRange(EnumSet.of(Direction.NORTH, Direction.WEST),
|
||||
292.5, 337.5),
|
||||
new CardinalRange(EnumSet.of(Direction.NORTH), 337.5, 360) };
|
||||
|
||||
/**
|
||||
* Calculates the cardinal directions of a location.
|
||||
*
|
||||
* @param geom
|
||||
* @param intersection
|
||||
* @param gc
|
||||
* @return
|
||||
*/
|
||||
private static EnumSet<Direction> calculateLocationPortion(Geometry geom,
|
||||
Geometry intersection, GeodeticCalculator gc) {
|
||||
EnumSet<Direction> directions = EnumSet.noneOf(Direction.class);
|
||||
Coordinate geomCentroid = geom.convexHull().getCentroid()
|
||||
.getCoordinate();
|
||||
Coordinate intersectCentroid = intersection.convexHull().getCentroid()
|
||||
.getCoordinate();
|
||||
|
||||
gc.setStartingGeographicPoint(geomCentroid.x, geomCentroid.y);
|
||||
gc.setDestinationGeographicPoint(intersectCentroid.x,
|
||||
intersectCentroid.y);
|
||||
|
||||
Envelope envelope = geom.getEnvelopeInternal();
|
||||
double centerThresholdX = envelope.getWidth() * 0.10;
|
||||
double centerThresholdY = envelope.getHeight() * 0.10;
|
||||
double distanceX = Math.abs(intersectCentroid.x - geomCentroid.x);
|
||||
double distanceY = Math.abs(intersectCentroid.y - geomCentroid.y);
|
||||
|
||||
if (distanceX > centerThresholdX || distanceY > centerThresholdY) {
|
||||
// Convert azimuth from -180/180 to 0/360
|
||||
double degrees = gc.getAzimuth();
|
||||
if (degrees < 0) {
|
||||
degrees += 360;
|
||||
}
|
||||
|
||||
for (CardinalRange range : ranges) {
|
||||
if (degrees > range.lowRange && degrees <= range.highRange) {
|
||||
directions = range.directions;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return directions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,23 +19,24 @@
|
|||
**/
|
||||
package com.raytheon.viz.warngen.config;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import javax.measure.converter.UnitConverter;
|
||||
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PathcastConfiguration;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.PointSourceConfiguration;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.geospatial.SpatialQueryResult;
|
||||
import com.raytheon.uf.viz.core.maps.rsc.DbMapQueryFactory;
|
||||
import com.raytheon.uf.viz.core.exception.VizException;
|
||||
import com.raytheon.viz.warngen.PreferenceUtil;
|
||||
import com.raytheon.viz.warngen.gis.ClosestPoint;
|
||||
import com.vividsolutions.jts.geom.Coordinate;
|
||||
import com.vividsolutions.jts.geom.Geometry;
|
||||
|
||||
/**
|
||||
* PointSource data adaptor for data retrieved from a Database.
|
||||
|
@ -57,19 +58,35 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
|
||||
public class DbPointSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
||||
|
||||
public DbPointSourceDataAdaptor(
|
||||
PathcastConfiguration pathcastConfiguration,
|
||||
UnitConverter distanceToMeters, Geometry searchArea,
|
||||
String localizedSite) throws VizException {
|
||||
super(pathcastConfiguration, distanceToMeters, searchArea,
|
||||
localizedSite);
|
||||
}
|
||||
|
||||
public DbPointSourceDataAdaptor(
|
||||
PointSourceConfiguration pointSourceConfiguration,
|
||||
Geometry searchArea, String localizedSite) throws VizException {
|
||||
super(pointSourceConfiguration, searchArea, localizedSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<String> createSpatialQueryField() {
|
||||
protected Set<String> createSpatialQueryField(String pointField,
|
||||
String[] sortBy) {
|
||||
Set<String> ptFields = new HashSet<String>();
|
||||
ptFields.add(pointConfig.getPointField());
|
||||
ptFields.add(pointField);
|
||||
|
||||
List<String> fields = new ArrayList<String>();
|
||||
if (pointConfig.getSortBy() != null) {
|
||||
fields = Arrays.asList(pointConfig.getSortBy());
|
||||
if (sortBy != null) {
|
||||
fields = Arrays.asList(sortBy);
|
||||
}
|
||||
|
||||
// Sort fields don't exist in the db.
|
||||
for (String field : fields) {
|
||||
if (sortFields.contains(field.toLowerCase()) == false) {
|
||||
ptFields.add(field.toLowerCase());
|
||||
if (undatabasedSortableFields.contains(field.toUpperCase()) == false) {
|
||||
ptFields.add(field.toUpperCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,12 +94,11 @@ public class DbPointSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ClosestPoint createClosestPoint(Set<String> ptFields,
|
||||
SpatialQueryResult ptRslt) {
|
||||
protected ClosestPoint createClosestPoint(String pointField,
|
||||
Set<String> ptFields, SpatialQueryResult ptRslt) {
|
||||
Map<String, Object> attributes = ptRslt.attributes;
|
||||
|
||||
String name = String
|
||||
.valueOf(attributes.get(pointConfig.getPointField()));
|
||||
String name = String.valueOf(attributes.get(pointField));
|
||||
Coordinate point = ptRslt.geometry.getCoordinate();
|
||||
int population = getPopulation(ptFields, attributes);
|
||||
int warngenlev = getWangenlev(ptFields, attributes);
|
||||
|
@ -92,8 +108,8 @@ public class DbPointSourceDataAdaptor extends AbstractDbSourceDataAdaptor {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, RequestConstraint> processFilterSubstitution() {
|
||||
Map<String, RequestConstraint> filter = pointConfig.getFilter();
|
||||
protected Map<String, RequestConstraint> processFilterSubstitution(
|
||||
Map<String, RequestConstraint> filter) {
|
||||
if (filter != null) {
|
||||
// Process substitutes for filter
|
||||
for (RequestConstraint rc : filter.values()) {
|
||||
|
|
|
@ -38,6 +38,7 @@ import com.vividsolutions.jts.geom.Coordinate;
|
|||
* APr 18, 2012 #14733 Qinglu Lin David's fix is used, which adds
|
||||
* a copy constructor.
|
||||
* Sep 25, 2012 #15425 Qinglu Lin Updated two ClosestPoint() and added getGid().
|
||||
* Oct 17, 2012 jsanchez Added setter methods.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -178,10 +179,74 @@ public class ClosestPoint implements Comparable<ClosestPoint> {
|
|||
return partOfArea;
|
||||
}
|
||||
|
||||
public int getGid() {
|
||||
public int getGid() {
|
||||
return gid;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(Date time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setArea(String area) {
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public void setParentArea(String parentArea) {
|
||||
this.parentArea = parentArea;
|
||||
}
|
||||
|
||||
public void setPoint(Coordinate point) {
|
||||
this.point = point;
|
||||
}
|
||||
|
||||
public void setDistance(double distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public void setRoundedDistance(int roundedDistance) {
|
||||
this.roundedDistance = roundedDistance;
|
||||
}
|
||||
|
||||
public void setAzimuth(double azimuth) {
|
||||
this.azimuth = azimuth;
|
||||
}
|
||||
|
||||
public void setRoundedAzimuth(double roundedAzimuth) {
|
||||
this.roundedAzimuth = roundedAzimuth;
|
||||
}
|
||||
|
||||
public void setOppositeAzimuth(double oppositeAzimuth) {
|
||||
this.oppositeAzimuth = oppositeAzimuth;
|
||||
}
|
||||
|
||||
public void setOppositeRoundedAzimuth(double oppositeRoundedAzimuth) {
|
||||
this.oppositeRoundedAzimuth = oppositeRoundedAzimuth;
|
||||
}
|
||||
|
||||
public void setPopulation(int population) {
|
||||
this.population = population;
|
||||
}
|
||||
|
||||
public void setWarngenlev(int warngenlev) {
|
||||
this.warngenlev = warngenlev;
|
||||
}
|
||||
|
||||
public void setPartOfArea(List<String> partOfArea) {
|
||||
this.partOfArea = partOfArea;
|
||||
}
|
||||
|
||||
public void setGid(int gid) {
|
||||
this.gid = gid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the angle from -360/360 to be between -180/180
|
||||
*
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.commons.lang.ArrayUtils;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Mar 3, 2011 jsanchez Initial creation
|
||||
* Sep 25, 2012 15425 Qinglu Lin Implemented sorting on 'gid' in ascending order.
|
||||
* Oct 17, 2012 jsanchez Refactored the enum sort to be more flexible.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -47,11 +48,11 @@ import org.apache.commons.lang.ArrayUtils;
|
|||
|
||||
public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
||||
|
||||
private enum Sort {
|
||||
NAME, POPULATION, DISTANCE, LEVEL, LAT, LON, AREA, PARENT_AREA, GID
|
||||
public static enum Sort {
|
||||
NAME, POPULATION, DISTANCE, WARNGENLEV, LAT, LON, AREA, PARENTAREA, GID
|
||||
}
|
||||
|
||||
private ArrayList<Sort> list;
|
||||
private final ArrayList<Sort> list;
|
||||
|
||||
private int counter;
|
||||
|
||||
|
@ -64,25 +65,25 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
counter = 0;
|
||||
list = new ArrayList<Sort>();
|
||||
for (String field : fields) {
|
||||
if (field.equalsIgnoreCase("name")) {
|
||||
if (field.equalsIgnoreCase(Sort.NAME.toString())) {
|
||||
list.add(Sort.NAME);
|
||||
} else if (field.equalsIgnoreCase("population")) {
|
||||
} else if (field.equalsIgnoreCase(Sort.POPULATION.toString())) {
|
||||
list.add(Sort.POPULATION);
|
||||
} else if (field.equalsIgnoreCase("distance")) {
|
||||
} else if (field.equalsIgnoreCase(Sort.DISTANCE.toString())) {
|
||||
list.add(Sort.DISTANCE);
|
||||
} else if (field.equalsIgnoreCase("warngenlev")
|
||||
} else if (field.equalsIgnoreCase(Sort.WARNGENLEV.toString())
|
||||
|| field.equalsIgnoreCase("watch_warn")) {
|
||||
list.add(Sort.LEVEL);
|
||||
} else if (field.equalsIgnoreCase("lat")) {
|
||||
list.add(Sort.WARNGENLEV);
|
||||
} else if (field.equalsIgnoreCase(Sort.LAT.toString())) {
|
||||
list.add(Sort.LAT);
|
||||
} else if (field.equalsIgnoreCase("lon")) {
|
||||
} else if (field.equalsIgnoreCase(Sort.LON.toString())) {
|
||||
list.add(Sort.LON);
|
||||
} else if (field.equalsIgnoreCase("area")) {
|
||||
} else if (field.equalsIgnoreCase(Sort.AREA.toString())) {
|
||||
list.add(Sort.AREA);
|
||||
} else if (field.equalsIgnoreCase("parentArea")) {
|
||||
list.add(Sort.PARENT_AREA);
|
||||
} else if (field.equalsIgnoreCase("gid")) {
|
||||
list.add(Sort.GID);
|
||||
} else if (field.equalsIgnoreCase(Sort.PARENTAREA.toString())) {
|
||||
list.add(Sort.PARENTAREA);
|
||||
} else if (field.equalsIgnoreCase(Sort.GID.toString())) {
|
||||
list.add(Sort.GID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,13 +106,13 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
list.clear();
|
||||
|
||||
ClosestPointComparator comparator = new ClosestPointComparator(
|
||||
(ArrayList<String>) Arrays.asList(fields));
|
||||
Collections
|
||||
.sort((List<ClosestPoint>) Arrays.asList(points), comparator);
|
||||
Arrays.asList(fields));
|
||||
Collections.sort(Arrays.asList(points), comparator);
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(ClosestPoint cp1, ClosestPoint cp2) {
|
||||
if (list.isEmpty()) {
|
||||
return cp1.compareTo(cp2);
|
||||
|
@ -121,7 +122,7 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
switch (list.get(counter)) {
|
||||
case NAME:
|
||||
if (cp1.name.matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")
|
||||
&& cp1.name.matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {
|
||||
&& cp2.name.matches("((-|\\+)?[0-9]+(\\.[0-9]+)?)+")) {
|
||||
value = Double.valueOf(cp1.name).compareTo(
|
||||
Double.valueOf(cp2.name));
|
||||
} else {
|
||||
|
@ -131,7 +132,7 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
case POPULATION:
|
||||
value = -1 * Double.compare(cp1.population, cp2.population);
|
||||
break;
|
||||
case LEVEL:
|
||||
case WARNGENLEV:
|
||||
value = Double.compare(cp1.warngenlev, cp2.warngenlev);
|
||||
break;
|
||||
case LAT:
|
||||
|
@ -143,7 +144,7 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
case AREA:
|
||||
value = cp1.area.compareTo(cp2.area);
|
||||
break;
|
||||
case PARENT_AREA:
|
||||
case PARENTAREA:
|
||||
value = cp1.parentArea.compareTo(cp2.parentArea);
|
||||
break;
|
||||
case DISTANCE:
|
||||
|
@ -151,8 +152,7 @@ public class ClosestPointComparator implements Comparator<ClosestPoint> {
|
|||
.compareTo(cp2.roundedDistance);
|
||||
break;
|
||||
case GID:
|
||||
value = new Integer(cp1.gid)
|
||||
.compareTo(cp2.gid);
|
||||
value = new Integer(cp1.gid).compareTo(cp2.gid);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ import com.raytheon.viz.awipstools.common.stormtrack.StormTrackState;
|
|||
import com.raytheon.viz.core.map.GeoUtil;
|
||||
import com.raytheon.viz.warngen.PreferenceUtil;
|
||||
import com.raytheon.viz.warngen.WarngenException;
|
||||
import com.raytheon.viz.warngen.config.AbstractDbSourceDataAdaptor;
|
||||
import com.raytheon.viz.warngen.config.DataAdaptorFactory;
|
||||
import com.raytheon.viz.warngen.util.Abbreviation;
|
||||
import com.raytheon.viz.warnings.DateUtil;
|
||||
|
@ -99,6 +100,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* in pathcast.
|
||||
* Oct 05, 2012 DR15429 Qinglu Lin Updated code to keep duplicate names of cities
|
||||
* which are at different locations in pathcast.
|
||||
* Oct 17, 2012 jsanchez Moved the path cast data collecting to a seperate class.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -109,8 +111,6 @@ public class Wx {
|
|||
private static final transient IUFStatusHandler statusHandler = UFStatus
|
||||
.getHandler(Wx.class);
|
||||
|
||||
private static final String transformedKey = "com.raytheon.transformed";
|
||||
|
||||
private long wwaStopTime;
|
||||
|
||||
private long wwaStartTime;
|
||||
|
@ -184,7 +184,6 @@ public class Wx {
|
|||
.getPathcastConfig();
|
||||
UnitConverter distanceToMeters = config.getUnitDistance()
|
||||
.getConverterTo(SI.METER);
|
||||
UnitConverter metersToDistance = distanceToMeters.inverse();
|
||||
|
||||
int maxCount = pathcastConfiguration.getMaxResults();
|
||||
int maxGroup = pathcastConfiguration.getMaxGroup();
|
||||
|
@ -196,7 +195,6 @@ public class Wx {
|
|||
String areaNotationField = pathcastConfiguration.getAreaNotationField();
|
||||
String areaNotationAbbrevField = pathcastConfiguration
|
||||
.getAreaNotationTranslationFile();
|
||||
String timezoneTable = geospatialConfig.getTimezoneSource();
|
||||
String timezoneField = geospatialConfig.getTimezoneField();
|
||||
String pointSource = pathcastConfiguration.getPointSource();
|
||||
String pointField = pathcastConfiguration.getPointField().toLowerCase();
|
||||
|
@ -344,18 +342,12 @@ public class Wx {
|
|||
}
|
||||
}
|
||||
|
||||
SpatialQueryResult[] ptFeatures = null;
|
||||
AbstractDbSourceDataAdaptor pathcastDataAdaptor = null;
|
||||
if (pointSource != null) {
|
||||
ptFeatures = SpatialQueryFactory.create().query(pointSource,
|
||||
ptFields.toArray(new String[ptFields.size()]),
|
||||
bufferedPathCastArea, pointFilter,
|
||||
SearchMode.INTERSECTS);
|
||||
if (latLonToLocal != null) {
|
||||
for (SpatialQueryResult rslt : ptFeatures) {
|
||||
rslt.attributes.put(transformedKey,
|
||||
JTS.transform(rslt.geometry, latLonToLocal));
|
||||
}
|
||||
}
|
||||
pathcastDataAdaptor = DataAdaptorFactory
|
||||
.createPathcastDataAdaptor(pathcastConfiguration,
|
||||
distanceToMeters, bufferedPathCastArea,
|
||||
localizedSite);
|
||||
}
|
||||
|
||||
SpatialQueryResult[] areaFeatures = null;
|
||||
|
@ -432,99 +424,14 @@ public class Wx {
|
|||
.get(timezoneField));
|
||||
}
|
||||
|
||||
Geometry localPCGeom = null;
|
||||
if (pcGeom != null) {
|
||||
localPCGeom = JTS.transform(pcGeom, latLonToLocal);
|
||||
}
|
||||
|
||||
// Find closest points
|
||||
GeodeticCalculator gc = new GeodeticCalculator();
|
||||
List<ClosestPoint> points = new ArrayList<ClosestPoint>(
|
||||
ptFeatures.length);
|
||||
for (SpatialQueryResult pointRslt : ptFeatures) {
|
||||
Geometry localPt = (Geometry) pointRslt.attributes
|
||||
.get(transformedKey);
|
||||
double minDist = Double.MAX_VALUE;
|
||||
Coordinate closestCoord = null;
|
||||
if (localPCGeom != null) {
|
||||
Coordinate[] localPts = localPCGeom.getCoordinates();
|
||||
Coordinate[] latLonPts = pcGeom.getCoordinates();
|
||||
for (int i = 0; i < localPts.length; ++i) {
|
||||
Coordinate loc = localPts[i];
|
||||
double distance = loc.distance(localPt
|
||||
.getCoordinate());
|
||||
if (distance <= thresholdInMeters
|
||||
&& distance < minDist) {
|
||||
minDist = distance;
|
||||
closestCoord = latLonPts[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
closestCoord = centroid.getCoordinate();
|
||||
minDist = 0;
|
||||
}
|
||||
|
||||
if (closestCoord != null) {
|
||||
ClosestPoint cp = new ClosestPoint();
|
||||
cp.point = pointRslt.geometry.getCoordinate();
|
||||
cp.name = String.valueOf(pointRslt.attributes
|
||||
.get(pointField));
|
||||
cp.distance = minDist;
|
||||
cp.roundedDistance = (int) metersToDistance
|
||||
.convert(minDist);
|
||||
gc.setStartingGeographicPoint(cp.point.x, cp.point.y);
|
||||
gc.setDestinationGeographicPoint(closestCoord.x,
|
||||
closestCoord.y);
|
||||
cp.azimuth = gc.getAzimuth();
|
||||
cp.oppositeAzimuth = ClosestPoint
|
||||
.adjustAngle(cp.azimuth + 180);
|
||||
cp.roundedAzimuth = GeoUtil.roundAzimuth(cp.azimuth);
|
||||
cp.oppositeRoundedAzimuth = ClosestPoint
|
||||
.adjustAngle(cp.roundedAzimuth + 180);
|
||||
|
||||
boolean found = false;
|
||||
for (SpatialQueryResult areaRslt : areaFeatures) {
|
||||
if (areaRslt.geometry.contains(pointRslt.geometry)) {
|
||||
cp.area = String.valueOf(areaRslt.attributes
|
||||
.get(areaField));
|
||||
cp.parentArea = String
|
||||
.valueOf(areaRslt.attributes
|
||||
.get(parentAreaField));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
cp.area = pc.area;
|
||||
cp.parentArea = pc.parentArea;
|
||||
}
|
||||
|
||||
if (ptFields.contains("population")) {
|
||||
try {
|
||||
cp.population = Integer.valueOf(String
|
||||
.valueOf(pointRslt.attributes
|
||||
.get("population")));
|
||||
} catch (Exception e) {
|
||||
cp.population = 0;
|
||||
}
|
||||
}
|
||||
if (ptFields.contains("warngenlev")) {
|
||||
try {
|
||||
cp.warngenlev = Integer.valueOf(String
|
||||
.valueOf(pointRslt.attributes
|
||||
.get("warngenlev")));
|
||||
} catch (Exception e) {
|
||||
cp.warngenlev = 3;
|
||||
}
|
||||
}
|
||||
points.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
if (fields.isEmpty() == false) {
|
||||
// Sort the points based on sortBy fields
|
||||
Collections
|
||||
.sort(points, new ClosestPointComparator(fields));
|
||||
List<ClosestPoint> points = null;
|
||||
if (pathcastDataAdaptor != null) {
|
||||
points = pathcastDataAdaptor.getPathcastData(
|
||||
pathcastConfiguration, distanceToMeters,
|
||||
latLonToLocal, pcGeom, centroid, areaFeatures,
|
||||
pc.area, pc.parentArea);
|
||||
} else {
|
||||
points = new ArrayList<ClosestPoint>(0);
|
||||
}
|
||||
pcPoints.put(pc, points);
|
||||
}
|
||||
|
@ -773,9 +680,13 @@ public class Wx {
|
|||
List<ClosestPoint> availablePoints = new ArrayList<ClosestPoint>();
|
||||
for (PointSourceConfiguration pointConfig : pointConfigs) {
|
||||
long t0 = System.currentTimeMillis();
|
||||
availablePoints.addAll(DataAdaptorFactory.createPointSource(
|
||||
pointConfig).getData(config, pointConfig,
|
||||
bufferedSearchArea, localizedSite));
|
||||
AbstractDbSourceDataAdaptor adaptor = DataAdaptorFactory
|
||||
.createDataAdaptor(pointConfig, bufferedSearchArea,
|
||||
localizedSite);
|
||||
if (adaptor != null) {
|
||||
availablePoints.addAll(adaptor.getData(config, pointConfig,
|
||||
localizedSite));
|
||||
}
|
||||
long t1 = System.currentTimeMillis();
|
||||
System.out.println("getClosestPoint.dbQuery took " + (t1 - t0)
|
||||
+ " for point source " + pointConfig.getPointSource());
|
||||
|
|
|
@ -42,7 +42,8 @@ import com.raytheon.viz.warngen.gis.AffectedAreas;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2012 15322 jsanchez Initial creation
|
||||
* Sep 24, 2012 15332 jsanchez Initial creation
|
||||
* Oct 18, 2012 15332 jsanchez Updated the find method.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -177,6 +178,8 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
* Locks the list of area names.
|
||||
*/
|
||||
private void areaNames() {
|
||||
Pattern listOfAreaNamePtrn = Pattern.compile(listOfAreaName + newline,
|
||||
Pattern.MULTILINE);
|
||||
find(listOfAreaNamePtrn.matcher(text));
|
||||
}
|
||||
|
||||
|
@ -186,7 +189,7 @@ abstract public class AbstractLockingBehavior implements ICommonPatterns {
|
|||
* @param m
|
||||
*/
|
||||
protected void find(Matcher m) {
|
||||
if (m.find()) {
|
||||
while (m.find()) {
|
||||
String group = m.group();
|
||||
// If line already starts with a LOCK_END, the LOCK_END is removed
|
||||
// and the line just adds to the LOCK_END at the end.
|
||||
|
|
|
@ -30,7 +30,8 @@ import java.util.regex.Pattern;
|
|||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2012 15322 jsanchez Initial creation
|
||||
* Sep 24, 2012 15332 jsanchez Initial creation
|
||||
* Oct 18, 2012 15332 jsanchez Replaced listOfAreaNamesPtrn with String pattern.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -53,9 +54,8 @@ public interface ICommonPatterns {
|
|||
|
||||
// LOCK_END can be added at the start of the line if a previous line has
|
||||
// been locked.
|
||||
public static Pattern listOfAreaNamePtrn = Pattern.compile("^((" + LOCK_END
|
||||
+ "){0,1}(((\\w+\\s{1})+\\w{2}-)*((\\w+\\s{1})+\\w{2}-))" + newline
|
||||
+ ")", Pattern.MULTILINE);
|
||||
public static final String listOfAreaName = "^((" + LOCK_END
|
||||
+ "){0,1}(((\\w+\\s{1})+\\w{2}-)*((\\w+\\s{1})+\\w{2}-)))";
|
||||
|
||||
// LOCK_END should not be found at the beginning of a first bullet since the
|
||||
// previous line should be blank.
|
||||
|
|
|
@ -32,6 +32,7 @@ import java.util.regex.Pattern;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Sep 24, 2012 15322 jsanchez Initial creation
|
||||
* Oct 19, 2012 15332 jsanchez Created a local pattern listOfAreaNamesPtrn.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -69,6 +70,10 @@ public class WrapUtil implements ICommonPatterns {
|
|||
// ugc pattern
|
||||
private static final Pattern ugcPtrn = Pattern.compile(ugc);
|
||||
|
||||
// list of areas pattern
|
||||
private static final Pattern listOfAreaNamePtrn = Pattern
|
||||
.compile(listOfAreaName);
|
||||
|
||||
/**
|
||||
* Wraps the text independent of being locked before or after.
|
||||
*
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.raytheon.viz.warngen.text.ICommonPatterns;
|
|||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Jul 22, 2008 #1284 bwoodle Initial creation
|
||||
* Oct 18, 2012 15332 jsanchez Fixed refactor bugs.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -165,26 +166,18 @@ public class FollowUpUtil {
|
|||
*/
|
||||
public static ArrayList<AffectedAreas> canceledAreasFromText(
|
||||
String originalText) {
|
||||
boolean ugcdone = false;
|
||||
boolean namedone = false;
|
||||
boolean insideHeadline = false;
|
||||
String ugcLine = "";
|
||||
String ugcLine = getUgcLineCanFromText(originalText);
|
||||
String namesLine = "";
|
||||
String headline = "";
|
||||
Pattern ugcPtrn = Pattern.compile(ICommonPatterns.ugc);
|
||||
Pattern listOfAreaNamePtrn = Pattern
|
||||
.compile(ICommonPatterns.listOfAreaName);
|
||||
for (String line : originalText.trim().split("\n")) {
|
||||
if (line.contains("TEST") || line.trim().length() == 0) {
|
||||
continue;
|
||||
}
|
||||
Matcher m = ugcPtrn.matcher(line);
|
||||
if (!ugcdone && m.find()) {
|
||||
ugcLine += m.group();
|
||||
continue;
|
||||
} else if (ugcLine.length() > 0) {
|
||||
ugcdone = true;
|
||||
}
|
||||
|
||||
m = ICommonPatterns.listOfAreaNamePtrn.matcher(line);
|
||||
Matcher m = listOfAreaNamePtrn.matcher(line);
|
||||
if (!namedone && m.find()) {
|
||||
namesLine += m.group();
|
||||
continue;
|
||||
|
@ -221,7 +214,6 @@ public class FollowUpUtil {
|
|||
AffectedAreas affectedArea = new AffectedAreas();
|
||||
String ugc = ugcs[i].trim();
|
||||
if (ugc.length() == 6) {
|
||||
stateAbbreviation = ugc.substring(0, 2);
|
||||
if (ugc.charAt(2) == 'Z') {
|
||||
areaNotation = "ZONE";
|
||||
areasNotation = "ZONES";
|
||||
|
@ -235,6 +227,7 @@ public class FollowUpUtil {
|
|||
|
||||
if (i < names.length) {
|
||||
name = names[i].substring(0, names[i].length() - 3);
|
||||
stateAbbreviation = names[i].substring(names[i].length() - 2);
|
||||
}
|
||||
|
||||
if (name != null) {
|
||||
|
@ -268,7 +261,7 @@ public class FollowUpUtil {
|
|||
public static String getUgcLineCanFromText(String originalText) {
|
||||
String ugcLine = "";
|
||||
Pattern ugcPtrn = Pattern.compile(ICommonPatterns.ugc);
|
||||
for (String line : originalText.trim().split("\n")) {
|
||||
for (String line : originalText.replaceAll("\r", "").trim().split("\n")) {
|
||||
Matcher m = ugcPtrn.matcher(line);
|
||||
if (m.find()) {
|
||||
ugcLine += line;
|
||||
|
|
Loading…
Add table
Reference in a new issue