Issue #2619 Fix rare dateline bug.
Former-commit-id:399c579671
[formerly399c579671
[formerly 8231fde4fdcb25ad19e31dd8e4f5716becba347c]] Former-commit-id:607b5edb69
Former-commit-id:d0f4b18b78
This commit is contained in:
parent
d0fbf8df6b
commit
a92f15a8fa
2 changed files with 47 additions and 11 deletions
|
@ -46,10 +46,12 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory;
|
|||
*
|
||||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------ ---------- ----------- --------------------------
|
||||
* Oct 12, 2011 mschenke Initial creation
|
||||
* May 30, 2013 #2028 randerso Changed to return simple geometry or multi-geometry if possible
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- -----------------------------------------
|
||||
* Oct 12, 2011 mschenke Initial creation
|
||||
* May 30, 2013 2028 randerso Changed to return simple geometry or
|
||||
* multi-geometry if possible
|
||||
* Dec 11, 2013 2619 bsteffen Fix rare dateline bug in flattenGeometry.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -318,14 +320,14 @@ public class WorldWrapCorrector {
|
|||
Coordinate a = coords[i];
|
||||
Coordinate b = coords[ip1];
|
||||
|
||||
b.x += currOffset;
|
||||
double testX = b.x + currOffset;
|
||||
|
||||
Boolean low = null;
|
||||
if (a.x - b.x > 180.0) {
|
||||
if (a.x - testX > 180.0) {
|
||||
low = false;
|
||||
} else if (b.x - a.x > 180.0) {
|
||||
} else if (testX - a.x > 180.0) {
|
||||
low = true;
|
||||
} else if (checker.check(a.x, b.x)) {
|
||||
} else if (checker.check(a.x, testX)) {
|
||||
handle = true;
|
||||
}
|
||||
|
||||
|
@ -334,18 +336,20 @@ public class WorldWrapCorrector {
|
|||
// we wrap either low end or high
|
||||
if (low) {
|
||||
currOffset -= 360;
|
||||
b.x -= 360.0;
|
||||
if (currOffset < minOffset) {
|
||||
minOffset = currOffset;
|
||||
}
|
||||
} else {
|
||||
currOffset += 360;
|
||||
b.x += 360;
|
||||
if (currOffset > maxOffset) {
|
||||
maxOffset = currOffset;
|
||||
}
|
||||
}
|
||||
b.x += currOffset;
|
||||
} else {
|
||||
b.x = testX;
|
||||
}
|
||||
|
||||
}
|
||||
return handle ? new double[] { minOffset, maxOffset } : null;
|
||||
}
|
||||
|
|
|
@ -57,9 +57,10 @@ import com.vividsolutions.jts.simplify.TopologyPreservingSimplifier;
|
|||
* SOFTWARE HISTORY
|
||||
*
|
||||
* Date Ticket# Engineer Description
|
||||
* ------------- -------- ----------- --------------------------
|
||||
* ------------- -------- ----------- -----------------------------------------
|
||||
* Sep 13, 2013 2309 bsteffen Initial creation
|
||||
* Nov 18, 2013 2528 bsteffen Add test for geostationary.
|
||||
* Dec 11, 2013 2619 bsteffen Add alaska test for dateline issues.
|
||||
*
|
||||
* </pre>
|
||||
*
|
||||
|
@ -148,6 +149,24 @@ public class EnvelopeIntersectionTest {
|
|||
"Unable to create geostationary projection", e);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/*
|
||||
* This envelope has really weird issues with the dataline. Specifically
|
||||
* the lower left corner longitude is just right so if you convert it to
|
||||
* LatLon space, add 360 to longitude and then subtract 360 from
|
||||
* longitude you will get a slightly different LatLon point. This
|
||||
* combined with the fact that the lewer left corner ends up being the
|
||||
* last point in a polygon and the second to last point is on the
|
||||
* opposite side of the dataline results in strange problems.
|
||||
*/
|
||||
ALASKA {
|
||||
public Envelope getEnvelope() {
|
||||
return new ReferencedEnvelope(-2047000.023104792,
|
||||
999.9768952080049, -3879539.946249751,
|
||||
-1831539.946249751, MapUtil.constructNorthPolarStereo(
|
||||
6371200, 6371200, 52.5, -149.5));
|
||||
}
|
||||
};
|
||||
|
||||
public abstract Envelope getEnvelope();
|
||||
|
@ -330,6 +349,19 @@ public class EnvelopeIntersectionTest {
|
|||
19097.596365784917, 64, 49, expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
public final void testAlaskaToUkmet() throws TransformException,
|
||||
FactoryException {
|
||||
/* This was created using printSimplePolygon. */
|
||||
float[] expected = { 3703712, 5337060, 3317194, 5775708, 2834468,
|
||||
6206521, 2222747, 6619845, 1439512, 7001657, 2352844, 7380677,
|
||||
3551651, 7694056, 5063542, 7906556, 6800513, 7982537, 6798676,
|
||||
5836944, 5962640, 5803467, 5154389, 5704811, 4396584, 5546637,
|
||||
3703712, 5337060 };
|
||||
test(KNOWN_ENVELOPES.ALASKA, KNOWN_ENVELOPES.UKMET, 29863.10130618981,
|
||||
16, 16, expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method can be used to assist in generating test cases. It starts
|
||||
* with a known good result and minimizes the amount of text to put in the
|
||||
|
|
Loading…
Add table
Reference in a new issue