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

Change-Id: Iff5460327f799c69800672deb9481e4d65874a62

Former-commit-id: cbfdfa4818 [formerly 361a999d368e183513518e87bd350f3ff26ea8c0]
Former-commit-id: 9a7a8c0f9c
This commit is contained in:
Max Schenkelberg 2012-11-01 16:38:10 -05:00
parent bcf575966b
commit 3eebdd0ded

View file

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