Skip to content

Commit e7abc2d

Browse files
committed
additional spatial and temporal shortcut methods
1 parent eedd6e1 commit e7abc2d

File tree

3 files changed

+98
-38
lines changed

3 files changed

+98
-38
lines changed

src/main/java/mil/nga/oapi/features/json/Spatial.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,64 @@ public Spatial() {
4343
}
4444

4545
/**
46-
* Get the bounding box
46+
* Get the bounding box collection
4747
*
48-
* @return bounding box
48+
* @return bounding box collection
49+
* @since 3.0.0
4950
*/
5051
public List<List<Double>> getBbox() {
5152
return bbox;
5253
}
5354

5455
/**
55-
* Set the bounding box
56+
* Set the bounding box collection
5657
*
5758
* @param bbox
58-
* bounding box
59+
* bounding box collection
60+
* @since 3.0.0
5961
*/
6062
public void setBbox(List<List<Double>> bbox) {
6163
this.bbox = bbox;
6264
}
6365

66+
/**
67+
* Get the bounding box collection count
68+
*
69+
* @return count
70+
* @since 3.0.0
71+
*/
72+
public int bboxCount() {
73+
return this.bbox.size();
74+
}
75+
76+
/**
77+
* Get the first bounding box
78+
*
79+
* @return bounding box
80+
* @since 3.0.0
81+
*/
82+
public List<Double> firstBbox() {
83+
return getBbox(0);
84+
}
85+
86+
/**
87+
* Get the bounding box at the index
88+
*
89+
* @param index
90+
* 0 based index
91+
* @return bounding box
92+
* @since 3.0.0
93+
*/
94+
public List<Double> getBbox(int index) {
95+
return this.bbox.get(index);
96+
}
97+
6498
/**
6599
* Add a bounding box
66100
*
67101
* @param bbox
68102
* single bounding box
103+
* @since 3.0.0
69104
*/
70105
public void addBbox(List<Double> bbox) {
71106
this.bbox.add(bbox);

src/main/java/mil/nga/oapi/features/json/Temporal.java

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,64 @@ public Temporal() {
3939
}
4040

4141
/**
42-
* Get the interval
42+
* Get the interval collection
4343
*
44-
* @return interval
44+
* @return interval collection
45+
* @since 3.0.0
4546
*/
4647
public List<List<String>> getInterval() {
4748
return interval;
4849
}
4950

5051
/**
51-
* Set the interval
52+
* Set the interval collection
5253
*
5354
* @param interval
54-
* interval
55+
* interval collection
56+
* @since 3.0.0
5557
*/
5658
public void setInterval(List<List<String>> interval) {
5759
this.interval = interval;
5860
}
5961

62+
/**
63+
* Get the interval collection count
64+
*
65+
* @return count
66+
* @since 3.0.0
67+
*/
68+
public int intervalCount() {
69+
return this.interval.size();
70+
}
71+
72+
/**
73+
* Get the first interval
74+
*
75+
* @return interval
76+
* @since 3.0.0
77+
*/
78+
public List<String> firstInterval() {
79+
return getInterval(0);
80+
}
81+
82+
/**
83+
* Get the interval at the index
84+
*
85+
* @param index
86+
* 0 based index
87+
* @return interval
88+
* @since 3.0.0
89+
*/
90+
public List<String> getInterval(int index) {
91+
return this.interval.get(index);
92+
}
93+
6094
/**
6195
* Add an interval
6296
*
6397
* @param interval
6498
* single interval
99+
* @since 3.0.0
65100
*/
66101
public void addInterval(List<String> interval) {
67102
this.interval.add(interval);

src/test/java/mil/nga/oapi/features/json/FeaturesTest.java

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -233,22 +233,17 @@ public void testCollections2() {
233233
collection.getDescription());
234234
Extent extent = collection.getExtent();
235235
TestCase.assertNotNull(extent);
236-
TestCase.assertEquals(1, extent.getSpatial().getBbox().size());
237-
TestCase.assertEquals(4, extent.getSpatial().getBbox().get(0).size());
238-
TestCase.assertEquals(7.01,
239-
extent.getSpatial().getBbox().get(0).get(0));
240-
TestCase.assertEquals(50.63,
241-
extent.getSpatial().getBbox().get(0).get(1));
242-
TestCase.assertEquals(7.22,
243-
extent.getSpatial().getBbox().get(0).get(2));
244-
TestCase.assertEquals(50.78,
245-
extent.getSpatial().getBbox().get(0).get(3));
246-
TestCase.assertEquals(1, extent.getTemporal().getInterval().size());
247-
TestCase.assertEquals(2,
248-
extent.getTemporal().getInterval().get(0).size());
236+
TestCase.assertEquals(1, extent.getSpatial().bboxCount());
237+
TestCase.assertEquals(4, extent.getSpatial().firstBbox().size());
238+
TestCase.assertEquals(7.01, extent.getSpatial().firstBbox().get(0));
239+
TestCase.assertEquals(50.63, extent.getSpatial().firstBbox().get(1));
240+
TestCase.assertEquals(7.22, extent.getSpatial().firstBbox().get(2));
241+
TestCase.assertEquals(50.78, extent.getSpatial().firstBbox().get(3));
242+
TestCase.assertEquals(1, extent.getTemporal().intervalCount());
243+
TestCase.assertEquals(2, extent.getTemporal().firstInterval().size());
249244
TestCase.assertEquals("2010-02-15T12:34:56Z",
250-
extent.getTemporal().getInterval().get(0).get(0));
251-
TestCase.assertNull(extent.getTemporal().getInterval().get(0).get(1));
245+
extent.getTemporal().firstInterval().get(0));
246+
TestCase.assertNull(extent.getTemporal().firstInterval().get(1));
252247
TestCase.assertEquals("feature", collection.getItemType());
253248
List<Link> collectionLinks = collection.getLinks();
254249
TestCase.assertNotNull(collectionLinks);
@@ -313,23 +308,18 @@ public void testCollection() {
313308
collection.getDescription());
314309
Extent extent = collection.getExtent();
315310
TestCase.assertNotNull(extent);
316-
TestCase.assertEquals(1, extent.getSpatial().getBbox().size());
317-
TestCase.assertEquals(4, extent.getSpatial().getBbox().get(0).size());
318-
TestCase.assertEquals(7.01,
319-
extent.getSpatial().getBbox().get(0).get(0));
320-
TestCase.assertEquals(50.63,
321-
extent.getSpatial().getBbox().get(0).get(1));
322-
TestCase.assertEquals(7.22,
323-
extent.getSpatial().getBbox().get(0).get(2));
324-
TestCase.assertEquals(50.78,
325-
extent.getSpatial().getBbox().get(0).get(3));
326-
TestCase.assertEquals(1, extent.getTemporal().getInterval().size());
327-
TestCase.assertEquals(2,
328-
extent.getTemporal().getInterval().get(0).size());
311+
TestCase.assertEquals(1, extent.getSpatial().bboxCount());
312+
TestCase.assertEquals(4, extent.getSpatial().firstBbox().size());
313+
TestCase.assertEquals(7.01, extent.getSpatial().firstBbox().get(0));
314+
TestCase.assertEquals(50.63, extent.getSpatial().firstBbox().get(1));
315+
TestCase.assertEquals(7.22, extent.getSpatial().firstBbox().get(2));
316+
TestCase.assertEquals(50.78, extent.getSpatial().firstBbox().get(3));
317+
TestCase.assertEquals(1, extent.getTemporal().intervalCount());
318+
TestCase.assertEquals(2, extent.getTemporal().firstInterval().size());
329319
TestCase.assertEquals("2010-02-15T12:34:56Z",
330-
extent.getTemporal().getInterval().get(0).get(0));
320+
extent.getTemporal().firstInterval().get(0));
331321
TestCase.assertEquals("2018-03-18T12:11:00Z",
332-
extent.getTemporal().getInterval().get(0).get(1));
322+
extent.getTemporal().firstInterval().get(1));
333323
List<Link> links = collection.getLinks();
334324
TestCase.assertNotNull(links);
335325
TestCase.assertEquals(2, links.size());

0 commit comments

Comments
 (0)