Skip to content

Commit

Permalink
temporal interval and spatial bbox array fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bosborn committed Mar 27, 2024
1 parent 7add31d commit 3814800
Show file tree
Hide file tree
Showing 7 changed files with 249 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Adheres to [Semantic Versioning](http://semver.org/).

## 4.2.5 (TBD)

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

## [4.2.4](https://github.com/ngageoint/ogc-api-features-json-ios/releases/tag/4.2.4) (11-13-2023)
Expand Down
2 changes: 1 addition & 1 deletion ogc-api-features-json-ios/OAFCollection.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ -(NSMutableDictionary *) toTree{
[tree setObject:self.crs forKey:OAF_CRS];
}
if(self.itemType != nil){
[tree setObject:self.theDescription forKey:OAF_ITEM_TYPE];
[tree setObject:self.itemType forKey:OAF_ITEM_TYPE];
}
return tree;
}
Expand Down
40 changes: 36 additions & 4 deletions ogc-api-features-json-ios/OAFSpatial.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ extern NSString * const OAF_CRS;
@interface OAFSpatial : OAFFeaturesObject

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

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

/**
* Get the bounding box collection count
*
* @return count
*/
-(int) bboxCount;

/**
* Get the first bounding box
*
* @return bounding box
*/
-(NSMutableArray<NSDecimalNumber *> *) firstBbox;

/**
* Get the bounding box at the index
*
* @param index
* 0 based index
* @return bounding box
*/
-(NSMutableArray<NSDecimalNumber *> *) bboxAtIndex: (int) index;

/**
* Add a bounding box
*
* @param bbox
* single bounding box
*/
-(void) addBbox: (NSMutableArray<NSDecimalNumber *> *) bbox;

@end
27 changes: 25 additions & 2 deletions ogc-api-features-json-ios/OAFSpatial.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ -(instancetype) initWithTree: (NSDictionary *) tree{
return self;
}

-(int) bboxCount{
return _bbox != nil ? (int) _bbox.count : 0;
}

-(NSMutableArray<NSDecimalNumber *> *) firstBbox{
return [self bboxAtIndex:0];
}

-(NSMutableArray<NSDecimalNumber *> *) bboxAtIndex: (int) index{
return [_bbox objectAtIndex:index];
}

-(void) addBbox: (NSMutableArray<NSDecimalNumber *> *) bbox{
if(_bbox == nil){
_bbox = [NSMutableArray array];
}
[_bbox addObject:bbox];
}

-(NSMutableDictionary *) toTree{
NSMutableDictionary *tree = [super toTree];
if(self.bbox != nil){
Expand All @@ -47,8 +66,12 @@ -(void) fromTree: (NSDictionary *) tree{
NSArray *boundingBox = [tree objectForKey:OAF_BBOX];
if(![boundingBox isEqual:[NSNull null]] && boundingBox != nil){
self.bbox = [NSMutableArray array];
for(NSNumber *number in boundingBox){
[self.bbox addObject:[[NSDecimalNumber alloc] initWithDouble:[number doubleValue]]];
for(NSArray<NSNumber *> *boundingBoxItem in boundingBox){
NSMutableArray<NSDecimalNumber *> *bboxItem = [NSMutableArray array];
for(NSNumber *number in boundingBoxItem){
[bboxItem addObject:[[NSDecimalNumber alloc] initWithDouble:[number doubleValue]]];
}
[self addBbox:bboxItem];
}
}
self.crs = [tree objectForKey:OAF_CRS];
Expand Down
41 changes: 37 additions & 4 deletions ogc-api-features-json-ios/OAFTemporal.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ extern NSString * const OAF_TRS;
@interface OAFTemporal : OAFFeaturesObject

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

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

/**
* Get the interval collection count
*
* @return count
*/
-(int) intervalCount;

/**
* Get the first interval
*
* @return interval
*/
-(NSMutableArray<NSString *> *) firstInterval;

/**
* Get the interval at the index
*
* @param index
* 0 based index
* @return interval
*/
-(NSMutableArray<NSString *> *) intervalAtIndex: (int) index;

/**
* Add an interval
*
* @param interval
* single interval
*/
-(void) addInterval: (NSMutableArray<NSString *> *) interval;

@end
23 changes: 21 additions & 2 deletions ogc-api-features-json-ios/OAFTemporal.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,25 @@ -(instancetype) initWithTree: (NSDictionary *) tree{
return self;
}

-(int) intervalCount{
return _interval != nil ? (int) _interval.count : 0;
}

-(NSMutableArray<NSString *> *) firstInterval{
return [self intervalAtIndex:0];
}

-(NSMutableArray<NSString *> *) intervalAtIndex: (int) index{
return [_interval objectAtIndex:index];
}

-(void) addInterval: (NSMutableArray<NSString *> *) interval{
if(_interval == nil){
_interval = [NSMutableArray array];
}
[_interval addObject:interval];
}

-(NSMutableDictionary *) toTree{
NSMutableDictionary *tree = [super toTree];
if(self.interval != nil){
Expand All @@ -47,8 +66,8 @@ -(void) fromTree: (NSDictionary *) tree{
NSArray *interval = [tree objectForKey:OAF_INTERVAL];
if(![interval isEqual:[NSNull null]] && interval != nil){
self.interval = [NSMutableArray array];
for(NSString *value in interval){
[self.interval addObject:[NSMutableString stringWithString:value]];
for(NSArray<NSString *> *intervalItem in interval){
[self addInterval:[NSMutableArray arrayWithArray:intervalItem]];
}
}
self.trs = [tree objectForKey:OAF_TRS];
Expand Down
Loading

0 comments on commit 3814800

Please sign in to comment.