diff --git a/src/main/java/mil/nga/oapi/features/json/Spatial.java b/src/main/java/mil/nga/oapi/features/json/Spatial.java index e66fbbe..6ef423c 100644 --- a/src/main/java/mil/nga/oapi/features/json/Spatial.java +++ b/src/main/java/mil/nga/oapi/features/json/Spatial.java @@ -43,29 +43,64 @@ public Spatial() { } /** - * Get the bounding box + * Get the bounding box collection * - * @return bounding box + * @return bounding box collection + * @since 3.0.0 */ public List> getBbox() { return bbox; } /** - * Set the bounding box + * Set the bounding box collection * * @param bbox - * bounding box + * bounding box collection + * @since 3.0.0 */ public void setBbox(List> bbox) { this.bbox = bbox; } + /** + * Get the bounding box collection count + * + * @return count + * @since 3.0.0 + */ + public int bboxCount() { + return this.bbox.size(); + } + + /** + * Get the first bounding box + * + * @return bounding box + * @since 3.0.0 + */ + public List firstBbox() { + return getBbox(0); + } + + /** + * Get the bounding box at the index + * + * @param index + * 0 based index + * @return bounding box + * @since 3.0.0 + */ + public List getBbox(int index) { + return this.bbox.get(index); + } + /** * Add a bounding box * * @param bbox * single bounding box + * @since 3.0.0 */ public void addBbox(List bbox) { this.bbox.add(bbox); diff --git a/src/main/java/mil/nga/oapi/features/json/Temporal.java b/src/main/java/mil/nga/oapi/features/json/Temporal.java index 8bb2be4..0270aaa 100644 --- a/src/main/java/mil/nga/oapi/features/json/Temporal.java +++ b/src/main/java/mil/nga/oapi/features/json/Temporal.java @@ -39,29 +39,64 @@ public Temporal() { } /** - * Get the interval + * Get the interval collection * - * @return interval + * @return interval collection + * @since 3.0.0 */ public List> getInterval() { return interval; } /** - * Set the interval + * Set the interval collection * * @param interval - * interval + * interval collection + * @since 3.0.0 */ public void setInterval(List> interval) { this.interval = interval; } + /** + * Get the interval collection count + * + * @return count + * @since 3.0.0 + */ + public int intervalCount() { + return this.interval.size(); + } + + /** + * Get the first interval + * + * @return interval + * @since 3.0.0 + */ + public List firstInterval() { + return getInterval(0); + } + + /** + * Get the interval at the index + * + * @param index + * 0 based index + * @return interval + * @since 3.0.0 + */ + public List getInterval(int index) { + return this.interval.get(index); + } + /** * Add an interval * * @param interval * single interval + * @since 3.0.0 */ public void addInterval(List interval) { this.interval.add(interval); diff --git a/src/test/java/mil/nga/oapi/features/json/FeaturesTest.java b/src/test/java/mil/nga/oapi/features/json/FeaturesTest.java index dd7413c..336b7a6 100644 --- a/src/test/java/mil/nga/oapi/features/json/FeaturesTest.java +++ b/src/test/java/mil/nga/oapi/features/json/FeaturesTest.java @@ -233,22 +233,17 @@ public void testCollections2() { collection.getDescription()); Extent extent = collection.getExtent(); TestCase.assertNotNull(extent); - TestCase.assertEquals(1, extent.getSpatial().getBbox().size()); - TestCase.assertEquals(4, extent.getSpatial().getBbox().get(0).size()); - TestCase.assertEquals(7.01, - extent.getSpatial().getBbox().get(0).get(0)); - TestCase.assertEquals(50.63, - extent.getSpatial().getBbox().get(0).get(1)); - TestCase.assertEquals(7.22, - extent.getSpatial().getBbox().get(0).get(2)); - TestCase.assertEquals(50.78, - extent.getSpatial().getBbox().get(0).get(3)); - TestCase.assertEquals(1, extent.getTemporal().getInterval().size()); - TestCase.assertEquals(2, - extent.getTemporal().getInterval().get(0).size()); + TestCase.assertEquals(1, extent.getSpatial().bboxCount()); + TestCase.assertEquals(4, extent.getSpatial().firstBbox().size()); + TestCase.assertEquals(7.01, extent.getSpatial().firstBbox().get(0)); + TestCase.assertEquals(50.63, extent.getSpatial().firstBbox().get(1)); + TestCase.assertEquals(7.22, extent.getSpatial().firstBbox().get(2)); + TestCase.assertEquals(50.78, extent.getSpatial().firstBbox().get(3)); + TestCase.assertEquals(1, extent.getTemporal().intervalCount()); + TestCase.assertEquals(2, extent.getTemporal().firstInterval().size()); TestCase.assertEquals("2010-02-15T12:34:56Z", - extent.getTemporal().getInterval().get(0).get(0)); - TestCase.assertNull(extent.getTemporal().getInterval().get(0).get(1)); + extent.getTemporal().firstInterval().get(0)); + TestCase.assertNull(extent.getTemporal().firstInterval().get(1)); TestCase.assertEquals("feature", collection.getItemType()); List collectionLinks = collection.getLinks(); TestCase.assertNotNull(collectionLinks); @@ -313,23 +308,18 @@ public void testCollection() { collection.getDescription()); Extent extent = collection.getExtent(); TestCase.assertNotNull(extent); - TestCase.assertEquals(1, extent.getSpatial().getBbox().size()); - TestCase.assertEquals(4, extent.getSpatial().getBbox().get(0).size()); - TestCase.assertEquals(7.01, - extent.getSpatial().getBbox().get(0).get(0)); - TestCase.assertEquals(50.63, - extent.getSpatial().getBbox().get(0).get(1)); - TestCase.assertEquals(7.22, - extent.getSpatial().getBbox().get(0).get(2)); - TestCase.assertEquals(50.78, - extent.getSpatial().getBbox().get(0).get(3)); - TestCase.assertEquals(1, extent.getTemporal().getInterval().size()); - TestCase.assertEquals(2, - extent.getTemporal().getInterval().get(0).size()); + TestCase.assertEquals(1, extent.getSpatial().bboxCount()); + TestCase.assertEquals(4, extent.getSpatial().firstBbox().size()); + TestCase.assertEquals(7.01, extent.getSpatial().firstBbox().get(0)); + TestCase.assertEquals(50.63, extent.getSpatial().firstBbox().get(1)); + TestCase.assertEquals(7.22, extent.getSpatial().firstBbox().get(2)); + TestCase.assertEquals(50.78, extent.getSpatial().firstBbox().get(3)); + TestCase.assertEquals(1, extent.getTemporal().intervalCount()); + TestCase.assertEquals(2, extent.getTemporal().firstInterval().size()); TestCase.assertEquals("2010-02-15T12:34:56Z", - extent.getTemporal().getInterval().get(0).get(0)); + extent.getTemporal().firstInterval().get(0)); TestCase.assertEquals("2018-03-18T12:11:00Z", - extent.getTemporal().getInterval().get(0).get(1)); + extent.getTemporal().firstInterval().get(1)); List links = collection.getLinks(); TestCase.assertNotNull(links); TestCase.assertEquals(2, links.size());