Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 70BA8200D5B for ; Tue, 28 Nov 2017 10:23:18 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6AD0A160C18; Tue, 28 Nov 2017 09:23:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id B6D5F160C17 for ; Tue, 28 Nov 2017 10:23:17 +0100 (CET) Received: (qmail 40344 invoked by uid 500); 28 Nov 2017 09:23:14 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 40080 invoked by uid 99); 28 Nov 2017 09:23:14 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Nov 2017 09:23:14 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4263EF600E; Tue, 28 Nov 2017 09:23:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ab@apache.org To: commits@lucene.apache.org Date: Tue, 28 Nov 2017 09:23:30 -0000 Message-Id: <17df9ccea3754ed6a0cdc23be94a99dd@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [19/41] lucene-solr:jira/solr-11285-sim: LUCENE-8061: Add convenience factory methods for building solids and BBoxes using bounds objects. Committed in part on behalf of Ignacio Vera. archived-at: Tue, 28 Nov 2017 09:23:18 -0000 LUCENE-8061: Add convenience factory methods for building solids and BBoxes using bounds objects. Committed in part on behalf of Ignacio Vera. Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/558fc4b5 Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/558fc4b5 Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/558fc4b5 Branch: refs/heads/jira/solr-11285-sim Commit: 558fc4b52b3b8ae08d5730c440d44762a301f133 Parents: e33e78c Author: Karl Wright Authored: Wed Nov 22 15:02:23 2017 -0500 Committer: Karl Wright Committed: Wed Nov 22 15:02:23 2017 -0500 ---------------------------------------------------------------------- .../apache/lucene/spatial3d/geom/GeoBBoxFactory.java | 15 +++++++++++++++ .../lucene/spatial3d/geom/XYZSolidFactory.java | 12 ++++++++++++ 2 files changed, 27 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/558fc4b5/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java ---------------------------------------------------------------------- diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java index 12d479b..28b3a79 100755 --- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java +++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/GeoBBoxFactory.java @@ -116,4 +116,19 @@ public class GeoBBoxFactory { return new GeoRectangle(planetModel, topLat, bottomLat, leftLon, rightLon); } + /** + * Create a geobbox of the right kind given the specified {@link LatLonBounds}. + * + * @param planetModel is the planet model + * @param bounds are the bounds + * @return a GeoBBox corresponding to what was specified. + */ + public static GeoBBox makeGeoBBox(final PlanetModel planetModel, LatLonBounds bounds) { + final double topLat = (bounds.checkNoTopLatitudeBound()) ? Math.PI * 0.5 : bounds.getMaxLatitude(); + final double bottomLat = (bounds.checkNoBottomLatitudeBound()) ? -Math.PI * 0.5 : bounds.getMinLatitude(); + final double leftLon = (bounds.checkNoLongitudeBound()) ? -Math.PI : bounds.getLeftLongitude(); + final double rightLon = (bounds.checkNoLongitudeBound()) ? Math.PI : bounds.getRightLongitude(); + return makeGeoBBox(planetModel, topLat, bottomLat, leftLon, rightLon); + } + } http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/558fc4b5/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java ---------------------------------------------------------------------- diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java index 25ea400..14b9bb6 100644 --- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java +++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/geom/XYZSolidFactory.java @@ -64,4 +64,16 @@ public class XYZSolidFactory { return new StandardXYZSolid(planetModel, minX, maxX, minY, maxY, minZ, maxZ); } + /** + * Create a XYZSolid of the right kind given (x,y,z) bounds. + * @param planetModel is the planet model + * @param bounds is the XYZ bounds object. + * @return the solid. + */ + public static XYZSolid makeXYZSolid(final PlanetModel planetModel, final XYZBounds bounds) { + return makeXYZSolid(planetModel, bounds.getMinimumX(), bounds.getMaximumX(), + bounds.getMinimumY(), bounds.getMaximumY(), + bounds.getMinimumZ(), bounds.getMaximumZ()); + } + }