Issue #1819 Added precision fields for point source configuration.
Former-commit-id: b250ff50f8a2ac6ad8ec91e14735edcd6f053343
This commit is contained in:
parent
f65989454a
commit
b0f61cf86c
2 changed files with 78 additions and 1 deletions
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import javax.measure.converter.UnitConverter;
|
||||
import javax.measure.unit.SI;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.geotools.geometry.jts.JTS;
|
||||
|
@ -19,6 +20,7 @@ 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.PointSourceConfiguration.PointType;
|
||||
import com.raytheon.uf.common.dataplugin.warning.config.WarngenConfiguration;
|
||||
import com.raytheon.uf.common.dataquery.requests.RequestConstraint;
|
||||
import com.raytheon.uf.common.geospatial.ISpatialQuery.SearchMode;
|
||||
|
@ -50,6 +52,7 @@ import com.vividsolutions.jts.geom.Point;
|
|||
* Oct 17, 2012 jsanchez Added pathcast algorithm.
|
||||
* Feb 12, 2013 1600 jsanchez Used adjustAngle method from AbstractStormTrackResource.
|
||||
* Mar 5, 2013 1600 jsanchez Used AdjustAngle instead of AbstractStormTrackResource to handle angle adjusting.
|
||||
* Mar 26, 2013 1819 jsanchez Allowed points to be not be based on point source inclusion constraints.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -62,6 +65,9 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
|
||||
private static final String GEOM_FIELD = "the_geom";
|
||||
|
||||
private static UnitConverter meterSqToKmSq = SI.METRE.times(SI.METRE)
|
||||
.getConverterTo(SI.KILOMETRE.times(SI.KILOMETRE));
|
||||
|
||||
protected Set<String> undatabasedSortableFields = new HashSet<String>(
|
||||
Arrays.asList(new String[] {
|
||||
ClosestPointComparator.Sort.DISTANCE.toString(),
|
||||
|
@ -209,7 +215,10 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
ClosestPoint cp = createClosestPoint(pointField, ptFields,
|
||||
ptRslt);
|
||||
cp.setGid(getGid(ptFields, ptRslt.attributes));
|
||||
points.add(cp);
|
||||
if (pointConfig.getType() == PointType.POINT
|
||||
|| includeArea(pointConfig, ptRslt.geometry)) {
|
||||
points.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,6 +226,40 @@ abstract public class AbstractDbSourceDataAdaptor {
|
|||
return points;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the geom surpasses the inclusion percent and/or inclusion
|
||||
* area configurations.
|
||||
*
|
||||
* @param pointConfig
|
||||
* @param geom
|
||||
* @return
|
||||
*/
|
||||
private boolean includeArea(PointSourceConfiguration pointConfig,
|
||||
Geometry geom) {
|
||||
String inclusionAndOr = pointConfig.getInclusionAndOr();
|
||||
double inclusionPercent = pointConfig.getInclusionPercent();
|
||||
double inclusionArea = pointConfig.getInclusionArea();
|
||||
|
||||
Geometry intersection = searchArea.intersection(geom);
|
||||
double ratio = intersection.getArea() / geom.getArea();
|
||||
double ratioInPercent = ratio * 100;
|
||||
double areaOfGeom = geom.getArea();
|
||||
double areaInKmSqOfIntersection = meterSqToKmSq.convert(areaOfGeom
|
||||
* ratio);
|
||||
|
||||
boolean includeArea = false;
|
||||
if (inclusionAndOr.equalsIgnoreCase("AND")
|
||||
&& ratioInPercent >= inclusionPercent
|
||||
&& areaInKmSqOfIntersection > inclusionArea) {
|
||||
includeArea = true;
|
||||
} else if (inclusionAndOr.equalsIgnoreCase("OR")
|
||||
&& (ratioInPercent >= inclusionPercent || areaInKmSqOfIntersection > inclusionArea)) {
|
||||
includeArea = true;
|
||||
}
|
||||
|
||||
return includeArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of implacted points/areas that are relative to the
|
||||
* centroid.
|
||||
|
|
|
@ -27,6 +27,7 @@ import com.raytheon.uf.common.dataquery.requests.RequestableMetadataMarshaller;
|
|||
* ------------ ---------- ----------- --------------------------
|
||||
* Aug 17, 2011 mschenke Initial creation
|
||||
* Jan 31, 2013 1557 jsanchez Added the XMLElement allowDuplicates.
|
||||
* Mar 26, 2013 1819 jsanchez Added inclusionPercent, inclusionArea, inclusionAndOr.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -88,6 +89,15 @@ public class PointSourceConfiguration {
|
|||
@XmlElement(name = "sort")
|
||||
private String[] sortBy;
|
||||
|
||||
@XmlElement
|
||||
private double inclusionPercent = 0.00;
|
||||
|
||||
@XmlElement
|
||||
private String inclusionAndOr = "AND";
|
||||
|
||||
@XmlElement
|
||||
private double inclusionArea = 0.00;
|
||||
|
||||
public String getVariable() {
|
||||
return variable;
|
||||
}
|
||||
|
@ -185,4 +195,28 @@ public class PointSourceConfiguration {
|
|||
this.allowDuplicates = allowDuplicates;
|
||||
}
|
||||
|
||||
public double getInclusionPercent() {
|
||||
return inclusionPercent;
|
||||
}
|
||||
|
||||
public void setInclusionPercent(double inclusionPercent) {
|
||||
this.inclusionPercent = inclusionPercent;
|
||||
}
|
||||
|
||||
public String getInclusionAndOr() {
|
||||
return inclusionAndOr;
|
||||
}
|
||||
|
||||
public void setInclusionAndOr(String inclusionAndOr) {
|
||||
this.inclusionAndOr = inclusionAndOr;
|
||||
}
|
||||
|
||||
public double getInclusionArea() {
|
||||
return inclusionArea;
|
||||
}
|
||||
|
||||
public void setInclusionArea(double inclusionArea) {
|
||||
this.inclusionArea = inclusionArea;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue