Merge "Issue #1307 Ensured wrap correcting occurs fully over -180-180 boundary at a minimum." into development

Former-commit-id: 32c1912eef76a513b79e6419ec90c9141dd56479
This commit is contained in:
Nate Jensen 2012-11-01 17:29:57 -05:00 committed by Gerrit Code Review
commit ada2d72a9c

View file

@ -225,15 +225,25 @@ public class WorldWrapCorrector {
// throw them out since we can't guarantee integrity
GeometryFactory gf = flattenedGeom.getFactory();
double delta = 0.00001;
double start = checker.getLowInverseCentralMeridian() + offsets[0];
double end = checker.getHighInverseCentralMeridian() + offsets[1];
// Because Geometries are within bounds -180-180, ensure our initial
// start/end range will fully cover it
double lowInverseCentral = checker.getLowInverseCentralMeridian();
if (lowInverseCentral > -180.0) {
lowInverseCentral -= 360.0;
}
double highInverseCentral = checker.getHighInverseCentralMeridian();
if (highInverseCentral < 180.0) {
highInverseCentral += 360.0;
}
double start = lowInverseCentral + offsets[0];
double end = highInverseCentral + offsets[1];
double minY = -90, maxY = 90;
while (start < end) {
double useStart = start;
double useEnd = start + 360;
double minX = useStart + delta;
double maxX = (useEnd) - delta;
double maxX = useEnd - delta;
Geometry section = gf.createPolygon(
gf.createLinearRing(new Coordinate[] {
@ -246,7 +256,7 @@ public class WorldWrapCorrector {
if (section.isEmpty() == false) {
geoms.add(section);
}
start += 360.0;
start = useEnd;
}
}
}