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: b8629a0f20 [formerly ef64da82bb8594eddead221f7c5bf5fa95e4ff8b]
Former-commit-id: 8e3ecc1efd
This commit is contained in:
Steve Harris 2012-08-22 13:01:08 -05:00
parent e404398ea6
commit 04c8c3ca55
3 changed files with 75 additions and 18 deletions

View file

@ -316,6 +316,22 @@ public class Area {
return areas.toArray(new AffectedAreas[areas.size()]); 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<String, Object> findInsectingAreas( public static Map<String, Object> findInsectingAreas(
WarngenConfiguration config, Geometry warnPolygon, WarngenConfiguration config, Geometry warnPolygon,
Geometry warnArea, String localizedSite, WarngenLayer warngenLayer) Geometry warnArea, String localizedSite, WarngenLayer warngenLayer)
@ -332,8 +348,17 @@ public class Area {
for (GeospatialData f : warngenLayer.getGeodataFeatures(key)) { for (GeospatialData f : warngenLayer.getGeodataFeatures(key)) {
for (int i = 0; i < warnArea.getNumGeometries(); i++) { for (int i = 0; i < warnArea.getNumGeometries(); i++) {
Geometry geom = warnArea.getGeometryN(i); Geometry geom = warnArea.getGeometryN(i);
if (f.geometry.intersects(geom)) { if (GeometryUtil.intersects(f.geometry, geom)) {
GeometryUtil.buildGeometryList(geoms, f.geometry); 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; break;
} }
} }

View file

@ -39,6 +39,13 @@ public class AreaSourceConfiguration {
@XmlElement @XmlElement
private AreaType areaType = AreaType.INTERSECT; 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 @XmlAttribute
private String variable; private String variable;
@ -59,7 +66,7 @@ public class AreaSourceConfiguration {
@XmlElement @XmlElement
private String areaNotationTranslationFile; private String areaNotationTranslationFile;
@XmlElement @XmlElement
private String timeZoneField; private String timeZoneField;
@ -271,4 +278,12 @@ public class AreaSourceConfiguration {
this.timeZoneField = timeZoneField; this.timeZoneField = timeZoneField;
} }
public AreaType getAreaType() {
return areaType;
}
public void setAreaType(AreaType areaType) {
this.areaType = areaType;
}
} }

View file

@ -25,7 +25,6 @@ import java.text.ParseException;
import java.text.ParsePosition; import java.text.ParsePosition;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -81,6 +80,8 @@ public class WarngenConfiguration implements ISerializableObject {
@XmlElement @XmlElement
private PathcastConfiguration pathcastConfig; private PathcastConfiguration pathcastConfig;
private AreaSourceConfiguration hatchedAreaSource;
@XmlElement @XmlElement
private AreaConfiguration areaConfig; private AreaConfiguration areaConfig;
@ -200,31 +201,39 @@ public class WarngenConfiguration implements ISerializableObject {
} }
} }
List<AreaSourceConfiguration> ascList = new ArrayList<AreaSourceConfiguration>(); // 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) { if (config.getAreaConfig() != null) {
AreaSourceConfiguration areaSourceConfig = new AreaSourceConfiguration( ArrayList<AreaSourceConfiguration> areaSources = null;
config.getAreaConfig());
ascList.add(areaSourceConfig);
}
AreaSourceConfiguration ascs[] = config.getAreaSources(); if (config.getAreaSources() == null) {
if (ascs != null) { areaSources = new ArrayList<AreaSourceConfiguration>();
ascList.addAll(Arrays.asList(ascs)); } else {
areaSources = new ArrayList<AreaSourceConfiguration>(
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) { if (asc.getAreaSource() == null) {
asc.setAreaSource(config.getGeospatialConfig().getAreaSource()); asc.setAreaSource(config.getGeospatialConfig().getAreaSource());
} }
if (asc.getAreaType() == AreaType.HATCHING) { // 12.9. 12.10 get rid of 'areaType'
config.setAreaConfig(asc.getAreaConfig()); 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 if (config.getPathcastConfig() != null
&& config.getPathcastConfig().getPointSource() == null) { && config.getPathcastConfig().getPointSource() == null) {
config.getPathcastConfig().setPointSource( config.getPathcastConfig().setPointSource(
@ -482,4 +491,12 @@ public class WarngenConfiguration implements ISerializableObject {
this.enableDuration = enableDuration; this.enableDuration = enableDuration;
} }
public AreaSourceConfiguration getHatchedAreaSource() {
return hatchedAreaSource;
}
public void setHatchedAreaSource(AreaSourceConfiguration hatchedAreaSource) {
this.hatchedAreaSource = hatchedAreaSource;
}
} }