Issue #1133 Better error handling for invalid polygons in map resource.
Change-Id: Ib935f3c4fee42dae21eb52adf19ea9e2e9d76442 Former-commit-id: 68f1b06c79639874b94b87e4f4365f1fe36c7bac
This commit is contained in:
parent
d8124958b5
commit
27594e6808
1 changed files with 29 additions and 7 deletions
|
@ -27,9 +27,11 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
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.Envelope;
|
||||||
import com.vividsolutions.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import com.vividsolutions.jts.geom.Point;
|
import com.vividsolutions.jts.geom.Point;
|
||||||
|
import com.vividsolutions.jts.geom.TopologyException;
|
||||||
import com.vividsolutions.jts.io.WKBReader;
|
import com.vividsolutions.jts.io.WKBReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,7 +89,9 @@ import com.vividsolutions.jts.io.WKBReader;
|
||||||
* Date Ticket# Engineer Description
|
* Date Ticket# Engineer Description
|
||||||
* ------------ ---------- ----------- --------------------------
|
* ------------ ---------- ----------- --------------------------
|
||||||
* Feb 19, 2009 randerso Initial creation
|
* 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>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
@ -383,6 +388,9 @@ public class DbMapResource extends
|
||||||
|
|
||||||
List<Geometry> resultingGeoms = new ArrayList<Geometry>(
|
List<Geometry> resultingGeoms = new ArrayList<Geometry>(
|
||||||
mappedResult.getResultCount());
|
mappedResult.getResultCount());
|
||||||
|
|
||||||
|
Set<String> unlabelablePoints = new HashSet<String>(0);
|
||||||
|
|
||||||
int numPoints = 0;
|
int numPoints = 0;
|
||||||
for (int i = 0; i < mappedResult.getResultCount(); ++i) {
|
for (int i = 0; i < mappedResult.getResultCount(); ++i) {
|
||||||
if (canceled) {
|
if (canceled) {
|
||||||
|
@ -426,12 +434,20 @@ public class DbMapResource extends
|
||||||
});
|
});
|
||||||
|
|
||||||
for (Geometry poly : gList) {
|
for (Geometry poly : gList) {
|
||||||
|
try {
|
||||||
Point point = poly.getInteriorPoint();
|
Point point = poly.getInteriorPoint();
|
||||||
if (point.getCoordinate() != null) {
|
if (point.getCoordinate() != null) {
|
||||||
LabelNode node = new LabelNode(label,
|
LabelNode node = new LabelNode(label,
|
||||||
point, req.target);
|
point, req.target);
|
||||||
newLabels.add(node);
|
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);
|
newOutlineShape.allocate(numPoints);
|
||||||
|
|
||||||
for (Geometry g : resultingGeoms) {
|
for (Geometry g : resultingGeoms) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue