Merge "Issue #1133 Better error handling for invalid polygons in map resource. Change-Id: Ib935f3c4fee42dae21eb52adf19ea9e2e9d76442" into development

Former-commit-id: 5afcf8bee2 [formerly 2b491f11ad] [formerly 5afcf8bee2 [formerly 2b491f11ad] [formerly ca560e5fc0 [formerly 9f4d6e687d0dae6dd9104fd39c44144c0d7ce174]]]
Former-commit-id: ca560e5fc0
Former-commit-id: 7924115bbc [formerly 86b10cfd4b]
Former-commit-id: 6ae94c0f65
This commit is contained in:
Ron Anderson 2013-08-15 10:50:57 -05:00 committed by Gerrit Code Review
commit 6a8381426a

View file

@ -27,9 +27,11 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import org.apache.commons.lang.StringUtils;
@ -75,6 +77,7 @@ import com.raytheon.viz.core.spatial.GeometryCache;
import com.vividsolutions.jts.geom.Envelope;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.TopologyException;
import com.vividsolutions.jts.io.WKBReader;
/**
@ -85,8 +88,10 @@ import com.vividsolutions.jts.io.WKBReader;
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2009 randerso Initial creation
* Sep 18, 2012 #1019 randerso improved error handling
* Feb 19, 2009 randerso Initial creation
* Sep 18, 2012 1019 randerso improved error handling
* Aug 12, 2013 1133 bsteffen Better error handling for invalid
* polygons in map resource.
*
* </pre>
*
@ -383,6 +388,9 @@ public class DbMapResource extends
List<Geometry> resultingGeoms = new ArrayList<Geometry>(
mappedResult.getResultCount());
Set<String> unlabelablePoints = new HashSet<String>(0);
int numPoints = 0;
for (int i = 0; i < mappedResult.getResultCount(); ++i) {
if (canceled) {
@ -426,11 +434,19 @@ public class DbMapResource extends
});
for (Geometry poly : gList) {
Point point = poly.getInteriorPoint();
if (point.getCoordinate() != null) {
LabelNode node = new LabelNode(label,
point, req.target);
newLabels.add(node);
try {
Point point = poly.getInteriorPoint();
if (point.getCoordinate() != null) {
LabelNode node = new LabelNode(label,
point, req.target);
newLabels.add(node);
}
} catch (TopologyException e) {
statusHandler.handle(Priority.VERBOSE,
"Invalid geometry cannot be labeled: "
+ label,
e);
unlabelablePoints.add(label);
}
}
}
@ -445,6 +461,12 @@ public class DbMapResource extends
}
}
if (!unlabelablePoints.isEmpty()) {
statusHandler.handle(Priority.WARN,
"Invalid geometries cannot be labeled: "
+ unlabelablePoints.toString());
}
newOutlineShape.allocate(numPoints);
for (Geometry g : resultingGeoms) {