Issue #1133 Better error handling for invalid polygons in map resource.
Change-Id: Ib935f3c4fee42dae21eb52adf19ea9e2e9d76442 Former-commit-id:aa08c8af42
[formerly27594e6808
] [formerlyaa08c8af42
[formerly27594e6808
] [formerly7f9bbf3d52
[formerly 68f1b06c79639874b94b87e4f4365f1fe36c7bac]]] Former-commit-id:7f9bbf3d52
Former-commit-id:b970d2ffbb
[formerly5b51795a18
] Former-commit-id:717b078a6a
This commit is contained in:
parent
35dec4295c
commit
8830b5717f
1 changed files with 29 additions and 7 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue