Issue #2528 Allow geostationary data to display on an identical projection.

Change-Id: I930cd35a2e2fd7f6b1347cd9d5063fe9cd578d46

Former-commit-id: 5369a757ce [formerly 048f968147] [formerly 59d806fa7e [formerly c2b5cca6c1c02122a8d006704f415868debe4f75]]
Former-commit-id: 59d806fa7e
Former-commit-id: 37f6acbb99
This commit is contained in:
Ben Steffensmeier 2013-11-26 17:33:18 -06:00
parent ca5e771451
commit a78188ecb9
3 changed files with 64 additions and 6 deletions

View file

@ -49,10 +49,11 @@ import org.opengis.referencing.operation.MathTransform;
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jun 27, 2013 mschenke Initial creation
* Oct 02, 2013 2333 mschenke Converted from libproj to CGMS algorithm
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jun 27, 2013 mschenke Initial creation
* Oct 02, 2013 2333 mschenke Converted from libproj to CGMS algorithm
* Nov 18, 2013 2528 bsteffen Add hashCode/equals.
*
* </pre>
*
@ -212,6 +213,34 @@ public class Geostationary extends MapProjection {
return ptDst;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
long temp;
temp = Double.doubleToLongBits(orbitalHeight);
result = prime * result + (int) (temp ^ (temp >>> 32));
result = prime * result + (swapAxis ? 1231 : 1237);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
Geostationary other = (Geostationary) obj;
if (Double.doubleToLongBits(orbitalHeight) != Double
.doubleToLongBits(other.orbitalHeight))
return false;
if (swapAxis != other.swapAxis)
return false;
return true;
}
public static class Provider extends AbstractProvider {
private static final long serialVersionUID = 3868187206568280453L;

View file

@ -88,11 +88,30 @@ public class EnvelopeIntersection {
int maxVertDivisions) throws TransformException, FactoryException {
ReferencedEnvelope sourceREnvelope = reference(sourceEnvelope);
ReferencedEnvelope targetREnvelope = reference(targetEnvelope);
Geometry border = null;
WorldWrapCorrector corrector = new WorldWrapCorrector(targetREnvelope);
MathTransform sourceCRSToTargetCRS = CRS.findMathTransform(
sourceREnvelope.getCoordinateReferenceSystem(),
targetREnvelope.getCoordinateReferenceSystem());
if (sourceCRSToTargetCRS.isIdentity()) {
com.vividsolutions.jts.geom.Envelope intersection = sourceREnvelope
.intersection(targetREnvelope);
if (intersection == null) {
return gf.createGeometryCollection(new Geometry[0]);
} else {
Coordinate[] border = new Coordinate[5];
border[0] = new Coordinate(intersection.getMinX(),
intersection.getMinY());
border[1] = new Coordinate(intersection.getMinX(),
intersection.getMaxY());
border[2] = new Coordinate(intersection.getMaxX(),
intersection.getMaxY());
border[3] = new Coordinate(intersection.getMaxX(),
intersection.getMinY());
border[4] = border[0];
return gf.createPolygon(gf.createLinearRing(border), null);
}
}
Geometry border = null;
WorldWrapCorrector corrector = new WorldWrapCorrector(targetREnvelope);
MathTransform targetCRSToSourceCRS = sourceCRSToTargetCRS.inverse();
MathTransform targetCRSToLatLon = MapUtil
.getTransformToLatLon(targetREnvelope

View file

@ -320,6 +320,16 @@ public class EnvelopeIntersectionTest {
19097.596365784917, 64, 49, expected);
}
@Test
public final void testGeostationaryToGeostationary()
throws TransformException, FactoryException {
/* This was created using printSimplePolygon. */
float[] expected = { -5434871, -3799600, -5434871, -721443, -2356714,
-721443, -2356714, -3799600, -5434871, -3799600 };
test(KNOWN_ENVELOPES.GEOSTATIONARY, KNOWN_ENVELOPES.GEOSTATIONARY,
19097.596365784917, 64, 49, 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