Issue #2896 Fix sat best res on weird projections

Former-commit-id: a9c4875038 [formerly c7fa392f3f] [formerly 8bb517836a] [formerly a9c4875038 [formerly c7fa392f3f] [formerly 8bb517836a] [formerly 560fc688bc [formerly 8bb517836a [formerly 029b8b30365fd3ec2cb9f5139dec02cc918a0dbb]]]]
Former-commit-id: 560fc688bc
Former-commit-id: 20b99bc6c5 [formerly 7a06fdd71a] [formerly 3dd12b4d2d8faad952b606b3c39220f5602545d4 [formerly b474e92189]]
Former-commit-id: 5c6ba99d716537fdfe23db7e188caebb8b401e59 [formerly 30683880ee]
Former-commit-id: 470ac4a1b9
This commit is contained in:
Ben Steffensmeier 2014-03-11 11:07:43 -05:00
parent c508c4d9bb
commit d3992ef6d7

View file

@ -62,12 +62,14 @@ import com.vividsolutions.jts.geom.Polygon;
* <pre>
*
* SOFTWARE HISTORY
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Jul 30, 2010 mschenke Initial creation
* Oct 31, 2012 DR 15287 D. Friedman Fix overlap calculation
* Nov 06, 2012 DR 15157 D. Friedman Allow configured inclusion percentage
* Oct 10, 2013 2104 mschenke Fixed broken percentage calculation
* Date Ticket# Engineer Description
* ------------- -------- ----------- --------------------------
* Jul 30, 2010 mschenke Initial creation
* Oct 31, 2012 15287 D. Friedman Fix overlap calculation
* Nov 06, 2012 15157 D. Friedman Allow configured inclusion percentage
* Oct 10, 2013 2104 mschenke Fixed broken percentage calculation
* Mar 11, 2014 2896 bsteffen Limit the number of divisions.
*
*
* </pre>
*
@ -322,11 +324,22 @@ public class SatBestResResourceData extends AbstractRequestableResourceData {
double threshold = targetGeometry.getEnvelope().getSpan(0)
/ targetGeometry.getGridRange().getSpan(0);
int xDiv = (int) (envWidth / 100);
int yDiv = (int) (envHeight / 100);
if (xDiv * yDiv > 1024 * 1024) {
/* Don't wasste too much time/memory, preserve aspect ratio. */
if (xDiv > yDiv) {
yDiv = 1024 * yDiv / xDiv;
xDiv = 1024;
} else {
xDiv = 1024 * xDiv / yDiv;
yDiv = 1024;
}
}
Geometry intersection = EnvelopeIntersection
.createEnvelopeIntersection(gridGeometry.getEnvelope(),
targetGeometry.getEnvelope(), threshold,
(int) (envWidth / 100.0),
(int) (envHeight / 100.0));
targetGeometry.getEnvelope(), threshold, xDiv,
yDiv);
if (area == null) {
area = intersection;
} else {