In addition to a decoder, the S-57 package also provides an encoder for writing S-57 models back to S-57-compatible cell files,
Sample Program: Encoding an S-57 file illustrates the creation of an encoder and the export of a previously decoded S-57 model.
TLcdS57ProductConfiguration s57Configuration = TLcdS57ProductConfiguration.getInstance(ELcdS57ProductType.ENC); TLcdS57ModelEncoder encoder = s57Configuration.createModelEncoder(); encoder.export(model, "EX000000.000");
The encoder supports the encoding of any S-57 model, with the following limitations:
The record IDs of a decoded file will not correspond with the record IDs in the re-encoded file.
There is no guarantee that order of elements is kept.
New updates for an existing cell cannot be applied to a re-encoded file.
The encoding of relationships is not supported.
The encoding of edited models is also supported, as long as the model is still consistent after you have edited it. Take special care if you change a geometry: make sure to link edges and nodes properly, and maintain a valid topology, edges should never cross each other, for example.