Merge branch 'master_14.1.2' into master_14.2.1 CM-MERGE:OB14.1.2-6,-7 into 14.2.1
Former-commit-id:d5a4669fc4
[formerly 19032f03b1d2166f4afd936bb2b56e0b4851d9f4] Former-commit-id:dbd3bb54e8
This commit is contained in:
commit
c4b7b8dd74
3 changed files with 52 additions and 3 deletions
|
@ -75,6 +75,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
||||||
* May 2, 2013 1963 jsanchez Updated method to determine partOfArea.
|
* May 2, 2013 1963 jsanchez Updated method to determine partOfArea.
|
||||||
* Aug 19, 2013 2177 jsanchez Used portionsUtil to calculate area portion descriptions.
|
* Aug 19, 2013 2177 jsanchez Used portionsUtil to calculate area portion descriptions.
|
||||||
* Apr 29, 2014 3033 jsanchez Updated method to retrieve files in localization.
|
* Apr 29, 2014 3033 jsanchez Updated method to retrieve files in localization.
|
||||||
|
* May 16, 2014 DR 17365 D. Friedman Reduce precision of warning area to avoid topology errors.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author chammack
|
* @author chammack
|
||||||
|
@ -292,6 +293,15 @@ public class Area {
|
||||||
WarngenLayer warngenLayer) throws VizException {
|
WarngenLayer warngenLayer) throws VizException {
|
||||||
Map<String, Object> areasMap = new HashMap<String, Object>();
|
Map<String, Object> areasMap = new HashMap<String, Object>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
Geometry precisionReducedArea = PolygonUtil.reducePrecision(warnArea);
|
||||||
|
if (precisionReducedArea.isValid()) {
|
||||||
|
warnArea = precisionReducedArea;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
|
||||||
String hatchedAreaSource = config.getHatchedAreaSource()
|
String hatchedAreaSource = config.getHatchedAreaSource()
|
||||||
.getAreaSource();
|
.getAreaSource();
|
||||||
for (AreaSourceConfiguration asc : config.getAreaSources()) {
|
for (AreaSourceConfiguration asc : config.getAreaSources()) {
|
||||||
|
|
|
@ -47,13 +47,16 @@ import com.vividsolutions.jts.geom.Coordinate;
|
||||||
import com.vividsolutions.jts.geom.CoordinateSequence;
|
import com.vividsolutions.jts.geom.CoordinateSequence;
|
||||||
import com.vividsolutions.jts.geom.Envelope;
|
import com.vividsolutions.jts.geom.Envelope;
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
import com.vividsolutions.jts.geom.GeometryCollection;
|
||||||
import com.vividsolutions.jts.geom.GeometryFactory;
|
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||||
import com.vividsolutions.jts.geom.LineSegment;
|
import com.vividsolutions.jts.geom.LineSegment;
|
||||||
import com.vividsolutions.jts.geom.LinearRing;
|
import com.vividsolutions.jts.geom.LinearRing;
|
||||||
import com.vividsolutions.jts.geom.Point;
|
import com.vividsolutions.jts.geom.Point;
|
||||||
import com.vividsolutions.jts.geom.Polygon;
|
import com.vividsolutions.jts.geom.Polygon;
|
||||||
|
import com.vividsolutions.jts.geom.PrecisionModel;
|
||||||
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
import com.vividsolutions.jts.geom.prep.PreparedGeometry;
|
||||||
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
||||||
|
import com.vividsolutions.jts.precision.SimpleGeometryPrecisionReducer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility for polygon operations
|
* Utility for polygon operations
|
||||||
|
@ -81,6 +84,7 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
||||||
* 10/18/2013 DR 16632 Qinglu Lin Catch exception thrown when coords length is less than 4 and doing createLinearRing(coords).
|
* 10/18/2013 DR 16632 Qinglu Lin Catch exception thrown when coords length is less than 4 and doing createLinearRing(coords).
|
||||||
* 01/09/2014 DR 16974 D. Friedman Improve followup redraw-from-hatched-area polygons.
|
* 01/09/2014 DR 16974 D. Friedman Improve followup redraw-from-hatched-area polygons.
|
||||||
* 04/15/2014 DR 17247 D. Friedman Prevent some invalid coordinates in adjustVertex.
|
* 04/15/2014 DR 17247 D. Friedman Prevent some invalid coordinates in adjustVertex.
|
||||||
|
* 05/16/2014 DR 17365 D. Friedman Prevent some Coordinate reuse. Add reducePrecision.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mschenke
|
* @author mschenke
|
||||||
|
@ -99,6 +103,8 @@ public class PolygonUtil {
|
||||||
|
|
||||||
private MathTransform latLonToContour, contourToLatLon;
|
private MathTransform latLonToContour, contourToLatLon;
|
||||||
|
|
||||||
|
private static final PrecisionModel REDUCED_PRECISION = new PrecisionModel(10000000000.0);
|
||||||
|
|
||||||
public PolygonUtil(WarngenLayer layer, int nx, int ny, int maxVertices,
|
public PolygonUtil(WarngenLayer layer, int nx, int ny, int maxVertices,
|
||||||
IExtent localExtent, MathTransform localToLatLon) throws Exception {
|
IExtent localExtent, MathTransform localToLatLon) throws Exception {
|
||||||
this.layer = layer;
|
this.layer = layer;
|
||||||
|
@ -127,9 +133,15 @@ public class PolygonUtil {
|
||||||
* hatched area. If it does, that intersection can be used instead of
|
* hatched area. If it does, that intersection can be used instead of
|
||||||
* generating a new contour.
|
* generating a new contour.
|
||||||
*/
|
*/
|
||||||
if (oldWarningPolygon != null) {
|
if (oldWarningPolygon != null && oldWarningPolygon.isValid()
|
||||||
|
&& origPolygon.isValid()) {
|
||||||
try {
|
try {
|
||||||
Geometry intersection = origPolygon.intersection(oldWarningPolygon);
|
/*
|
||||||
|
* Create a clone to ensure we do not use a Coordinate from
|
||||||
|
* oldWarningPolygon.
|
||||||
|
*/
|
||||||
|
Geometry intersection = (Geometry) origPolygon
|
||||||
|
.intersection(oldWarningPolygon).clone();
|
||||||
if (intersection instanceof Polygon) {
|
if (intersection instanceof Polygon) {
|
||||||
Polygon polygonIntersection = (Polygon) intersection;
|
Polygon polygonIntersection = (Polygon) intersection;
|
||||||
if (polygonIntersection.isValid() &&
|
if (polygonIntersection.isValid() &&
|
||||||
|
@ -1657,4 +1669,27 @@ public class PolygonUtil {
|
||||||
}
|
}
|
||||||
return slope;
|
return slope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Creates a copy of a Geometry with reduced precision to reduce the chance of topology errors when used
|
||||||
|
* in intersection operations.
|
||||||
|
*
|
||||||
|
* @param g
|
||||||
|
* @return a new Geometry that is a copy of given Geometry with reduced
|
||||||
|
* precision. References to user data are copied. If there are GeometryCollection
|
||||||
|
* objects, user data is copied for each element.
|
||||||
|
*/
|
||||||
|
static public Geometry reducePrecision(Geometry g) {
|
||||||
|
Geometry result;
|
||||||
|
if (g instanceof GeometryCollection) {
|
||||||
|
Geometry[] list = new Geometry[g.getNumGeometries()];
|
||||||
|
for (int i = 0; i < list.length; ++i) {
|
||||||
|
list[i] = reducePrecision(g.getGeometryN(i));
|
||||||
|
}
|
||||||
|
GeometryFactory gf = new GeometryFactory();
|
||||||
|
result = gf.createGeometryCollection(list);
|
||||||
|
} else
|
||||||
|
result = SimpleGeometryPrecisionReducer.reduce(g, REDUCED_PRECISION);
|
||||||
|
result.setUserData(g.getUserData());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,6 +196,7 @@ import com.vividsolutions.jts.io.WKTReader;
|
||||||
* 01/09/2014 DR 16974 D. Friedman Improve followup redraw-from-hatched-area polygons.
|
* 01/09/2014 DR 16974 D. Friedman Improve followup redraw-from-hatched-area polygons.
|
||||||
* 04/15/2014 DR 17247 D. Friedman Rework error handling in AreaHatcher.
|
* 04/15/2014 DR 17247 D. Friedman Rework error handling in AreaHatcher.
|
||||||
* 04/28,2014 3033 jsanchez Properly handled back up configuration (*.xml) files. Set backupSite to null when backup site is not selected.
|
* 04/28,2014 3033 jsanchez Properly handled back up configuration (*.xml) files. Set backupSite to null when backup site is not selected.
|
||||||
|
* 05/16/2014 DR 17365 D. Friedman Check if moved vertex results in polygon valid in both lat/lon and local coordinates.
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
* @author mschenke
|
* @author mschenke
|
||||||
|
@ -2734,7 +2735,10 @@ public class WarngenLayer extends AbstractStormTrackResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!intersectFlag) {
|
if (!intersectFlag) {
|
||||||
state.setWarningPolygon(gf.createPolygon(ring, null));
|
Polygon p = gf.createPolygon(ring, null);
|
||||||
|
if (p.isValid() && latLonToLocal(p).isValid()) {
|
||||||
|
state.setWarningPolygon(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue