Issue #1553 fix RenderableTileSet for round projections.
Former-commit-id:1e6d6ac799
[formerly 8bd997f193b4a8cc75fc6609b321b29f2524c08b] Former-commit-id:f31215a999
This commit is contained in:
parent
9183e40c5f
commit
8c3deb1a93
1 changed files with 28 additions and 1 deletions
|
@ -174,6 +174,10 @@ public class EnvelopeIntersection {
|
|||
|
||||
MathTransform latLonToTargetCRS = targetCRSToLatLon.inverse();
|
||||
|
||||
// If we are able to create a polygon from the lineStrings, save it in
|
||||
// this variable to use later if all else fails.
|
||||
Geometry correctedPolygon = null;
|
||||
|
||||
int numStrings = lineStrings.size();
|
||||
if (numStrings == 1) {
|
||||
// Check for one continuous line string that starts and ends at same
|
||||
|
@ -182,7 +186,8 @@ public class EnvelopeIntersection {
|
|||
Coordinate[] coords = ls.getCoordinates();
|
||||
if (coords[0].equals(coords[coords.length - 1])) {
|
||||
border = gf.createPolygon(gf.createLinearRing(coords), null);
|
||||
border = JTS.transform(corrector.correct(JTS.transform(border,
|
||||
border = correctedPolygon = JTS.transform(corrector.correct(JTS
|
||||
.transform(border,
|
||||
targetCRSToLatLon)), latLonToTargetCRS);
|
||||
}
|
||||
}
|
||||
|
@ -481,6 +486,28 @@ public class EnvelopeIntersection {
|
|||
}
|
||||
}
|
||||
|
||||
if ((border == null || border.isEmpty() || border.isValid() == false)) {
|
||||
if (correctedPolygon != null) {
|
||||
// buffering will make an invalid polygon valid. This is known
|
||||
// to be the correct action for rounded grids such as lat/lon
|
||||
// source on a polar stereographic target or radial data.
|
||||
border = correctedPolygon.buffer(0);
|
||||
} else if (lineStrings.size() == 1) {
|
||||
// There is a last resort. There are no known envelopes that hit
|
||||
// this but just in case we have problems this will be slightly
|
||||
// better than nothing.
|
||||
border = lineStrings.get(0).getEnvelope();
|
||||
} else {
|
||||
// Also a last resort.
|
||||
List<Geometry> envelopes = new ArrayList<Geometry>(
|
||||
lineStrings.size());
|
||||
for (LineString ls : lineStrings) {
|
||||
envelopes.add(ls.getEnvelope());
|
||||
}
|
||||
gf.createGeometryCollection(envelopes.toArray(new Geometry[0]));
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Time to create EnvelopeIntersection: "
|
||||
+ (System.currentTimeMillis() - t0) + "ms");
|
||||
return border;
|
||||
|
|
Loading…
Add table
Reference in a new issue