Issue #1170 Made checks so world wrap correct only occurs if polygon was actually flattened. If polygon was flattened and it is invalid, polygon will be skipped so we only attempt to correct valid polygons. If no correction is needed, we add invalid ones anyway since half of downscaled US invalid.
Change-Id: I0c1ddf9f673ff1353f82dec42404985b7f269c10 Former-commit-id:a47387a466
[formerly c57bd3a8e0015541f41cff4d2ec6b36e1067146c] Former-commit-id:084ac453b0
This commit is contained in:
parent
51e565c6ff
commit
a458e73cef
1 changed files with 28 additions and 21 deletions
|
@ -163,30 +163,37 @@ public class WorldWrapCorrector {
|
|||
|
||||
private void correct(List<Geometry> geoms, Geometry flattenedGeom,
|
||||
double inverseCentralMeridian, double minOffset, double maxOffset) {
|
||||
GeometryFactory gf = flattenedGeom.getFactory();
|
||||
double delta = 0.00001;
|
||||
double start = inverseCentralMeridian + minOffset - 360;
|
||||
double end = inverseCentralMeridian + maxOffset + 360;
|
||||
double minY = -90, maxY = 90;
|
||||
if (minOffset == 0.0 && maxOffset == 0.0) {
|
||||
// no offsets to apply, add and return
|
||||
geoms.add(flattenedGeom);
|
||||
return;
|
||||
} else if (flattenedGeom.isValid()) {
|
||||
// Only apply world wrap correcting to valid geometries
|
||||
GeometryFactory gf = flattenedGeom.getFactory();
|
||||
double delta = 0.00001;
|
||||
double start = inverseCentralMeridian + minOffset - 360;
|
||||
double end = inverseCentralMeridian + maxOffset + 360;
|
||||
double minY = -90, maxY = 90;
|
||||
|
||||
while (start < end) {
|
||||
double useStart = start;
|
||||
double useEnd = start + 360;
|
||||
double minX = useStart + delta;
|
||||
double maxX = (useEnd) - delta;
|
||||
while (start < end) {
|
||||
double useStart = start;
|
||||
double useEnd = start + 360;
|
||||
double minX = useStart + delta;
|
||||
double maxX = (useEnd) - delta;
|
||||
|
||||
Geometry section = gf.createPolygon(
|
||||
gf.createLinearRing(new Coordinate[] {
|
||||
new Coordinate(minX, maxY),
|
||||
new Coordinate(maxX, maxY),
|
||||
new Coordinate(maxX, minY),
|
||||
new Coordinate(minX, minY),
|
||||
new Coordinate(minX, maxY) }), null);
|
||||
section = section.intersection(flattenedGeom);
|
||||
if (section.isEmpty() == false) {
|
||||
geoms.add(section);
|
||||
Geometry section = gf.createPolygon(
|
||||
gf.createLinearRing(new Coordinate[] {
|
||||
new Coordinate(minX, maxY),
|
||||
new Coordinate(maxX, maxY),
|
||||
new Coordinate(maxX, minY),
|
||||
new Coordinate(minX, minY),
|
||||
new Coordinate(minX, maxY) }), null);
|
||||
section = section.intersection(flattenedGeom);
|
||||
if (section.isEmpty() == false) {
|
||||
geoms.add(section);
|
||||
}
|
||||
start += 360.0;
|
||||
}
|
||||
start += 360.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue