Issue #915 Set the user data.

Former-commit-id: f37a75f265 [formerly 865136f6ef] [formerly f37a75f265 [formerly 865136f6ef] [formerly 03ed8ee0b0 [formerly d0e0b6160cc0969353555bd7282829a3440c9ef6]]]
Former-commit-id: 03ed8ee0b0
Former-commit-id: f1749f4fcc [formerly e584d728f0]
Former-commit-id: 38bb2743e5
This commit is contained in:
Jonathan Sanchez 2012-08-15 14:05:50 -05:00
parent d47eda2d66
commit 49c757f958
3 changed files with 62 additions and 10 deletions

View file

@ -319,6 +319,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<String, Object> findInsectingAreas(
WarngenConfiguration config, Geometry warnPolygon,
Geometry warnArea, String localizedSite, WarngenLayer warngenLayer)
@ -335,8 +351,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;
}
}

View file

@ -39,6 +39,13 @@ public class AreaSourceConfiguration {
@XmlElement
private AreaType type = AreaType.HATCHING;
/*
* 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;
@ -270,4 +277,12 @@ public class AreaSourceConfiguration {
this.type = type;
}
public AreaType getAreaType() {
return areaType;
}
public void setAreaType(AreaType areaType) {
this.areaType = areaType;
}
}

View file

@ -24,6 +24,7 @@ import java.io.IOException;
import java.text.ParseException;
import java.text.ParsePosition;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -200,23 +201,34 @@ public class WarngenConfiguration implements ISerializableObject {
}
}
// TODO This section needs to be removed after new templates have been
// adopted dropping 'areaConfig'
if (config.getAreaSources() == null) {
ArrayList<AreaSourceConfiguration> areaSources = new ArrayList<AreaSourceConfiguration>();
if (config.getAreaConfig() != null) {
areaSources.add(new AreaSourceConfiguration(config
.getAreaConfig()));
// 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) {
ArrayList<AreaSourceConfiguration> areaSources = null;
if (config.getAreaSources() == null) {
areaSources = new ArrayList<AreaSourceConfiguration>();
} 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 : config.getAreaSources()) {
if (asc.getAreaSource() == null) {
asc.setAreaSource(config.getGeospatialConfig().getAreaSource());
}
// 12.9. 12.10 get rid of 'areaType'
if (asc.getAreaType() != null) {
asc.setType(asc.getAreaType());
}
if (asc.getType() == AreaType.HATCHING) {
config.setHatchedAreaSource(asc);
}