Skip to content

Commit

Permalink
additional spatial and temporal shortcut methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Mar 13, 2024
1 parent eedd6e1 commit e7abc2d
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 38 deletions.
43 changes: 39 additions & 4 deletions src/main/java/mil/nga/oapi/features/json/Spatial.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<List<Double>> 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<List<Double>> 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<Double> 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<Double> 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<Double> bbox) {
this.bbox.add(bbox);
Expand Down
43 changes: 39 additions & 4 deletions src/main/java/mil/nga/oapi/features/json/Temporal.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,64 @@ public Temporal() {
}

/**
* Get the interval
* Get the interval collection
*
* @return interval
* @return interval collection
* @since 3.0.0
*/
public List<List<String>> getInterval() {
return interval;
}

/**
* Set the interval
* Set the interval collection
*
* @param interval
* interval
* interval collection
* @since 3.0.0
*/
public void setInterval(List<List<String>> 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<String> firstInterval() {
return getInterval(0);
}

/**
* Get the interval at the index
*
* @param index
* 0 based index
* @return interval
* @since 3.0.0
*/
public List<String> getInterval(int index) {
return this.interval.get(index);
}

/**
* Add an interval
*
* @param interval
* single interval
* @since 3.0.0
*/
public void addInterval(List<String> interval) {
this.interval.add(interval);
Expand Down
50 changes: 20 additions & 30 deletions src/test/java/mil/nga/oapi/features/json/FeaturesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Link> collectionLinks = collection.getLinks();
TestCase.assertNotNull(collectionLinks);
Expand Down Expand Up @@ -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<Link> links = collection.getLinks();
TestCase.assertNotNull(links);
TestCase.assertEquals(2, links.size());
Expand Down

0 comments on commit e7abc2d

Please sign in to comment.