Display electronic navigational charts

Electronic navigational charts (ENCs) are georeferenced vector datasets for the visualization and analysis of hydrographic and maritime information. ArcGIS Runtime supports ENCs that conform to the International Hydrographic Organization (IHO) S-57 standard. Use ENCs in your ArcGIS Runtime apps to:

  • Visualize S-57 data in compliance with S-52 standards and specifications for chart content display
  • Use maritime data as an additional data source for situational awareness and decision making
  • Combine S-57 datasets with other sources of information for geospatial analysis

Get started

Before ENC data can be displayed in an application, you must add code to:

  • Set the path to the resource directory that contains the styles required to render the ENC data. The directory contents is available for download from developers.arcgis.com.
  • Set a location for the SENC data. The first time that ENC data is displayed it is processed and placed into the SENC directory. Subsequent displays of the ENC data will be faster because the data is already processed and is read directly from the SENC directory.
settings = AGSENCEnvironmentSettings.shared()
settings.resourceDirectory = URL(fileURLWithPath: "pathToHydrographyDirectory")
settings.sencDataDirectory = URL(fileURLWithPath: "pathToSENCDirectory")

Display an electronic navigational chart

ENC data is distributed as cells, or collections of cells, which are exchange sets. An exchange set is composed of a single catalog file along with dataset files (cells) for specific geographic extents. Cells can be loaded individually or as part of an exchange set.

ENC layers are constructed from ENC cells. A cell can be constructed from a dataset or from a path. When cells are distributed as part of an exchange set, always use the dataset-based constructor. Cells loaded from a path directly will not include any updates that were distributed as part of the exchange set. You can add all of the cells in an exchange set to a map by iterating through the loaded exchange set’s datasets.

To add an exchange set to your map view, create a new exchange set object and provide the file path to a catalog file (named "CATALOG.031" per the specification). If the catalog file you are processing represents updates only, then you must provide the path to the original catalog file plus the update catalog file(s). See Working with updates for more information.

Once the exchange set is loaded, iterate through the datasets property and construct cells from each data set.

// create an exchange set
let catalogURL = URL(fileURLWithPath: "pathToENCData/CATALOG.031")
encExchangeSet = AGSENCExchangeSet(fileURLs: [catalogURL])
//load the exchange set
self.encExchangeSet.load {[weak self] (error) in
    if let error = error {
        print("Error loading exchange dataset \(error.localizedDescription)")
        return
    }
    //Loop through the exchange set datasets
    self?.encExchangeSet.datasets.forEach {(dataset) in
        //create the ENC Cell from the dataset
        let encCell = AGSENCCell(dataset: dataset)
        // create the ENC layer
        let encLayer = AGSENCLayer(cell: encCell)
        encLayer.name = dataset.name
        // add the ENC layer to the map
        self?.map.basemap.baseLayers.add(encLayer)
    }
}

Working with updates

ENC charts are often distributed as base cells (.000 files) with one or more update cells (.001, .002, etc. files). An exchange set can consist exclusively of update cells; in order to load an update exchange set, the path to the base exchange set must be provided simultaneously.

let pathToOriginal = URL(fileURLWithPath: "pathToOriginalDirectory")
let pathToUpdate = URL(fileURLWithPath: "pathToUpdateDirectory")
 let encExchangeSetUpdate = AGSENCExchangeSet(fileURLs: [pathToOriginal, pathToUpdate])

When loading an ENC cell, it is important to use the dataset-based constructor. If updates for a cell are part of an exchange set, they will only be found by the runtime when the dataset-based constructor is used. Loading the cell from a path will not load any associated updates.

Set ENC environment settings

ENC layers are displayed in accordance with the IHO S-52 standard. You can define the display properties of your ENC layers by using the static AGSEncEnvironmentSettings class. These settings apply to all ENC layers in all maps. Settings fall under three categories: mariner settings, text group visibility settings, and viewing group settings. Text group settings control the display of labels for features, mariner settings control the symbolization and presentation of ENC features, and viewing group settings allow for quickly applying settings to logical groups of feature types.

settings.displaySettings.textGroupVisibilitySettings.natureOfSeabed = true

Runtime’s ENC implementation works with ENC content via compiled SENC files. SENC is an acronym for System Electronic Navigational Chart. After an ENC cell has been loaded, all future loads of that cell will reference the underlying SENC file directly. You can use the SENCDataDirectory property of the environment settings to find or set the location where SENC files are stored.

Identify and select ENC features

ENC layers support identify through the common geo view feature identification mechanism, which takes a screen point and tolerance in pixels. Identify will return a collection of AGSIdentifyLayerResult objects, one per matching layer. For ENC layers, the results will have a geoElements property, which is a collection of AGSEncFeatures.

Once a feature has been identified, you can call select on the layer that contains the feature to select it.

func geoView(_ geoView: AGSGeoView, didTapAtScreenPoint screenPoint: CGPoint, mapPoint: AGSPoint) {
         self.mapView.identifyLayer(self.encLayer, screenPoint: screenPoint, tolerance: 12, returnPopupsOnly: false, maximumResults: 10) { (identifyLayerResult: AGSIdentifyLayerResult) -> Void in
        //check for errors and ensure identifyLayerResult is not nil
        if let error = identifyLayerResult.error {
            print(error)
            return
        }
        // get the layer identified and cast it to an ENC Layer
        if let theENCLayer = identifyLayerResult.layerContent as? AGSENCLayer {
            // iterate each identified GeoElement in the results
            for geoElement in identifyLayerResult.geoElements
            {
                // select the ENC feature in the ENC layer
                if let theENCFeature = geoElement as? AGSENCFeature {
                    theENCLayer.select(theENCFeature)
                                     }
            }
        }
    }
}


In this topic