From commits-return-8760-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Sat Jan 21 10:53:35 2017 Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 52D4B19566 for ; Sat, 21 Jan 2017 10:53:35 +0000 (UTC) Received: (qmail 87310 invoked by uid 500); 21 Jan 2017 10:53:35 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 87280 invoked by uid 500); 21 Jan 2017 10:53:35 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 87269 invoked by uid 99); 21 Jan 2017 10:53:35 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Jan 2017 10:53:35 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 974663A04F2 for ; Sat, 21 Jan 2017 10:53:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1779722 - in /sis/branches/JDK7: ./ core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java Date: Sat, 21 Jan 2017 10:53:34 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170121105334.974663A04F2@svn01-us-west.apache.org> Author: desruisseaux Date: Sat Jan 21 10:53:33 2017 New Revision: 1779722 URL: http://svn.apache.org/viewvc?rev=1779722&view=rev Log: Merge fix for JUnit test failure. Modified: sis/branches/JDK7/ (props changed) sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java Propchange: sis/branches/JDK7/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sat Jan 21 10:53:33 2017 @@ -1,5 +1,5 @@ /sis/branches/Android:1430670-1480699 /sis/branches/JDK6:1394913-1508480 -/sis/branches/JDK8:1584960-1779703 +/sis/branches/JDK8:1584960-1779720 /sis/branches/JDK9:1773327-1773512 /sis/trunk:1394364-1508466,1519089-1519674 Modified: sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java?rev=1779722&r1=1779721&r2=1779722&view=diff ============================================================================== --- sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] (original) +++ sis/branches/JDK7/core/sis-referencing/src/main/java/org/apache/sis/referencing/CRS.java [UTF-8] Sat Jan 21 10:53:33 2017 @@ -302,6 +302,7 @@ public final class CRS extends Static { public static CoordinateReferenceSystem suggestTargetCRS(GeographicBoundingBox regionOfInterest, CoordinateReferenceSystem... sourceCRS) { + CoordinateReferenceSystem bestCRS = null; /* * Compute the union of the domain of validity of all CRS. If a CRS does not specify a domain of validity, * then assume that the CRS is valid for the whole world if the CRS is geodetic or return null otherwise. @@ -312,7 +313,7 @@ public final class CRS extends Static { final GeographicBoundingBox[] domains = new GeographicBoundingBox[sourceCRS.length]; for (int i=0; i < sourceCRS.length; i++) { final CoordinateReferenceSystem crs = sourceCRS[i]; - GeographicBoundingBox bbox = getGeographicBoundingBox(crs); + final GeographicBoundingBox bbox = getGeographicBoundingBox(crs); if (bbox == null) { /* * If no domain of validity is specified and we can not fallback @@ -322,28 +323,22 @@ public final class CRS extends Static { return null; } /* - * If no region of interest has been specified, conservatively assume that the caller is - * interested in a worldwide area. Since we have a Geodetic CRS, we will not find better. - */ - if (regionOfInterest == null) { - return crs; - } - /* * Geodetic CRS (geographic or geocentric) can generally be presumed valid in a worldwide area. - * Since the caller has specified an area of interest, that will be taken as our validity domain. * The 'worldwide' flag is a little optimization for remembering that we do not need to compute * the union anymore, but we still need to continue the loop for fetching all bounding boxes. */ - bbox = regionOfInterest; + bestCRS = crs; worldwide = true; - } else if (!worldwide) { - if (domain == null) { - domain = new DefaultGeographicBoundingBox(bbox); - } else { - domain.add(bbox); + } else { + domains[i] = bbox; + if (!worldwide) { + if (domain == null) { + domain = new DefaultGeographicBoundingBox(bbox); + } else { + domain.add(bbox); + } } } - domains[i] = bbox; } /* * At this point we got the union of the domain of validity of all CRS. We are interested only in the @@ -375,7 +370,6 @@ public final class CRS extends Static { * - Otherwise (i.e. if the region of interest is likely to be wider than the projected CRS * domain of validity), then the geographic CRS will be returned. */ - CoordinateReferenceSystem bestCRS = null; final double roiArea = Extents.area(regionOfInterest); // NaN if 'regionOfInterest' is null. double maxInsideArea = 0; double minOutsideArea = Double.POSITIVE_INFINITY; @@ -383,23 +377,25 @@ public final class CRS extends Static { do { for (int i=0; i < domains.length; i++) { final GeographicBoundingBox bbox = domains[i]; - double insideArea = Extents.area(bbox); - double outsideArea = 0; - if (regionOfInterest != null) { - if (domain == null) { - domain = new DefaultGeographicBoundingBox(bbox); - } else { - domain.setBounds(bbox); + if (bbox != null) { + double insideArea = Extents.area(bbox); + double outsideArea = 0; + if (regionOfInterest != null) { + if (domain == null) { + domain = new DefaultGeographicBoundingBox(bbox); + } else { + domain.setBounds(bbox); + } + domain.intersect(regionOfInterest); + final double area = insideArea; + insideArea = Extents.area(domain); + outsideArea = area - insideArea; + } + if (insideArea > maxInsideArea || (insideArea == maxInsideArea && outsideArea < minOutsideArea)) { + maxInsideArea = insideArea; + minOutsideArea = outsideArea; + bestCRS = sourceCRS[i]; } - domain.intersect(regionOfInterest); - final double area = insideArea; - insideArea = Extents.area(domain); - outsideArea = area - insideArea; - } - if (insideArea > maxInsideArea || (insideArea == maxInsideArea && outsideArea < minOutsideArea)) { - maxInsideArea = insideArea; - minOutsideArea = outsideArea; - bestCRS = sourceCRS[i]; } } /* @@ -416,8 +412,8 @@ public final class CRS extends Static { if (crs instanceof GeneralDerivedCRS) { final SingleCRS baseCRS = ((GeneralDerivedCRS) crs).getBaseCRS(); bbox = getGeographicBoundingBox(baseCRS); - if (bbox == null) { - bbox = regionOfInterest; + if (bbox == null && bestCRS == null && baseCRS instanceof GeodeticCRS) { + bestCRS = baseCRS; } tryDerivedCRS = true; derivedCRS[i] = baseCRS;