Package com.luciad.model
Interface ILcdModelEncoder
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
ILcdWCSModelEncoder
,ILcdWFSModelEncoder
- All Known Implementing Classes:
ALcdXMLModelEncoder
,TLcdAIXM51ModelEncoder
,TLcdASTERIXFinalModelEncoder
,TLcdDatabaseModelEncoder
,TLcdDB2SpatialModelEncoder
,TLcdEarthAssetModelCodec
,TLcdGDFModelEncoder
,TLcdGDFMultiLevelTiledModelEncoder
,TLcdGeoJsonModelEncoder
,TLcdGeoPackageModelEncoder
,TLcdGeoTIFFModelEncoder
,TLcdGML2ModelEncoder
,TLcdGML2ModelEncoder
,TLcdGML31ModelEncoder
,TLcdGML32ModelEncoder
,TLcdGML3ModelEncoder
,TLcdGMLApplicationModelEncoder
,TLcdInformixGeodeticModelEncoder
,TLcdInformixSpatialModelEncoder
,TLcdJPEG2000ModelEncoder
,TLcdKML22ModelEncoder
,TLcdLRDBModelEncoder
,TLcdLuciadPanoramaModelEncoder
,TLcdLVDBModelEncoder
,TLcdMIFModelEncoder
,TLcdMSSQLModelEncoder
,TLcdNVG15ModelEncoder
,TLcdNVG20ModelEncoder
,TLcdOGC3DTilesModelEncoder
,TLcdOracleSpatialModelEncoder
,TLcdPOLModelEncoder
,TLcdPostGISModelEncoder
,TLcdS57ModelEncoder
,TLcdSHPModelEncoder
,TLcdSpatiaLiteModelEncoder
,TLcdSVGModelEncoder
,TLcdWFSModelEncoder
Writes models to files or other types of storage.
The supported types of storage and
ILcdModel
objects (implemented interfaces, structure, contents, ...) are
defined by the actual implementations of this interface.
Each model encoder has a displayable name that identifies the data format, encoded by this encoder.
Two ways are provided for storing a model: saving and exporting. Saving a model is always done to its original location, and should normally not involve a conversion of the model's contents. Exporting a model however can be done to a different place and can involve a conversion from the model's contents if it is exported to another format than the one it originated from (for example, a model decoded from a SHP file will need to be converted when exported by a GML encoder). Since some formats store more or other information that others, exporting data may sometimes result in partial loss of data.
Example usages
Saving a model to its native format
TLcdCompositeModelDecoder decoder = new TLcdCompositeModelDecoder(
TLcdServiceLoader.getInstance(ILcdModelDecoder.class)
);
ILcdModel model = decoder.decode(pathToGeoJsonFile);
// Make some changes to the model
// For example add, remove or update elements
// Save those changes back to disk
ILcdModelEncoder modelEncoder = model.getModelEncoder();
if (modelEncoder != null && modelEncoder.canSave(model)) {
//This will override the file located at 'pathToGeoJsonFile'
modelEncoder.save(model);
} else {
// this kind of model can't be saved back
}
Exporting a model to a different format
//Decode a .shp file
TLcdCompositeModelDecoder decoder = new TLcdCompositeModelDecoder(
TLcdServiceLoader.getInstance(ILcdModelDecoder.class)
);
ILcdModel model = decoder.decode(pathToSHPFile);
TLcdGeoJsonModelEncoder geoJsonModelEncoder = new TLcdGeoJsonModelEncoder();
if (geoJsonModelEncoder.canExport(model, geoJsonOutputPath)) {
//This will create a .geojson file at 'geoJsonOutputPath'
geoJsonModelEncoder.export(model, geoJsonOutputPath);
} else {
// can happen, but probably not in this case
}
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this encoder can export the specified model to the specified destination.boolean
Returns whether this model encoder can save the specified model to the location it originally came from.void
Exports the specified model to the specified destination.Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.void
Saves the model to the location where it originally came from.
-
Method Details
-
getDisplayName
String getDisplayName()Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.- Returns:
- the displayable name of this
ILcdModelEncoder
.
-
canSave
Returns whether this model encoder can save the specified model to the location it originally came from. Often this will only be a simple test, for example checking the type of the model's model descriptor.- Parameters:
aModel
- the model to be verified.- Returns:
true
if this encoder can save the model in the location where it originally came from,false
otherwise.- See Also:
-
save
Saves the model to the location where it originally came from.- Parameters:
aModel
- the model to be saved.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.
-
canExport
Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.- Parameters:
aModel
- the model to be verified.aDestinationName
- the location where the model should be exported to.- Returns:
true
if this encoder can export the specified model to the specified location,false
otherwise.- See Also:
-
export
Exports the specified model to the specified destination.- Parameters:
aModel
- the model to be exported.aDestinationName
- the location where the model should be saved. Typically, this is a name for the output file, but it can also point to a file containing the required properties to create a set of data files.- Throws:
NullPointerException
- if the specified model isnull
, or ifnull
is not accepted as value foraDestinationName
by this model encoder.IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.
-