Skip to content

Commit 3814800

Browse files
committed
temporal interval and spatial bbox array fixes
1 parent 7add31d commit 3814800

File tree

7 files changed

+249
-31
lines changed

7 files changed

+249
-31
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Adheres to [Semantic Versioning](http://semver.org/).
66

77
## 4.2.5 (TBD)
88

9+
* Temporal interval fixed to be an array of intervals
10+
* Spatial bbox fixed to be an array of bounding boxes
11+
* Collection itemType write to JSON fix
912
* sf-geojson-ios 4.2.5
1013

1114
## [4.2.4](https://github.com/ngageoint/ogc-api-features-json-ios/releases/tag/4.2.4) (11-13-2023)

ogc-api-features-json-ios/OAFCollection.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ -(NSMutableDictionary *) toTree{
7171
[tree setObject:self.crs forKey:OAF_CRS];
7272
}
7373
if(self.itemType != nil){
74-
[tree setObject:self.theDescription forKey:OAF_ITEM_TYPE];
74+
[tree setObject:self.itemType forKey:OAF_ITEM_TYPE];
7575
}
7676
return tree;
7777
}

ogc-api-features-json-ios/OAFSpatial.h

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ extern NSString * const OAF_CRS;
2424
@interface OAFSpatial : OAFFeaturesObject
2525

2626
/**
27-
* West, south, east, north edges of the bounding box. The coordinates are
28-
* in the coordinate reference system specified in `crs`. By default this is
29-
* WGS 84 longitude/latitude.
27+
* One or more bounding boxes that describe the spatial extent of the
28+
* dataset. In the Core only a single bounding box is supported. Extensions
29+
* may support additional areas. If multiple areas are provided, the union
30+
* of the bounding boxes describes the spatial extent.
3031
*/
31-
@property (nonatomic, strong) NSMutableArray<NSDecimalNumber *> *bbox;
32+
@property (nonatomic, strong) NSMutableArray<NSMutableArray<NSDecimalNumber *>*> *bbox;
3233

3334
/**
3435
* Coordinate reference system of the coordinates in the spatial extent
@@ -55,4 +56,35 @@ extern NSString * const OAF_CRS;
5556
*/
5657
-(instancetype) initWithTree: (NSDictionary *) tree;
5758

59+
/**
60+
* Get the bounding box collection count
61+
*
62+
* @return count
63+
*/
64+
-(int) bboxCount;
65+
66+
/**
67+
* Get the first bounding box
68+
*
69+
* @return bounding box
70+
*/
71+
-(NSMutableArray<NSDecimalNumber *> *) firstBbox;
72+
73+
/**
74+
* Get the bounding box at the index
75+
*
76+
* @param index
77+
* 0 based index
78+
* @return bounding box
79+
*/
80+
-(NSMutableArray<NSDecimalNumber *> *) bboxAtIndex: (int) index;
81+
82+
/**
83+
* Add a bounding box
84+
*
85+
* @param bbox
86+
* single bounding box
87+
*/
88+
-(void) addBbox: (NSMutableArray<NSDecimalNumber *> *) bbox;
89+
5890
@end

ogc-api-features-json-ios/OAFSpatial.m

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ -(instancetype) initWithTree: (NSDictionary *) tree{
3131
return self;
3232
}
3333

34+
-(int) bboxCount{
35+
return _bbox != nil ? (int) _bbox.count : 0;
36+
}
37+
38+
-(NSMutableArray<NSDecimalNumber *> *) firstBbox{
39+
return [self bboxAtIndex:0];
40+
}
41+
42+
-(NSMutableArray<NSDecimalNumber *> *) bboxAtIndex: (int) index{
43+
return [_bbox objectAtIndex:index];
44+
}
45+
46+
-(void) addBbox: (NSMutableArray<NSDecimalNumber *> *) bbox{
47+
if(_bbox == nil){
48+
_bbox = [NSMutableArray array];
49+
}
50+
[_bbox addObject:bbox];
51+
}
52+
3453
-(NSMutableDictionary *) toTree{
3554
NSMutableDictionary *tree = [super toTree];
3655
if(self.bbox != nil){
@@ -47,8 +66,12 @@ -(void) fromTree: (NSDictionary *) tree{
4766
NSArray *boundingBox = [tree objectForKey:OAF_BBOX];
4867
if(![boundingBox isEqual:[NSNull null]] && boundingBox != nil){
4968
self.bbox = [NSMutableArray array];
50-
for(NSNumber *number in boundingBox){
51-
[self.bbox addObject:[[NSDecimalNumber alloc] initWithDouble:[number doubleValue]]];
69+
for(NSArray<NSNumber *> *boundingBoxItem in boundingBox){
70+
NSMutableArray<NSDecimalNumber *> *bboxItem = [NSMutableArray array];
71+
for(NSNumber *number in boundingBoxItem){
72+
[bboxItem addObject:[[NSDecimalNumber alloc] initWithDouble:[number doubleValue]]];
73+
}
74+
[self addBbox:bboxItem];
5275
}
5376
}
5477
self.crs = [tree objectForKey:OAF_CRS];

ogc-api-features-json-ios/OAFTemporal.h

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ extern NSString * const OAF_TRS;
2424
@interface OAFTemporal : OAFFeaturesObject
2525

2626
/**
27-
* Begin and end times of the time interval. The timestamps are in the
28-
* coordinate reference system specified in `trs`. By default this is the
29-
* Gregorian calendar.
27+
* One or more time intervals that describe the temporal extent of the
28+
* dataset. The value `null` is supported and indicates an unbounded
29+
* interval end. In the Core only a single time interval is supported.
30+
* Extensions may support multiple intervals. If multiple intervals are
31+
* provided, the union of the intervals describes the temporal extent.
3032
*/
31-
@property (nonatomic, strong) NSMutableArray<NSString *> *interval;
33+
@property (nonatomic, strong) NSMutableArray<NSMutableArray<NSString *> *> *interval;
3234

3335
/**
3436
* Coordinate reference system of the coordinates in the temporal extent
@@ -55,4 +57,35 @@ extern NSString * const OAF_TRS;
5557
*/
5658
-(instancetype) initWithTree: (NSDictionary *) tree;
5759

60+
/**
61+
* Get the interval collection count
62+
*
63+
* @return count
64+
*/
65+
-(int) intervalCount;
66+
67+
/**
68+
* Get the first interval
69+
*
70+
* @return interval
71+
*/
72+
-(NSMutableArray<NSString *> *) firstInterval;
73+
74+
/**
75+
* Get the interval at the index
76+
*
77+
* @param index
78+
* 0 based index
79+
* @return interval
80+
*/
81+
-(NSMutableArray<NSString *> *) intervalAtIndex: (int) index;
82+
83+
/**
84+
* Add an interval
85+
*
86+
* @param interval
87+
* single interval
88+
*/
89+
-(void) addInterval: (NSMutableArray<NSString *> *) interval;
90+
5891
@end

ogc-api-features-json-ios/OAFTemporal.m

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ -(instancetype) initWithTree: (NSDictionary *) tree{
3131
return self;
3232
}
3333

34+
-(int) intervalCount{
35+
return _interval != nil ? (int) _interval.count : 0;
36+
}
37+
38+
-(NSMutableArray<NSString *> *) firstInterval{
39+
return [self intervalAtIndex:0];
40+
}
41+
42+
-(NSMutableArray<NSString *> *) intervalAtIndex: (int) index{
43+
return [_interval objectAtIndex:index];
44+
}
45+
46+
-(void) addInterval: (NSMutableArray<NSString *> *) interval{
47+
if(_interval == nil){
48+
_interval = [NSMutableArray array];
49+
}
50+
[_interval addObject:interval];
51+
}
52+
3453
-(NSMutableDictionary *) toTree{
3554
NSMutableDictionary *tree = [super toTree];
3655
if(self.interval != nil){
@@ -47,8 +66,8 @@ -(void) fromTree: (NSDictionary *) tree{
4766
NSArray *interval = [tree objectForKey:OAF_INTERVAL];
4867
if(![interval isEqual:[NSNull null]] && interval != nil){
4968
self.interval = [NSMutableArray array];
50-
for(NSString *value in interval){
51-
[self.interval addObject:[NSMutableString stringWithString:value]];
69+
for(NSArray<NSString *> *intervalItem in interval){
70+
[self addInterval:[NSMutableArray arrayWithArray:intervalItem]];
5271
}
5372
}
5473
self.trs = [tree objectForKey:OAF_TRS];

0 commit comments

Comments
 (0)