Issue #1133 Better error handling for invalid polygons in map resource.

Change-Id: Ib935f3c4fee42dae21eb52adf19ea9e2e9d76442

Former-commit-id: aa08c8af42 [formerly 27594e6808] [formerly aa08c8af42 [formerly 27594e6808] [formerly 7f9bbf3d52 [formerly 68f1b06c79639874b94b87e4f4365f1fe36c7bac]]]
Former-commit-id: 7f9bbf3d52
Former-commit-id: b970d2ffbb [formerly 5b51795a18]
Former-commit-id: 717b078a6a
This commit is contained in:
Ben Steffensmeier 2013-08-12 16:07:17 -05:00
parent 35dec4295c
commit 8830b5717f

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;
/**
@ -86,7 +89,9 @@ import com.vividsolutions.jts.io.WKBReader;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 19, 2009 randerso Initial creation
* Sep 18, 2012 #1019 randerso improved error handling
* 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,12 +434,20 @@ public class DbMapResource extends
});
for (Geometry poly : gList) {
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) {