Language
Mobile SDK Guide
  1. Quick Start
    1. Add the OneAtlas SDK to Your Project
    2. Sample Code

Quick Start

Add the OneAtlas SDK to Your Project

Once you’ve created your Xcode project, navigate into its folder using the Terminal and initialize your Podfile using the following command:

$ cd path/to/your/project
$ pod init

Add pod OneAtlas into your Podfile:

target 'your_target' do
  pod 'OneAtlas'

  # add any other pods below this line
end

By running this command in the Terminal, CocoaPods will create the matching Xcode workspace:

$ pod install

Close your opened Xcode project, and open the generated Xcode workspace instead:

$ open <your_project>.xcworkspace

Sample Code

The sample code below will help you execute those simple steps:

  • Authenticate with your API key.
  • Create a simple filter based on a location.
  • Perform a Feature search into the Living Library.
  • Retrieve the WMTS template URL from the Feature.

Authenticate with Your API Key

#import <OneAtlas/OneAtlas.h>

// authenticate with your API Key on IDP realm
[[[OneAtlas sharedInstance] authenticateService] loginWithAPIKey:@"<your_api_key>" clientID:EIDPClientID block:^(OAError * aError) {
    // check for errors and continue
}];
@import OneAtlas

OneAtlas.sharedInstance()?.authenticateService.login(withAPIKey: "your_api_key", clientID: EIDPClientID, block: { (aError) in
    // check for errors and continue
})

Create a Simple Filter Based On a Location


// create the filter
OAPoint * location = [OAPoint pointFromLatitude:43.0 longitude:3.0];
OASearchFilter * filter = [OASearchFilter new];
[filter setGeometry:location];

// create a sort object
OASearchSort * sort = [OASearchSort new];
[sort addSortingCriteria:ESearchSortAcquisitionDate order:ESortOrderDescending];

// create a pagination object (here, we want the 10 first items)
OAPagination * page = [OAPagination makePage:0 itemsPerPage:10];
// create the filter
let location = OAPoint.init(fromLatitude: 43.0, longitude: 3.0)
let filter = OASearchFilter.init()
filter.setGeometry(location)

// create a sort object
let sort = OASearchSort.init()
sort.addSortingCriteria(ESearchSortAcquisitionDate, order: ESortOrderDescending)

// create a pagination object (here, we want the 10 first items)
let page = OAPagination.makePage(0, itemsPerPage: 10)

Perform a Feature Search Into the Living Library

// perform the search using the above criterias
[[[OneAtlas sharedInstance] searchService] openSearchWithPagination:page workspaceID:[OneAtlas livingLibraryWorkspaceID] filter:filter sort:sort block:^(NSArray<OAFeature *> *aFeatures, OAPagination *aPagination, OAError *aError) {
    if(aError) {
        // handle error
    }
    else {
        // all ok !
    }
}];
OneAtlas.sharedInstance()?.searchService.openSearch(with: page, workspaceID: OneAtlas.livingLibraryWorkspaceID(), filter: filter, sort: sort, block: { (aFeatures, aPagination, aError) in
    // check for errors and continue   
})

Retrieve the WMTS Template URL from the Feature

// retrieve the Feature's Capabilities
[[[OneAtlas sharedInstance] viewService] getWMTS:my_feature
                                       withBlock:^(OACapabilities *aCapabilities, OAError *aError) {
    if(aError) {
        // handle error
    }
    else {
        NSString * default_layer_id = @"default";
        NSString * tile_matrix_set = @"EPSG3857";

        // you can now use this WMTS template URL with your mapping engine !
        NSString * url_template = [aCapabilities wmtsTemplateURLWithTileMatrixSet:tile_matrix_set
                                                                            layerID:default_layer_id
                                                                             useXYZ:YES];
   }
}];
// retrive an OAProductFeature
let my_feature = aFeatures?[0] as! OAProductFeature

// retrieve the Feature's Capabilities
OneAtlas.sharedInstance()?.viewService.getWMTS (my_feature, with: { (aCapabilities, aError) in
    if let err = aError {
        // handle error
    }
    else {
        let default_layer_id = "default";
        let tile_matrix_set = "EPSG3857";

        // you can now use this WMTS template URL with your mapping engine !
        let url_template = aCapabilities?.wmtsTemplateURL(withTileMatrixSet: tile_matrix_set, layerID: default_layer_id, useXYZ: true)
    }
})