skip to main content
Defense > Programmer's documentation > Programming with JViews Maps for Defense > Readers and writers > The S57 Reader
 
The S57 Reader
Describes the S57 Reader provided.
*Overview
*Introduces the S57 standard.
*The IlvS57Reader class
*Describes the IlvS57Reader class.
*Using the IlvS57Reader class to create vector data
*Explains how to create an S57 reader, limit the features to be read and create a default renderer.
*The IlvS57DataSource class
*Describes the IlvS57DataSource class.
*Using the IlvS57DataSource Class to Create Vector Data
*Explains how to create an S57 data source, connect it to the manager, limit the features to be read and read the data.
Overview
This package contains classes for reading S57 files. The S57 standard is a numerical map format for nautical maps, which is a standard published by the International Hydrographic Organization (IHO). You can find more information at:
http://www.iho.shom.fr/
The S57 readers provided in this package are based on the IHO TRANSFER STANDARD FOR DIGITAL HYDROGRAPHIC DATA Edition 3.1.
The S57 Reader module provides access to data in IHO S57 formatted file sets. The S57 Reader module produces S57 features in one or more related S57 data files. An S57 data set can be a directory, in which case all S57 files in the directory are selected, an S57 catalog file, in which case all files referred to from the catalog are selected, or an individual S57 data file. An S57 catalog covers an area with nautical data. It is composed of a single directory containing both a catalog file (.030 or .031) and cell files (.000). Usually cells contain data for only a subzone of the global catalog zone.
S57 feature objects are translated into features. S57 geometry objects are automatically collected and formed into geometries on the features. Geometry objects are not separately accessible with the S57 reader.
When simplified rendering is activated, S52 symbols are rendered using a predefined icon per object type, whatever the object attributes are. Polygon and polyline colors are likewise predefined. When simplified rendering is deactivated, JViews Maps for Defense uses the IHO ECDIS Presentation library (Edition 3.3, March 2004) definitions to create S52 symbols according to attribute content.
The following limitations apply to the use of the ECDIS Presentation library:
*Conditional procedures defined in this document are not implemented, except for a partial implementation of DEPARE02 DEPCNT03 LIGHTS05 and QUAPOS01.
*Complex line sets are not used.
*S52 Symbols are displayed based on the SIMPLIFIED look up table
*The styling of polygons and areas is limited to the polygon style supported, and is built based on PLAIN_BOUNDARIES, LINES_SET or SIMPLIFIED look up tables.
*S52 symbols for lights are not rotated.
There are two ways of reading S57 data:
*Using an IlvS57Reader instance directly. In this case, you must write all the code required to render the map features into graphic objects, and to add them to the manager.
*Using an IlvS57DataSource instance. This is a convenient way of performing all the above operations at once and is more integrated with the map data model.
The source code for the Map Builder demonstration, which contains all the code described in this section, can be found at <installdir> /jviews-maps/samples/mapbuilder/index.html.
The IlvS57Reader class
The IlvS57Reader class reads S57 features from a specified S57 file or catalog. It implements the IlvMapFeatureIterator interface to iterate over the read features.
Using the IlvS57Reader class to create vector data
To read S57 features using the IlvS57Reader object:
1. Create an IlvS57Reader instance from the path of the S57 cell or catalog. Note that if the file name ends with 000, it will point to a single S57 cell. If it ends with 030, it will point to a S57 catalog that merges many S57 cells:
 
String s57path = "C:/S57/sxx.000";
IlvS57Reader S57Reader = new IlvS57Reader(s57path);
2. You can also limit what is read to features specified by particular object codes (for more information about S57 Object codes, refer to the S57 format specification). For example, to read only roads you can use:
 
S57Reader.setFeatureClassFilter
   (new IlvFeatureClassInformation("Roads","116"));
3. Create a default renderer:
 
IlvFeatureRenderer renderer = new IlvDefaultFeatureRenderer();
4. Iterate over the features, render them with an appropriate IlvFeatureRenderer, and assign them to a manager:
 
IlvMapFeature feature = S57Reader.getNextFeature();
while(feature != null) {
  // Render map feature into graphic object
  IlvGraphic graphic = renderer.makeGraphic(feature,null);
  // Add this object on the first layer of the manager
  manager.addObject(graphic, 0, false);
  feature = S57Reader.getNextFeature();
}
The IlvS57DataSource class
The IlvS57DataSource class provides a convenient way of creating a layer containing S57 data in a manager. You can also filter the geographic objects to create, as S57 data sets can be quite large.
Using the IlvS57DataSource Class to Create Vector Data
To read S57 features using the IlvS57DataSource object:
1. Create an IlvS57DataSource. Note that if the file name ends with 000, it will point to a single S57 cell. If it ends with 030, it will point to a S57 catalog that merges many S57 cells:
 
String s57path = "C:/S57/sxx.000";
IlvS57DataSource S57Source = new IlvS57DataSource(s57path);
2. Connect this data source with the manager of the view:
 
S57Source.setManager(getView().getManager());
3. Select the map features you want to read by specifying the S57 object codes for those features (for further information about object codes, refer to the S57 format specification). For example, to read only roads you can use:
 
S57Source.setAcceptedCodeList(new String[]{"116"});
4. Select the way you want to render S52 symbology. For example:
 
S57Source.setSimplifiedRendering(false);
S57Source.setColorSet("DUSK");
5. Start the S57 data source:
 
S57Source.start(); S57Source.start();
For further information about defense-specific data sources, see:
*Vector data sources, for defense-specific data sources.
*Introducing the main classes and Creating a map application using the API for non defense-specific data.

Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.