From 04c8c3ca55acba881a6596b14070de329a330467 Mon Sep 17 00:00:00 2001 From: Steve Harris Date: Wed, 22 Aug 2012 13:01:08 -0500 Subject: [PATCH] Issue #915 Set the user data. (cherry picked from development_on_ss_builds) Conflicts: edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/WarngenConfiguration.java Former-commit-id: b8629a0f20ab48986b238b9e69b2d7e288ef9f20 [formerly ef64da82bb8594eddead221f7c5bf5fa95e4ff8b] Former-commit-id: 8e3ecc1efd4fa9132d64b04373e9aaa52c5bedc0 --- .../com/raytheon/viz/warngen/gis/Area.java | 29 +++++++++++- .../config/AreaSourceConfiguration.java | 17 ++++++- .../warning/config/WarngenConfiguration.java | 47 +++++++++++++------ 3 files changed, 75 insertions(+), 18 deletions(-) diff --git a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java index 951197ee00..2cd987c0db 100644 --- a/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java +++ b/cave/com.raytheon.viz.warngen/src/com/raytheon/viz/warngen/gis/Area.java @@ -316,6 +316,22 @@ public class Area { return areas.toArray(new AffectedAreas[areas.size()]); } + /** + * Determines the affected areas that intersect the warnArea. This method + * should be used if the intersected areas are of a different area source + * compared to the hatched area source. Otherwise, the information in the + * warnArea can just be re-used in the template. If the area source of the + * intersect and the hatched are the same, then the configuration and + * template files are configured inefficiently. + * + * @param config + * @param warnPolygon + * @param warnArea + * @param localizedSite + * @param warngenLayer + * @return + * @throws VizException + */ public static Map findInsectingAreas( WarngenConfiguration config, Geometry warnPolygon, Geometry warnArea, String localizedSite, WarngenLayer warngenLayer) @@ -332,8 +348,17 @@ public class Area { for (GeospatialData f : warngenLayer.getGeodataFeatures(key)) { for (int i = 0; i < warnArea.getNumGeometries(); i++) { Geometry geom = warnArea.getGeometryN(i); - if (f.geometry.intersects(geom)) { - GeometryUtil.buildGeometryList(geoms, f.geometry); + if (GeometryUtil.intersects(f.geometry, geom)) { + Geometry intersect = f.geometry.intersection(geom); + if (intersect != null && !intersect.isEmpty()) { + for (int j = 0; j < intersect + .getNumGeometries(); j++) { + intersect.getGeometryN(j).setUserData( + f.geometry.getUserData()); + } + GeometryUtil + .buildGeometryList(geoms, intersect); + } break; } } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/AreaSourceConfiguration.java b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/AreaSourceConfiguration.java index 14e6c046b5..a303c7c932 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/AreaSourceConfiguration.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/AreaSourceConfiguration.java @@ -39,6 +39,13 @@ public class AreaSourceConfiguration { @XmlElement private AreaType areaType = AreaType.INTERSECT; + /* + * TODO This is for 12.9 to be backwards compatible. This will be removed in + * 12.10 + */ + @XmlElement + private AreaType areaType; + @XmlAttribute private String variable; @@ -59,7 +66,7 @@ public class AreaSourceConfiguration { @XmlElement private String areaNotationTranslationFile; - + @XmlElement private String timeZoneField; @@ -271,4 +278,12 @@ public class AreaSourceConfiguration { this.timeZoneField = timeZoneField; } + public AreaType getAreaType() { + return areaType; + } + + public void setAreaType(AreaType areaType) { + this.areaType = areaType; + } + } diff --git a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/WarngenConfiguration.java b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/WarngenConfiguration.java index 5d5b99ce12..2ebe4da7fb 100644 --- a/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/WarngenConfiguration.java +++ b/edexOsgi/com.raytheon.uf.common.dataplugin.warning/src/com/raytheon/uf/common/dataplugin/warning/config/WarngenConfiguration.java @@ -25,7 +25,6 @@ import java.text.ParseException; import java.text.ParsePosition; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -81,6 +80,8 @@ public class WarngenConfiguration implements ISerializableObject { @XmlElement private PathcastConfiguration pathcastConfig; + private AreaSourceConfiguration hatchedAreaSource; + @XmlElement private AreaConfiguration areaConfig; @@ -200,31 +201,39 @@ public class WarngenConfiguration implements ISerializableObject { } } - List ascList = new ArrayList(); + // TODO This section is for 12.9 to be backwards compatible with old + // configuration files. 12.10 will drop the use of 'areaConfig'. if (config.getAreaConfig() != null) { - AreaSourceConfiguration areaSourceConfig = new AreaSourceConfiguration( - config.getAreaConfig()); - ascList.add(areaSourceConfig); - } + ArrayList areaSources = null; - AreaSourceConfiguration ascs[] = config.getAreaSources(); - if (ascs != null) { - ascList.addAll(Arrays.asList(ascs)); + if (config.getAreaSources() == null) { + areaSources = new ArrayList(); + } else { + areaSources = new ArrayList( + Arrays.asList(config.getAreaSources())); + } + areaSources + .add(new AreaSourceConfiguration(config.getAreaConfig())); + config.setAreaSources(areaSources + .toArray(new AreaSourceConfiguration[areaSources.size()])); } + // 12.9 section end - for (AreaSourceConfiguration asc : ascList) { + for (AreaSourceConfiguration asc : config.getAreaSources()) { if (asc.getAreaSource() == null) { asc.setAreaSource(config.getGeospatialConfig().getAreaSource()); } - if (asc.getAreaType() == AreaType.HATCHING) { - config.setAreaConfig(asc.getAreaConfig()); + // 12.9. 12.10 get rid of 'areaType' + if (asc.getAreaType() != null) { + asc.setType(asc.getAreaType()); + } + + if (asc.getType() == AreaType.HATCHING) { + config.setHatchedAreaSource(asc); } } - config.setAreaSources(ascList - .toArray(new AreaSourceConfiguration[ascList.size()])); - if (config.getPathcastConfig() != null && config.getPathcastConfig().getPointSource() == null) { config.getPathcastConfig().setPointSource( @@ -482,4 +491,12 @@ public class WarngenConfiguration implements ISerializableObject { this.enableDuration = enableDuration; } + public AreaSourceConfiguration getHatchedAreaSource() { + return hatchedAreaSource; + } + + public void setHatchedAreaSource(AreaSourceConfiguration hatchedAreaSource) { + this.hatchedAreaSource = hatchedAreaSource; + } + }